mirror of
https://github.com/InsanusMokrassar/PlaguBotBotTemplate.git
synced 2024-11-21 23:23:48 +00:00
fill
This commit is contained in:
parent
43d361c9e1
commit
8c7e527468
42
README.md
42
README.md
@ -1,28 +1,22 @@
|
||||
# Telegram Bot Template
|
||||
# PlaguBot Bot Template
|
||||
|
||||
That is template for telegram bots based on next stack of technologies:
|
||||
1. Update your dependencies [here](./build.gradle#L30). Usually in gradle projects/readmes developers define names of
|
||||
their dependencies
|
||||
2. Edit [config](config.json). The main points
|
||||
([full list of parameters with explanation](https://github.com/InsanusMokrassar/PlaguBot/blob/master/template.config.json):
|
||||
* Change [database](./config.json#L3) section
|
||||
* Change [bot token](./config.json#L5))
|
||||
* Change [list of plugins](./config.json#L6-L11):
|
||||
* Field `type` - it is name of the plugin provided by developer/dependency
|
||||
* Other fields are parameters of plugin and must be provided directly
|
||||
* Example is available in the [example section](./config.json#L6-L11): here `Hello` is name of plugin and
|
||||
`parameter` is its configuration parameter
|
||||
|
||||
* [Kotlin Coroutines](https://github.com/Kotlin/kotlinx.coroutines)
|
||||
* [Kotlin Serialization](https://github.com/Kotlin/kotlinx.serialization)
|
||||
* [Telegram Bot API Library](https://github.com/InsanusMokrassar/TelegramBotAPI) (by default everything is included like
|
||||
it was described [here](https://github.com/InsanusMokrassar/TelegramBotAPI#ok-where-should-i-start))
|
||||
## How to launch
|
||||
|
||||
## Default
|
||||
There are two main ways to launch it:
|
||||
|
||||
Since you have used this repo as a template you can simply run command `./gradlew run --args="BOT_TOKEN"` (of course,
|
||||
replace here `BOT_TOKEN` with your telegram bot token like `1234567890:ABCDEFGHIJKLM_OPqrstuvwxyz012345678`). As an
|
||||
output you will get your bot information like:
|
||||
|
||||
```bash
|
||||
ExtendedBot(id=ChatId(chatId=1234567890), username=Username(username=@username_of_your_bot), firstName=Name of bot, lastName=, canJoinGroups=(some boolean), canReadAllGroupMessages=(some boolean), supportsInlineQueries=(some boolean))
|
||||
```
|
||||
|
||||
## What next?
|
||||
|
||||
There are several ways to continue:
|
||||
|
||||
* [Tutorials](https://bookstack.inmo.dev/books/telegrambotapi)
|
||||
* [Github readme](https://github.com/InsanusMokrassar/TelegramBotAPI)
|
||||
|
||||
In other words, this template (and [TelegramBotAPI library](https://github.com/InsanusMokrassar/TelegramBotAPI)) does
|
||||
not limit you on choosing of way to continue 😊
|
||||
* 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](build/distributions/bot.zip) 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
|
||||
|
17
build.gradle
17
build.gradle
@ -12,22 +12,29 @@ buildscript {
|
||||
plugins {
|
||||
id 'org.jetbrains.kotlin.jvm' version "$kotlin_version"
|
||||
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version"
|
||||
id "org.jetbrains.kotlin.kapt" version "$kotlin_version"
|
||||
id 'application'
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
maven { url 'https://jitpack.io' }
|
||||
maven { url "https://dl.bintray.com/insanusmokrassar/PlaguBot/" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlin_serialisation_runtime_version"
|
||||
|
||||
implementation "dev.inmo:tgbotapi:$tgbotapi_version"
|
||||
api "dev.inmo:plagubot.bot:$plagubot_version"
|
||||
}
|
||||
|
||||
application {
|
||||
mainClassName = 'telegram_bot.AppKt'
|
||||
mainClassName = 'dev.inmo.plagubot.AppKt'
|
||||
}
|
||||
|
||||
kapt {
|
||||
arguments {
|
||||
arg("com.github.matfax.klassindex.IndexSubclasses", "dev.inmo.plagubot.Plugin")
|
||||
}
|
||||
}
|
||||
|
12
config.json
Normal file
12
config.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"database": {
|
||||
"url": "jdbc:sqlite:file:test?mode=memory&cache=shared"
|
||||
},
|
||||
"botToken": "1234567890:ABCDEFGHIJKLMNOP_qrstuvwxyz12345678",
|
||||
"plugins": [
|
||||
{
|
||||
"type": "Hello",
|
||||
"parameter": "Example"
|
||||
}
|
||||
]
|
||||
}
|
@ -1,10 +1,7 @@
|
||||
org.gradle.jvmargs=-Xmx2048m
|
||||
kotlin.code.style=official
|
||||
org.gradle.parallel=true
|
||||
kotlin.js.generate.externals=true
|
||||
kotlin.incremental=true
|
||||
|
||||
kotlin_version=1.4.10
|
||||
kotlin_coroutines_version=1.4.1
|
||||
kotlin_serialisation_runtime_version=1.0.1
|
||||
tgbotapi_version=0.30.0
|
||||
plagubot_version=0.0.1
|
||||
|
@ -1 +1 @@
|
||||
rootProject.name = 'telegram_bot'
|
||||
rootProject.name = "bot"
|
||||
|
@ -1,13 +0,0 @@
|
||||
package telegram_bot
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.api.bot.getMe
|
||||
import dev.inmo.tgbotapi.extensions.api.telegramBot
|
||||
|
||||
/**
|
||||
* This method by default expects one argument in [args] field: telegram bot token
|
||||
*/
|
||||
suspend fun main(args: Array<String>) {
|
||||
val bot = telegramBot(args.first())
|
||||
|
||||
println(bot.getMe())
|
||||
}
|
Loading…
Reference in New Issue
Block a user