Telegram AFK Bot is a lightweight and reliable Telegram bot that allows the bot owner to enable an AFK (Away From Keyboard) status with an optional reason. While AFK mode is active, the bot automatically replies to private messages with the reason and the duration since the AFK status was activated.
/afk [reason]— Enables AFK mode with an optional reason./off_afk— Disables AFK mode.- Sends auto-replies only once per user while AFK.
- Includes the AFK reason and elapsed time in replies.
- Minimal and easy to configure.
- Python 3.9 or higher
python-telegram-bot==20.0- A Telegram Business Bot (Business connection enabled)
- A Telegram Premium account (required to receive messages from strangers in private chats)
git clone https://github.com/FoxCoderGit/telegram-afk-bot.git
cd telegram-afk-bot
pip install -r requirements.txt- Open
afk_bot.py - Replace
OWNER_IDwith your own Telegram user ID. - Replace
YOUR_BOT_TOKEN_HEREwith the bot token from BotFather. - Make sure your bot is connected as a business bot and you are using Telegram Premium.
- Run the bot:
python afk_bot.pyThe bot will automatically reply to private messages while you’re AFK, and stop when you disable it.
This project is licensed under the MIT License — see the LICENSE file for details.