Another Vibcoding creation: Meet Chur-bot!

Another Vibcoding creation: Meet Chur-bot!

It turned out that I'm managing a Telegram group in a new residential complex.
Due to the large number of spammers in Telegram, access had to be granted based on requests.
Initially, there were a few requests per week, which I handled manually. However, recently, the spammers have become very active. There can be up to 20-30 requests per day.
I have to go into the profile of each applicant, ask them control questions. It doesn't seem like much time, but it's still a lot :)

So, I had to vibecode a bot :)
It took about 5 hours of pure time. Most of that was spent on testing :)
The configuration file allows you to define lists of control questions. For example, I ask for the apartment number and the floor it's located on.
The bot checks the correctness of the apartment number and its location on the floor.

Excerpts from README.md

Why Chur-Bot?

Mythology: Slavic.
Legend: Chur is an ancient deity of boundaries, borders, and the protection of property. Just as Chur protected the borders of our ancestors, this bot protects the borders of your Telegram group.

Description

Chur-Bot allows you to automate the process of admitting new members to a Telegram group based on their answers to questions.

Functionality

  • Guardian: Intercepts requests to join the chat (chat_join_request).
  • Interrogation: Asks configured questions in private messages.
  • Court: Approves the request if the answers are correct; otherwise, rejects it.
  • Timeout: Automatically rejects requests if the user remains silent for too long.

Installation and Update (Linux)

  1. Run the installation script:

    bash
    chmod +x setup.sh
    ./setup.sh
    

    The script will perform all the necessary actions:

    • Creates the user chur_bot.
    • Creates a virtual environment and installs dependencies.
    • Configures and starts the systemd service.
  2. Configuration:

    • Copy config.yaml.example to config.yaml.
    • Edit config.yaml: specify the token, admin IDs, and questions.
    • Restart the service to apply the settings: sudo systemctl restart chur_bot
  3. Configuration in Telegram:

    • Go to group settings -> Group Type / Members.
    • Enable "Approve New Members".
    • Add the bot to the group and make it an Administrator with the permission "Invitation Links".

Update

To update the bot code and dependencies:

bash
chmod +x update.sh
./update.sh

Service Management

  • Status: sudo systemctl status chur_bot
  • Logs: journalctl -u chur_bot -f
  • Restart: sudo systemctl restart chur_bot

Administrator Commands

  • /stats: Shows statistics of requests (pending, approved, rejected).
  • /logs: Shows the last 10 log entries directly in Telegram.
  • Important: These commands only work for users specified in admin_ids in config.yaml.

Utility Commands

  • /id: Sends the current chat ID and user ID. Use this to fill in config.yaml.

Viewing Logs

The bot writes logs to the console and to the file bot.log.

  • Console: Just look at the terminal where the bot is running.
  • File: tail -f bot.log or open bot.log in an editor.
  • Telegram command: Send /logs to the bot in a private message (only for Admins).

Share this article