- Removes any join and leave messages.
- Removes any channel-originated messages.
- Adds captcha for joining users.
- Logs all join actions.
- Nix: use
ugragatekeeper
package orugragatekeeper
NixOS module from the flake - Other systems: use Poetry:
poetry install
- TODO: publish to PyPI/etc
ugragatekeeper -c CONFIG (-t TCP | -u UNIX) -d DOMAIN
-c CONFIG
— path to configuration file-t TCP
— host and port to listen on (ex.127.0.0.1:5050
), or just a port (ex.5050
), implying listening on all hostnames-u UNIX
— path to UNIX-socket to listen on (ex./tmp/gate.sock
)-d DOMAIN
— domain name which will be sent to Telegram
Notes:
- You need a reverse proxy to support HTTPS. Telegram does not allow HTTP webhooks.
- You can provide only one of
-t
,-u
options.
Configuration file is an YAML file. Example is provided in config-example.yaml
.
Configuration of Telegram bot.
bot.token
— Telegram bot token, str, required.bot.chat_id
— Chat ID to manage, int, required.
Bot is single-chat and won't work in others, even if added as an admin.
Configuration of modules. Now there is 5 modules. To enable module, add its key without a parameters. Example:
modules:
some_module: {}
You may also specify some options, if supported:
modules:
some_module:
some_option: value
Logs all actions to Telegram.
modules.logging.chat_id
— Chat ID to log into, int, required.
If it's a channel or group (negative value), bot should be added to chat. If it's a user (positive value), you should start conversation with a bot.
If module is disabled, bot will log to stderr.
Removes messages X was accepted into group
, X joined the group
, etc.
No options.
Removes messages X left the group
, X removed Y
, etc.
Removes all anonymous messages.
This is not applied to anonymous admins of the current group, messages from the linked channel (both forwarded posts and anonymous) and allowed channels.
modules.remove_channel_messages.exceptions
— IDs of allowed channels for anonymous posting, list[int], optional, default is empty
Enables processing of chat join requests. You should enable “Request Admin Approval” in private chats or “Who can send messages? → Only members, Approve new members” in public chats.
If public chat is linked to a channel, you should protect comments as well.
When someone tries to join the chat, bot will send question to them. If they answer correctly, they are approved. The number of tries is unlimited.
modules.process_join_requests.question
— Question text, str, requiredmodules.process_join_requests.answer
— Correct answer, str, requiredmodules.process_join_requests.correct_feedback
— Feedback for correct answer, str, requiredmodules.process_join_requests.incorrect_feedback
— Feedback for wrong answer, str, requiredmodules.process_join_requests.approve_fail_feedback
— Feedback when approve failed, str, required
Notes:
- Correct answer is checked the following way:
config.answer in message.text.lower()
- Approve may fail, if user deleted the group or was approved by admin manually, or send answer after the first approval.
The project provides module ugragatekeeper
with three options:
config
— configuration with the same keys as aboveprivateConfigFile
— path to YAML file with “secret” keys (likebot.token
), will be merged into config usingyaml-merge
domain
— domain name for-d
The module uses nginx as a reverse proxy.
- Add Telegram Premium users right away.
- Add users that were approved once right away.
- Add other metrics.