Ben is echo-bot application for Telegram and Vk.
Bot can send a message from the user to him back. Bot send response message several times. This number is set by the user.
Command | Action |
---|---|
/help | bot send info about itself |
/repeat | bot send keyboard, where user can change number of repeats messages. Keyboard also has info msg about current number of repeats |
Telegram | Vk |
---|---|
all types | Text, sticker, photo, doc, audioMessage, video, audio, market, wall, poll |
Unsupported types will be ignored
You can install bot with:
$ git clone https://github.com/JekaGrib/ben.git
$ stack build
You should create your bot in Tg or Vk.
Necessary info for Tg: https://core.telegram.org/bots#3-how-do-i-create-a-bot
Necessary info for Vk: https://vk.com/dev/bots_docs Long Poll API version - 5.85 (vk bot settings).
When you create a bot, you will receive a token
Before start, you should rename "example.config" to "bot.config". Then you should make changes in this file.
There is table with descriptions of each values in configuration file, that should be replace to your values.
App | Value | Description |
---|---|---|
Tg,Vk | startN | Default number of repeats messages. This number is set automatically, when user start work with bot. This number can then be changed by the user with the command "/repeat". It can be whole number from 1 to 5 |
Tg,Vk | botToken | Bot token |
Tg,Vk | logLevel | The logging level is specified here. The log will only display entries of this level and levels above. It can be one of four levels: DEBUG,INFO,WARNING,ERROR. More information here |
Tg,Vk | help_Info_Msg | The message that is sent to the user for the command "/help" |
Tg,Vk | repeat_Info_Question | The question that is sent to the user for the command "/repeat" |
Vk | group_id | Id of bot group |
You can run Tg bot with:
$ stack exec ben-exe Tg
You can run Vk bot with:
$ stack exec ben-exe Vk
There are 4 logging levels from lowest to highest:
- DEBUG
- INFO
- WARNING
- ERROR
The logging level is specified in Configuration. The log will only display entries of this level and levels above.
Application has three main parts.
Сommon functionality part and two specialized messenger parts. For Vk and Tg messengers.
All parts has following modeles :
App - module with main functionality (has handler)
Types - module with types
Conf - module with configuration
Log - module with logging (has handler)
Error - module with exceptions processing
Messenger parts has some extra modules:
Api - folder with parsing requests and responses modules
PrepareAttachment - module with prepare attachment messages functionality for Vk (has handler)
Modules, which has handlers, have Tests
You can test bot with:
$ stack test
Modules, which has handlers, have unit-tests:
- App.hs
- Tg.App.hs
- Vk.App.hs
- Vk.App.PrepareAttachment.hs