From 60ace19f50233734480f65a5690c2d322ad9bfc5 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 10 Apr 2022 22:14:56 +0600 Subject: [PATCH] upupdate --- CHANGELOG.md | 6 +- Dockerfile | 2 +- build.gradle | 6 +- example.config.json | 49 +++++-- gradle.properties | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- publish.gradle | 120 +++++++++++------- publish.kpsb | 2 +- .../FormatterBot.kt | 4 +- .../config/Restrictions.kt | 4 +- 10 files changed, 120 insertions(+), 77 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c94fa28..ea5f1b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,6 @@ ## 0.0.2 -* `Kotlin`: `1.4.30` -> `1.4.32` -* `tgbotapi`: `0.32.5` -> `0.34.0` -* `ktor`: `1.5.2` -> `1.5.3` +* `Kotlin`: `1.4.30` -> `1.6.10` +* `tgbotapi`: `0.32.5` -> `0.38.12` +* `ktor`: `1.5.2` -> `1.6.8` diff --git a/Dockerfile b/Dockerfile index 1dca5af..569ab57 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM java:8 +FROM adoptopenjdk/openjdk11 USER 1000 diff --git a/build.gradle b/build.gradle index 5bfbadd..cd5e12d 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,6 @@ project.group = "com.insanusmokrassar" buildscript { repositories { mavenLocal() - jcenter() mavenCentral() } @@ -28,14 +27,13 @@ project.group = "$library_group" repositories { mavenLocal() - jcenter() mavenCentral() maven { url "https://kotlin.bintray.com/kotlinx" } } dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - + implementation "dev.inmo:tgbotapi:$telegram_bot_api_version" api "io.ktor:ktor-client-core:$ktor_version" @@ -45,5 +43,5 @@ dependencies { api "io.ktor:ktor-server-tomcat:$ktor_version" // Use JUnit test framework - testImplementation 'junit:junit:4.13.1' + testImplementation 'junit:junit:4.13.2' } diff --git a/example.config.json b/example.config.json index 1a76f84..f83cf1c 100644 --- a/example.config.json +++ b/example.config.json @@ -1,15 +1,38 @@ { - "botToken": "bot token from @BotFather", - "apiUrl": "(optional) can be used if you are using your bot server", - "clientConfig": { - "proxy": { - "host": "localhost", - "port": 1080, - "username": "optional", - "password": "optional" - }, - "connectTimeout": "(optional) number, milliseconds", - "writeTimeout": "(optional) number, milliseconds", - "readTimeout": "(optional) number, milliseconds" + "botConfig": { + "botToken": "bot token from @BotFather", + "apiUrl": "(optional) can be used if you are using your bot server", + "clientConfig": { + "proxy": { + "host": "localhost", + "port": 1080, + "username": "optional", + "password": "optional" + }, + "connectTimeout": "(optional) number, milliseconds", + "writeTimeout": "(optional) number, milliseconds", + "readTimeout": "(optional) number, milliseconds" + } + }, + "templates": [ + { + "title": "Some example", + "formats": [ + { + "template": "Some message which will be sent after clicking on option and opportunity to use format options from java with splitting of incoming query by splitBy option", + "regexTemplate": "Some regex, by default it is ^$ which means empty string", + "splitBy": "Optional splitter, by default is null but the most regular case is to use \" \" to split query by spaces", + "enableMarkdownSupport": false, + "enableMarkdownSupport_description": "THAT IS NOT A FIELD. enableMarkdownSupport is a flat to use markdown 2 markup with template" + } + ], + "description": "It is optional description of some example format" + } + ], + "restrictions": { + "allowedUsers": [ + + ], + "description": "THAT IS NOT A FIELD. allowedUsers is an optional field which contains list of users which may use this bot to call its inline queries" } -} \ No newline at end of file +} diff --git a/gradle.properties b/gradle.properties index 98a434c..6dbd64e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ kotlin.code.style=official kotlin_version=1.6.10 -telegram_bot_api_version=0.38.10 +telegram_bot_api_version=0.38.12 ktor_version=1.6.8 library_version=0.0.2 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 4f9920e..cde8341 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip diff --git a/publish.gradle b/publish.gradle index 87e35dc..f3da06b 100644 --- a/publish.gradle +++ b/publish.gradle @@ -1,61 +1,72 @@ apply plugin: 'maven-publish' -apply plugin: 'signing' -task javadocsJar(type: Jar) { +task javadocJar(type: Jar) { + from javadoc classifier = 'javadoc' } +task sourcesJar(type: Jar) { + from sourceSets.main.allSource + classifier = 'sources' +} publishing { - publications.all { - artifact javadocsJar + publications { + maven(MavenPublication) { + from components.java - pom { - description = "This library is fully ready to launch bot for working with presets of inline answers in Telegram via Bot API" - name = "${project.name}" - url = "https://insanusmokrassar.github.io/${project.name}" + artifact javadocJar + artifact sourcesJar - scm { - developerConnection = "scm:git:[fetch=]https://github.com/InsanusMokrassar/${project.name}[push=]https://github.com/InsanusMokrassar/${project.name}" - url = "https://github.com/InsanusMokrassar/${project.name}" - } + pom { + resolveStrategy = Closure.DELEGATE_FIRST - developers { - - developer { - id = "InsanusMokrassar" - name = "Ovsiannikov Aleksei" - email = "ovsyannikov.alexey95@gmail.com" - } - - } + description = "This library is fully ready to launch bot for working with presets of inline answers in Telegram via Bot API" + name = "${project.name}" + url = "https://insanusmokrassar.github.io/${project.name}" - licenses { - - license { - name = "Apache Software License 2.0" - url = "https://opensource.org/licenses/Apache-2.0" - } - - } - } - repositories { - if ((project.hasProperty('GITHUBPACKAGES_USER') || System.getenv('GITHUBPACKAGES_USER') != null) && (project.hasProperty('GITHUBPACKAGES_PASSWORD') || System.getenv('GITHUBPACKAGES_PASSWORD') != null)) { - maven { - name = "GithubPackages" - url = uri("https://maven.pkg.github.com/InsanusMokrassar/ConfigurableInlineTelegramBot") - credentials { - username = project.hasProperty('GITHUBPACKAGES_USER') ? project.property('GITHUBPACKAGES_USER') : System.getenv('GITHUBPACKAGES_USER') - password = project.hasProperty('GITHUBPACKAGES_PASSWORD') ? project.property('GITHUBPACKAGES_PASSWORD') : System.getenv('GITHUBPACKAGES_PASSWORD') - } + scm { + developerConnection = "scm:git:[fetch=]https://github.com/InsanusMokrassar/${project.name}[push=]https://github.com/InsanusMokrassar/${project.name}" + url = "https://github.com/InsanusMokrassar/${project.name}" + } + + developers { + + developer { + id = "InsanusMokrassar" + name = "Ovsiannikov Aleksei" + email = "ovsyannikov.alexey95@gmail.com" + } + + } + + licenses { + + license { + name = "Apache Software License 2.0" + url = "https://opensource.org/licenses/Apache-2.0" + } + } } - if ((project.hasProperty('SONATYPE_USER') || System.getenv('SONATYPE_USER') != null) && (project.hasProperty('SONATYPE_PASSWORD') || System.getenv('SONATYPE_PASSWORD') != null)) { - 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') + repositories { + if ((project.hasProperty('GITHUBPACKAGES_USER') || System.getenv('GITHUBPACKAGES_USER') != null) && (project.hasProperty('GITHUBPACKAGES_PASSWORD') || System.getenv('GITHUBPACKAGES_PASSWORD') != null)) { + maven { + name = "GithubPackages" + url = uri("https://maven.pkg.github.com/InsanusMokrassar/ConfigurableInlineTelegramBot") + credentials { + username = project.hasProperty('GITHUBPACKAGES_USER') ? project.property('GITHUBPACKAGES_USER') : System.getenv('GITHUBPACKAGES_USER') + password = project.hasProperty('GITHUBPACKAGES_PASSWORD') ? project.property('GITHUBPACKAGES_PASSWORD') : System.getenv('GITHUBPACKAGES_PASSWORD') + } + } + } + if ((project.hasProperty('SONATYPE_USER') || System.getenv('SONATYPE_USER') != null) && (project.hasProperty('SONATYPE_PASSWORD') || System.getenv('SONATYPE_PASSWORD') != null)) { + 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') + } } } } @@ -63,7 +74,18 @@ publishing { } } -signing { - useGpgCmd() - sign publishing.publications +if (project.hasProperty("signing.gnupg.keyName")) { + apply plugin: 'signing' + + signing { + useGpgCmd() + + sign publishing.publications + } + + task signAll { + tasks.withType(Sign).forEach { + dependsOn(it) + } + } } diff --git a/publish.kpsb b/publish.kpsb index 61a0431..c84d92c 100644 --- a/publish.kpsb +++ b/publish.kpsb @@ -1 +1 @@ -{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://opensource.org/licenses/Apache-2.0"}],"mavenConfig":{"name":"${project.name}","description":"This library is fully ready to launch bot for working with presets of inline answers in Telegram via Bot API","url":"https://insanusmokrassar.github.io/${project.name}","vcsUrl":"https://github.com/InsanusMokrassar/${project.name}","includeGpgSigning":true,"developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}],"repositories":[{"name":"GithubPackages","url":"https://maven.pkg.github.com/InsanusMokrassar/ConfigurableInlineTelegramBot"},{"name":"sonatype","url":"https://oss.sonatype.org/service/local/staging/deploy/maven2/"}]}} \ No newline at end of file +{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://opensource.org/licenses/Apache-2.0"}],"mavenConfig":{"name":"${project.name}","description":"This library is fully ready to launch bot for working with presets of inline answers in Telegram via Bot API","url":"https://insanusmokrassar.github.io/${project.name}","vcsUrl":"https://github.com/InsanusMokrassar/${project.name}","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}],"repositories":[{"name":"GithubPackages","url":"https://maven.pkg.github.com/InsanusMokrassar/ConfigurableInlineTelegramBot"},{"name":"sonatype","url":"https://oss.sonatype.org/service/local/staging/deploy/maven2/"}],"gpgSigning":{"type":"dev.inmo.kmppscriptbuilder.core.models.GpgSigning.Optional"}},"type":"JVM"} \ No newline at end of file diff --git a/src/main/kotlin/dev/inmo/configurable_inline_telegram_bot/FormatterBot.kt b/src/main/kotlin/dev/inmo/configurable_inline_telegram_bot/FormatterBot.kt index 4e1b7d3..b9c0f8f 100644 --- a/src/main/kotlin/dev/inmo/configurable_inline_telegram_bot/FormatterBot.kt +++ b/src/main/kotlin/dev/inmo/configurable_inline_telegram_bot/FormatterBot.kt @@ -54,8 +54,8 @@ data class FormatterBot( val bot = botConfig.createBot() val filter = FlowsUpdatesFilter() bot.buildBehaviour( + filter, scope, - filter ) { enableFormatterBot(templates, restrictions) } @@ -74,4 +74,4 @@ data class FormatterBot( } } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/dev/inmo/configurable_inline_telegram_bot/config/Restrictions.kt b/src/main/kotlin/dev/inmo/configurable_inline_telegram_bot/config/Restrictions.kt index 2e25416..50bd6b2 100644 --- a/src/main/kotlin/dev/inmo/configurable_inline_telegram_bot/config/Restrictions.kt +++ b/src/main/kotlin/dev/inmo/configurable_inline_telegram_bot/config/Restrictions.kt @@ -1,7 +1,7 @@ package dev.inmo.configurable_inline_telegram_bot.config import dev.inmo.tgbotapi.types.* -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InlineQuery +import dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery import kotlinx.serialization.Serializable @Serializable @@ -11,4 +11,4 @@ data class Restrictions( fun check(query: InlineQuery): Boolean { return query.from.id in allowedUsers || query.from.username ?.let { it in allowedUsers } ?: false } -} \ No newline at end of file +}