A Telegram bot built with TypeScript and Bun for RF compliance information and regulations.
- Bun v1.2.23 or higher
- A Telegram Bot Token (obtain from @BotFather)
-
Clone the repository (if applicable)
-
Install dependencies:
bun install
-
Configure environment variables:
- Copy
.env.exampleto.env:cp .env.example .env
- Edit
.envand add your Telegram bot token:TELEGRAM_BOT_TOKEN=your_actual_bot_token_here
- Copy
bun run dev- Start the bot in development mode with hot reloadbun run start- Start the bot in production modebun run build- Build the bot for productionbun run test- Run testsbun run test:coverage- Run tests with coverage reportbun run lint- Lint the codebun run lint:fix- Lint and auto-fix issuesbun run format- Format code with Prettierbun run format:check- Check code formatting
rf-compliance-bot/
├── src/ # Source code
│ └── index.ts # Main bot file
├── tests/ # Test files
│ └── bot.test.ts # Bot tests
├── .env.example # Environment variables template
├── bunfig.toml # Bun test configuration
├── tsconfig.json # TypeScript configuration
├── eslint.config.js # ESLint configuration
└── .prettierrc # Prettier configuration
/start- Start the bot and see welcome message/help- Show available commands/set_fa_blurb- Configure the foreign-agent disclosure for the current channel/notify_add,/notify_remove,/notify_list- Maintain the admins that receive moderation notifications
- The bot listens to posts that appear directly in a configured channel. If the text or caption does not contain the configured foreign-agent blurb, the bot copies the offending message to the notification list, attempts to DM the author, and removes the post from the channel.
- Make sure the blurb is configured with
/set_fa_blurbfor every moderated channel; otherwise the compliance check is skipped. - Grant the bot administrator rights with Post Messages and Delete Messages so it can remove non-compliant posts and deliver notifications.
- Use
/notify_addto enlist channel administrators who should be notified when a message is rejected. The bot will exclude the posting user from the fan-out to avoid duplicate notifications. - Telegram only includes the author ID for certain channel posts. When that identifier is unavailable, the bot still removes the message and notifies the subscribed administrators.
Run tests with:
bun testRun tests with coverage:
bun run test:coverage-
Build the bot:
bun run build
-
Set your production environment variables
-
Run the bot:
bun run start
| Variable | Description | Required |
|---|---|---|
TELEGRAM_BOT_TOKEN |
Your Telegram bot token from BotFather | Yes |
NODE_ENV |
Environment (development/production) | No |
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and linting
- Submit a pull request
This project was created using bun init in Bun v1.2.23.