Giter Site home page Giter Site logo

moc-oss / ua-anti-spam-bot Goto Github PK

View Code? Open in Web Editor NEW
9.0 3.0 6.0 8.14 MB

πŸ€– The bot automatically deletes messages containing the names of city locations, shelters, as well as keywords for the movement of troops

Home Page: https://t.me/UaAntiSpam_bot

License: GNU General Public License v3.0

Shell 0.32% JavaScript 3.79% Dockerfile 0.07% TypeScript 95.50% HTML 0.23% CSS 0.08%
bot telegram telegraf grammy grammyjs antispam antispambot ukraine stopwar

ua-anti-spam-bot's Introduction

UA Anti Spam Bot πŸ‡ΊπŸ‡¦

last commit

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.

Table of Content

Before you start

If you from Master of Code Global (MOC), PM me for next things:

1. Files

ua-anti-spam-bot-ml-v3.zip
.env.new

2. Github Access

You need to be added into UA Anti Spam Bot Developers team.

Installation

1. Cloning

git clone [email protected]:MoC-OSS/ua-anti-spam-bot.git
cd ua-anti-spam-bot

2. Installing Node.js

NVM (recommended)

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

Node

If you have Windows or want to install Node into the system, find the download Node.js version specified in .nvmrc.

3. Installing Redis

Docker-compose (recommended)

If you have docker and docker-compose, just run the following command:

docker-compose up -d redis

Install in System

If you don't want to use docker-compose, you can install redis in system.

4. Installing node_modules

npm i

5. Copy .env file

Copy .env.template file to .env:

cp .env.template .env

6. Create your bot

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

7. Set your Telegram ID

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

8. Set local testing .env variables

We recommend to set the following variables in your .env file like this:

ENV=local
USE_SERVER=false
DISABLE_LOGS_CHAT=true

9. Set Google Credits (confidential)

You need to obtain your own credits (or ask me if you from MOC team) and set them here:

GOOGLE_CREDITS=
GOOGLE_SPREADSHEET_ID=

10. Set Alarm Credits (confidential)

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=

11. Copy tensor files

Extract and copy ua-anti-spam-bot-ml-v3.zip to src/tensor/temp.

For external users

If you are an external user, you need to set the following parameters for the following fields in .env

1. Disable Google API

If you don't have GOOGLE_CREDITS and GOOGLE_SPREADSHEET_ID, you need to specify the value like this:

DISABLE_GOOGLE_API=true

2. Disable Alarm API

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

Running your bot

To start your bot, simply run the following command:

npm run start:bot

Enable bot in Telegram

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.

Docker

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

Code Style

Branch names

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

Commit names

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

Code Rules

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.

IDE Setup

Don't forget to setup your IDE:

  1. WebStorm: Enable eslint plugin in this repo;
  2. VSCode: Download and enable eslint plugin in this repo.

Credits

Made with ❀️ to save Ukraine πŸ‡ΊπŸ‡¦ 2023

ua-anti-spam-bot's People

Contributors

174n avatar andrii-smahin-moc avatar dependabot[bot] avatar dmytroavramenko avatar drsmile444 avatar eshatokhin avatar filosoff13 avatar jaxin007 avatar mzabolotnev-liveperson avatar pavlo-sokurenko-moc avatar roman-dashko-moc avatar vadym-tyshchenko-moc avatar vadym-zinchenko-moc avatar vbrusentsov avatar yaroslavbelinskyimoc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.