mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2026-09-13 11:34:13 +00:00
Compare commits
14 Commits
9.2.0
...
b8cc8854ea
| Author | SHA1 | Date | |
|---|---|---|---|
| b8cc8854ea | |||
| 13470999e8 | |||
| af04a854ef | |||
| 44e86c9349 | |||
| 65c32d97d5 | |||
| 9b7605591e | |||
| 89d5a4f911 | |||
| 53cf212175 | |||
| 28301a92c9 | |||
| f814b11777 | |||
| 9773a74890 | |||
| a81cfaaba9 | |||
|
|
ee599611f3 | ||
| d3d6cd16c6 |
@@ -32,16 +32,16 @@ suspend fun main(vararg args: String) {
|
|||||||
val chat = message.chat
|
val chat = message.chat
|
||||||
|
|
||||||
val answerText = when (val chat = message.chat) {
|
val answerText = when (val chat = message.chat) {
|
||||||
is ChannelChat -> {
|
is PreviewChannelChat -> {
|
||||||
val answer = "Hi everybody in this channel \"${chat.title}\""
|
val answer = "Hi everybody in this channel \"${chat.title}\""
|
||||||
reply(message, answer, MarkdownV2)
|
reply(message, answer, MarkdownV2)
|
||||||
return@onMentionWithAnyContent
|
return@onMentionWithAnyContent
|
||||||
}
|
}
|
||||||
is PrivateChat -> {
|
is PreviewPrivateChat -> {
|
||||||
reply(message, "Hi, " + "${chat.firstName} ${chat.lastName}".textMentionMarkdownV2(chat.id), MarkdownV2)
|
reply(message, "Hi, " + "${chat.firstName} ${chat.lastName}".textMentionMarkdownV2(chat.id), MarkdownV2)
|
||||||
return@onMentionWithAnyContent
|
return@onMentionWithAnyContent
|
||||||
}
|
}
|
||||||
is GroupChat -> {
|
is PreviewGroupChat -> {
|
||||||
message.ifFromChannelGroupContentMessage {
|
message.ifFromChannelGroupContentMessage {
|
||||||
val answer = "Hi, ${it.senderChat.title}"
|
val answer = "Hi, ${it.senderChat.title}"
|
||||||
reply(message, answer, MarkdownV2)
|
reply(message, answer, MarkdownV2)
|
||||||
@@ -56,9 +56,7 @@ suspend fun main(vararg args: String) {
|
|||||||
} ?: chat.title
|
} ?: chat.title
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is UnknownExtendedChat,
|
|
||||||
is UnknownChatType -> "Unknown :(".escapeMarkdownV2Common()
|
is UnknownChatType -> "Unknown :(".escapeMarkdownV2Common()
|
||||||
else -> error("Something went wrong: unknown type of chat $chat")
|
|
||||||
}
|
}
|
||||||
reply(
|
reply(
|
||||||
message,
|
message,
|
||||||
|
|||||||
@@ -16,15 +16,9 @@ apply plugin: 'application'
|
|||||||
|
|
||||||
mainClassName="InlineQueriesBotKt"
|
mainClassName="InlineQueriesBotKt"
|
||||||
|
|
||||||
|
apply from: "$nativePartTemplate"
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
def hostOs = System.getProperty("os.name")
|
|
||||||
def isMingwX64 = hostOs.startsWith("Windows")
|
|
||||||
def nativeTarget
|
|
||||||
if (hostOs == "Linux") nativeTarget = linuxX64("native") { binaries { executable() } }
|
|
||||||
else if (isMingwX64) nativeTarget = mingwX64("native") { binaries { executable() } }
|
|
||||||
else throw new GradleException("Host OS is not supported in Kotlin/Native.")
|
|
||||||
|
|
||||||
jvm()
|
jvm()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
@@ -35,18 +29,6 @@ kotlin {
|
|||||||
api "dev.inmo:tgbotapi:$telegram_bot_api_version"
|
api "dev.inmo:tgbotapi:$telegram_bot_api_version"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nativeMain {
|
|
||||||
dependencies {
|
|
||||||
def engine
|
|
||||||
|
|
||||||
if (hostOs == "Linux") engine = "curl"
|
|
||||||
else if (isMingwX64) engine = "winhttp"
|
|
||||||
else throw new GradleException("Host OS is not supported in Kotlin/Native.")
|
|
||||||
|
|
||||||
api "io.ktor:ktor-client-$engine:$ktor_version"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,15 +16,7 @@ apply plugin: 'application'
|
|||||||
|
|
||||||
mainClassName="RandomFileSenderBotKt"
|
mainClassName="RandomFileSenderBotKt"
|
||||||
|
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
def hostOs = System.getProperty("os.name")
|
|
||||||
def isMingwX64 = hostOs.startsWith("Windows")
|
|
||||||
def nativeTarget
|
|
||||||
if (hostOs == "Linux") nativeTarget = linuxX64("native") { binaries { executable() } }
|
|
||||||
else if (isMingwX64) nativeTarget = mingwX64("native") { binaries { executable() } }
|
|
||||||
else throw new GradleException("Host OS is not supported in Kotlin/Native.")
|
|
||||||
|
|
||||||
jvm()
|
jvm()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
@@ -35,18 +27,8 @@ kotlin {
|
|||||||
api "dev.inmo:tgbotapi:$telegram_bot_api_version"
|
api "dev.inmo:tgbotapi:$telegram_bot_api_version"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nativeMain {
|
|
||||||
dependencies {
|
|
||||||
def engine
|
|
||||||
|
|
||||||
if (hostOs == "Linux") engine = "curl"
|
|
||||||
else if (isMingwX64) engine = "winhttp"
|
|
||||||
else throw new GradleException("Host OS is not supported in Kotlin/Native.")
|
|
||||||
|
|
||||||
api "io.ktor:ktor-client-$engine:$ktor_version"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apply from: "$nativePartTemplate"
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ kotlin {
|
|||||||
}
|
}
|
||||||
linuxX64()
|
linuxX64()
|
||||||
mingwX64()
|
mingwX64()
|
||||||
|
linuxArm64()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
commonMain {
|
commonMain {
|
||||||
|
|||||||
@@ -12,15 +12,9 @@ plugins {
|
|||||||
id "org.jetbrains.kotlin.multiplatform"
|
id "org.jetbrains.kotlin.multiplatform"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apply from: "$nativePartTemplate"
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
def hostOs = System.getProperty("os.name")
|
|
||||||
def isMingwX64 = hostOs.startsWith("Windows")
|
|
||||||
def nativeTarget
|
|
||||||
if (hostOs == "Linux") nativeTarget = linuxX64("native") { binaries { executable() } }
|
|
||||||
else if (isMingwX64) nativeTarget = mingwX64("native") { binaries { executable() } }
|
|
||||||
else throw new GradleException("Host OS is not supported in Kotlin/Native.")
|
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
commonMain {
|
commonMain {
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -29,18 +23,6 @@ kotlin {
|
|||||||
api project(":ResenderBot:ResenderBotLib")
|
api project(":ResenderBot:ResenderBotLib")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nativeMain {
|
|
||||||
dependencies {
|
|
||||||
def engine
|
|
||||||
|
|
||||||
if (hostOs == "Linux") engine = "curl"
|
|
||||||
else if (isMingwX64) engine = "winhttp"
|
|
||||||
else throw new GradleException("Host OS is not supported in Kotlin/Native.")
|
|
||||||
|
|
||||||
api "io.ktor:ktor-client-$engine:$ktor_version"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,8 +52,13 @@ suspend fun main(vararg args: String) {
|
|||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
routing {
|
routing {
|
||||||
staticFiles("", File("WebApp/build/distributions")) {
|
val baseJsFolder = File("WebApp/build/dist/js/")
|
||||||
default("WebApp/build/distributions/index.html")
|
baseJsFolder.list() ?.forEach {
|
||||||
|
if (it == "productionExecutable" || it == "developmentExecutable") {
|
||||||
|
staticFiles("", File(baseJsFolder, it)) {
|
||||||
|
default("WebApp/build/dist/js/$it/index.html")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
post("inline") {
|
post("inline") {
|
||||||
val requestBody = call.receiveText()
|
val requestBody = call.receiveText()
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
|
ext {
|
||||||
|
nativePartTemplate = "${rootProject.projectDir.absolutePath}/native_template.gradle"
|
||||||
|
}
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ org.gradle.parallel=true
|
|||||||
org.gradle.jvmargs=-Xmx2g
|
org.gradle.jvmargs=-Xmx2g
|
||||||
|
|
||||||
|
|
||||||
kotlin_version=1.8.22
|
kotlin_version=1.9.20
|
||||||
telegram_bot_api_version=9.2.0
|
telegram_bot_api_version=9.3.0-branch_9.3.0-build1918
|
||||||
micro_utils_version=0.19.9
|
micro_utils_version=0.20.12
|
||||||
serialization_version=1.5.1
|
serialization_version=1.6.0
|
||||||
ktor_version=2.3.3
|
ktor_version=2.3.5
|
||||||
|
|||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -2,4 +2,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-7.6.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
|
||||||
|
|||||||
20
native_template.gradle
Normal file
20
native_template.gradle
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
kotlin {
|
||||||
|
def hostOs = System.getProperty("os.name")
|
||||||
|
def isMingwX64 = hostOs.startsWith("Windows")
|
||||||
|
def isArch64 = System.getProperty("os.arch") == "aarch64"
|
||||||
|
|
||||||
|
def nativeTarget
|
||||||
|
if (hostOs == "Linux") {
|
||||||
|
if (isArch64) {
|
||||||
|
nativeTarget = linuxArm64("native") { binaries { executable() } }
|
||||||
|
} else {
|
||||||
|
nativeTarget = linuxX64("native") { binaries { executable() } }
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (isMingwX64) {
|
||||||
|
nativeTarget = mingwX64("native") { binaries { executable() } }
|
||||||
|
} else {
|
||||||
|
throw new GradleException("Host OS is not supported in Kotlin/Native.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user