Follow the steps below to set up and execute a Rust-based Telegram bot that removes users joining after a given date.
- Open the Telegram app.
- Search for BotFather and start a chat with it.
- Use the
/newbot
command to create a new bot. - Follow the instructions given by BotFather to set a name and username for your bot.
- Note down the token provided by BotFather, you'll need it later.
Clone the project locally.
cargo build --release
./target/release/telegram_bot_remove_users -d 2023-09-24 -t BOT_TOKEN
Note: Replace
2023-09-24
with any date of your choice.
- Navigate to the desired channel or group settings.
- Add your bot as an administrator.
- Ensure you grant the bot the "Can manage chat" permission, which will allow it to remove users.
With everything set up and running, the bot will begin monitoring the channel or group. It will automatically remove users joining after the specified cut-off date.
Important: This setup is basic, and the bot might behave unexpectedly if users have permissions to add other users or if other bots and configurations exist in the group. Ensure thorough testing and include adequate error handling for a production-level application.
Feel free to use, share, or modify this guide as needed!