Bot for getting aneks from https://vk.com/baneks
yarn
yarn start-dev
yarn build
yarn start
yarn test
/anek
- Get random anek
/top_day
- Get most popular anek per 24 hours
/top_week
- Get most popular anek per 7 days
/top_month
- Get most popular anek per 30 days
/top_ever
- Get most popular anek of all time
/subscribe
- Subscribe to new aneks broadcast
/unsubscribe
- Unsubscribe from new aneks broadcast
All available models are located in models
directory
All telegram based logic is located in telegram.ts
file. Here you can find all available types
and almost all methods which are used in this bot.
This model contains all types and methods which are required for getting posts and comments from open groups.
Here you can find all bot related logic
- Converting VK aneks to Telegram messages
- Converting VK attachments to Telegram attachments
- Helpers for creating inline and reply buttons.
- Events on messages, replies, inline queries etc.
Also this model contains Express
middleware, which gets Update
from webhook request
and add user
and message
fields into it.
This model is responsible for communicating with API and fulfilling multiple responses as one promise.
This model takes care of creating requests queue for sending them with rates and limits of service. e.g. Telegram has rates/limits of 1 message per second for private messages and 30 messages per second for broadcasting. This model creates queues with configuration via config and helps you not caring about delays and limits of sending per second.
Each request has hidden fields for operating queue:
_key
: Unique key of queue (e.g. for private messages)_rule
: Rule name of queue, which is described in config_getBackoff
: function for getting retry timeout in case if you get 429 error
Every request in bot goes through this model.
Directory helpers
contains bot specific helpers and functions which contains
This file describes all available commands and events in bots. It's kinda entry point for all bot communications.
This daemon starts as a child process in order to not disturb main thread when you're broadcasting aneks or updating all database.
File botApi.ts
joins all models and daemons and allows communicating between them.
Feel free to contribute and create pull requests. I'll really appreciate every your change to make this bot better.