Very simple telegram bot that uses TelegramBots library. The bot has 26 services for sending sms.
This material was taken from the public and provided for educational purposes only! I do not encourage you to repeat all the actions and I do not bear responsibility for this!
This library use Telegram bot API, you can find more information following the link.
Application architecture is designed using MVC pattern, which contains one model, nine controllers and one view.
java
βββ info.securedev.telegram.bot
βΒ Β βββ controllers
βΒ Β βΒ Β βββ CommandHandlerController
βΒ Β βΒ Β βββ RouteController
β β βββ Command (interface)
β β βββ BaseCommandController (abstract class implements Command interface)
β β βββ StartCommandController (extends BaseCommandController)
β β βββ HelpCommandController (extends BaseCommandController)
β β βββ FloodDataCommandController (extends BaseCommandController)
β β βββ FloodStartCommandController (extends BaseCommandController)
β β βββ FloodCancelCommandController (extends BaseCommandController)
β β βββ UnknownCommandController (extends BaseCommandController)
βΒ Β βββ models
βΒ Β βΒ Β βββ Model
βΒ Β βββ flood_services
βΒ Β β βββ Flood (interface)
βΒ Β βΒ Β βββ FloodService.Builder (implements Flood)
βΒ Β βΒ Β βββ FloodServiceFactory
βΒ Β βββ views
βΒ Β βΒ Β βββ StartFlood
βΒ Β βββ settings
βΒ Β βΒ Β βββ BotConfig
βΒ Β βΒ Β βββ RoutesContainer
βΒ Β βββ utils
βΒ Β βΒ Β βββ Message.Builder
βΒ Β βΒ Β βββ ...
β βββ MyBot
β βββ Main
βββ pom.xml
- Controllers - CommandHandlerController and RouteController are base controllers, define which controller should be called next, depending on the input command. CommandHandlerController get command controllers from RouteController. RouteController get routes from RoutesContainer, which located in settings package. CommandΠ‘ontrollers (like StartCommandController) are responsible for base logics for proccesing the command, like send message, interact with model, view, etc. This is all designed by factory method pattern.
- Model - contains ArrayLists of flood services and filtered input numbers.
- View - get data from model and start flood.
- Flood_services - FloodService.Builder class build objects for flood services, which send HTTP/HTTPS request with input numbers (Builder pattern). FloodServiceFactory class generate this objects and add in ArrayList.
Before compile project you need to add the TelegramBots library to your project and create new bot with BotFather bot (if you don't have bot), set bot token, bot username and creater id (you can get with another bots) into BotConfig class, which located in settings package. And in this class you can turn on/of validation numbers for KZ format and change messages text, text in inline buttons, etc.