mirror of
https://github.com/InsanusMokrassar/PlaguBot.git
synced 2024-11-22 07:33:46 +00:00
commit
6dec930a9d
16
.github/workflows/build.yml
vendored
Normal file
16
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
name: Build
|
||||||
|
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set up JDK 1.8
|
||||||
|
uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: 1.8
|
||||||
|
- name: Build with Gradle
|
||||||
|
run: ./gradlew build
|
12
CHANGELOG.md
12
CHANGELOG.md
@ -1,5 +1,17 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.1.0
|
||||||
|
|
||||||
|
* `Versions`
|
||||||
|
* `kotlin`: `1.4.21` -> `1.4.30`
|
||||||
|
* `serialization`: `1.0.1` -> `1.1.0-RC`
|
||||||
|
* `exposed`: `0.28.1` -> `0.29.1`
|
||||||
|
* `tgbotapi`: `0.30.10` -> `0.32.5`
|
||||||
|
* `microutils`: `0.4.11` -> `0.4.25`
|
||||||
|
* `Plugin`
|
||||||
|
* New method `BehaviourContext#invoke`
|
||||||
|
* Old method `invoke` has been deprecated
|
||||||
|
|
||||||
## 0.0.5
|
## 0.0.5
|
||||||
|
|
||||||
* `Versions`
|
* `Versions`
|
||||||
|
@ -1 +1 @@
|
|||||||
{"bintrayConfig":{"repo":"PlaguBot","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/PlaguBot","autoPublish":true,"overridePublish":true},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/PlaguBot/LICENSE"}],"mavenConfig":{"name":"PlaguBot ${project.name}","description":"","url":"https://github.com/InsanusMokrassar/PlaguBot","vcsUrl":"ssh://git@github.com/InsanusMokrassar/PlaguBot.git","developers":[{"id":"InsanusMokrassar","name":"Aleksei Ovsiannikov","eMail":"ovsyannikov.alexey95@gmail.com"}]},"type":"JVM"}
|
{"bintrayConfig":{"repo":"PlaguBot","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/PlaguBot","autoPublish":true,"overridePublish":true},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/PlaguBot/LICENSE"}],"mavenConfig":{"name":"PlaguBot Bot","description":"Base PlaguBot project","url":"https://github.com/InsanusMokrassar/PlaguBot","vcsUrl":"ssh://git@github.com/InsanusMokrassar/PlaguBot.git","includeGpgSigning":true,"publishToMavenCentral":true,"developers":[{"id":"InsanusMokrassar","name":"Aleksei Ovsiannikov","eMail":"ovsyannikov.alexey95@gmail.com"}]},"type":"JVM"}
|
@ -1,9 +1,6 @@
|
|||||||
apply plugin: 'maven-publish'
|
apply plugin: 'maven-publish'
|
||||||
|
apply plugin: 'signing'
|
||||||
|
|
||||||
task sourcesJar(type: Jar) {
|
|
||||||
from sourceSets.main.allSource
|
|
||||||
classifier = 'sources'
|
|
||||||
}
|
|
||||||
|
|
||||||
task javadocJar(type: Jar) {
|
task javadocJar(type: Jar) {
|
||||||
from javadoc
|
from javadoc
|
||||||
@ -15,14 +12,13 @@ publishing {
|
|||||||
maven(MavenPublication) {
|
maven(MavenPublication) {
|
||||||
from components.java
|
from components.java
|
||||||
|
|
||||||
artifact sourcesJar
|
|
||||||
artifact javadocJar
|
artifact javadocJar
|
||||||
|
|
||||||
pom {
|
pom {
|
||||||
resolveStrategy = Closure.DELEGATE_FIRST
|
resolveStrategy = Closure.DELEGATE_FIRST
|
||||||
|
|
||||||
description = ""
|
description = "Base PlaguBot project"
|
||||||
name = "PlaguBot ${project.name}"
|
name = "PlaguBot Bot"
|
||||||
url = "https://github.com/InsanusMokrassar/PlaguBot"
|
url = "https://github.com/InsanusMokrassar/PlaguBot"
|
||||||
|
|
||||||
scm {
|
scm {
|
||||||
@ -59,8 +55,23 @@ publishing {
|
|||||||
password = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY')
|
password = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maven {
|
||||||
|
name = "sonatype"
|
||||||
|
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
|
||||||
|
credentials {
|
||||||
|
username = project.hasProperty('SONATYPE_USER') ? project.property('SONATYPE_USER') : System.getenv('SONATYPE_USER')
|
||||||
|
password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
signing {
|
||||||
|
useGpgCmd()
|
||||||
|
sign publishing.publications
|
||||||
|
}
|
||||||
|
@ -3,9 +3,10 @@ package dev.inmo.plagubot
|
|||||||
import dev.inmo.micro_utils.coroutines.safelyWithoutExceptions
|
import dev.inmo.micro_utils.coroutines.safelyWithoutExceptions
|
||||||
import dev.inmo.plagubot.config.Config
|
import dev.inmo.plagubot.config.Config
|
||||||
import dev.inmo.plagubot.config.configSerialFormat
|
import dev.inmo.plagubot.config.configSerialFormat
|
||||||
|
import dev.inmo.tgbotapi.bot.Ktor.telegramBot
|
||||||
import dev.inmo.tgbotapi.extensions.api.bot.setMyCommands
|
import dev.inmo.tgbotapi.extensions.api.bot.setMyCommands
|
||||||
import dev.inmo.tgbotapi.extensions.api.telegramBot
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.buildBehaviour
|
||||||
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingFlowsUpdatesByLongPolling
|
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.longPolling
|
||||||
import dev.inmo.tgbotapi.types.botCommandsLimit
|
import dev.inmo.tgbotapi.types.botCommandsLimit
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.serialization.InternalSerializationApi
|
import kotlinx.serialization.InternalSerializationApi
|
||||||
@ -17,9 +18,9 @@ suspend inline fun initPlaguBot(
|
|||||||
) {
|
) {
|
||||||
val bot = telegramBot(config.botToken)
|
val bot = telegramBot(config.botToken)
|
||||||
|
|
||||||
bot.startGettingFlowsUpdatesByLongPolling(scope = scope) {
|
bot.buildBehaviour(scope) {
|
||||||
val commands = config.plugins.flatMap {
|
val commands = config.plugins.flatMap {
|
||||||
it.invoke(bot, config.database.database, this, scope)
|
it.apply { invoke(config.database.database) }
|
||||||
it.getCommands()
|
it.getCommands()
|
||||||
}.let {
|
}.let {
|
||||||
val futureUnavailable = it.drop(botCommandsLimit.last)
|
val futureUnavailable = it.drop(botCommandsLimit.last)
|
||||||
@ -28,11 +29,7 @@ suspend inline fun initPlaguBot(
|
|||||||
}
|
}
|
||||||
it.take(botCommandsLimit.last)
|
it.take(botCommandsLimit.last)
|
||||||
}
|
}
|
||||||
scope.launch {
|
safelyWithoutExceptions { setMyCommands(commands) }
|
||||||
safelyWithoutExceptions {
|
|
||||||
bot.setMyCommands(commands)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package dev.inmo.plagubot
|
package dev.inmo.plagubot
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||||
import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import org.jetbrains.exposed.sql.Database
|
import org.jetbrains.exposed.sql.Database
|
||||||
@ -12,12 +10,7 @@ import org.jetbrains.exposed.sql.Database
|
|||||||
data class HelloPlugin(
|
data class HelloPlugin(
|
||||||
val parameter: String
|
val parameter: String
|
||||||
) : Plugin {
|
) : Plugin {
|
||||||
override suspend fun invoke(
|
override suspend fun BehaviourContext.invoke(database: Database) {
|
||||||
bot: TelegramBot,
|
|
||||||
database: Database,
|
|
||||||
updatesFilter: FlowsUpdatesFilter,
|
|
||||||
scope: CoroutineScope
|
|
||||||
) {
|
|
||||||
println(parameter)
|
println(parameter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,16 +4,16 @@ org.gradle.parallel=true
|
|||||||
kotlin.js.generate.externals=true
|
kotlin.js.generate.externals=true
|
||||||
kotlin.incremental=true
|
kotlin.incremental=true
|
||||||
|
|
||||||
kotlin_version=1.4.21
|
kotlin_version=1.4.30
|
||||||
kotlin_coroutines_version=1.4.2
|
kotlin_coroutines_version=1.4.2
|
||||||
kotlin_serialisation_runtime_version=1.0.1
|
kotlin_serialisation_runtime_version=1.1.0-RC
|
||||||
kotlin_exposed_version=0.28.1
|
kotlin_exposed_version=0.29.1
|
||||||
tgbotapi_version=0.30.10
|
tgbotapi_version=0.32.5
|
||||||
microutils_version=0.4.11
|
microutils_version=0.4.25
|
||||||
klassindex_version=4.1.0-rc.1
|
klassindex_version=4.1.0-rc.1
|
||||||
sqlite_version=3.30.1
|
sqlite_version=3.30.1
|
||||||
|
|
||||||
github_release_plugin_version=2.2.12
|
github_release_plugin_version=2.2.12
|
||||||
|
|
||||||
group=dev.inmo
|
group=dev.inmo
|
||||||
version=0.0.5
|
version=0.1.0
|
||||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -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.7-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
@ -1 +1 @@
|
|||||||
{"bintrayConfig":{"repo":"PlaguBot","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/PlaguBot","autoPublish":true,"overridePublish":true},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/PlaguBot/LICENSE"}],"mavenConfig":{"name":"PlaguBot ${project.name}","description":"","url":"https://github.com/InsanusMokrassar/PlaguBot","vcsUrl":"ssh://git@github.com/InsanusMokrassar/PlaguBot.git","developers":[{"id":"InsanusMokrassar","name":"Aleksei Ovsiannikov","eMail":"ovsyannikov.alexey95@gmail.com"}]},"type":"JVM"}
|
{"bintrayConfig":{"repo":"PlaguBot","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/PlaguBot","autoPublish":true,"overridePublish":true},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/PlaguBot/LICENSE"}],"mavenConfig":{"name":"PlaguBot Plugin","description":"Base dependency for whole PlaguBot project","url":"https://github.com/InsanusMokrassar/PlaguBot","vcsUrl":"ssh://git@github.com/InsanusMokrassar/PlaguBot.git","includeGpgSigning":true,"publishToMavenCentral":true,"developers":[{"id":"InsanusMokrassar","name":"Aleksei Ovsiannikov","eMail":"ovsyannikov.alexey95@gmail.com"}]},"type":"JVM"}
|
@ -1,9 +1,6 @@
|
|||||||
apply plugin: 'maven-publish'
|
apply plugin: 'maven-publish'
|
||||||
|
apply plugin: 'signing'
|
||||||
|
|
||||||
task sourcesJar(type: Jar) {
|
|
||||||
from sourceSets.main.allSource
|
|
||||||
classifier = 'sources'
|
|
||||||
}
|
|
||||||
|
|
||||||
task javadocJar(type: Jar) {
|
task javadocJar(type: Jar) {
|
||||||
from javadoc
|
from javadoc
|
||||||
@ -15,14 +12,13 @@ publishing {
|
|||||||
maven(MavenPublication) {
|
maven(MavenPublication) {
|
||||||
from components.java
|
from components.java
|
||||||
|
|
||||||
artifact sourcesJar
|
|
||||||
artifact javadocJar
|
artifact javadocJar
|
||||||
|
|
||||||
pom {
|
pom {
|
||||||
resolveStrategy = Closure.DELEGATE_FIRST
|
resolveStrategy = Closure.DELEGATE_FIRST
|
||||||
|
|
||||||
description = ""
|
description = "Base dependency for whole PlaguBot project"
|
||||||
name = "PlaguBot ${project.name}"
|
name = "PlaguBot Plugin"
|
||||||
url = "https://github.com/InsanusMokrassar/PlaguBot"
|
url = "https://github.com/InsanusMokrassar/PlaguBot"
|
||||||
|
|
||||||
scm {
|
scm {
|
||||||
@ -59,8 +55,23 @@ publishing {
|
|||||||
password = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY')
|
password = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maven {
|
||||||
|
name = "sonatype"
|
||||||
|
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
|
||||||
|
credentials {
|
||||||
|
username = project.hasProperty('SONATYPE_USER') ? project.property('SONATYPE_USER') : System.getenv('SONATYPE_USER')
|
||||||
|
password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
signing {
|
||||||
|
useGpgCmd()
|
||||||
|
sign publishing.publications
|
||||||
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.plagubot
|
package dev.inmo.plagubot
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||||
import dev.inmo.tgbotapi.types.BotCommand
|
import dev.inmo.tgbotapi.types.BotCommand
|
||||||
import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter
|
import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
@ -19,13 +20,20 @@ interface Plugin {
|
|||||||
*/
|
*/
|
||||||
suspend fun getCommands(): List<BotCommand> = emptyList()
|
suspend fun getCommands(): List<BotCommand> = emptyList()
|
||||||
|
|
||||||
/**
|
@Deprecated("Override other method with receiver BehaviourContext")
|
||||||
* This method (usually) will be invoked just one time in the whole application.
|
|
||||||
*/
|
|
||||||
suspend operator fun invoke(
|
suspend operator fun invoke(
|
||||||
bot: TelegramBot,
|
bot: TelegramBot,
|
||||||
database: Database,
|
database: Database,
|
||||||
updatesFilter: FlowsUpdatesFilter,
|
updatesFilter: FlowsUpdatesFilter,
|
||||||
scope: CoroutineScope
|
scope: CoroutineScope
|
||||||
)
|
) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method (usually) will be invoked just one time in the whole application.
|
||||||
|
*/
|
||||||
|
suspend operator fun BehaviourContext.invoke(
|
||||||
|
database: Database
|
||||||
|
) {
|
||||||
|
invoke(bot, database, flowsUpdatesFilter, scope)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user