KitDevguides

KitDev / Guides / AFK mode

AFK mode

Automatically tells anyone looking for you that you're not there. Your own account replies (the assistant isn't needed) and everything is stored in the database.

Command What it does
afk Turns on AFK mode without a reason
afk reason Turns it on with a reason, for example .afk eating, back in 20 min
afk replying to a photo, video, GIF, sticker or video note Turns it on and that media is sent with each reply (with or without a reason)
unafk Leaves AFK mode

When you turn it on, the message with your command changes to a single line: 💤 Your name is now AFK (with your name as a mention). The reason and the media are seen in the replies it sends. If you reply to something that is not a photo, video, GIF, sticker or video note, it is ignored and it is left without media.

When it replies

  • Someone mentions you with your @username in a group.
  • Someone replies to a message of yours in a group.
  • Someone writes to you in private.

The reply says how long you've been AFK and the reason, for example:

💤 Estoy AFK desde hace 2 h 5 min.
Razón: comiendo

If you saved a photo, video or GIF, it goes with that text as the caption. Stickers and video notes don't support a caption, so they are sent first and the text goes right after. The reply is to their message and respects group topics.

At most once every 10 seconds per person and chat (by default), so it doesn't flood the chat if they write to you several times in a row. After that time, it replies again, even to new mentions. The time is changed in the assistant (see below). It doesn't reply to bots or to other userbots with AFK (so they don't answer each other endlessly).

When it turns off

  • When you write a message in any chat (groups, private chats or your Saved Messages). They don't count: commands (any message that starts with your prefix, such as .ping or .snips), what you write to the assistant (for example, to set texts or numbers in the settings) and the AFK's own replies. Snips ($name) do count, because they are messages sent to the chat.
  • To write without leaving AFK, put #afk anywhere in the message (in the text or in a photo's caption): that message doesn't take you out of the mode. For example: I can't right now, I'll write you later #afk. It works in any chat, also with a snip ($name #afk). The hashtag stays visible in the message; only #afk as a whole word counts (#afk2 or #afkfan don't work).
  • With unafk.

In both cases it is announced in that same chat (replying to your message, or in place of the unafk command):

✅ Tu nombre ya no está AFK.
Estuvo ausente 2 h 5 min.
Razón: comiendo

If you had saved a photo, video or GIF, it goes with that text as the caption; a sticker or a short video are sent first and the text right after. Without a reason, the reason line doesn't appear.

Changing the time between replies

In the assistant: /start → Settings → 💤 AFK → Change time, and you send the seconds. The minimum is 10 (also the factory value) and there is no maximum. It's up to you: with very short times the AFK can flood the chat with messages and Telegram could limit you; with long times, whoever writes to you several times only gets one reply. Reset goes back to 10 s.

Notes

  • AFK mode is stored in the database: if you restart the userbot, you stay AFK.
  • If you use PM Permit, private chats may get both notices (the PM Permit one and the AFK one).
  • So that it doesn't reply to private chats (only mentions and replies), set AFK_IN_PRIVATE = False at the top of plugins/afk.py.
  • It is included in .backup because it lives in the same database.