mirror of
https://github.com/InsanusMokrassar/ConfigurableInlineTelegramBot.git
synced 2024-11-22 08:13:51 +00:00
commit
f9ed3c791c
15
.github/workflows/build.yml
vendored
15
.github/workflows/build.yml
vendored
@ -1,17 +1,12 @@
|
|||||||
name: Build
|
name: Publish package to GitHub Packages
|
||||||
|
|
||||||
on: [push]
|
on: [push]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
publishing:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Set up JDK 1.8
|
- 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
|
||||||
run: ./gradlew build
|
run: ./gradlew build
|
||||||
|
|
||||||
|
23
.github/workflows/build_and_publish.yml
vendored
Normal file
23
.github/workflows/build_and_publish.yml
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#name: Publish package to GitHub Packages
|
||||||
|
#on: [push]
|
||||||
|
#jobs:
|
||||||
|
# publishing:
|
||||||
|
# runs-on: ubuntu-latest
|
||||||
|
# steps:
|
||||||
|
# - uses: actions/checkout@v2
|
||||||
|
# - uses: actions/setup-java@v1
|
||||||
|
# with:
|
||||||
|
# java-version: 1.8
|
||||||
|
# - name: Rewrite version
|
||||||
|
# run: |
|
||||||
|
# branch="`echo "${{ github.ref }}" | grep -o "[^/]*$"`"
|
||||||
|
# cat gradle.properties | sed -e "s/^library_version=\([0-9\.]*\)/library_version=\1-branch_$branch-build${{ github.run_number }}/" > gradle.properties.tmp
|
||||||
|
# rm gradle.properties
|
||||||
|
# mv gradle.properties.tmp gradle.properties
|
||||||
|
# - name: Build
|
||||||
|
# run: ./gradlew build
|
||||||
|
# - name: Publish
|
||||||
|
# run: ./gradlew --no-parallel publishAllPublicationsToGithubPackagesRepository -x signJsPublication -x signJvmPublication -x signKotlinMultiplatformPublication -x signMetadataPublication -x signAndroidDebugPublication -x signAndroidReleasePublication -x signKotlinMultiplatformPublication
|
||||||
|
# env:
|
||||||
|
# GITHUBPACKAGES_USER: ${{ github.actor }}
|
||||||
|
# GITHUBPACKAGES_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
|
28
.github/workflows/build_and_publish_docker.yml
vendored
Normal file
28
.github/workflows/build_and_publish_docker.yml
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#name: Publish Docker image
|
||||||
|
#on: [push]
|
||||||
|
#jobs:
|
||||||
|
# push_to_registry:
|
||||||
|
# name: Push Docker image to Docker Hub
|
||||||
|
# runs-on: ubuntu-latest
|
||||||
|
# steps:
|
||||||
|
# - name: Check out the repo
|
||||||
|
# uses: actions/checkout@v2
|
||||||
|
# - uses: actions/setup-java@v1
|
||||||
|
# with:
|
||||||
|
# java-version: 1.8
|
||||||
|
# - name: Build
|
||||||
|
# run: ./gradlew build
|
||||||
|
# - name: Docker meta
|
||||||
|
# id: docker_meta
|
||||||
|
# uses: crazy-max/ghaction-docker-meta@v1
|
||||||
|
# with:
|
||||||
|
# images: name/app
|
||||||
|
# tag-sha: true
|
||||||
|
# tag-latest: false
|
||||||
|
# - name: Push to Docker Hub
|
||||||
|
# uses: docker/build-push-action@v1
|
||||||
|
# with:
|
||||||
|
# username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
# password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
# context: .
|
||||||
|
# tags: ${{ steps.docker_meta.outputs.tags }}
|
7
CHANGELOG.md
Normal file
7
CHANGELOG.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## 0.0.2
|
||||||
|
|
||||||
|
* `Kotlin`: `1.4.30` -> `1.6.10`
|
||||||
|
* `tgbotapi`: `0.32.5` -> `0.38.12`
|
||||||
|
* `ktor`: `1.5.2` -> `1.6.8`
|
@ -1,4 +1,4 @@
|
|||||||
FROM java:8
|
FROM adoptopenjdk/openjdk11
|
||||||
|
|
||||||
USER 1000
|
USER 1000
|
||||||
|
|
||||||
|
3
README.md
Normal file
3
README.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Configurable Inline Bot
|
||||||
|
|
||||||
|
This bot was created for helping with other bot commands templating, but it also can be used in other ways.
|
@ -3,7 +3,6 @@ project.group = "com.insanusmokrassar"
|
|||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
jcenter()
|
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,7 +27,6 @@ project.group = "$library_group"
|
|||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
jcenter()
|
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven { url "https://kotlin.bintray.com/kotlinx" }
|
maven { url "https://kotlin.bintray.com/kotlinx" }
|
||||||
}
|
}
|
||||||
@ -45,5 +43,5 @@ dependencies {
|
|||||||
api "io.ktor:ktor-server-tomcat:$ktor_version"
|
api "io.ktor:ktor-server-tomcat:$ktor_version"
|
||||||
|
|
||||||
// Use JUnit test framework
|
// Use JUnit test framework
|
||||||
testImplementation 'junit:junit:4.13.1'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
}
|
}
|
||||||
|
38
example.config.json
Normal file
38
example.config.json
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,8 @@
|
|||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
kotlin_version=1.6.10
|
kotlin_version=1.6.10
|
||||||
|
|
||||||
telegram_bot_api_version=0.32.5
|
telegram_bot_api_version=0.38.12
|
||||||
ktor_version=1.5.1
|
ktor_version=1.6.8
|
||||||
|
|
||||||
library_version=0.1
|
library_version=0.0.2
|
||||||
library_group=dev.inmo
|
library_group=dev.inmo
|
||||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
|||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
||||||
|
126
publish.gradle
126
publish.gradle
@ -1,75 +1,91 @@
|
|||||||
apply plugin: 'maven-publish'
|
apply plugin: 'maven-publish'
|
||||||
apply plugin: 'signing'
|
|
||||||
|
|
||||||
task javadocsJar(type: Jar) {
|
task javadocJar(type: Jar) {
|
||||||
|
from javadoc
|
||||||
classifier = 'javadoc'
|
classifier = 'javadoc'
|
||||||
}
|
}
|
||||||
task sourceJar (type : Jar) {
|
task sourcesJar(type: Jar) {
|
||||||
|
from sourceSets.main.allSource
|
||||||
classifier = 'sources'
|
classifier = 'sources'
|
||||||
}
|
}
|
||||||
|
|
||||||
afterEvaluate {
|
|
||||||
project.publishing.publications.all {
|
|
||||||
// rename artifacts
|
|
||||||
groupId "${project.group}"
|
|
||||||
if (it.name.contains('kotlinMultiplatform')) {
|
|
||||||
artifactId = "${project.name}"
|
|
||||||
artifact sourceJar
|
|
||||||
} else {
|
|
||||||
artifactId = "${project.name}-$name"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
publications.all {
|
publications {
|
||||||
artifact javadocsJar
|
maven(MavenPublication) {
|
||||||
|
from components.java
|
||||||
|
|
||||||
pom {
|
artifact javadocJar
|
||||||
description = "This library is fully ready to launch bot for working with presets of inline answers in Telegram via Bot API"
|
artifact sourcesJar
|
||||||
name = "${project.name}"
|
|
||||||
url = "https://insanusmokrassar.github.io/${project.name}"
|
|
||||||
|
|
||||||
scm {
|
pom {
|
||||||
developerConnection = "scm:git:[fetch=]https://github.com/InsanusMokrassar/${project.name}[push=]https://github.com/InsanusMokrassar/${project.name}"
|
resolveStrategy = Closure.DELEGATE_FIRST
|
||||||
url = "https://github.com/InsanusMokrassar/${project.name}"
|
|
||||||
|
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}"
|
||||||
|
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
repositories {
|
||||||
developers {
|
if ((project.hasProperty('GITHUBPACKAGES_USER') || System.getenv('GITHUBPACKAGES_USER') != null) && (project.hasProperty('GITHUBPACKAGES_PASSWORD') || System.getenv('GITHUBPACKAGES_PASSWORD') != null)) {
|
||||||
|
maven {
|
||||||
developer {
|
name = "GithubPackages"
|
||||||
id = "InsanusMokrassar"
|
url = uri("https://maven.pkg.github.com/InsanusMokrassar/ConfigurableInlineTelegramBot")
|
||||||
name = "Ovsiannikov Aleksei"
|
credentials {
|
||||||
email = "ovsyannikov.alexey95@gmail.com"
|
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 {
|
||||||
licenses {
|
name = "sonatype"
|
||||||
|
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
|
||||||
license {
|
credentials {
|
||||||
name = "Apache Software License 2.0"
|
username = project.hasProperty('SONATYPE_USER') ? project.property('SONATYPE_USER') : System.getenv('SONATYPE_USER')
|
||||||
url = "https://opensource.org/licenses/Apache-2.0"
|
password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
maven {
|
|
||||||
name = "bintray"
|
|
||||||
url = uri("https://api.bintray.com/maven/${project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER')}/insanusmokrassar/${project.name}/;publish=1;override=1")
|
|
||||||
credentials {
|
|
||||||
username = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER')
|
|
||||||
password = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
signing {
|
if (project.hasProperty("signing.gnupg.keyName")) {
|
||||||
useGpgCmd()
|
apply plugin: 'signing'
|
||||||
publishing.publications.forEach { sign it }
|
|
||||||
|
signing {
|
||||||
|
useGpgCmd()
|
||||||
|
|
||||||
|
sign publishing.publications
|
||||||
|
}
|
||||||
|
|
||||||
|
task signAll {
|
||||||
|
tasks.withType(Sign).forEach {
|
||||||
|
dependsOn(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
{"bintrayConfig":{"repo":"insanusmokrassar","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/${project.name}","autoPublish":true,"overridePublish":true},"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"}]}}
|
{"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"}
|
@ -54,8 +54,8 @@ data class FormatterBot(
|
|||||||
val bot = botConfig.createBot()
|
val bot = botConfig.createBot()
|
||||||
val filter = FlowsUpdatesFilter()
|
val filter = FlowsUpdatesFilter()
|
||||||
bot.buildBehaviour(
|
bot.buildBehaviour(
|
||||||
|
filter,
|
||||||
scope,
|
scope,
|
||||||
filter
|
|
||||||
) {
|
) {
|
||||||
enableFormatterBot(templates, restrictions)
|
enableFormatterBot(templates, restrictions)
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package dev.inmo.configurable_inline_telegram_bot.config
|
package dev.inmo.configurable_inline_telegram_bot.config
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
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
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
Loading…
Reference in New Issue
Block a user