2.1 KiB
2.1 KiB
Task Force Beta Bot
General-purpose Telegram bot with modular handler architecture.
Build & Run
cargo build --release
Usage
task_force_beta_bot <token_file> <allowed_chats_file>
Both arguments are required:
token_file- Path to file containing the Telegram bot tokenallowed_chats_file- Path to file containing allowed chat IDs
Example:
cargo run -- /path/to/token /path/to/allowed_chats
Allowed Chats File
One chat ID per line. Lines starting with # are comments.
# My group
-100123456789
The bot ignores messages from chats not in this list.
Architecture
src/main.rs- Entry point, dispatcher setupsrc/config.rs- Token and allowed chats loading from CLI argumentssrc/handlers/- Message handlers (modular, each feature in own file)src/utils/- Shared utilities
NixOS Deployment
Module location: /home/fabian/nix/sys/modules/task-force-beta-bot.nix
local.sys.task-force-beta-bot = {
enable = true;
tokenFile = "/var/trust/task_force_beta_bot/telegram_token";
allowedChats = [ (-1001234567890) ]; # Negative IDs for groups
};
The module:
- Fetches and builds the package from git
- Generates the allowed chats file in the nix store
- Runs as a hardened systemd service (
task-force-beta-bot.service)
After code changes: update rev and hash in the module's fetchgit block.
Adding New Handlers
- Create
src/handlers/new_feature.rs - Export in
src/handlers/mod.rs - Add handler branch in
handlers::schema()
Current Features
Instagram Link Cleaning (handlers/instagram.rs)
Strips tracking parameters from Instagram links:
igsh,igshid- Instagram share trackingutm_*- UTM campaign trackingref- Referral trackingfbclid- Facebook click IDsi- Session identifier
Tag All (handlers/tag_all.rs)
WhatsApp-style @all mentions. When a message contains "@all", bot replies tagging everyone it has seen.
- Tracks users by observing messages (requires privacy mode disabled)
- In-memory only - resets on restart
- Uses MarkdownV2 text mentions