How to display the status of the user?

I created a TWIG template for the “Teaser” view of the user account.

I want to display a logo and change its color according to the status of the user :

  • When the user is logged in <i class="user-online fa fa-circle fa-lg"></i> Online

  • When the user is logged in and the last access is less than 30 minutes <i class="user-absent fa fa-circle fa-lg"></i> Absent

  • When the user is offline <i class="user-offline fa fa-circle fa-lg"></i> Offline

How to display the status of the user ?

I think it must be possible to create conditions in TWIG