mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template.git
synced 2026-10-25 21:36:56 +00:00
Compare commits
43
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e6b75e5000 | ||
|
|
4a71d78aba | ||
|
|
6e7210326a | ||
|
|
25583c6947 | ||
|
|
c7a5631184 | ||
|
|
9f1ae5bd17 | ||
|
|
1f2bd0b14a | ||
|
|
18ff841e9a | ||
|
|
a103cfb0f3 | ||
|
|
cbaf7277b0 | ||
|
|
ede5d944d5 | ||
|
|
0b08886be1 | ||
|
|
0487b44a3e | ||
|
|
ed12f41336 | ||
|
|
171a4a5060 | ||
|
|
0477319f12 | ||
|
|
fcc0b49576 | ||
|
|
e86d07d25d | ||
|
|
2c1f4e8202 | ||
|
|
14ce90d323 | ||
|
|
fbbc7d8cc0 | ||
|
|
c543f7ff6c | ||
|
|
77b61dff04 | ||
|
|
be4cefb875 | ||
|
|
97731ea814 | ||
|
|
6db81e1cb4 | ||
|
|
5428b048b8 | ||
|
|
86d535a1dc | ||
|
|
cf91388eef | ||
|
|
72e1e2feab | ||
|
|
dc1c783df3 | ||
|
|
df5c32a194 | ||
|
|
3181e7c985 | ||
|
|
0d9965f953 | ||
|
|
e2626f4163 | ||
|
|
f46b976f52 | ||
|
|
cfe4a79b19 | ||
|
|
31b5a18354 | ||
|
|
439d51cdfe | ||
|
|
84677466f2 | ||
|
|
28e5b337f2 | ||
|
|
25b264d8ed | ||
|
|
558c047d26 |
No files matched your search
@@ -8,9 +8,9 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Set up JDK 1.8
|
- name: Set up JDK 11
|
||||||
uses: actions/setup-java@v1
|
uses: actions/setup-java@v1
|
||||||
with:
|
with:
|
||||||
java-version: 1.8
|
java-version: 11
|
||||||
- name: Build with Gradle
|
- name: Build with Gradle
|
||||||
run: ./gradlew build
|
run: ./gradlew build
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
FROM adoptopenjdk/openjdk11
|
||||||
|
|
||||||
|
USER 1000
|
||||||
|
|
||||||
|
VOLUME /config.json
|
||||||
|
|
||||||
|
ENTRYPOINT ["/telegram_bot/bin/telegram_bot", "TOKEN"]
|
||||||
|
|
||||||
|
ADD ./build/distributions/telegram_bot.tar /
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#!make
|
||||||
|
|
||||||
|
.ONESHELL:
|
||||||
|
.PHONY:
|
||||||
|
|
||||||
|
clean:
|
||||||
|
./gradlew clean
|
||||||
|
|
||||||
|
build:
|
||||||
|
./gradlew build
|
||||||
|
|
||||||
|
start:
|
||||||
|
./gradlew run
|
||||||
|
|
||||||
|
startCompose:
|
||||||
|
docker-compose build && docker-compose up
|
||||||
|
|
||||||
|
buildAndStartCompose:
|
||||||
|
make clean build startCompose
|
||||||
@@ -17,6 +17,13 @@ output you will get your bot information like:
|
|||||||
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))
|
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))
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Docker
|
||||||
|
|
||||||
|
In this template there is template-like [docker-compose](docker-compose.yml) and [docker](Dockerfile) files. Besides,
|
||||||
|
there is [Makefile](Makefile) and you may use something like `make buildAndStartCompose` to start your bot.
|
||||||
|
|
||||||
|
It is important to replace `"TOKEN"` in [Dockerfile](Dockerfile) or remove and add some config as a volume.
|
||||||
|
|
||||||
## What next?
|
## What next?
|
||||||
|
|
||||||
There are several ways to continue:
|
There are several ways to continue:
|
||||||
|
|||||||
+12
-8
@@ -1,31 +1,35 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath libs.kotlin.gradle.plugin
|
||||||
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
classpath libs.kotlin.serialization.plugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'org.jetbrains.kotlin.jvm' version "$kotlin_version"
|
alias libs.plugins.kotlin.jvm
|
||||||
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version"
|
alias libs.plugins.kotlin.serialization
|
||||||
id 'application'
|
id 'application'
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
implementation libs.kotlin
|
||||||
|
|
||||||
implementation "dev.inmo:tgbotapi:$tgbotapi_version"
|
implementation libs.tgbotapi
|
||||||
}
|
}
|
||||||
|
|
||||||
application {
|
application {
|
||||||
mainClassName = 'telegram_bot.AppKt'
|
mainClassName = 'telegram_bot.AppKt'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_11
|
||||||
|
targetCompatibility = JavaVersion.VERSION_11
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
version: "3.4"
|
||||||
|
|
||||||
|
services:
|
||||||
|
server:
|
||||||
|
build: .
|
||||||
|
restart: unless-stopped
|
||||||
@@ -3,6 +3,3 @@ kotlin.code.style=official
|
|||||||
org.gradle.parallel=true
|
org.gradle.parallel=true
|
||||||
kotlin.js.generate.externals=true
|
kotlin.js.generate.externals=true
|
||||||
kotlin.incremental=true
|
kotlin.incremental=true
|
||||||
|
|
||||||
kotlin_version=1.4.30
|
|
||||||
tgbotapi_version=0.32.5
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
[versions]
|
||||||
|
|
||||||
|
kotlin = "1.6.10"
|
||||||
|
tgbotapi = "0.38.12"
|
||||||
|
|
||||||
|
[libraries]
|
||||||
|
|
||||||
|
kotlin = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
|
||||||
|
tgbotapi = { module = "dev.inmo:tgbotapi", version.ref = "tgbotapi" }
|
||||||
|
|
||||||
|
# Libs for classpath
|
||||||
|
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
|
||||||
|
kotlin-serialization-plugin = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin" }
|
||||||
|
|
||||||
|
[plugins]
|
||||||
|
|
||||||
|
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
|
||||||
|
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
|
||||||
|
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
@@ -1 +1,3 @@
|
|||||||
rootProject.name = 'telegram_bot'
|
rootProject.name = 'telegram_bot'
|
||||||
|
|
||||||
|
enableFeaturePreview("VERSION_CATALOGS")
|
||||||
@@ -3,7 +3,7 @@ package telegram_bot
|
|||||||
import dev.inmo.tgbotapi.bot.Ktor.telegramBot
|
import dev.inmo.tgbotapi.bot.Ktor.telegramBot
|
||||||
import dev.inmo.tgbotapi.extensions.api.bot.getMe
|
import dev.inmo.tgbotapi.extensions.api.bot.getMe
|
||||||
import dev.inmo.tgbotapi.extensions.api.send.reply
|
import dev.inmo.tgbotapi.extensions.api.send.reply
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.buildBehaviour
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.buildBehaviourWithLongPolling
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onCommand
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onCommand
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ suspend fun main(args: Array<String>) {
|
|||||||
val scope = CoroutineScope(Dispatchers.Default)
|
val scope = CoroutineScope(Dispatchers.Default)
|
||||||
|
|
||||||
// here should be main logic of your bot
|
// here should be main logic of your bot
|
||||||
bot.buildBehaviour(scope) {
|
bot.buildBehaviourWithLongPolling(scope) {
|
||||||
// in this lambda you will be able to call methods without "bot." prefix
|
// in this lambda you will be able to call methods without "bot." prefix
|
||||||
val me = getMe()
|
val me = getMe()
|
||||||
|
|
||||||
@@ -27,7 +27,9 @@ suspend fun main(args: Array<String>) {
|
|||||||
// simply reply :)
|
// simply reply :)
|
||||||
reply(it, "Hello, I am ${me.firstName}")
|
reply(it, "Hello, I am ${me.firstName}")
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
scope.coroutineContext.job.join()
|
// That will be called on the end of bot initiation. After that prinln will be started long polling and bot will
|
||||||
|
// react on your commands
|
||||||
|
println(me)
|
||||||
|
}.join()
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user