Go to file
2023-06-09 14:02:45 +06:00
.github/workflows Initial commit 2022-06-17 21:54:20 +06:00
.templates/tutorial_module add runner sample 2023-05-11 01:25:11 +06:00
gradle update dependencies 2023-06-09 14:02:45 +06:00
introduction Update build.gradle 2022-12-08 11:36:03 +06:00
runner fixes in build scripts and config jsons 2023-05-11 01:50:12 +06:00
template Update build.gradle 2022-12-08 11:36:31 +06:00
welcome actualization 2023-04-27 12:11:39 +06:00
_config.yml Initial commit 2022-06-17 21:54:20 +06:00
.gitattributes Initial commit 2022-06-17 21:54:20 +06:00
.gitignore Initial commit 2022-06-17 21:54:20 +06:00
build.gradle Update build.gradle 2022-12-08 11:32:16 +06:00
config.json fixes in build scripts and config jsons 2023-05-11 01:50:12 +06:00
gradle.properties Initial commit 2022-06-17 21:54:20 +06:00
gradlew Initial commit 2022-06-17 21:54:20 +06:00
gradlew.bat Initial commit 2022-06-17 21:54:20 +06:00
LICENSE Initial commit 2022-06-17 21:54:20 +06:00
README.md upfixes 2022-06-20 21:23:49 +06:00
settings.gradle add runner sample 2023-05-11 01:25:11 +06:00

Telegram Bot Tutorial

Introduction before introduction :)

This project uses Gradle build tool and there is high chance to see gradle in the other kotlin configuration. Each part will be included in separated gradle module as Plugin from PlaguBot. Of course, that does not mean that all the logic of each plugin will be only in one file, but I will try hard to not forget mention it.

Basically, PlaguBot uses this template of config, but in each (or almost each) part of this tutorial will be shown how to add your own fields to this config and deserialize it. There are several important things about plugins:

  • Plugin realization (excepting abstract ones, of course) must have empty constructor for creating an instance or be an object (like object MyPlugin : Plugin)
  • Plugin have two sections - for DI setup (lets name it config stage) and bot setup (plelaunch stage)
  • Plugin have access predefined things from koin in setupBotPlugin or received in modules scopes:
    • PlaguBot config
    • PlaguBot plugins
    • Database and its config
    • Default Json format (can be accessed as koin.get<Json>())
    • The PlaguBot itself

How to launch

First, you need to change bot token inside of config.json. The other parts should be described in the readmes of the modules with these parts.

There are two main ways to launch it:

  • Run ./gradlew build && ./gradlew run --args="PATH_TO_YOUR_CONFIG" with replacing of PATH_TO_YOUR_CONFIG
  • Run ./gradlew build and get zip of bot and unarchive it somewhere you need. In this archive there is an executable files bot.bat (for windows) and bot (for linux) by the path inside of archive /bot/bin. After unarchiving you can just launch executable file with one argument: path to the config