UA Anti Spam Bot πΊπ¦ is a Node.js bot designed to detect and block spam messages on Ukrainian language groups and channels in Telegram. The bot is built on machine learning algorithms, natural language processing techniques, and basic algorithms which allow it to effectively detect and filter out unwanted messages.
We use grammY
grammY is a powerful and user-friendly framework for building Telegram bots using Node.js. It provides a simple yet robust API for interacting with the Telegram Bot API and handling user messages, inline queries, and other events. With Grammy.js, you can quickly build complex bots with ease.
The framework comes with comprehensive documentation available at https://grammy.dev, which covers everything from getting started with installing and configuring the framework to more advanced topics like handling bot commands, keyboard interactions, and file uploads. The documentation is easy to follow and provides plenty of examples to help you get started with building your own Telegram bot.
- Before you start
- Installation
- For external users
- Running your bot
- Code Style
- Credits
If you from Master of Code Global (MOC), PM me for next things:
ua-anti-spam-bot-ml-v3.zip
.env.new
You need to be added into UA Anti Spam Bot Developers
team.
git clone git@github.com:MoC-OSS/ua-anti-spam-bot.git
cd ua-anti-spam-bot
If you have Linux or MacOS, it's better to use nvm. We have .nvmrc
file which includes the current version of node that we use on the project. Just run the following command at the root of the folder:
nvm use
If you have Windows or want to install Node into the system, find the download Node.js version specified in .nvmrc
.
If you have docker
and docker-compose
, just run the following command:
docker-compose up -d redis
If you don't want to use docker-compose
, you can install redis in system.
npm i
Copy .env.template
file to .env
:
cp .env.template .env
Now you need to get BOT_TOKEN
from @BotFather. You may find instruction here: https://core.telegram.org/bots/tutorial#obtain-your-bot-token
Set it into .env
file:
BOT_TOKEN=4839574812:AAFD39kkdpWt3ywyRZergyOLMaJhac60qc
You can ask @RawDataBot to get your ID. Simply write /start
and find message.from.id
. E.g, it will be 999999999
.
Set it into .env
file:
CREATOR_ID=999999999
We recommend to set the following variables in your .env file like this:
ENV=local
USE_SERVER=false
DISABLE_LOGS_CHAT=true
You need to obtain your own credits (or ask me if you from MOC team) and set them here:
GOOGLE_CREDITS=
GOOGLE_SPREADSHEET_ID=
We use https://alerts.com.ua/ to obtain air raid alarms. You need to ask for a key from the API developer (or me if you from MOC).
ALARM_KEY=
Extract and copy ua-anti-spam-bot-ml-v3.zip
to src/tensor/temp
.
If you are an external user, you need to set the following parameters for the following fields in .env
If you don't have GOOGLE_CREDITS
and GOOGLE_SPREADSHEET_ID
, you need to specify the value like this:
DISABLE_GOOGLE_API=true
If you don't have ALARM_KEY
, you need to specify the value like this:
DISABLE_ALARM_API=true
If you're outside the MOC organization, use the copy-swindlers.sh script to copy models from `./src/tensor/swindlers-temp` into the `./src/tensor/temp` destination:
```bash
./copy-swindlers.sh
To start your bot, simply run the following command:
npm run start:bot
After it, navigate to your bot and call /start
command. If you receive the answer, your bot is working.
Then, try to call /enable
command. If you receive the answer, your bot is set correctly and ready to be used.
If you want to run the bot via Docker, make sure that you have Docker and Docker Compose installed. Then, run the following command to start the bot in Docker:
docker-compose up --build
We use branch-name-lint
.
To push a branch, be sure you have right prefix, ticket name in uppercase, and description split by underscore. Example branch name:
- feature/UABOT-8_create_lp_ui_elements
- hotfix/UABOT-11_add_missing_login_routes
Read more: https://github.com/barzik/branch-name-lint
We use Conversational Commits Conversational with commitlint
.
To make a commit, be sure you follow it. Example:
- feat(UABOT-20): add the users page
- refactor(UABOT-10): refactor tests
Read more: https://www.conventionalcommits.org
We have a pretty heavy eslint
and prettier
setup, so you don't need to be worried about code style. Tools will make everything for you.
Don't forget to setup your IDE:
- WebStorm: Enable
eslint
plugin in this repo; - VSCode: Download and enable
eslint
plugin in this repo.
Made with β€οΈ to save Ukraine πΊπ¦ 2023