A simple Telegram bot that mentions all opted-in group members when someone
says @everyone or @tagall in a group — public or private.
- Members join the tag list with
/tagmeand leave it with/untagme— nobody gets tagged unless they chose to. - Reply to any message and say
@everyone, and the mentions attach to that message, pointing the whole group at it. - Members without a public @username are tagged with a clickable name link, so they still get notified.
Follow these in order. You'll be done in about 10 minutes.
- Open Telegram and search for @BotFather (it has a blue verified badge).
- Tap Start.
- Send the message:
/newbot - BotFather asks for a name — this is the display name people see.
Example:
Tagall. Send it. - BotFather asks for a username — it must be unique and end in
bot. Example:MyGroupTagBot. Send it. - BotFather replies with a token — a long code like
1234567890:AAHxxxxxxxxxxxxxxxxxxxxxxxx. Copy it and keep it secret. Anyone who has it controls your bot.
Still chatting with BotFather:
- Send:
/setprivacy - Tap your bot's name.
- Tap Disable.
Without this the bot cannot see normal group messages, so @everyone would
never work.
Still in BotFather:
-
Send:
/setcommands -
Tap your bot's name.
-
Copy-paste this whole block as one message:
tagall - Tag all opted-in members tagme - Include me in @everyone untagme - Leave me out of @everyone help - How this bot works
Now group members will see these commands pop up whenever they type /.
You need Python 3.10 or newer — on Windows, tick "Add Python to PATH" during installation.
Then download this project:
- Easy way: click the green Code button at the top of this GitHub page → Download ZIP → unzip it anywhere.
- Git way:
git clone https://github.com/maztees/tagall.git cd tagall
Open a terminal in the project folder and run:
Windows (PowerShell):
pip install -r requirements.txt
$env:BOT_TOKEN = "paste-your-token-here"
python bot.pyLinux / macOS:
pip install -r requirements.txt
export BOT_TOKEN="paste-your-token-here"
python bot.pyYou should see Tagall bot starting. Leave this window open — the bot only
works while it is running. (For 24/7 hosting see below.)
- Open your group in Telegram.
- Tap the group name at the top → Add members (or Edit → Members).
- Search for your bot's username and add it.
- Recommended: make it an admin (group name → Edit → Administrators → Add Administrator). It needs no special rights — admin status just lets it track joins and leaves reliably.
- Everyone who wants to be tagged sends
/tagmein the group (one time). - Anyone can now write
@everyoneor@tagallin any message — the bot tags all opted-in members (except the person who triggered it). - To point everyone at a specific message: reply to it and say
@everyone— the mentions attach to that message. - Changed your mind? Send
/untagmeand you won't be tagged anymore.
| You send | What happens |
|---|---|
@everyone or @tagall anywhere in a message |
tags all opted-in members |
/tagall, /all, /everyone |
same, as a command |
reply to a message + @everyone |
mentions attach to that message |
/tagme (or /optin) |
include me in future tags |
/untagme (or /optout) |
stop tagging me |
/help |
short explanation in chat |
In groups with several bots, add your bot's username to target it
specifically: /tagme@MyGroupTagBot.
Set these as environment variables before starting the bot:
| Variable | Default | Meaning |
|---|---|---|
BOT_TOKEN |
(required) | the token from BotFather |
TAGALL_DB |
members.db |
where the SQLite member list is stored |
TAGALL_ADMINS_ONLY |
off | 1 = only group admins can trigger a tag |
TAGALL_DEFAULT |
out |
out = members must /tagme to be tagged; in = everyone is tagged unless they /untagme |
Note on TAGALL_DEFAULT=in: Telegram doesn't let bots download a group's
member list, so in this mode the bot can only tag members it has seen post
or join since it was added. With the default opt-in mode this never matters —
sending /tagme is what registers you.
The bot works only while python bot.py is running. For always-on operation,
run it on any small server or spare machine. On Linux with systemd, this repo
includes ready-made files: copy the project to /root/tagall/, create
/root/tagall/.env containing BOT_TOKEN=your-token, then run
bash deploy/setup.sh — this installs it as a service that starts on boot
and restarts itself if it crashes.
- The bot ignores
@everyonecompletely — privacy mode is still on. Redo Part 2, then remove the bot from the group and add it back. - "Nobody has opted in to being tagged yet" — working as intended:
members must send
/tagmein the group once (Part 7, step 1). - Commands don't pop up when typing
/— redo Part 3. Conflict: terminated by other getUpdates requestin the logs — the bot is running twice (e.g. on your PC and a server). Stop one copy.- Bot stopped responding after closing the terminal — that's expected; the bot runs only while the window is open. See "Running it 24/7".
MIT — free to use, modify, and redistribute for any purpose; just keep the copyright notice with copies.