1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-11-17 12:30:20 +00:00

Compare commits

..

1 Commits

Author SHA1 Message Date
618017c160 add exceptions handling readme 2022-01-11 21:21:31 +06:00
1276 changed files with 13391 additions and 97243 deletions

2
.github/FUNDING.yml vendored
View File

@@ -1,3 +1,3 @@
# These are supported funding model platforms # These are supported funding model platforms
custom: ['https://tonscan.org/address/UQAtuSLJ76Zehc3qP-eRYMR98fPIu_oOp_atcpVX55zxHwTU'] custom: ['https://www.tinkoff.ru/rm/ovsyannikov.aleksey113/ObMJ712472']

View File

@@ -5,9 +5,6 @@ on: [pull_request, issues]
jobs: jobs:
greeting: greeting:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps: steps:
- uses: actions/first-interaction@v1 - uses: actions/first-interaction@v1
with: with:

View File

@@ -10,12 +10,12 @@ jobs:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/setup-java@v1 - uses: actions/setup-java@v1
with: with:
java-version: 17 java-version: 1.8
- name: Build - name: Build
run: ./gradlew dokkaHtmlMultiModule run: ./gradlew dokkaHtml
- name: Publish KDocs - name: Publish KDocs
uses: peaceiris/actions-gh-pages@v3 uses: peaceiris/actions-gh-pages@v3
with: with:
github_token: ${{ secrets.GITHUB_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build/dokka/htmlMultiModule publish_dir: ./docs/build/dokka/html
publish_branch: kdocs publish_branch: kdocs

View File

@@ -7,30 +7,21 @@ jobs:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/setup-java@v1 - uses: actions/setup-java@v1
with: with:
java-version: 17 java-version: 1.8
- name: Setup LibCurl - name: Fix android 31.0.0 dx
run: sudo apt update && sudo apt install -y libcurl4-openssl-dev continue-on-error: true
run: cd /usr/local/lib/android/sdk/build-tools/31.0.0/ && mv d8 dx && cd lib && mv d8.jar dx.jar
- name: Rewrite version - name: Rewrite version
run: | run: |
branch="`echo "${{ github.ref }}" | grep -o "[^/]*$"`" 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 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 rm gradle.properties
mv gradle.properties.tmp gradle.properties mv gradle.properties.tmp gradle.properties
- name: KotlinSymbolProcessing execution
run: ./gradlew kspCommonMainKotlinMetadata
- name: Build - name: Build
run: ./gradlew build run: ./gradlew build
- name: API compatibility check - name: Publish
run: ./gradlew apiCheck
- name: Publish to GithubPackages
continue-on-error: true continue-on-error: true
run: ./gradlew publishAllPublicationsToGithubPackagesRepository --no-parallel run: ./gradlew publishAllPublicationsToGithubPackagesRepository --no-parallel -x signJsPublication -x signJvmPublication -x signKotlinMultiplatformPublication
env: env:
GITHUB_USER: ${{ github.actor }} GITHUBPACKAGES_USER: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUBPACKAGES_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to Gitea
continue-on-error: true
run: ./gradlew publishAllPublicationsToInmoNexusRepository
env:
INMONEXUS_USER: ${{ secrets.INMONEXUS_USER }}
INMONEXUS_PASSWORD: ${{ secrets.INMONEXUS_PASSWORD }}

1
.gitignore vendored
View File

@@ -1,5 +1,4 @@
.idea .idea
.kotlin
out/* out/*
*.iml *.iml
target target

File diff suppressed because it is too large Load Diff

View File

@@ -1,19 +1,8 @@
# TelegramBotAPI [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [![Supported version](https://img.shields.io/badge/Telegram%20Bot%20API-8.3-blue)](https://core.telegram.org/bots/api-changelog#february-12-2025) # TelegramBotAPI [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [![Supported version](https://img.shields.io/badge/Telegram%20Bot%20API-5.6-blue)](https://core.telegram.org/bots/api-changelog#december-30-2021)
| Docs | [![KDocs](https://img.shields.io/static/v1?label=Dokka&message=KDocs&color=blue&logo=kotlin)](https://tgbotapi.inmo.dev/index.html) [![Mini tutorial](https://img.shields.io/static/v1?label=Mk&message=Docs&color=blue&logo=mkdocs)](https://docs.inmo.dev/tgbotapi/index.html) | | [![Awesome Kotlin Badge](https://kotlin.link/awesome-kotlin.svg)](https://github.com/KotlinBy/awesome-kotlin) [![Build Status](https://github.com/InsanusMokrassar/TelegramBotAPI/workflows/Build/badge.svg)](https://github.com/InsanusMokrassar/TelegramBotAPI/actions) [![Small survey](https://img.shields.io/static/v1?label=Google&message=Survey&color=blue)](https://forms.gle/2Hex2ynbHWHhi1KY7) [![Chat in Telegram](https://img.shields.io/static/v1?label=Telegram&message=Chat&color=blue)](https://t.me/InMoTelegramBotAPI) |
|:----------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| |:---:|
| Useful repos | [![Create bot](https://img.shields.io/static/v1?label=Github&message=Template&color=blue&logo=github)](https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template/generate) [![Examples](https://img.shields.io/static/v1?label=Github&message=Examples&color=blue&logo=github)](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/) | | [![Create bot](https://img.shields.io/static/v1?label=Github&message=Template&color=blue)](https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template/generate) [![Examples](https://img.shields.io/static/v1?label=Github&message=Examples&color=blue)](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/) [![KDocs](https://img.shields.io/static/v1?label=Dokka&message=KDocs&color=blue)](https://tgbotapi.inmo.dev/index.html) [![Mini tutorial](https://img.shields.io/static/v1?label=Bookstack&message=Tutorial&color=blue)](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) |
| Misc | [![Awesome Kotlin Badge](https://kotlin.link/awesome-kotlin.svg)](https://github.com/KotlinBy/awesome-kotlin) [![Small survey](https://img.shields.io/static/v1?label=Google&message=Survey&color=blue&logo=google-sheets)](https://docs.google.com/forms/d/e/1FAIpQLSctdJHT_aEniyYT0-IUAEfo1hsIlezX2owlkEAYX4KPl2V2_A/viewform?usp=sf_link) |
| Platforms | ![JVM](https://img.shields.io/badge/JVM-red?style=plastic&logo=openjdk&logoColor=white) ![Js](https://img.shields.io/badge/JavaScript-323330?style=plastic&logo=javascript&logoColor=F7DF1E) |
| Experimental Platforms | [![Linux x64](https://img.shields.io/badge/LinuxX64-FCC624?style=plastic&logo=linux&logoColor=black)](https://kotlinlang.org/docs/native-target-support.html#tier-1) [![MinGW x64](https://img.shields.io/badge/MinGWX64-black?style=plastic&logo=windows&logoColor=green)](https://kotlinlang.org/docs/native-target-support.html#tier-1) |
<!--- [![Telegram Channel](./resources/tg_channel_qr.jpg)](https://t.me/ktgbotapi) --->
<p align="center">
<a href="https://t.me/ktgbotapi">
<img src="./resources/tg_channel_qr.jpg">
</a>
</p>
Hello! This is a set of libraries for working with Telegram Bot API. Hello! This is a set of libraries for working with Telegram Bot API.
@@ -39,7 +28,7 @@ Other configuration examples:
suspend fun main() { suspend fun main() {
val bot = telegramBot(TOKEN) val bot = telegramBot(TOKEN)
bot.buildBehaviourWithLongPolling { bot.buildBehaviour {
println(getMe()) println(getMe())
onCommand("start") { onCommand("start") {
@@ -80,7 +69,7 @@ and maybe some updates it got after launch)
suspend fun main() { suspend fun main() {
val bot = telegramBot(TOKEN) val bot = telegramBot(TOKEN)
bot.buildBehaviourWithLongPolling { bot.buildBehaviour {
println(getMe()) println(getMe())
val nameReplyMarkup = ReplyKeyboardMarkup( val nameReplyMarkup = ReplyKeyboardMarkup(
@@ -118,5 +107,5 @@ suspend fun main() {
### More examples ### More examples
You may find examples in [this project](https://github.com/InsanusMokrassar/TelegramBotAPI-examples). Besides, you are You may find examples in [this project](https://github.com/InsanusMokrassar/TelegramBotAPI-examples). Besides, you are
always welcome in our [docs](https://docs.inmo.dev/tgbotapi/index.html) and always welcome in our [wiki](https://github.com/InsanusMokrassar/TelegramBotAPI/wiki/About-this-project) and
[chat](https://t.me/InMoTelegramBotAPIChat). [chat](https://t.me/InMoTelegramBotAPIChat).

View File

@@ -6,28 +6,19 @@ buildscript {
} }
dependencies { dependencies {
classpath libs.kotlin.gradle.plugin classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath libs.kotlin.ksp.plugin classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
classpath libs.kotlin.serialization.plugin classpath "com.github.breadmoirai:github-release:$github_release_plugin_version"
classpath libs.kotlin.dokka.plugin
classpath libs.github.release.plugin
} }
} }
plugins { plugins {
alias(libs.plugins.kotlin.dokka) id "org.jetbrains.kotlin.multiplatform" version "$kotlin_version" apply false
alias(libs.plugins.versions) id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" apply false
alias(libs.plugins.validator)
} }
// temporal crutch until legacy tests will be stabled or legacy target will be removed // temporal crutch until legacy tests will be stabled or legacy target will be removed
allprojects { allprojects {
repositories {
mavenLocal()
maven { url "https://nexus.inmo.dev/repository/maven-releases/" }
mavenCentral()
google()
}
if (it != rootProject.findProject("docs")) { if (it != rootProject.findProject("docs")) {
tasks.whenTaskAdded { task -> tasks.whenTaskAdded { task ->
if(task.name == "jsLegacyBrowserTest" || task.name == "jsLegacyNodeTest") { if(task.name == "jsLegacyBrowserTest" || task.name == "jsLegacyNodeTest") {
@@ -36,7 +27,6 @@ allprojects {
} }
} }
} }
apply from: "./extensions.gradle"
private String getCurrentVersionChangelog() { private String getCurrentVersionChangelog() {
OutputStream changelogDataOS = new ByteArrayOutputStream() OutputStream changelogDataOS = new ByteArrayOutputStream()
@@ -55,13 +45,13 @@ if (new File(projectDir, "secret.gradle").exists()) {
githubRelease { githubRelease {
token "${project.property('GITHUB_RELEASE_TOKEN')}" token "${project.property('GITHUB_RELEASE_TOKEN')}"
owner = "InsanusMokrassar" owner "InsanusMokrassar"
repo = "TelegramBotAPI" repo "TelegramBotAPI"
tagName = "v$library_version" tagName "$library_version"
releaseName = "$library_version" releaseName "$library_version"
targetCommitish = "$library_version" targetCommitish "$library_version"
body = getCurrentVersionChangelog() body getCurrentVersionChangelog()
} }
} }

View File

@@ -1,28 +1,50 @@
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
}
}
plugins { plugins {
id "org.jetbrains.kotlin.multiplatform" id "org.jetbrains.kotlin.multiplatform"
id "org.jetbrains.kotlin.plugin.serialization" id "org.jetbrains.kotlin.plugin.serialization"
id "org.jetbrains.dokka" id "org.jetbrains.dokka" version "$dokka_version"
} }
project.description = "Full collection of all built-in tgbotapi tools" repositories {
mavenLocal()
apply from: "$mppProjectWithSerialization" mavenCentral()
}
kotlin { kotlin {
jvm {
compilations.main {
kotlinOptions {
jvmTarget = "1.8"
}
}
}
js(IR) {
browser()
nodejs()
}
sourceSets { sourceSets {
commonMain { commonMain {
dependencies { dependencies {
api project(":tgbotapi.core") implementation kotlin('stdlib')
api project(":tgbotapi.api")
api project(":tgbotapi.utils") rootProject.subprojects.forEach {
api project(":tgbotapi.behaviour_builder") if (it != project) {
api project(":tgbotapi.behaviour_builder.fsm") api it
api project(":tgbotapi") }
} }
}
jsMain {
dependencies {
api project(":tgbotapi.webapps")
} }
} }
} }
@@ -30,13 +52,12 @@ kotlin {
private List<SourceDirectorySet> findSourcesWithName(String... approximateNames) { private List<SourceDirectorySet> findSourcesWithName(String... approximateNames) {
return parent.subprojects return parent.subprojects
.findAll { it != project && it.hasProperty("kotlin") } .findAll { it != project }
.collectMany { it.kotlin.sourceSets } .collectMany { it.kotlin.sourceSets }
.findAll { sourceSet -> .findAll { sourceSet -> approximateNames.any {
approximateNames.any { nameToFilter -> nameToFilter -> sourceSet.name.contains(nameToFilter)
sourceSet.name.contains(nameToFilter) }
} }.collect { it.kotlin }
}.collect { it.kotlin }
} }
Object callback = { Object callback = {
@@ -54,8 +75,8 @@ Object callback = {
skipDeprecated.set(true) skipDeprecated.set(true)
sourceLink { sourceLink {
localDirectory.set(file("../")) localDirectory.set(file("./"))
remoteUrl.set(new URL("https://github.com/InsanusMokrassar/ktgbotapi")) remoteUrl.set(new URL("https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/"))
remoteLineSuffix.set("#L") remoteLineSuffix.set("#L")
} }
} }
@@ -76,3 +97,8 @@ Object callback = {
tasks.dokkaGfm(callback) tasks.dokkaGfm(callback)
tasks.dokkaHtml(callback) tasks.dokkaHtml(callback)
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

View File

@@ -1 +1,3 @@
dokka_version=1.6.0
org.gradle.jvmargs=-Xmx1024m org.gradle.jvmargs=-Xmx1024m

View File

@@ -1,17 +0,0 @@
File templatesFolder = new File("$rootProject.projectDir.absolutePath${File.separatorChar}gradle${File.separatorChar}templates")
Map properties = new HashMap<String, String>()
if (templatesFolder.exists() && templatesFolder.isDirectory()) {
templatesFolder.listFiles().each {
properties[it.name - ".gradle"] = it.absolutePath
}
}
allprojects {
ext {
properties.forEach { k, v ->
it[k] = v
}
}
}

View File

@@ -5,5 +5,19 @@ kotlin.js.generate.externals=true
kotlin.incremental=true kotlin.incremental=true
kotlin.incremental.js=true kotlin.incremental.js=true
kotlin_version=1.6.10
kotlin_coroutines_version=1.6.0
kotlin_serialisation_runtime_version=1.3.2
klock_version=2.4.10
uuid_version=0.3.1
ktor_version=1.6.7
micro_utils_version=0.9.1
javax_activation_version=1.1.1
library_group=dev.inmo library_group=dev.inmo
library_version=24.0.2 library_version=0.38.2
github_release_plugin_version=2.2.12

View File

@@ -1,87 +0,0 @@
[versions]
kotlin = "2.1.20"
kotlin-serialization = "1.8.0"
kotlin-coroutines = "1.10.1"
javax-activation = "1.1.1"
korlibs = "5.4.0"
uuid = "0.8.4"
ktor = "3.1.1"
ksp = "2.1.20-1.0.31"
kotlin-poet = "1.18.1"
microutils = "0.25.3"
kslog = "1.4.1"
versions = "0.51.0"
github-release-plugin = "2.5.2"
dokka = "2.0.0"
validator = "0.17.0"
[libraries]
kotlin = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
kotlin-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlin-coroutines" }
kotlin-serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlin-serialization" }
kotlin-serialization-properties = { module = "org.jetbrains.kotlinx:kotlinx-serialization-properties", version.ref = "kotlin-serialization" }
kotlin-test-common = { module = "org.jetbrains.kotlin:kotlin-test-common", version.ref = "kotlin" }
kotlin-test-annotations-common = { module = "org.jetbrains.kotlin:kotlin-test-annotations-common", version.ref = "kotlin" }
kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" }
kotlin-test-js = { module = "org.jetbrains.kotlin:kotlin-test-js", version.ref = "kotlin" }
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
ktor-client-curl = { module = "io.ktor:ktor-client-curl", version.ref = "ktor" }
ktor-client-winhttp = { module = "io.ktor:ktor-client-winhttp", version.ref = "ktor" }
ktor-server = { module = "io.ktor:ktor-server", version.ref = "ktor" }
ktor-server-host-common = { module = "io.ktor:ktor-server-host-common", version.ref = "ktor" }
javax-activation = { module = "javax.activation:activation", version.ref = "javax-activation" }
korlibs-klock = { module = "com.soywiz.korge:korlibs-time", version.ref = "korlibs" }
korlibs-krypto = { module = "com.soywiz.korge:korlibs-crypto", version.ref = "korlibs" }
uuid = { module = "com.benasher44:uuid", version.ref = "uuid" }
microutils-colors-common = { module = "dev.inmo:micro_utils.colors.common", version.ref = "microutils" }
microutils-coroutines = { module = "dev.inmo:micro_utils.coroutines", version.ref = "microutils" }
microutils-serialization-base64 = { module = "dev.inmo:micro_utils.serialization.base64", version.ref = "microutils" }
microutils-serialization-encapsulator = { module = "dev.inmo:micro_utils.serialization.encapsulator", version.ref = "microutils" }
microutils-serialization-typedSerializer = { module = "dev.inmo:micro_utils.serialization.typed_serializer", version.ref = "microutils" }
microutils-serialization-mapper = { module = "dev.inmo:micro_utils.serialization.mapper", version.ref = "microutils" }
microutils-languageCodes = { module = "dev.inmo:micro_utils.language_codes", version.ref = "microutils" }
microutils-ktor-common = { module = "dev.inmo:micro_utils.ktor.common", version.ref = "microutils" }
microutils-fsm-common = { module = "dev.inmo:micro_utils.fsm.common", version.ref = "microutils" }
microutils-ksp-sealed = { module = "dev.inmo:micro_utils.ksp.sealed", version.ref = "microutils" }
microutils-ksp-sealed-generator = { module = "dev.inmo:micro_utils.ksp.sealed.generator", version.ref = "microutils" }
microutils-ksp-variations = { module = "dev.inmo:micro_utils.ksp.variations", version.ref = "microutils" }
microutils-ksp-variations-generator = { module = "dev.inmo:micro_utils.ksp.variations.generator", version.ref = "microutils" }
kslog = { module = "dev.inmo:kslog", version.ref = "kslog" }
# ksp dependencies
kotlin-poet = { module = "com.squareup:kotlinpoet-ksp", version.ref = "kotlin-poet" }
ksp = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp" }
# buildscript classpaths
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
kotlin-ksp-plugin = { module = "com.google.devtools.ksp:symbol-processing-gradle-plugin", version.ref = "ksp" }
kotlin-serialization-plugin = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin" }
kotlin-dokka-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" }
github-release-plugin = { module = "com.github.breadmoirai:github-release", version.ref = "github-release-plugin" }
[plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
kotlin-dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
versions = { id = "com.github.ben-manes.versions", version.ref = "versions" }
validator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "validator" }

View File

@@ -1,31 +0,0 @@
project.version = "$version"
project.group = "$group"
apply from: "$mpp_publish"
kotlin {
js (IR) {
browser()
nodejs()
}
sourceSets {
commonMain {
dependencies {
implementation libs.kotlin
api libs.kotlin.serialization
}
}
commonTest {
dependencies {
implementation libs.kotlin.test.common
implementation libs.kotlin.test.annotations.common
}
}
jsTest {
dependencies {
implementation libs.kotlin.test.js
}
}
}
}

View File

@@ -1,57 +0,0 @@
project.version = "$library_version"
project.group = "$library_group"
kotlin {
jvm {
compilations.main {
kotlinOptions {
jvmTarget = "17"
}
}
}
js (IR) {
browser()
nodejs()
}
linuxX64()
mingwX64()
linuxArm64()
sourceSets {
commonMain {
dependencies {
implementation libs.kotlin
api libs.kotlin.serialization
}
}
commonTest {
dependencies {
implementation libs.kotlin.test.common
implementation libs.kotlin.test.annotations.common
}
}
jvmTest {
dependencies {
implementation libs.kotlin.test.junit
}
}
jsTest {
dependencies {
implementation libs.kotlin.test.js
}
}
all {
languageSettings {
optIn('dev.inmo.tgbotapi.utils.RiskFeature')
optIn('dev.inmo.tgbotapi.utils.PreviewFeature')
optIn('dev.inmo.micro_utils.common.Warning')
optIn('dev.inmo.micro_utils.common.PreviewFeature')
}
}
}
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

View File

@@ -1,118 +0,0 @@
apply plugin: 'maven-publish'
task javadocsJar(type: Jar) {
archiveClassifier = 'javadoc'
}
publishing {
publications.all {
artifact javadocsJar
pom {
description = "${project.description}"
name = "${project.name}"
url = "https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI"
scm {
developerConnection = "scm:git:[fetch=]https://github.com/insanusmokrassar/TelegramBotAPI.git[push=]https://github.com/insanusmokrassar/TelegramBotAPI.git"
url = "https://github.com/insanusmokrassar/TelegramBotAPI.git"
}
developers {
developer {
id = "InsanusMokrassar"
name = "Ovsiannikov Aleksei"
email = "ovsyannikov.alexey95@gmail.com"
}
}
licenses {
license {
name = "Apache Software License 2.0"
url = "https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"
}
}
}
repositories {
if ((project.hasProperty('GITHUB_USER') || System.getenv('GITHUB_USER') != null) && (project.hasProperty('GITHUB_TOKEN') || System.getenv('GITHUB_TOKEN') != null)) {
maven {
name = "GithubPackages"
url = uri("https://maven.pkg.github.com/InsanusMokrassar/ktgbotapi")
credentials {
username = project.hasProperty('GITHUB_USER') ? project.property('GITHUB_USER') : System.getenv('GITHUB_USER')
password = project.hasProperty('GITHUB_TOKEN') ? project.property('GITHUB_TOKEN') : System.getenv('GITHUB_TOKEN')
}
}
}
if ((project.hasProperty('INMONEXUS_USER') || System.getenv('INMONEXUS_USER') != null) && (project.hasProperty('INMONEXUS_PASSWORD') || System.getenv('INMONEXUS_PASSWORD') != null)) {
maven {
name = "InmoNexus"
url = uri("https://nexus.inmo.dev/repository/maven-releases/")
credentials {
username = project.hasProperty('INMONEXUS_USER') ? project.property('INMONEXUS_USER') : System.getenv('INMONEXUS_USER')
password = project.hasProperty('INMONEXUS_PASSWORD') ? project.property('INMONEXUS_PASSWORD') : System.getenv('INMONEXUS_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')
}
}
}
}
}
}
if (project.hasProperty("signing.gnupg.keyName")) {
apply plugin: 'signing'
signing {
useGpgCmd()
sign publishing.publications
}
task signAll {
tasks.withType(Sign).forEach {
dependsOn(it)
}
}
// Workaround to make android sign operations depend on signing tasks
project.getTasks().withType(AbstractPublishToMaven.class).configureEach {
def signingTasks = project.getTasks().withType(Sign.class)
mustRunAfter(signingTasks)
}
// Workaround to make test tasks use sign
project.getTasks().withType(Sign.class).configureEach { signTask ->
def withoutSign = (signTask.name.startsWith("sign") ? signTask.name.minus("sign") : signTask.name)
def pubName = withoutSign.endsWith("Publication") ? withoutSign.substring(0, withoutSign.length() - "Publication".length()) : withoutSign
// These tasks only exist for native targets, hence findByName() to avoid trying to find them for other targets
// Task ':linkDebugTest<platform>' uses this output of task ':sign<platform>Publication' without declaring an explicit or implicit dependency
def debugTestTask = tasks.findByName("linkDebugTest$pubName")
if (debugTestTask != null) {
signTask.mustRunAfter(debugTestTask)
}
// Task ':compileTestKotlin<platform>' uses this output of task ':sign<platform>Publication' without declaring an explicit or implicit dependency
def testTask = tasks.findByName("compileTestKotlin$pubName")
if (testTask != null) {
signTask.mustRunAfter(testTask)
}
}
}

View File

@@ -1 +0,0 @@
{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"${project.name}","description":"${project.description}","url":"https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}],"repositories":[{"name":"GithubPackages","url":"https://maven.pkg.github.com/InsanusMokrassar/ktgbotapi","credsType":{"type":"dev.inmo.kmppscriptbuilder.core.models.MavenPublishingRepository.CredentialsType.UsernameAndPassword","usernameProperty":"GITHUB_USER","passwordProperty":"GITHUB_TOKEN"}},{"name":"InmoNexus","url":"https://nexus.inmo.dev/repository/maven-releases/"},{"name":"sonatype","url":"https://oss.sonatype.org/service/local/staging/deploy/maven2/"}],"gpgSigning":{"type":"dev.inmo.kmppscriptbuilder.core.models.GpgSigning.Optional"}}}

View File

@@ -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-8.12.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip

Binary file not shown.

Before

Width:  |  Height:  |  Size: 448 KiB

View File

@@ -12,10 +12,13 @@ pluginManagement {
} }
include ":tgbotapi.core" include ":tgbotapi.core"
include ":tgbotapi.ksp"
include ":tgbotapi.api" include ":tgbotapi.api"
include ":tgbotapi.utils" include ":tgbotapi.utils"
include ":tgbotapi.behaviour_builder" include ":tgbotapi.behaviour_builder"
include ":tgbotapi.behaviour_builder.fsm" include ":tgbotapi.behaviour_builder.fsm"
include ":tgbotapi.extensions.api"
include ":tgbotapi.extensions.utils"
include ":tgbotapi.extensions.behaviour_builder"
include ":tgbotapi.extensions.behaviour_builder.fsm"
include ":tgbotapi" include ":tgbotapi"
include ":tgbotapi.webapps" include ":docs"

File diff suppressed because it is too large Load Diff

View File

@@ -1,31 +1,55 @@
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
}
}
plugins { plugins {
id "org.jetbrains.kotlin.multiplatform" id "org.jetbrains.kotlin.multiplatform"
id "org.jetbrains.kotlin.plugin.serialization" id "org.jetbrains.kotlin.plugin.serialization"
id "org.jetbrains.dokka"
id "com.google.devtools.ksp"
} }
project.description = "API extensions with \"Telegram Bot API\"-like extensions for TelegramBot and RequestsExecutor" project.version = "$library_version"
project.group = "$library_group"
apply from: "$mppProjectWithSerialization" apply from: "publish.gradle"
apply from: "$mpp_publish"
repositories {
mavenLocal()
mavenCentral()
}
kotlin { kotlin {
jvm {
compilations.main {
kotlinOptions {
jvmTarget = "1.8"
}
}
}
js(IR) {
browser()
nodejs()
}
sourceSets { sourceSets {
commonMain { commonMain {
dependencies { dependencies {
implementation kotlin('stdlib')
api project(":tgbotapi.core") api project(":tgbotapi.core")
api libs.microutils.ksp.variations
} }
} }
configureEach {
languageSettings.optIn("kotlinx.serialization.ExperimentalSerializationApi")
}
} }
explicitApi()
} }
dependencies { java {
add("kspCommonMainMetadata", libs.microutils.ksp.variations.generator) sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
} }

View File

@@ -0,0 +1,79 @@
apply plugin: 'maven-publish'
task javadocsJar(type: Jar) {
classifier = 'javadoc'
}
publishing {
publications.all {
artifact javadocsJar
pom {
description = "API extensions which provide work with RequestsExecutor of TelegramBotAPI almost like it is described in original Telegram Bot API reference"
name = "Telegram Bot API Extensions for API"
url = "https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-extensions-api"
scm {
developerConnection = "scm:git:[fetch=]https://github.com/insanusmokrassar/TelegramBotAPI.git[push=]https://github.com/insanusmokrassar/TelegramBotAPI.git"
url = "https://github.com/insanusmokrassar/TelegramBotAPI.git"
}
developers {
developer {
id = "InsanusMokrassar"
name = "Ovsiannikov Aleksei"
email = "ovsyannikov.alexey95@gmail.com"
}
}
licenses {
license {
name = "Apache Software License 2.0"
url = "https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"
}
}
}
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/TelegramBotAPI")
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')
}
}
}
}
}
}
if (project.hasProperty("signing.gnupg.keyName")) {
apply plugin: 'signing'
signing {
useGpgCmd()
sign publishing.publications
}
task signAll {
tasks.withType(Sign).forEach {
dependsOn(it)
}
}
}

View File

@@ -0,0 +1 @@
{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API Extensions for API","description":"API extensions which provide work with RequestsExecutor of TelegramBotAPI almost like it is described in original Telegram Bot API reference","url":"https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-extensions-api","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}],"repositories":[{"name":"GithubPackages","url":"https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI"},{"name":"sonatype","url":"https://oss.sonatype.org/service/local/staging/deploy/maven2/"}],"gpgSigning":{"type":"dev.inmo.kmppscriptbuilder.core.models.GpgSigning.Optional"}}}

View File

@@ -12,7 +12,7 @@ import io.ktor.client.engine.*
* @param ktorClientEngine Engine like [io.ktor.client.engine.cio.CIO] * @param ktorClientEngine Engine like [io.ktor.client.engine.cio.CIO]
* @param ktorClientConfig Config block for preconfiguring of bot [HttpClient] * @param ktorClientConfig Config block for preconfiguring of bot [HttpClient]
*/ */
public data class BotBuilder internal constructor( data class BotBuilder internal constructor(
var proxy: ProxyConfig? = null, var proxy: ProxyConfig? = null,
var ktorClientEngineFactory: HttpClientEngineFactory<HttpClientEngineConfig>? = null, var ktorClientEngineFactory: HttpClientEngineFactory<HttpClientEngineConfig>? = null,
var ktorClientConfig: (HttpClientConfig<*>.() -> Unit) ? = null var ktorClientConfig: (HttpClientConfig<*>.() -> Unit) ? = null
@@ -37,12 +37,11 @@ public data class BotBuilder internal constructor(
* @return Created by [telegramBotWithCustomClientConfig] function [TelegramBot]. This executor will be preconfigured using [token] and * @return Created by [telegramBotWithCustomClientConfig] function [TelegramBot]. This executor will be preconfigured using [token] and
* [block] * [block]
*/ */
public fun buildBot( fun buildBot(
token: String, token: String,
apiUrl: String = telegramBotAPIDefaultUrl, apiUrl: String = telegramBotAPIDefaultUrl,
testServer: Boolean = false,
block: BotBuilder.() -> Unit block: BotBuilder.() -> Unit
): TelegramBot = telegramBot( ) = telegramBot(
TelegramAPIUrlsKeeper(token, testServer, apiUrl), TelegramAPIUrlsKeeper(token, apiUrl),
BotBuilder().apply(block).createHttpClient() BotBuilder().apply(block).createHttpClient()
) )

View File

@@ -1,6 +1,6 @@
package dev.inmo.tgbotapi.extensions.api package dev.inmo.tgbotapi.extensions.api
import dev.inmo.tgbotapi.bot.ktor.telegramBot import dev.inmo.tgbotapi.bot.Ktor.telegramBot
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
import dev.inmo.tgbotapi.utils.telegramBotAPIDefaultUrl import dev.inmo.tgbotapi.utils.telegramBotAPIDefaultUrl
@@ -11,9 +11,9 @@ import io.ktor.client.engine.*
/** /**
* Allows to create bot using bot [urlsKeeper] and already prepared [client] * Allows to create bot using bot [urlsKeeper] and already prepared [client]
*/ */
public fun telegramBot( fun telegramBot(
urlsKeeper: TelegramAPIUrlsKeeper, urlsKeeper: TelegramAPIUrlsKeeper,
client: HttpClient = HttpClient() client: HttpClient
): TelegramBot = telegramBot(urlsKeeper) { ): TelegramBot = telegramBot(urlsKeeper) {
this.client = client this.client = client
} }
@@ -23,11 +23,11 @@ public fun telegramBot(
* configure it with [clientConfig] * configure it with [clientConfig]
*/ */
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
public inline fun <T: HttpClientEngineConfig> telegramBot( inline fun <T: HttpClientEngineConfig> telegramBot(
urlsKeeper: TelegramAPIUrlsKeeper, urlsKeeper: TelegramAPIUrlsKeeper,
clientFactory: HttpClientEngineFactory<T>, clientFactory: HttpClientEngineFactory<T>,
noinline clientConfig: HttpClientConfig<T>.() -> Unit = {} noinline clientConfig: HttpClientConfig<T>.() -> Unit = {}
): TelegramBot = telegramBot( ) = telegramBot(
urlsKeeper, urlsKeeper,
HttpClient(clientFactory, clientConfig) HttpClient(clientFactory, clientConfig)
) )
@@ -37,11 +37,11 @@ public inline fun <T: HttpClientEngineConfig> telegramBot(
* configure [HttpClient] using [clientConfig] * configure [HttpClient] using [clientConfig]
*/ */
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
public inline fun telegramBot( inline fun telegramBot(
urlsKeeper: TelegramAPIUrlsKeeper, urlsKeeper: TelegramAPIUrlsKeeper,
clientEngine: HttpClientEngine, clientEngine: HttpClientEngine,
noinline clientConfig: HttpClientConfig<*>.() -> Unit = {} noinline clientConfig: HttpClientConfig<*>.() -> Unit = {}
): TelegramBot = telegramBot( ) = telegramBot(
urlsKeeper, urlsKeeper,
HttpClient(clientEngine, clientConfig) HttpClient(clientEngine, clientConfig)
) )
@@ -51,10 +51,10 @@ public inline fun telegramBot(
* [clientConfig] * [clientConfig]
*/ */
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
public inline fun telegramBot( inline fun telegramBot(
urlsKeeper: TelegramAPIUrlsKeeper, urlsKeeper: TelegramAPIUrlsKeeper,
noinline clientConfig: HttpClientConfig<*>.() -> Unit noinline clientConfig: HttpClientConfig<*>.() -> Unit
): TelegramBot = telegramBot( ) = telegramBot(
urlsKeeper, urlsKeeper,
HttpClient(clientConfig) HttpClient(clientConfig)
) )
@@ -63,22 +63,20 @@ public inline fun telegramBot(
* Allows to create bot using bot [token], [apiUrl] (for custom api servers) and already prepared [client] * Allows to create bot using bot [token], [apiUrl] (for custom api servers) and already prepared [client]
*/ */
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
public inline fun telegramBot( inline fun telegramBot(
token: String, token: String,
apiUrl: String = telegramBotAPIDefaultUrl, apiUrl: String = telegramBotAPIDefaultUrl,
testServer: Boolean = false, client: HttpClient
client: HttpClient = HttpClient() ): TelegramBot = telegramBot(TelegramAPIUrlsKeeper(token, apiUrl), client)
): TelegramBot = telegramBot(TelegramAPIUrlsKeeper(token, testServer, apiUrl), client)
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
public inline fun <T: HttpClientEngineConfig> telegramBot( inline fun <T: HttpClientEngineConfig> telegramBot(
token: String, token: String,
clientFactory: HttpClientEngineFactory<T>, clientFactory: HttpClientEngineFactory<T>,
apiUrl: String = telegramBotAPIDefaultUrl, apiUrl: String = telegramBotAPIDefaultUrl,
testServer: Boolean = false,
noinline clientConfig: HttpClientConfig<T>.() -> Unit = {} noinline clientConfig: HttpClientConfig<T>.() -> Unit = {}
): TelegramBot = telegramBot( ) = telegramBot(
TelegramAPIUrlsKeeper(token, testServer, apiUrl), TelegramAPIUrlsKeeper(token, apiUrl),
clientFactory, clientFactory,
clientConfig clientConfig
) )
@@ -88,14 +86,13 @@ public inline fun <T: HttpClientEngineConfig> telegramBot(
* configure [HttpClient] using [clientConfig] * configure [HttpClient] using [clientConfig]
*/ */
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
public inline fun telegramBot( inline fun telegramBot(
token: String, token: String,
clientEngine: HttpClientEngine, clientEngine: HttpClientEngine,
apiUrl: String = telegramBotAPIDefaultUrl, apiUrl: String = telegramBotAPIDefaultUrl,
testServer: Boolean = false,
noinline clientConfig: HttpClientConfig<*>.() -> Unit = {} noinline clientConfig: HttpClientConfig<*>.() -> Unit = {}
): TelegramBot = telegramBot( ) = telegramBot(
TelegramAPIUrlsKeeper(token, testServer, apiUrl), TelegramAPIUrlsKeeper(token, apiUrl),
clientEngine, clientEngine,
clientConfig clientConfig
) )
@@ -105,12 +102,11 @@ public inline fun telegramBot(
* [clientConfig] * [clientConfig]
*/ */
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
public inline fun telegramBot( inline fun telegramBot(
token: String, token: String,
apiUrl: String = telegramBotAPIDefaultUrl, apiUrl: String = telegramBotAPIDefaultUrl,
testServer: Boolean = false,
noinline clientConfig: HttpClientConfig<*>.() -> Unit noinline clientConfig: HttpClientConfig<*>.() -> Unit
): TelegramBot = telegramBot( ) = telegramBot(
TelegramAPIUrlsKeeper(token, testServer, apiUrl), TelegramAPIUrlsKeeper(token, apiUrl),
clientConfig clientConfig
) )

View File

@@ -4,4 +4,4 @@ import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.local.Close import dev.inmo.tgbotapi.requests.local.Close
@Suppress("unused") @Suppress("unused")
public suspend inline fun TelegramBot.close(): Boolean = execute(Close) suspend inline fun TelegramBot.close() = execute(Close)

View File

@@ -3,51 +3,26 @@ package dev.inmo.tgbotapi.extensions.api
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.DeleteMessage import dev.inmo.tgbotapi.requests.DeleteMessage
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageIdentifier
import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.chat.abstracts.Chat
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.content.MediaGroupCollectionContent
public suspend fun TelegramBot.deleteMessage( suspend fun TelegramBot.deleteMessage(
chatId: ChatIdentifier, chatId: ChatIdentifier,
messageId: MessageId messageId: MessageIdentifier
): Boolean = execute( ) = execute(
DeleteMessage(chatId, messageId) DeleteMessage(chatId, messageId)
) )
public suspend fun TelegramBot.deleteMessage( suspend fun TelegramBot.deleteMessage(
chat: Chat, chat: Chat,
messageId: MessageId messageId: MessageIdentifier
): Boolean = deleteMessage(chat.id, messageId) ) = deleteMessage(chat.id, messageId)
public suspend fun TelegramBot.deleteMessage( suspend fun TelegramBot.deleteMessage(
message: AccessibleMessage message: Message
): Boolean { ) = deleteMessage(message.chat, message.messageId)
val mediaGroupContent = ((message as? ContentMessage<*>) ?.content as? MediaGroupCollectionContent<*>)
if (mediaGroupContent == null) {
return deleteMessage(message.chat, message.messageId)
} else {
return mediaGroupContent.group.map {
deleteMessage(it.sourceMessage)
}.all { it }
}
}
public suspend fun TelegramBot.delete( suspend fun Message.delete(
chatId: ChatIdentifier,
messageId: MessageId
): Boolean = deleteMessage(chatId, messageId)
public suspend fun TelegramBot.delete(
chat: Chat,
messageId: MessageId
): Boolean = deleteMessage(chat, messageId)
public suspend fun TelegramBot.delete(
message: AccessibleMessage
): Boolean = deleteMessage(message)
public suspend fun AccessibleMessage.delete(
requestsExecutor: TelegramBot requestsExecutor: TelegramBot
): Boolean = requestsExecutor.deleteMessage(this) ) = requestsExecutor.deleteMessage(this)

View File

@@ -1,61 +0,0 @@
package dev.inmo.tgbotapi.extensions.api
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.DeleteMessages
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.abstracts.Message
import kotlin.jvm.JvmName
public suspend fun TelegramBot.deleteMessages(
chatId: ChatIdentifier,
messageIds: List<MessageId>
): Boolean = messageIds.chunked(deleteMessagesLimit.last).map {
execute(
DeleteMessages(
chatId = chatId,
messageIds = it
)
)
}.all { it }
public suspend fun TelegramBot.deleteMessages(
chatId: ChatIdentifier,
messageIds: Array<MessageId>
): Boolean = deleteMessages(
chatId = chatId,
messageIds = messageIds.toList()
)
public suspend fun TelegramBot.deleteMessages(
messagesMetas: List<Message.MetaInfo>
): Boolean = messagesMetas.groupBy { it.chatId }.map { (chatId, messages) ->
deleteMessages(
chatId = chatId,
messageIds = messages.map { it.messageId }
)
}.all { it }
@JvmName("deleteMessagesWithMessages")
public suspend fun TelegramBot.deleteMessages(
messages: List<AccessibleMessage>
): Boolean = deleteMessages(messages.map { it.metaInfo })
public suspend fun TelegramBot.delete(
chatId: ChatIdentifier,
messageIds: List<MessageId>
): Boolean = deleteMessages(chatId = chatId, messageIds = messageIds)
public suspend fun TelegramBot.delete(
chatId: ChatIdentifier,
messageIds: Array<MessageId>
): Boolean = deleteMessages(chatId = chatId, messageIds = messageIds)
public suspend fun TelegramBot.delete(
messagesMetas: List<Message.MetaInfo>
): Boolean = deleteMessages(messagesMetas)
@JvmName("deleteWithMessages")
public suspend fun TelegramBot.delete(
messages: List<AccessibleMessage>
): Boolean = deleteMessages(messages)

View File

@@ -3,70 +3,54 @@ package dev.inmo.tgbotapi.extensions.api
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.ForwardMessage import dev.inmo.tgbotapi.requests.ForwardMessage
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageIdentifier
import dev.inmo.tgbotapi.types.MessageThreadId import dev.inmo.tgbotapi.types.chat.abstracts.Chat
import dev.inmo.tgbotapi.types.Seconds import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.abstracts.PossiblyForwardedMessage
import dev.inmo.tgbotapi.types.threadId
public suspend fun TelegramBot.forwardMessage( suspend fun TelegramBot.forwardMessage(
fromChatId: ChatIdentifier, fromChatId: ChatIdentifier,
toChatId: ChatIdentifier, toChatId: ChatIdentifier,
messageId: MessageId, messageId: MessageIdentifier,
threadId: MessageThreadId? = toChatId.threadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false protectContent: Boolean = false
): PossiblyForwardedMessage = execute( ) = execute(
ForwardMessage(fromChatId, toChatId, messageId, threadId, startTimestamp, disableNotification, protectContent) ForwardMessage(fromChatId, toChatId, messageId, disableNotification, protectContent)
) )
public suspend fun TelegramBot.forwardMessage( suspend fun TelegramBot.forwardMessage(
fromChat: Chat, fromChat: Chat,
toChatId: ChatIdentifier, toChatId: ChatIdentifier,
messageId: MessageId, messageId: MessageIdentifier,
threadId: MessageThreadId? = toChatId.threadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false protectContent: Boolean = false
): PossiblyForwardedMessage = forwardMessage(fromChat.id, toChatId, messageId, threadId, startTimestamp, disableNotification, protectContent) ) = forwardMessage(fromChat.id, toChatId, messageId, disableNotification, protectContent)
public suspend fun TelegramBot.forwardMessage( suspend fun TelegramBot.forwardMessage(
fromChatId: ChatIdentifier, fromChatId: ChatIdentifier,
toChat: Chat, toChat: Chat,
messageId: MessageId, messageId: MessageIdentifier,
threadId: MessageThreadId? = toChat.id.threadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false protectContent: Boolean = false
): PossiblyForwardedMessage = forwardMessage(fromChatId, toChat.id, messageId, threadId, startTimestamp, disableNotification, protectContent) ) = forwardMessage(fromChatId, toChat.id, messageId, disableNotification, protectContent)
public suspend fun TelegramBot.forwardMessage( suspend fun TelegramBot.forwardMessage(
fromChat: Chat, fromChat: Chat,
toChat: Chat, toChat: Chat,
messageId: MessageId, messageId: MessageIdentifier,
threadId: MessageThreadId? = toChat.id.threadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false protectContent: Boolean = false
): PossiblyForwardedMessage = forwardMessage(fromChat.id, toChat.id, messageId, threadId, startTimestamp, disableNotification, protectContent) ) = forwardMessage(fromChat.id, toChat.id, messageId, disableNotification, protectContent)
public suspend fun TelegramBot.forwardMessage( suspend fun TelegramBot.forwardMessage(
toChatId: ChatIdentifier, toChatId: ChatIdentifier,
message: AccessibleMessage, message: Message,
threadId: MessageThreadId? = toChatId.threadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false protectContent: Boolean = false
): PossiblyForwardedMessage = forwardMessage(message.chat, toChatId, message.messageId, threadId, startTimestamp, disableNotification, protectContent) ) = forwardMessage(message.chat, toChatId, message.messageId, disableNotification, protectContent)
public suspend fun TelegramBot.forwardMessage( suspend fun TelegramBot.forwardMessage(
toChat: Chat, toChat: Chat,
message: AccessibleMessage, message: Message,
threadId: MessageThreadId? = toChat.id.threadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false protectContent: Boolean = false
): PossiblyForwardedMessage = forwardMessage(message.chat, toChat, message.messageId, threadId, startTimestamp, disableNotification, protectContent) ) = forwardMessage(message.chat, toChat, message.messageId, disableNotification, protectContent)

View File

@@ -1,154 +0,0 @@
package dev.inmo.tgbotapi.extensions.api
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.extensions.api.send.copyMessages
import dev.inmo.tgbotapi.requests.ForwardMessages
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.abstracts.Message
import kotlin.jvm.JvmName
public suspend fun TelegramBot.forwardMessages(
toChatId: ChatIdentifier,
fromChatId: ChatIdentifier,
messageIds: List<MessageId>,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
): List<MessageId> = messageIds.chunked(forwardMessagesLimit.last).flatMap {
execute(
ForwardMessages(
toChatId = toChatId,
fromChatId = fromChatId,
messageIds = it,
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption
)
)
}
public suspend fun TelegramBot.forwardMessages(
toChatId: ChatIdentifier,
fromChatId: ChatIdentifier,
messageIds: Array<MessageId>,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
): List<MessageId> = forwardMessages(
toChatId = toChatId,
fromChatId = fromChatId,
messageIds = messageIds.toList(),
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption
)
public suspend fun TelegramBot.forwardMessages(
toChatId: ChatIdentifier,
messagesMetas: List<Message.MetaInfo>,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
): List<MessageId> = messagesMetas.groupBy { it.chatId }.flatMap { (chatId, messages) ->
forwardMessages(
toChatId = toChatId,
fromChatId = chatId,
messageIds = messages.map { it.messageId },
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption
)
}
@JvmName("forwardMessagesWithMessages")
public suspend fun TelegramBot.forwardMessages(
toChatId: ChatIdentifier,
messages: List<AccessibleMessage>,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
): List<MessageId> = forwardMessages(
toChatId = toChatId,
messagesMetas = messages.map { it.metaInfo },
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption
)
public suspend fun TelegramBot.forward(
toChatId: ChatIdentifier,
fromChatId: ChatIdentifier,
messageIds: List<MessageId>,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
): List<MessageId> = forwardMessages(
toChatId = toChatId,
fromChatId = fromChatId,
messageIds = messageIds,
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption
)
public suspend fun TelegramBot.forward(
toChatId: ChatIdentifier,
fromChatId: ChatIdentifier,
messageIds: Array<MessageId>,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
): List<MessageId> = forwardMessages(
toChatId = toChatId,
fromChatId = fromChatId,
messageIds = messageIds,
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption
)
public suspend fun TelegramBot.forward(
toChatId: ChatIdentifier,
messagesMetas: List<Message.MetaInfo>,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
): List<MessageId> = forwardMessages(
toChatId = toChatId,
messagesMetas = messagesMetas,
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption
)
@JvmName("forwardWithMessages")
public suspend fun TelegramBot.forward(
toChatId: ChatIdentifier,
messages: List<AccessibleMessage>,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
): List<MessageId> = forwardMessages(
toChatId = toChatId,
messages = messages,
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption
)

View File

@@ -5,22 +5,22 @@ import dev.inmo.tgbotapi.requests.GetUpdates
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.update.abstracts.Update import dev.inmo.tgbotapi.types.update.abstracts.Update
public suspend fun TelegramBot.getUpdates( suspend fun TelegramBot.getUpdates(
offset: UpdateId? = null, offset: UpdateIdentifier? = null,
limit: Int = getUpdatesLimit.last, limit: Int = getUpdatesLimit.last,
timeout: Seconds? = null, timeout: Seconds? = null,
allowed_updates: List<String>? = ALL_UPDATES_LIST allowed_updates: List<String>? = ALL_UPDATES_LIST
): List<Update> = execute( ) = execute(
GetUpdates( GetUpdates(
offset, limit, timeout, allowed_updates offset, limit, timeout, allowed_updates
) )
) )
public suspend fun TelegramBot.getUpdates( suspend fun TelegramBot.getUpdates(
lastUpdate: Update, lastUpdate: Update,
limit: Int = getUpdatesLimit.last, limit: Int = getUpdatesLimit.last,
timeout: Seconds? = null, timeout: Seconds? = null,
allowed_updates: List<String>? = ALL_UPDATES_LIST allowed_updates: List<String>? = ALL_UPDATES_LIST
): List<Update> = getUpdates( ) = getUpdates(
lastUpdate.updateId + 1, limit, timeout, allowed_updates lastUpdate.updateId + 1, limit, timeout, allowed_updates
) )

View File

@@ -1,27 +0,0 @@
package dev.inmo.tgbotapi.extensions.api
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.GetUpdatesRaw
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.update.abstracts.Update
import kotlinx.serialization.json.JsonArray
public suspend fun TelegramBot.getRawUpdates(
offset: UpdateId? = null,
limit: Int = getUpdatesLimit.last,
timeout: Seconds? = null,
allowed_updates: List<String>? = ALL_UPDATES_LIST
): JsonArray = execute(
GetUpdatesRaw(
offset, limit, timeout, allowed_updates
)
)
public suspend fun TelegramBot.getRawUpdates(
lastUpdate: Update,
limit: Int = getUpdatesLimit.last,
timeout: Seconds? = null,
allowed_updates: List<String>? = ALL_UPDATES_LIST
): JsonArray = getRawUpdates(
lastUpdate.updateId + 1, limit, timeout, allowed_updates
)

View File

@@ -1,57 +1,70 @@
package dev.inmo.tgbotapi.extensions.api.InternalUtils package dev.inmo.tgbotapi.extensions.api.InternalUtils
import dev.inmo.tgbotapi.types.MediaGroupId import dev.inmo.tgbotapi.types.MediaGroupIdentifier
import dev.inmo.tgbotapi.types.message.abstracts.PossiblySentViaBotCommonMessage import dev.inmo.tgbotapi.types.UpdateIdentifier
import dev.inmo.tgbotapi.types.message.content.MediaGroupPartContent import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
import dev.inmo.tgbotapi.types.update.* import dev.inmo.tgbotapi.types.update.*
import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.*
import dev.inmo.tgbotapi.types.update.abstracts.* import dev.inmo.tgbotapi.types.update.abstracts.*
import dev.inmo.tgbotapi.utils.extensions.asMediaGroupMessage
/** internal fun Update.lastUpdateIdentifier(): UpdateIdentifier {
* Will convert incoming list of updates to list with [MediaGroupUpdate]s return if (this is SentMediaGroupUpdate) {
*/ origins.last().updateId
} else {
updateId
}
}
internal fun List<Update>.lastUpdateIdentifier(): UpdateIdentifier? {
return maxByOrNull { it.updateId } ?.lastUpdateIdentifier()
}
internal fun List<Update>.convertWithMediaGroupUpdates(): List<Update> { internal fun List<Update>.convertWithMediaGroupUpdates(): List<Update> {
val resultUpdates = mutableListOf<Update>() val resultUpdates = mutableListOf<Update>()
val mediaGroups = mutableMapOf<MediaGroupId, MutableList<Pair<BaseSentMessageUpdate, PossiblySentViaBotCommonMessage<MediaGroupPartContent>>>>() val mediaGroups = mutableMapOf<MediaGroupIdentifier, MutableList<BaseSentMessageUpdate>>()
for (update in this) { for (update in this) {
val message = (update.data as? PossiblySentViaBotCommonMessage<*>) ?.let { val data = (update.data as? MediaGroupMessage<*>)
if (it.content is MediaGroupPartContent) { if (data == null) {
it as PossiblySentViaBotCommonMessage<MediaGroupPartContent>
} else {
null
}
}
val mediaGroupId = message ?.mediaGroupId
if (message == null || mediaGroupId == null) {
resultUpdates.add(update) resultUpdates.add(update)
continue continue
} }
when (update) { when (update) {
is BaseEditMessageUpdate -> resultUpdates.add(
update.toEditMediaGroupUpdate()
)
is BaseSentMessageUpdate -> { is BaseSentMessageUpdate -> {
mediaGroups.getOrPut(mediaGroupId) { mediaGroups.getOrPut(data.mediaGroupId) {
mutableListOf() mutableListOf()
}.add(update to message) }.add(update)
} }
else -> resultUpdates.add(update) else -> resultUpdates.add(update)
} }
} }
mediaGroups.values.map {
mediaGroups.map { (_, updatesWithMessages) -> it.toSentMediaGroupUpdate() ?.let { mediaGroupUpdate ->
val update = updatesWithMessages.maxBy { it.first.updateId }.first resultUpdates.add(mediaGroupUpdate)
resultUpdates.add( }
update.copy(updatesWithMessages.map { it.second }.asMediaGroupMessage())
)
} }
resultUpdates.sortBy { it.updateId } resultUpdates.sortBy { it.updateId }
return resultUpdates return resultUpdates
} }
/** internal fun List<BaseSentMessageUpdate>.toSentMediaGroupUpdate(): SentMediaGroupUpdate? = (this as? SentMediaGroupUpdate) ?: let {
* @return [EditMessageMediaGroupUpdate] in case if [this] is [EditMessageUpdate]. When [this] object is if (isEmpty()) {
* [EditChannelPostUpdate] instance - will return [EditChannelPostMediaGroupUpdate] return@let null
* }
* @throws IllegalStateException val resultList = sortedBy { it.updateId }
*/ when (first()) {
internal fun BaseEditMessageUpdate.toEditMediaGroupUpdate() = this is MessageUpdate -> MessageMediaGroupUpdate(resultList)
is ChannelPostUpdate -> ChannelPostMediaGroupUpdate(resultList)
else -> null
}
}
internal fun BaseEditMessageUpdate.toEditMediaGroupUpdate(): EditMediaGroupUpdate = (this as? EditMediaGroupUpdate) ?: let {
when (this) {
is EditMessageUpdate -> EditMessageMediaGroupUpdate(this)
is EditChannelPostUpdate -> EditChannelPostMediaGroupUpdate(this)
else -> error("Unsupported type of ${BaseEditMessageUpdate::class.simpleName}")
}
}

View File

@@ -1,197 +0,0 @@
package dev.inmo.tgbotapi.extensions.api
import dev.inmo.micro_utils.coroutines.LinkedSupervisorScope
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
import dev.inmo.tgbotapi.abstracts.Headed
import dev.inmo.tgbotapi.abstracts.HorizontallyAccured
import dev.inmo.tgbotapi.abstracts.Locationed
import dev.inmo.tgbotapi.abstracts.ProximityAlertable
import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.extensions.api.edit.edit
import dev.inmo.tgbotapi.extensions.api.send.send
import dev.inmo.tgbotapi.extensions.api.send.sendLiveLocation
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.location.LiveLocation
import dev.inmo.tgbotapi.types.location.Location
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.content.LiveLocationContent
import dev.inmo.tgbotapi.types.message.content.LocationContent
import kotlinx.coroutines.CoroutineStart
import kotlinx.coroutines.currentCoroutineContext
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.FlowCollector
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.isActive
import kotlinx.serialization.Serializable
import kotlin.js.JsName
import kotlin.jvm.JvmName
import kotlin.math.ceil
@Serializable
public data class EditLiveLocationInfo(
override val latitude: Double,
override val longitude: Double,
override val horizontalAccuracy: Meters? = null,
override val heading: Degrees? = null,
override val proximityAlertRadius: Meters? = null,
override val replyMarkup: InlineKeyboardMarkup? = null
) : Locationed, HorizontallyAccured, ProximityAlertable, Headed, WithReplyMarkup
/**
* Will [sendLiveLocation] with the first [EditLiveLocationInfo] data and update than. Each [liveTimeMillis] passing,
* the message will be sent again and new edits will be applied to the new message
*/
public suspend fun TelegramBot.handleLiveLocation(
chatId: ChatIdentifier,
locationsFlow: Flow<EditLiveLocationInfo>,
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
threadId: MessageThreadId? = chatId.threadId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false,
effectId: EffectId? = null,
replyParameters: ReplyParameters? = null,
sentMessageFlow: FlowCollector<ContentMessage<LiveLocationContent>>? = null
) {
var currentLiveLocationMessage: ContentMessage<LiveLocationContent>? = null
val updateMessageJob = if (liveTimeMillis == indefiniteLivePeriodDelayMillis) { // do not launch refreshing of message for indefinite live locations
null
} else {
val scope = currentCoroutineContext().LinkedSupervisorScope()
scope.launchSafelyWithoutExceptions(start = CoroutineStart.LAZY) {
while (scope.isActive) {
delay(liveTimeMillis)
// Remove previous location message info to resend live location message
currentLiveLocationMessage = null
}
}
}
locationsFlow.collect {
val capturedLiveLocationMessage = currentLiveLocationMessage
if (capturedLiveLocationMessage == null) {
updateMessageJob ?.start()
currentLiveLocationMessage = send(
chatId,
it.latitude,
it.longitude,
if (liveTimeMillis == indefiniteLivePeriodDelayMillis) {
LiveLocation.INDEFINITE_LIVE_PERIOD
} else {
ceil(liveTimeMillis.toDouble() / 1000).toInt()
},
it.horizontalAccuracy,
it.heading,
it.proximityAlertRadius,
threadId,
businessConnectionId,
disableNotification,
protectContent,
allowPaidBroadcast,
effectId,
replyParameters,
it.replyMarkup
).also {
sentMessageFlow ?.emit(it)
}
} else {
edit(
message = capturedLiveLocationMessage,
latitude = it.latitude,
longitude = it.longitude,
horizontalAccuracy = it.horizontalAccuracy,
heading = it.heading,
proximityAlertRadius = it.proximityAlertRadius,
replyMarkup = it.replyMarkup
).also {
sentMessageFlow ?.emit(it)
}
}
}
}
/**
* Will apply [Flow.map] to the [locationsFlow] to create [EditLiveLocationInfo] and pass the result flow to the
* [handleLiveLocation] with [Flow] typed by [EditLiveLocationInfo]
*/
@JvmName("handleLiveLocationWithLocation")
@JsName("handleLiveLocationWithLocation")
public suspend fun TelegramBot.handleLiveLocation(
chatId: ChatIdentifier,
locationsFlow: Flow<Location>,
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
threadId: MessageThreadId? = chatId.threadId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false,
effectId: EffectId? = null,
replyParameters: ReplyParameters? = null,
sentMessageFlow: FlowCollector<ContentMessage<LiveLocationContent>>? = null
) {
handleLiveLocation(
chatId = chatId,
locationsFlow = locationsFlow.map {
EditLiveLocationInfo(
it.latitude,
it.longitude,
it.horizontalAccuracy,
(it as? LiveLocation) ?.heading,
(it as? LiveLocation) ?.proximityAlertRadius,
(it as? WithReplyMarkup) ?.replyMarkup as? InlineKeyboardMarkup
)
},
liveTimeMillis = liveTimeMillis,
threadId = threadId,
businessConnectionId = businessConnectionId,
disableNotification = disableNotification,
protectContent = protectContent,
allowPaidBroadcast = allowPaidBroadcast,
effectId = effectId,
replyParameters = replyParameters,
sentMessageFlow = sentMessageFlow
)
}
/**
* Will apply [Flow.map] to the [locationsFlow] to create [EditLiveLocationInfo] and pass the result flow to the
* [handleLiveLocation] with [Flow] typed by [EditLiveLocationInfo]
*/
@JvmName("handleLiveLocationWithLatLong")
@JsName("handleLiveLocationWithLatLong")
public suspend fun TelegramBot.handleLiveLocation(
chatId: ChatIdentifier,
locationsFlow: Flow<Pair<Double, Double>>,
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
threadId: MessageThreadId? = chatId.threadId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false,
effectId: EffectId? = null,
replyParameters: ReplyParameters? = null,
sentMessageFlow: FlowCollector<ContentMessage<LiveLocationContent>>? = null
) {
handleLiveLocation(
chatId = chatId,
locationsFlow = locationsFlow.map { (lat, long) ->
EditLiveLocationInfo(
lat,
long
)
},
liveTimeMillis = liveTimeMillis,
threadId = threadId,
businessConnectionId = businessConnectionId,
disableNotification = disableNotification,
protectContent = protectContent,
allowPaidBroadcast = allowPaidBroadcast,
effectId = effectId,
replyParameters = replyParameters,
sentMessageFlow = sentMessageFlow
)
}

View File

@@ -1,35 +1,31 @@
package dev.inmo.tgbotapi.extensions.api package dev.inmo.tgbotapi.extensions.api
import korlibs.time.DateTime import com.soywiz.klock.DateTime
import korlibs.time.TimeSpan import com.soywiz.klock.TimeSpan
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation import dev.inmo.tgbotapi.extensions.api.edit.LiveLocation.editLiveLocation
import dev.inmo.tgbotapi.extensions.api.edit.location.live.stopLiveLocation import dev.inmo.tgbotapi.extensions.api.edit.LiveLocation.stopLiveLocation
import dev.inmo.tgbotapi.requests.send.SendLiveLocation import dev.inmo.tgbotapi.requests.send.SendLiveLocation
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.chat.abstracts.Chat
import dev.inmo.tgbotapi.types.location.LiveLocation import dev.inmo.tgbotapi.types.location.LiveLocation
import dev.inmo.tgbotapi.types.location.StaticLocation import dev.inmo.tgbotapi.types.location.StaticLocation
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.types.message.content.LocationContent import dev.inmo.tgbotapi.types.message.content.LocationContent
import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull
import io.ktor.utils.io.core.Closeable import io.ktor.utils.io.core.Closeable
import korlibs.time.millisecondsLong
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlin.math.ceil import kotlin.math.ceil
public const val indefiniteLivePeriodDelayMillis: Long = LiveLocation.INDEFINITE_LIVE_PERIOD * 1000L val defaultLivePeriodDelayMillis = (livePeriodLimit.last - 60L) * 1000L
public const val defaultLivePeriodDelayMillis: Long = indefiniteLivePeriodDelayMillis
/** /**
* @see startLiveLocation * @see startLiveLocation
*/ */
public class LiveLocationProvider internal constructor( class LiveLocationProvider internal constructor(
private val requestsExecutor: TelegramBot, private val requestsExecutor: TelegramBot,
scope: CoroutineScope, scope: CoroutineScope,
autoCloseTimeDelay: Double, autoCloseTimeDelay: Double,
@@ -41,23 +37,22 @@ public class LiveLocationProvider internal constructor(
} }
} }
private val autoCloseTime = DateTime.now() + TimeSpan(autoCloseTimeDelay) private val autoCloseTime = DateTime.now() + TimeSpan(autoCloseTimeDelay)
public val leftUntilCloseMillis: TimeSpan val leftUntilCloseMillis: TimeSpan
get() = autoCloseTime - DateTime.now() get() = autoCloseTime - DateTime.now()
public var isClosed: Boolean = false var isClosed: Boolean = false
private set private set
get() = field || leftUntilCloseMillis.millisecondsLong < 0L get() = field || leftUntilCloseMillis.millisecondsLong < 0L
public var message: ContentMessage<LocationContent> = initMessage private var message: ContentMessage<LocationContent> = initMessage
private set val lastLocation: LiveLocation
public val lastLocation: LiveLocation
get() = message.content.location as LiveLocation get() = message.content.location as LiveLocation
/** /**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that * as a builder for that
*/ */
public suspend fun updateLocation( suspend fun updateLocation(
location: LiveLocation, location: LiveLocation,
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
): LiveLocation { ): LiveLocation {
@@ -65,7 +60,7 @@ public class LiveLocationProvider internal constructor(
message = requestsExecutor.editLiveLocation( message = requestsExecutor.editLiveLocation(
message, message,
location, location,
replyMarkup = replyMarkup replyMarkup
) )
return lastLocation return lastLocation
} else { } else {
@@ -86,7 +81,7 @@ public class LiveLocationProvider internal constructor(
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/ */
public suspend fun TelegramBot.startLiveLocation( suspend fun TelegramBot.startLiveLocation(
scope: CoroutineScope, scope: CoroutineScope,
chatId: ChatIdentifier, chatId: ChatIdentifier,
latitude: Double, latitude: Double,
@@ -95,33 +90,27 @@ public suspend fun TelegramBot.startLiveLocation(
initHorizontalAccuracy: Meters? = null, initHorizontalAccuracy: Meters? = null,
initHeading: Degrees? = null, initHeading: Degrees? = null,
initProximityAlertRadius: Meters? = null, initProximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = chatId.threadId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false, replyToMessageId: MessageIdentifier? = null,
effectId: EffectId? = null, allowSendingWithoutReply: Boolean? = null,
replyParameters: ReplyParameters? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
): LiveLocationProvider { ): LiveLocationProvider {
val liveTimeAsDouble = liveTimeMillis.toDouble() val liveTimeAsDouble = liveTimeMillis.toDouble()
val locationMessage = execute( val locationMessage = execute(
SendLiveLocation( SendLiveLocation(
chatId = chatId, chatId,
latitude = latitude, latitude,
longitude = longitude, longitude,
livePeriod = ceil(liveTimeAsDouble / 1000).toInt(), ceil(liveTimeAsDouble / 1000).toInt(),
horizontalAccuracy = initHorizontalAccuracy, initHorizontalAccuracy,
heading = initHeading, initHeading,
proximityAlertRadius = initProximityAlertRadius, initProximityAlertRadius,
threadId = threadId, disableNotification,
businessConnectionId = businessConnectionId, protectContent,
disableNotification = disableNotification, replyToMessageId,
protectContent = protectContent, allowSendingWithoutReply,
allowPaidBroadcast = allowPaidBroadcast, replyMarkup
effectId = effectId,
replyParameters = replyParameters,
replyMarkup = replyMarkup
) )
) )
@@ -137,7 +126,7 @@ public suspend fun TelegramBot.startLiveLocation(
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/ */
public suspend fun TelegramBot.startLiveLocation( suspend fun TelegramBot.startLiveLocation(
scope: CoroutineScope, scope: CoroutineScope,
chat: Chat, chat: Chat,
latitude: Double, latitude: Double,
@@ -146,77 +135,65 @@ public suspend fun TelegramBot.startLiveLocation(
initHorizontalAccuracy: Meters? = null, initHorizontalAccuracy: Meters? = null,
initHeading: Degrees? = null, initHeading: Degrees? = null,
initProximityAlertRadius: Meters? = null, initProximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = chat.id.threadId,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false, replyToMessageId: MessageIdentifier? = null,
effectId: EffectId? = null, allowSendingWithoutReply: Boolean? = null,
replyParameters: ReplyParameters? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
): LiveLocationProvider = startLiveLocation( ): LiveLocationProvider = startLiveLocation(
scope = scope, scope,
chatId = chat.id, chat.id,
latitude = latitude, latitude,
longitude = longitude, longitude,
liveTimeMillis = liveTimeMillis, liveTimeMillis,
initHorizontalAccuracy = initHorizontalAccuracy, initHorizontalAccuracy,
initHeading = initHeading, initHeading,
initProximityAlertRadius = initProximityAlertRadius, initProximityAlertRadius,
threadId = threadId, disableNotification,
businessConnectionId = businessConnectionId, protectContent,
disableNotification = disableNotification, replyToMessageId,
protectContent = protectContent, allowSendingWithoutReply,
allowPaidBroadcast = allowPaidBroadcast, replyMarkup
effectId = effectId,
replyParameters = replyParameters,
replyMarkup = replyMarkup
) )
/** /**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/ */
public suspend fun TelegramBot.startLiveLocation( suspend fun TelegramBot.startLiveLocation(
scope: CoroutineScope, scope: CoroutineScope,
chatId: IdChatIdentifier, chatId: ChatId,
location: StaticLocation, location: StaticLocation,
liveTimeMillis: Long = defaultLivePeriodDelayMillis, liveTimeMillis: Long = defaultLivePeriodDelayMillis,
initHorizontalAccuracy: Meters? = null, initHorizontalAccuracy: Meters? = null,
initHeading: Degrees? = null, initHeading: Degrees? = null,
initProximityAlertRadius: Meters? = null, initProximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = chatId.threadId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false, replyToMessageId: MessageIdentifier? = null,
effectId: EffectId? = null, allowSendingWithoutReply: Boolean? = null,
replyParameters: ReplyParameters? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
): LiveLocationProvider = startLiveLocation( ): LiveLocationProvider = startLiveLocation(
scope = scope, scope,
chatId = chatId, chatId,
latitude = location.latitude, location.latitude,
longitude = location.longitude, location.longitude,
liveTimeMillis = liveTimeMillis, liveTimeMillis,
initHorizontalAccuracy = initHorizontalAccuracy, initHorizontalAccuracy,
initHeading = initHeading, initHeading,
initProximityAlertRadius = initProximityAlertRadius, initProximityAlertRadius,
threadId = threadId, disableNotification,
businessConnectionId = businessConnectionId, protectContent,
disableNotification = disableNotification, replyToMessageId,
protectContent = protectContent, allowSendingWithoutReply,
allowPaidBroadcast = allowPaidBroadcast, replyMarkup
effectId = effectId,
replyParameters = replyParameters,
replyMarkup = replyMarkup
) )
/** /**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/ */
public suspend fun TelegramBot.startLiveLocation( suspend fun TelegramBot.startLiveLocation(
scope: CoroutineScope, scope: CoroutineScope,
chat: Chat, chat: Chat,
location: StaticLocation, location: StaticLocation,
@@ -224,39 +201,33 @@ public suspend fun TelegramBot.startLiveLocation(
initHorizontalAccuracy: Meters? = null, initHorizontalAccuracy: Meters? = null,
initHeading: Degrees? = null, initHeading: Degrees? = null,
initProximityAlertRadius: Meters? = null, initProximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = chat.id.threadId,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false, replyToMessageId: MessageIdentifier? = null,
effectId: EffectId? = null, allowSendingWithoutReply: Boolean? = null,
replyParameters: ReplyParameters? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
): LiveLocationProvider = startLiveLocation( ): LiveLocationProvider = startLiveLocation(
scope = scope, scope,
chatId = chat.id, chat.id,
latitude = location.latitude, location.latitude,
longitude = location.longitude, location.longitude,
liveTimeMillis = liveTimeMillis, liveTimeMillis,
initHorizontalAccuracy = initHorizontalAccuracy, initHorizontalAccuracy,
initHeading = initHeading, initHeading,
initProximityAlertRadius = initProximityAlertRadius, initProximityAlertRadius,
threadId = threadId, disableNotification,
businessConnectionId = businessConnectionId, protectContent,
disableNotification = disableNotification, replyToMessageId,
protectContent = protectContent, allowSendingWithoutReply,
allowPaidBroadcast = allowPaidBroadcast, replyMarkup
effectId = effectId,
replyParameters = replyParameters,
replyMarkup = replyMarkup
) )
/** /**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/ */
public suspend inline fun TelegramBot.replyWithLiveLocation( suspend inline fun TelegramBot.replyWithLiveLocation(
to: AccessibleMessage, to: Message,
scope: CoroutineScope, scope: CoroutineScope,
latitude: Double, latitude: Double,
longitude: Double, longitude: Double,
@@ -264,67 +235,53 @@ public suspend inline fun TelegramBot.replyWithLiveLocation(
initHorizontalAccuracy: Meters? = null, initHorizontalAccuracy: Meters? = null,
initHeading: Degrees? = null, initHeading: Degrees? = null,
initProximityAlertRadius: Meters? = null, initProximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = to.threadIdOrNull,
businessConnectionId: BusinessConnectionId? = to.businessConnectionId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false,
effectId: EffectId? = null,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
): LiveLocationProvider = startLiveLocation( ) = startLiveLocation(
scope = scope, scope,
chat = to.chat, to.chat,
latitude = latitude, latitude,
longitude = longitude, longitude,
liveTimeMillis = liveTimeMillis, liveTimeMillis,
initHorizontalAccuracy = initHorizontalAccuracy, initHorizontalAccuracy,
initHeading = initHeading, initHeading,
initProximityAlertRadius = initProximityAlertRadius, initProximityAlertRadius,
threadId = threadId, disableNotification,
businessConnectionId = businessConnectionId, protectContent,
disableNotification = disableNotification, to.messageId,
protectContent = protectContent, allowSendingWithoutReply,
allowPaidBroadcast = allowPaidBroadcast, replyMarkup
effectId = effectId,
replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply),
replyMarkup = replyMarkup
) )
/** /**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/ */
public suspend inline fun TelegramBot.replyWithLiveLocation( suspend inline fun TelegramBot.replyWithLiveLocation(
to: AccessibleMessage, to: Message,
scope: CoroutineScope, scope: CoroutineScope,
location: StaticLocation, location: StaticLocation,
liveTimeMillis: Long = defaultLivePeriodDelayMillis, liveTimeMillis: Long = defaultLivePeriodDelayMillis,
initHorizontalAccuracy: Meters? = null, initHorizontalAccuracy: Meters? = null,
initHeading: Degrees? = null, initHeading: Degrees? = null,
initProximityAlertRadius: Meters? = null, initProximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = to.threadIdOrNull,
businessConnectionId: BusinessConnectionId? = to.businessConnectionId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false,
effectId: EffectId? = null,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
): LiveLocationProvider = startLiveLocation( ) = startLiveLocation(
scope = scope, scope,
chat = to.chat, to.chat,
location = location, location,
liveTimeMillis = liveTimeMillis, liveTimeMillis,
initHorizontalAccuracy = initHorizontalAccuracy, initHorizontalAccuracy,
initHeading = initHeading, initHeading,
initProximityAlertRadius = initProximityAlertRadius, initProximityAlertRadius,
threadId = threadId, disableNotification,
businessConnectionId = businessConnectionId, protectContent,
disableNotification = disableNotification, to.messageId,
protectContent = protectContent, allowSendingWithoutReply,
allowPaidBroadcast = allowPaidBroadcast, replyMarkup
effectId = effectId,
replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply),
replyMarkup = replyMarkup
) )

View File

@@ -3,4 +3,4 @@ package dev.inmo.tgbotapi.extensions.api
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.local.LogOut import dev.inmo.tgbotapi.requests.local.LogOut
public suspend inline fun TelegramBot.logOut(): Boolean = execute(LogOut) suspend inline fun TelegramBot.logOut() = execute(LogOut)

View File

@@ -3,54 +3,48 @@ package dev.inmo.tgbotapi.extensions.api
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.StopPoll import dev.inmo.tgbotapi.requests.StopPoll
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.chat.abstracts.Chat
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.types.polls.Poll
/** /**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that * as a builder for that
*/ */
public suspend fun TelegramBot.stopPoll( suspend fun TelegramBot.stopPoll(
chatId: ChatIdentifier, chatId: ChatIdentifier,
messageId: MessageId, messageId: MessageIdentifier,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
): Poll = execute( ) = execute(
StopPoll(chatId, messageId, businessConnectionId, replyMarkup) StopPoll(chatId, messageId, replyMarkup)
) )
/** /**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that * as a builder for that
*/ */
public suspend fun TelegramBot.stopPoll( suspend fun TelegramBot.stopPoll(
chat: Chat, chat: Chat,
messageId: MessageId, messageId: MessageIdentifier,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
): Poll = stopPoll(chat.id, messageId, businessConnectionId, replyMarkup) ) = stopPoll(chat.id, messageId, replyMarkup)
/** /**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that * as a builder for that
*/ */
public suspend fun TelegramBot.stopPoll( suspend fun TelegramBot.stopPoll(
chatId: IdChatIdentifier, chatId: ChatId,
message: AccessibleMessage, message: Message,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
): Poll = stopPoll(chatId, message.messageId, businessConnectionId, replyMarkup) ) = stopPoll(chatId, message.messageId, replyMarkup)
/** /**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that * as a builder for that
*/ */
public suspend fun TelegramBot.stopPoll( suspend fun TelegramBot.stopPoll(
chat: Chat, chat: Chat,
message: AccessibleMessage, message: Message,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
): Poll = stopPoll(chat.id, message.messageId, businessConnectionId, replyMarkup) ) = stopPoll(chat.id, message.messageId, replyMarkup)

View File

@@ -2,29 +2,29 @@ package dev.inmo.tgbotapi.extensions.api.answers
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.answers.AnswerCallbackQuery import dev.inmo.tgbotapi.requests.answers.AnswerCallbackQuery
import dev.inmo.tgbotapi.types.queries.callback.CallbackQuery import dev.inmo.tgbotapi.types.CallbackQuery.CallbackQuery
import dev.inmo.tgbotapi.types.CallbackQueryId import dev.inmo.tgbotapi.types.CallbackQueryIdentifier
public suspend fun TelegramBot.answerCallbackQuery( suspend fun TelegramBot.answerCallbackQuery(
callbackQueryId: CallbackQueryId, callbackQueryId: CallbackQueryIdentifier,
text: String? = null, text: String? = null,
showAlert: Boolean? = null, showAlert: Boolean? = null,
url: String? = null, url: String? = null,
cachedTimeSeconds: Int? = null cachedTimeSeconds: Int? = null
): Boolean = execute(AnswerCallbackQuery(callbackQueryId, text, showAlert, url, cachedTimeSeconds)) ) = execute(AnswerCallbackQuery(callbackQueryId, text, showAlert, url, cachedTimeSeconds))
public suspend fun TelegramBot.answerCallbackQuery( suspend fun TelegramBot.answerCallbackQuery(
callbackQuery: CallbackQuery, callbackQuery: CallbackQuery,
text: String? = null, text: String? = null,
showAlert: Boolean? = null, showAlert: Boolean? = null,
url: String? = null, url: String? = null,
cachedTimeSeconds: Int? = null cachedTimeSeconds: Int? = null
): Boolean = answerCallbackQuery(callbackQuery.id, text, showAlert, url, cachedTimeSeconds) ) = answerCallbackQuery(callbackQuery.id, text, showAlert, url, cachedTimeSeconds)
public suspend fun TelegramBot.answer( suspend fun TelegramBot.answer(
callbackQuery: CallbackQuery, callbackQuery: CallbackQuery,
text: String? = null, text: String? = null,
showAlert: Boolean? = null, showAlert: Boolean? = null,
url: String? = null, url: String? = null,
cachedTimeSeconds: Int? = null cachedTimeSeconds: Int? = null
): Boolean = answerCallbackQuery(callbackQuery.id, text, showAlert, url, cachedTimeSeconds) ) = answerCallbackQuery(callbackQuery.id, text, showAlert, url, cachedTimeSeconds)

View File

@@ -2,68 +2,38 @@ package dev.inmo.tgbotapi.extensions.api.answers
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.answers.AnswerInlineQuery import dev.inmo.tgbotapi.requests.answers.AnswerInlineQuery
import dev.inmo.tgbotapi.requests.answers.InlineQueryResultsButton
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
import dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery import dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery
import dev.inmo.tgbotapi.types.InlineQueryId import dev.inmo.tgbotapi.types.InlineQueryIdentifier
public suspend fun TelegramBot.answerInlineQuery( suspend fun TelegramBot.answerInlineQuery(
inlineQueryID: InlineQueryId, inlineQueryID: InlineQueryIdentifier,
results: List<InlineQueryResult> = emptyList(), results: List<InlineQueryResult> = emptyList(),
cachedTime: Int? = null, cachedTime: Int? = null,
isPersonal: Boolean? = null, isPersonal: Boolean? = null,
nextOffset: String? = null, nextOffset: String? = null,
button: InlineQueryResultsButton? = null switchPmText: String? = null,
): Boolean = execute( switchPmParameter: String? = null
AnswerInlineQuery(inlineQueryID, results, cachedTime, isPersonal, nextOffset, button) ) = execute(
)
public suspend fun TelegramBot.answerInlineQuery(
inlineQuery: InlineQuery,
results: List<InlineQueryResult> = emptyList(),
cachedTime: Int? = null,
isPersonal: Boolean? = null,
nextOffset: String? = null,
button: InlineQueryResultsButton? = null
): Boolean = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, button)
public suspend fun TelegramBot.answer(
inlineQuery: InlineQuery,
results: List<InlineQueryResult> = emptyList(),
cachedTime: Int? = null,
isPersonal: Boolean? = null,
nextOffset: String? = null,
button: InlineQueryResultsButton? = null
): Boolean = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, button)
public suspend fun TelegramBot.answerInlineQuery(
inlineQueryID: InlineQueryId,
results: List<InlineQueryResult> = emptyList(),
cachedTime: Int? = null,
isPersonal: Boolean? = null,
nextOffset: String? = null,
switchPmText: String?,
switchPmParameter: String?
): Boolean = execute(
AnswerInlineQuery(inlineQueryID, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter) AnswerInlineQuery(inlineQueryID, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)
) )
public suspend fun TelegramBot.answerInlineQuery( suspend fun TelegramBot.answerInlineQuery(
inlineQuery: InlineQuery, inlineQuery: InlineQuery,
results: List<InlineQueryResult> = emptyList(), results: List<InlineQueryResult> = emptyList(),
cachedTime: Int? = null, cachedTime: Int? = null,
isPersonal: Boolean? = null, isPersonal: Boolean? = null,
nextOffset: String? = null, nextOffset: String? = null,
switchPmText: String?, switchPmText: String? = null,
switchPmParameter: String? switchPmParameter: String? = null
): Boolean = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter) ) = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)
public suspend fun TelegramBot.answer( suspend fun TelegramBot.answer(
inlineQuery: InlineQuery, inlineQuery: InlineQuery,
results: List<InlineQueryResult> = emptyList(), results: List<InlineQueryResult> = emptyList(),
cachedTime: Int? = null, cachedTime: Int? = null,
isPersonal: Boolean? = null, isPersonal: Boolean? = null,
nextOffset: String? = null, nextOffset: String? = null,
switchPmText: String?, switchPmText: String? = null,
switchPmParameter: String? switchPmParameter: String? = null
): Boolean = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter) ) = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)

View File

@@ -1,17 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.answers
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.answers.AnswerWebAppQuery
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
import dev.inmo.tgbotapi.types.WebAppQueryId
import dev.inmo.tgbotapi.types.webapps.query.SentWebAppMessage
public suspend fun TelegramBot.answerWebAppQuery(
webAppQueryId: WebAppQueryId,
result: InlineQueryResult
): SentWebAppMessage = execute(AnswerWebAppQuery(webAppQueryId, result))
public suspend fun TelegramBot.answer(
webAppQueryId: WebAppQueryId,
result: InlineQueryResult
): SentWebAppMessage = execute(AnswerWebAppQuery(webAppQueryId, result))

View File

@@ -6,18 +6,18 @@ import dev.inmo.tgbotapi.requests.answers.payments.AnswerPreCheckoutQueryOk
import dev.inmo.tgbotapi.types.PreCheckoutQueryId import dev.inmo.tgbotapi.types.PreCheckoutQueryId
import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery
public suspend fun TelegramBot.answerPreCheckoutQueryOk( suspend fun TelegramBot.answerPreCheckoutQueryOk(
id: PreCheckoutQueryId id: PreCheckoutQueryId
): Boolean = execute(AnswerPreCheckoutQueryOk(id)) ) = execute(AnswerPreCheckoutQueryOk(id))
public suspend fun TelegramBot.answerPreCheckoutQueryOk( suspend fun TelegramBot.answerPreCheckoutQueryOk(
preCheckoutQuery: PreCheckoutQuery preCheckoutQuery: PreCheckoutQuery
): Boolean = answerPreCheckoutQueryOk(preCheckoutQuery.id) ) = answerPreCheckoutQueryOk(preCheckoutQuery.id)
public suspend fun TelegramBot.answerPreCheckoutQueryError( suspend fun TelegramBot.answerPreCheckoutQueryError(
id: PreCheckoutQueryId, id: PreCheckoutQueryId,
error: String error: String
): Boolean = execute(AnswerPreCheckoutQueryError(id, error)) ) = execute(AnswerPreCheckoutQueryError(id, error))
public suspend fun TelegramBot.answerPreCheckoutQueryError( suspend fun TelegramBot.answerPreCheckoutQueryError(
preCheckoutQuery: PreCheckoutQuery, preCheckoutQuery: PreCheckoutQuery,
error: String error: String
): Boolean = answerPreCheckoutQueryError(preCheckoutQuery.id, error) ) = answerPreCheckoutQueryError(preCheckoutQuery.id, error)

View File

@@ -3,26 +3,26 @@ package dev.inmo.tgbotapi.extensions.api.answers.payments
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.answers.payments.AnswerShippingQueryError import dev.inmo.tgbotapi.requests.answers.payments.AnswerShippingQueryError
import dev.inmo.tgbotapi.requests.answers.payments.AnswerShippingQueryOk import dev.inmo.tgbotapi.requests.answers.payments.AnswerShippingQueryOk
import dev.inmo.tgbotapi.types.ShippingQueryId import dev.inmo.tgbotapi.types.ShippingQueryIdentifier
import dev.inmo.tgbotapi.types.payments.ShippingOption import dev.inmo.tgbotapi.types.payments.ShippingOption
import dev.inmo.tgbotapi.types.payments.ShippingQuery import dev.inmo.tgbotapi.types.payments.ShippingQuery
public suspend fun TelegramBot.answerShippingQueryOk( suspend fun TelegramBot.answerShippingQueryOk(
id: ShippingQueryId, id: ShippingQueryIdentifier,
shippingOptions: List<ShippingOption> shippingOptions: List<ShippingOption>
): Boolean = execute(AnswerShippingQueryOk(id, shippingOptions)) ) = execute(AnswerShippingQueryOk(id, shippingOptions))
public suspend fun TelegramBot.answerShippingQueryOk( suspend fun TelegramBot.answerShippingQueryOk(
shippingQuery: ShippingQuery, shippingQuery: ShippingQuery,
shippingOptions: List<ShippingOption> shippingOptions: List<ShippingOption>
): Boolean = answerShippingQueryOk(shippingQuery.id, shippingOptions) ) = answerShippingQueryOk(shippingQuery.id, shippingOptions)
public suspend fun TelegramBot.answerShippingQueryError( suspend fun TelegramBot.answerShippingQueryError(
id: ShippingQueryId, id: ShippingQueryIdentifier,
error: String error: String
): Boolean = execute(AnswerShippingQueryError(id, error)) ) = execute(AnswerShippingQueryError(id, error))
public suspend fun TelegramBot.answerShippingQueryError( suspend fun TelegramBot.answerShippingQueryError(
shippingQuery: ShippingQuery, shippingQuery: ShippingQuery,
error: String error: String
): Boolean = answerShippingQueryError(shippingQuery.id, error) ) = answerShippingQueryError(shippingQuery.id, error)

View File

@@ -1,12 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.bot
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.bot.ClearMyDefaultAdministratorRights
public suspend fun TelegramBot.clearMyDefaultAdministratorRights(
forChannels: Boolean? = null
): Boolean = execute(ClearMyDefaultAdministratorRights(forChannels))
public suspend fun TelegramBot.clearMyDefaultAdministratorRightsForChannels(): Boolean = clearMyDefaultAdministratorRights(forChannels = true)
public suspend fun TelegramBot.clearMyDefaultAdministratorRightsForGroupsAndSupergroups(): Boolean = clearMyDefaultAdministratorRights(forChannels = false)

View File

@@ -1,17 +1,17 @@
package dev.inmo.tgbotapi.extensions.api.bot package dev.inmo.tgbotapi.extensions.api.bot
import dev.inmo.micro_utils.language_codes.IetfLang import dev.inmo.micro_utils.language_codes.IetfLanguageCode
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.bot.DeleteMyCommands import dev.inmo.tgbotapi.requests.bot.DeleteMyCommands
import dev.inmo.tgbotapi.types.commands.BotCommandScope import dev.inmo.tgbotapi.types.commands.BotCommandScope
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
public suspend fun TelegramBot.deleteMyCommands( suspend fun TelegramBot.deleteMyCommands(
scope: BotCommandScope = BotCommandScopeDefault, scope: BotCommandScope = BotCommandScopeDefault,
languageCode: IetfLang? languageCode: IetfLanguageCode?
): Boolean = execute(DeleteMyCommands(scope, languageCode)) ) = execute(DeleteMyCommands(scope, languageCode))
public suspend fun TelegramBot.deleteMyCommands( suspend fun TelegramBot.deleteMyCommands(
scope: BotCommandScope = BotCommandScopeDefault, scope: BotCommandScope = BotCommandScopeDefault,
languageCode: String? = null languageCode: String? = null
): Boolean = deleteMyCommands(scope, languageCode ?.let(::IetfLang)) ) = deleteMyCommands(scope, languageCode ?.let(::IetfLanguageCode))

View File

@@ -2,6 +2,5 @@ package dev.inmo.tgbotapi.extensions.api.bot
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.bot.GetMe import dev.inmo.tgbotapi.requests.bot.GetMe
import dev.inmo.tgbotapi.types.chat.ExtendedBot
public suspend fun TelegramBot.getMe(): ExtendedBot = execute(GetMe) suspend fun TelegramBot.getMe() = execute(GetMe)

View File

@@ -1,18 +1,17 @@
package dev.inmo.tgbotapi.extensions.api.bot package dev.inmo.tgbotapi.extensions.api.bot
import dev.inmo.micro_utils.language_codes.IetfLang import dev.inmo.micro_utils.language_codes.IetfLanguageCode
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.bot.GetMyCommands import dev.inmo.tgbotapi.requests.bot.GetMyCommands
import dev.inmo.tgbotapi.types.BotCommand
import dev.inmo.tgbotapi.types.commands.BotCommandScope import dev.inmo.tgbotapi.types.commands.BotCommandScope
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
public suspend fun TelegramBot.getMyCommands( suspend fun TelegramBot.getMyCommands(
scope: BotCommandScope = BotCommandScopeDefault, scope: BotCommandScope = BotCommandScopeDefault,
languageCode: IetfLang? = null languageCode: IetfLanguageCode? = null
): List<BotCommand> = execute(GetMyCommands(scope, languageCode)) ) = execute(GetMyCommands(scope, languageCode))
public suspend fun TelegramBot.getMyCommands( suspend fun TelegramBot.getMyCommands(
scope: BotCommandScope = BotCommandScopeDefault, scope: BotCommandScope = BotCommandScopeDefault,
languageCode: String? languageCode: String?
): List<BotCommand> = getMyCommands(scope, languageCode ?.let(::IetfLang)) ) = getMyCommands(scope, languageCode ?.let(::IetfLanguageCode))

View File

@@ -1,13 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.bot
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.bot.GetMyDefaultAdministratorRights
import dev.inmo.tgbotapi.types.chat.member.AdministratorChatMember
public suspend fun TelegramBot.getMyDefaultAdministratorRights(
forChannels: Boolean? = null
): AdministratorChatMember = execute(GetMyDefaultAdministratorRights(forChannels))
public suspend fun TelegramBot.getMyDefaultAdministratorRightsForChannels(): AdministratorChatMember = getMyDefaultAdministratorRights(forChannels = true)
public suspend fun TelegramBot.getMyDefaultAdministratorRightsForGroupsAndSupergroups(): AdministratorChatMember = getMyDefaultAdministratorRights(forChannels = false)

View File

@@ -1,14 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.bot
import dev.inmo.micro_utils.language_codes.IetfLang
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.bot.GetMyDescription
import dev.inmo.tgbotapi.types.BotDescription
public suspend fun TelegramBot.getMyDescription(
languageCode: IetfLang? = null
): BotDescription = execute(GetMyDescription(languageCode))
public suspend fun TelegramBot.getMyDescription(
languageCode: String?
): BotDescription = getMyDescription(languageCode ?.let(::IetfLang))

View File

@@ -1,14 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.bot
import dev.inmo.micro_utils.language_codes.IetfLang
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.bot.GetMyName
import dev.inmo.tgbotapi.types.BotName
public suspend fun TelegramBot.getMyName(
languageCode: IetfLang? = null
): BotName = execute(GetMyName(languageCode))
public suspend fun TelegramBot.getMyName(
languageCode: String?
): BotName = getMyName(languageCode ?.let(::IetfLang))

View File

@@ -1,17 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.bot
import dev.inmo.micro_utils.language_codes.IetfLang
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
import dev.inmo.tgbotapi.requests.bot.GetMyShortDescription
import dev.inmo.tgbotapi.types.BotShortDescription
import dev.inmo.tgbotapi.types.commands.BotCommandScope
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
public suspend fun TelegramBot.getMyShortDescription(
languageCode: IetfLang? = null
): BotShortDescription = execute(GetMyShortDescription(languageCode))
public suspend fun TelegramBot.getMyShortDescription(
languageCode: String?
): BotShortDescription = getMyShortDescription(languageCode ?.let(::IetfLang))

View File

@@ -1,32 +1,32 @@
package dev.inmo.tgbotapi.extensions.api.bot package dev.inmo.tgbotapi.extensions.api.bot
import dev.inmo.micro_utils.language_codes.IetfLang import dev.inmo.micro_utils.language_codes.IetfLanguageCode
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.bot.SetMyCommands import dev.inmo.tgbotapi.requests.bot.SetMyCommands
import dev.inmo.tgbotapi.types.BotCommand import dev.inmo.tgbotapi.types.BotCommand
import dev.inmo.tgbotapi.types.commands.BotCommandScope import dev.inmo.tgbotapi.types.commands.BotCommandScope
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
public suspend fun TelegramBot.setMyCommands( suspend fun TelegramBot.setMyCommands(
commands: List<BotCommand>, commands: List<BotCommand>,
scope: BotCommandScope = BotCommandScopeDefault, scope: BotCommandScope = BotCommandScopeDefault,
languageCode: IetfLang? languageCode: IetfLanguageCode?
): Boolean = execute(SetMyCommands(commands, scope, languageCode)) ) = execute(SetMyCommands(commands, scope, languageCode))
public suspend fun TelegramBot.setMyCommands( suspend fun TelegramBot.setMyCommands(
vararg commands: BotCommand, vararg commands: BotCommand,
scope: BotCommandScope = BotCommandScopeDefault, scope: BotCommandScope = BotCommandScopeDefault,
languageCode: IetfLang? languageCode: IetfLanguageCode?
): Boolean = setMyCommands(commands.toList(), scope, languageCode) ) = setMyCommands(commands.toList(), scope, languageCode)
public suspend fun TelegramBot.setMyCommands( suspend fun TelegramBot.setMyCommands(
commands: List<BotCommand>, commands: List<BotCommand>,
scope: BotCommandScope = BotCommandScopeDefault, scope: BotCommandScope = BotCommandScopeDefault,
languageCode: String? = null languageCode: String? = null
): Boolean = setMyCommands(commands, scope, languageCode ?.let(::IetfLang)) ) = setMyCommands(commands, scope, languageCode ?.let(::IetfLanguageCode))
public suspend fun TelegramBot.setMyCommands( suspend fun TelegramBot.setMyCommands(
vararg commands: BotCommand, vararg commands: BotCommand,
scope: BotCommandScope = BotCommandScopeDefault, scope: BotCommandScope = BotCommandScopeDefault,
languageCode: String? = null languageCode: String? = null
): Boolean = setMyCommands(commands.toList(), scope, languageCode) ) = setMyCommands(commands.toList(), scope, languageCode)

View File

@@ -1,18 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.bot
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.bot.SetMyDefaultAdministratorRights
import dev.inmo.tgbotapi.types.chat.member.ChatCommonAdministratorRights
public suspend fun TelegramBot.setMyDefaultAdministratorRights(
rights: ChatCommonAdministratorRights,
forChannels: Boolean? = null
): Boolean = execute(SetMyDefaultAdministratorRights(rights, forChannels))
public suspend fun TelegramBot.setMyDefaultAdministratorRightsForChannels(
rights: ChatCommonAdministratorRights
): Boolean = setMyDefaultAdministratorRights(rights, forChannels = true)
public suspend fun TelegramBot.setMyDefaultAdministratorRightsForGroupsAndSupergroups(
rights: ChatCommonAdministratorRights
): Boolean = setMyDefaultAdministratorRights(rights, forChannels = false)

View File

@@ -1,19 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.bot
import dev.inmo.micro_utils.language_codes.IetfLang
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
import dev.inmo.tgbotapi.requests.bot.GetMyDescription
import dev.inmo.tgbotapi.requests.bot.SetMyDescription
import dev.inmo.tgbotapi.types.commands.BotCommandScope
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
public suspend fun TelegramBot.setMyDescription(
description: String? = null,
languageCode: IetfLang? = null
): Boolean = execute(SetMyDescription(description, languageCode))
public suspend fun TelegramBot.setMyDescription(
description: String?,
languageCode: String?
): Boolean = setMyDescription(description, languageCode ?.let(::IetfLang))

View File

@@ -1,19 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.bot
import dev.inmo.micro_utils.language_codes.IetfLang
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
import dev.inmo.tgbotapi.requests.bot.GetMyName
import dev.inmo.tgbotapi.requests.bot.SetMyName
import dev.inmo.tgbotapi.types.commands.BotCommandScope
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
public suspend fun TelegramBot.setMyName(
name: String? = null,
languageCode: IetfLang? = null
): Boolean = execute(SetMyName(name, languageCode))
public suspend fun TelegramBot.setMyName(
name: String?,
languageCode: String?
): Boolean = setMyName(name, languageCode ?.let(::IetfLang))

View File

@@ -1,15 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.bot
import dev.inmo.micro_utils.language_codes.IetfLang
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.bot.SetMyShortDescription
public suspend fun TelegramBot.setMyShortDescription(
shortDescription: String? = null,
languageCode: IetfLang? = null
): Boolean = execute(SetMyShortDescription(shortDescription, languageCode))
public suspend fun TelegramBot.setMyShortDescription(
shortDescription: String?,
languageCode: String?
): Boolean = setMyShortDescription(shortDescription, languageCode ?.let(::IetfLang))

View File

@@ -3,12 +3,12 @@ package dev.inmo.tgbotapi.extensions.api.chat
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.ExportChatInviteLink import dev.inmo.tgbotapi.requests.chat.ExportChatInviteLink
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.PublicChat import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
public suspend fun TelegramBot.exportChatInviteLink( suspend fun TelegramBot.exportChatInviteLink(
chatId: ChatIdentifier chatId: ChatIdentifier
): String = execute(ExportChatInviteLink(chatId)) ) = execute(ExportChatInviteLink(chatId))
public suspend fun TelegramBot.exportChatInviteLink( suspend fun TelegramBot.exportChatInviteLink(
chat: PublicChat chat: PublicChat
): String = exportChatInviteLink(chat.id) ) = exportChatInviteLink(chat.id)

View File

@@ -3,12 +3,12 @@ package dev.inmo.tgbotapi.extensions.api.chat
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.LeaveChat import dev.inmo.tgbotapi.requests.chat.LeaveChat
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.PublicChat import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
public suspend fun TelegramBot.leaveChat( suspend fun TelegramBot.leaveChat(
chatId: ChatIdentifier chatId: ChatIdentifier
): Boolean = execute(LeaveChat(chatId)) ) = execute(LeaveChat(chatId))
public suspend fun TelegramBot.leaveChat( suspend fun TelegramBot.leaveChat(
chat: PublicChat chat: PublicChat
): Boolean = leaveChat(chat.id) ) = leaveChat(chat.id)

View File

@@ -1,28 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.forum
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.forum.CloseForumTopic
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.closeForumTopic(
chatId: ChatIdentifier,
messageThreadId: MessageThreadId
): Boolean = execute(
CloseForumTopic(
chatId,
messageThreadId
)
)
public suspend fun TelegramBot.closeForumTopic(
chat: Chat,
messageThreadId: MessageThreadId
): Boolean = closeForumTopic(chat.id, messageThreadId)
public suspend fun TelegramBot.closeForumTopic(
chat: Chat,
forumTopic: ForumTopic
): Boolean = closeForumTopic(chat.id, forumTopic.messageThreadId)

View File

@@ -1,19 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.forum
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.forum.CloseForumTopic
import dev.inmo.tgbotapi.requests.chat.forum.CloseGeneralForumTopic
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.closeGeneralForumTopic(
chatId: ChatIdentifier
): Boolean = execute(
CloseGeneralForumTopic(chatId)
)
public suspend fun TelegramBot.closeGeneralForumTopic(
chat: Chat
): Boolean = closeGeneralForumTopic(chat.id)

View File

@@ -1,30 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.forum
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.forum.CreateForumTopic
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.CustomEmojiId
import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.utils.RGBColor
public suspend fun TelegramBot.createForumTopic(
chatId: ChatIdentifier,
name: String,
color: RGBColor,
iconEmojiId: CustomEmojiId? = null
): ForumTopic = execute(
CreateForumTopic(
chatId,
name,
color,
iconEmojiId
)
)
public suspend fun TelegramBot.createForumTopic(
chat: Chat,
name: String,
color: RGBColor,
iconEmojiId: CustomEmojiId? = null
): ForumTopic = createForumTopic(chat.id, name, color, iconEmojiId)

View File

@@ -1,33 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.forum
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.forum.DeleteForumTopic
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.deleteForumTopic(
chatId: ChatIdentifier,
messageThreadId: MessageThreadId
): Boolean = execute(
DeleteForumTopic(
chatId,
messageThreadId
)
)
public suspend fun TelegramBot.deleteForumTopic(
chatId: ChatIdentifier,
forumTopic: ForumTopic
): Boolean = deleteForumTopic(chatId, forumTopic.messageThreadId)
public suspend fun TelegramBot.deleteForumTopic(
chat: Chat,
messageThreadId: MessageThreadId
): Boolean = deleteForumTopic(chat.id, messageThreadId)
public suspend fun TelegramBot.deleteForumTopic(
chat: Chat,
forumTopic: ForumTopic
): Boolean = deleteForumTopic(chat.id, forumTopic.messageThreadId)

View File

@@ -1,36 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.forum
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.forum.EditForumTopic
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.CustomEmojiId
import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.editForumTopic(
chatId: ChatIdentifier,
messageThreadId: MessageThreadId,
name: String? = null,
iconEmojiId: CustomEmojiId? = null
): Boolean = execute(
EditForumTopic(
chatId,
messageThreadId,
name,
iconEmojiId
)
)
public suspend fun TelegramBot.editForumTopic(
chat: Chat,
messageThreadId: MessageThreadId,
name: String? = null,
iconEmojiId: CustomEmojiId? = null
): Boolean = editForumTopic(chat.id, messageThreadId, name, iconEmojiId)
public suspend fun TelegramBot.editForumTopic(
chatIdentifier: ChatIdentifier,
forumTopic: ForumTopic,
iconEmojiId: CustomEmojiId? = forumTopic.iconEmojiId
): Boolean = editForumTopic(chatIdentifier, forumTopic.messageThreadId, forumTopic.name, iconEmojiId)

View File

@@ -1,30 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.forum
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.forum.EditForumTopic
import dev.inmo.tgbotapi.requests.chat.forum.EditGeneralForumTopic
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.CustomEmojiId
import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.editGeneralForumTopic(
chatId: ChatIdentifier,
name: String
): Boolean = execute(
EditGeneralForumTopic(
chatId,
name
)
)
public suspend fun TelegramBot.editGeneralForumTopic(
chat: Chat,
name: String
): Boolean = editGeneralForumTopic(chat.id, name)
public suspend fun TelegramBot.editGeneralForumTopic(
chatIdentifier: ChatIdentifier,
forumTopic: ForumTopic,
): Boolean = editGeneralForumTopic(chatIdentifier, forumTopic.name)

View File

@@ -1,20 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.forum
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.forum.CloseForumTopic
import dev.inmo.tgbotapi.requests.chat.forum.CloseGeneralForumTopic
import dev.inmo.tgbotapi.requests.chat.forum.HideGeneralForumTopic
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.hideGeneralForumTopic(
chatId: ChatIdentifier
): Boolean = execute(
HideGeneralForumTopic(chatId)
)
public suspend fun TelegramBot.hideGeneralForumTopic(
chat: Chat
): Boolean = hideGeneralForumTopic(chat.id)

View File

@@ -1,28 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.forum
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.forum.ReopenForumTopic
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.reopenForumTopic(
chatId: ChatIdentifier,
messageThreadId: MessageThreadId
): Boolean = execute(
ReopenForumTopic(
chatId,
messageThreadId
)
)
public suspend fun TelegramBot.reopenForumTopic(
chat: Chat,
messageThreadId: MessageThreadId
): Boolean = reopenForumTopic(chat.id, messageThreadId)
public suspend fun TelegramBot.reopenForumTopic(
chat: Chat,
forumTopic: ForumTopic
): Boolean = reopenForumTopic(chat.id, forumTopic.messageThreadId)

View File

@@ -1,19 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.forum
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.forum.ReopenForumTopic
import dev.inmo.tgbotapi.requests.chat.forum.ReopenGeneralForumTopic
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.reopenGeneralForumTopic(
chatId: ChatIdentifier
): Boolean = execute(
ReopenGeneralForumTopic(chatId)
)
public suspend fun TelegramBot.reopenGeneralForumTopic(
chat: Chat
): Boolean = reopenGeneralForumTopic(chat.id)

View File

@@ -1,21 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.forum
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.forum.CloseForumTopic
import dev.inmo.tgbotapi.requests.chat.forum.CloseGeneralForumTopic
import dev.inmo.tgbotapi.requests.chat.forum.HideGeneralForumTopic
import dev.inmo.tgbotapi.requests.chat.forum.UnhideGeneralForumTopic
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.unhideGeneralForumTopic(
chatId: ChatIdentifier
): Boolean = execute(
UnhideGeneralForumTopic(chatId)
)
public suspend fun TelegramBot.unhideGeneralForumTopic(
chat: Chat
): Boolean = unhideGeneralForumTopic(chat.id)

View File

@@ -1,28 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.forum
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.forum.UnpinAllForumTopicMessages
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.unpinAllForumTopicMessages(
chatId: ChatIdentifier,
messageThreadId: MessageThreadId
): Boolean = execute(
UnpinAllForumTopicMessages(
chatId,
messageThreadId
)
)
public suspend fun TelegramBot.unpinAllForumTopicMessages(
chat: Chat,
messageThreadId: MessageThreadId
): Boolean = unpinAllForumTopicMessages(chat.id, messageThreadId)
public suspend fun TelegramBot.unpinAllForumTopicMessages(
chat: Chat,
forumTopic: ForumTopic
): Boolean = unpinAllForumTopicMessages(chat.id, forumTopic.messageThreadId)

View File

@@ -1,21 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.forum
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.forum.UnpinAllForumTopicMessages
import dev.inmo.tgbotapi.requests.chat.forum.UnpinAllGeneralForumTopicMessages
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.unpinAllGeneralForumTopicMessages(
chatId: ChatIdentifier
): Boolean = execute(
UnpinAllGeneralForumTopicMessages(
chatId
)
)
public suspend fun TelegramBot.unpinAllGeneralForumTopicMessages(
chat: Chat
): Boolean = unpinAllGeneralForumTopicMessages(chat.id)

View File

@@ -2,128 +2,131 @@ package dev.inmo.tgbotapi.extensions.api.chat.get
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.get.GetChat import dev.inmo.tgbotapi.requests.chat.get.GetChat
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.chat.* import dev.inmo.tgbotapi.types.chat.*
import dev.inmo.tgbotapi.types.chat.abstracts.*
import dev.inmo.tgbotapi.types.chat.abstracts.extended.*
import dev.inmo.tgbotapi.types.chat.extended.*
import dev.inmo.tgbotapi.utils.PreviewFeature import dev.inmo.tgbotapi.utils.PreviewFeature
public suspend fun TelegramBot.getChat( suspend fun TelegramBot.getChat(
chatId: ChatIdentifier chatId: ChatIdentifier
): ExtendedChat = execute(GetChat(chatId)) ) = execute(GetChat(chatId))
public suspend fun TelegramBot.getChat( suspend fun TelegramBot.getChat(
chat: Chat chat: Chat
): ExtendedChat = getChat(chat.id) ) = getChat(chat.id)
/** /**
* Will cast incoming [dev.inmo.tgbotapi.types.chat.ExtendedChat] to a * Will cast incoming [dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat] to a
* [ExtendedPublicChat] with unsafe operator "as" * [ExtendedPublicChat] with unsafe operator "as"
* *
* @throws ClassCastException * @throws ClassCastException
*/ */
@PreviewFeature @PreviewFeature
public suspend fun TelegramBot.getChat( suspend fun TelegramBot.getChat(
chat: PublicChat chat: PublicChat
): ExtendedPublicChat = getChat(chat.id) as ExtendedPublicChat ) = getChat(chat.id) as ExtendedPublicChat
/** /**
* Will cast incoming [dev.inmo.tgbotapi.types.chat.ExtendedChat] to a * Will cast incoming [dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat] to a
* [ExtendedChannelChat] with unsafe operator "as" * [ExtendedChannelChat] with unsafe operator "as"
* *
* @throws ClassCastException * @throws ClassCastException
*/ */
@PreviewFeature @PreviewFeature
public suspend fun TelegramBot.getChat( suspend fun TelegramBot.getChat(
chat: ChannelChat chat: ChannelChat
): ExtendedChannelChat = getChat(chat.id) as ExtendedChannelChat ) = getChat(chat.id) as ExtendedChannelChat
/** /**
* Will cast incoming [dev.inmo.tgbotapi.types.chat.ExtendedChat] to a * Will cast incoming [dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat] to a
* [ExtendedChannelChatImpl] with unsafe operator "as" * [ExtendedChannelChatImpl] with unsafe operator "as"
* *
* @throws ClassCastException * @throws ClassCastException
*/ */
@PreviewFeature @PreviewFeature
public suspend fun TelegramBot.getChat( suspend fun TelegramBot.getChat(
chat: ChannelChatImpl chat: ChannelChatImpl
): ExtendedChannelChatImpl = getChat(chat.id) as ExtendedChannelChatImpl ) = getChat(chat.id) as ExtendedChannelChatImpl
/** /**
* Will cast incoming [dev.inmo.tgbotapi.types.chat.ExtendedChat] to a * Will cast incoming [dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat] to a
* [ExtendedGroupChat] with unsafe operator "as" * [ExtendedGroupChat] with unsafe operator "as"
* *
* @throws ClassCastException * @throws ClassCastException
*/ */
@PreviewFeature @PreviewFeature
public suspend fun TelegramBot.getChat( suspend fun TelegramBot.getChat(
chat: GroupChat chat: GroupChat
): ExtendedGroupChat = getChat(chat.id) as ExtendedGroupChat ) = getChat(chat.id) as ExtendedGroupChat
/** /**
* Will cast incoming [dev.inmo.tgbotapi.types.chat.ExtendedChat] to a * Will cast incoming [dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat] to a
* [ExtendedGroupChatImpl] with unsafe operator "as" * [ExtendedGroupChatImpl] with unsafe operator "as"
* *
* @throws ClassCastException * @throws ClassCastException
*/ */
@PreviewFeature @PreviewFeature
public suspend fun TelegramBot.getChat( suspend fun TelegramBot.getChat(
chat: GroupChatImpl chat: GroupChatImpl
): ExtendedGroupChatImpl = getChat(chat.id) as ExtendedGroupChatImpl ) = getChat(chat.id) as ExtendedGroupChatImpl
/** /**
* Will cast incoming [dev.inmo.tgbotapi.types.chat.ExtendedChat] to a * Will cast incoming [dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat] to a
* [ExtendedSupergroupChat] with unsafe operator "as" * [ExtendedSupergroupChat] with unsafe operator "as"
* *
* @throws ClassCastException * @throws ClassCastException
*/ */
@PreviewFeature @PreviewFeature
public suspend fun TelegramBot.getChat( suspend fun TelegramBot.getChat(
chat: SupergroupChat chat: SupergroupChat
): ExtendedSupergroupChat = getChat(chat.id) as ExtendedSupergroupChat ) = getChat(chat.id) as ExtendedSupergroupChat
/** /**
* Will cast incoming [dev.inmo.tgbotapi.types.chat.ExtendedChat] to a * Will cast incoming [dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat] to a
* [ExtendedSupergroupChatImpl] with unsafe operator "as" * [ExtendedSupergroupChatImpl] with unsafe operator "as"
* *
* @throws ClassCastException * @throws ClassCastException
*/ */
@PreviewFeature @PreviewFeature
public suspend fun TelegramBot.getChat( suspend fun TelegramBot.getChat(
chat: SupergroupChatImpl chat: SupergroupChatImpl
): ExtendedSupergroupChatImpl = getChat(chat.id) as ExtendedSupergroupChatImpl ) = getChat(chat.id) as ExtendedSupergroupChatImpl
/** /**
* Will cast incoming [dev.inmo.tgbotapi.types.chat.ExtendedChat] to a * Will cast incoming [dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat] to a
* [ExtendedPrivateChat] with unsafe operator "as" * [ExtendedPrivateChat] with unsafe operator "as"
* *
* @throws ClassCastException * @throws ClassCastException
*/ */
@PreviewFeature @PreviewFeature
public suspend fun TelegramBot.getChat( suspend fun TelegramBot.getChat(
chat: PrivateChat chat: PrivateChat
): ExtendedPrivateChat = getChat(chat.id) as ExtendedPrivateChat ) = getChat(chat.id) as ExtendedPrivateChat
/** /**
* Will cast incoming [dev.inmo.tgbotapi.types.chat.ExtendedChat] to a * Will cast incoming [dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat] to a
* [ExtendedPrivateChatImpl] with unsafe operator "as" * [ExtendedPrivateChatImpl] with unsafe operator "as"
* *
* @throws ClassCastException * @throws ClassCastException
*/ */
@PreviewFeature @PreviewFeature
public suspend fun TelegramBot.getChat( suspend fun TelegramBot.getChat(
chat: PrivateChatImpl chat: PrivateChatImpl
): ExtendedPrivateChatImpl = getChat(chat.id) as ExtendedPrivateChatImpl ) = getChat(chat.id) as ExtendedPrivateChatImpl
/** /**
* Will cast incoming [dev.inmo.tgbotapi.types.chat.ExtendedChat] to a * Will cast incoming [dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat] to a
* [ExtendedUser] with unsafe operator "as" * [ExtendedUser] with unsafe operator "as"
* *
* @throws ClassCastException * @throws ClassCastException
*/ */
@PreviewFeature @PreviewFeature
public suspend fun TelegramBot.getChat( suspend fun TelegramBot.getChat(
chat: CommonUser chat: CommonUser
): ExtendedUser = getChat(chat.id) as ExtendedUser ) = getChat(chat.id) as ExtendedUser

View File

@@ -3,13 +3,12 @@ package dev.inmo.tgbotapi.extensions.api.chat.get
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.get.GetChatAdministrators import dev.inmo.tgbotapi.requests.chat.get.GetChatAdministrators
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.PublicChat import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
import dev.inmo.tgbotapi.types.chat.member.AdministratorChatMember
public suspend fun TelegramBot.getChatAdministrators( suspend fun TelegramBot.getChatAdministrators(
chatId: ChatIdentifier chatId: ChatIdentifier
): List<AdministratorChatMember> = execute(GetChatAdministrators(chatId)) ) = execute(GetChatAdministrators(chatId))
public suspend fun TelegramBot.getChatAdministrators( suspend fun TelegramBot.getChatAdministrators(
chat: PublicChat chat: PublicChat
): List<AdministratorChatMember> = getChatAdministrators(chat.id) ) = getChatAdministrators(chat.id)

View File

@@ -3,12 +3,12 @@ package dev.inmo.tgbotapi.extensions.api.chat.get
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.get.GetChatMemberCount import dev.inmo.tgbotapi.requests.chat.get.GetChatMemberCount
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.PublicChat import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
public suspend fun TelegramBot.getChatMemberCount( suspend fun TelegramBot.getChatMemberCount(
chatId: ChatIdentifier chatId: ChatIdentifier
): Int = execute(GetChatMemberCount(chatId)) ) = execute(GetChatMemberCount(chatId))
public suspend fun TelegramBot.getChatMemberCount( suspend fun TelegramBot.getChatMemberCount(
chat: PublicChat chat: PublicChat
): Int = getChatMemberCount(chat.id) ) = getChatMemberCount(chat.id)

View File

@@ -1,15 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.get
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.get.GetChatMenuButton
import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.MenuButton
import dev.inmo.tgbotapi.types.chat.PrivateChat
public suspend fun TelegramBot.getChatMenuButton(
chatId: IdChatIdentifier
): MenuButton = execute(GetChatMenuButton(chatId))
public suspend fun TelegramBot.getChatMenuButton(
chat: PrivateChat
): MenuButton = getChatMenuButton(chat.id)

View File

@@ -1,7 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.get
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.get.GetDefaultChatMenuButton
import dev.inmo.tgbotapi.types.MenuButton
public suspend fun TelegramBot.getDefaultChatMenuButton(): MenuButton = execute(GetDefaultChatMenuButton)

View File

@@ -1,7 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.get
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.get.GetForumTopicIconStickers
import dev.inmo.tgbotapi.types.files.Sticker
public suspend fun TelegramBot.getForumTopicIconStickers(): List<Sticker> = execute(GetForumTopicIconStickers)

View File

@@ -2,41 +2,38 @@ package dev.inmo.tgbotapi.extensions.api.chat.invite_links
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.invite_links.ApproveChatJoinRequest import dev.inmo.tgbotapi.requests.chat.invite_links.ApproveChatJoinRequest
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.UserId import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
import dev.inmo.tgbotapi.types.chat.ChatJoinRequest
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.User
import dev.inmo.tgbotapi.types.update.ChatJoinRequestUpdate import dev.inmo.tgbotapi.types.update.ChatJoinRequestUpdate
public suspend fun TelegramBot.approveChatJoinRequest( suspend fun TelegramBot.approveChatJoinRequest(
chatId: ChatIdentifier, chatId: ChatIdentifier,
userId: UserId userId: UserId
): Boolean = execute(ApproveChatJoinRequest(chatId, userId)) ) = execute(ApproveChatJoinRequest(chatId, userId))
public suspend fun TelegramBot.approveChatJoinRequest( suspend fun TelegramBot.approveChatJoinRequest(
chat: PublicChat, chat: PublicChat,
userId: UserId userId: UserId
): Boolean = approveChatJoinRequest(chat.id, userId) ) = approveChatJoinRequest(chat.id, userId)
public suspend fun TelegramBot.approveChatJoinRequest( suspend fun TelegramBot.approveChatJoinRequest(
chatId: ChatIdentifier, chatId: ChatIdentifier,
user: User user: User
): Boolean = approveChatJoinRequest(chatId, user.id) ) = approveChatJoinRequest(chatId, user.id)
public suspend fun TelegramBot.approveChatJoinRequest( suspend fun TelegramBot.approveChatJoinRequest(
chat: PublicChat, chat: PublicChat,
user: User user: User
): Boolean = approveChatJoinRequest(chat.id, user.id) ) = approveChatJoinRequest(chat.id, user.id)
public suspend fun TelegramBot.approveChatJoinRequest( suspend fun TelegramBot.approveChatJoinRequest(
chatJoinRequest: ChatJoinRequest chatJoinRequest: ChatJoinRequest
): Boolean = approveChatJoinRequest(chatJoinRequest.chat, chatJoinRequest.user) ) = approveChatJoinRequest(chatJoinRequest.chat, chatJoinRequest.user)
public suspend fun TelegramBot.approve( suspend fun TelegramBot.approve(
chatJoinRequest: ChatJoinRequest chatJoinRequest: ChatJoinRequest
): Boolean = approveChatJoinRequest(chatJoinRequest) ) = approveChatJoinRequest(chatJoinRequest)
public suspend fun TelegramBot.approveChatJoinRequest( suspend fun TelegramBot.approveChatJoinRequest(
chatJoinRequestUpdate: ChatJoinRequestUpdate chatJoinRequestUpdate: ChatJoinRequestUpdate
): Boolean = approveChatJoinRequest(chatJoinRequestUpdate.data) ) = approveChatJoinRequest(chatJoinRequestUpdate.data)

View File

@@ -1,153 +1,83 @@
package dev.inmo.tgbotapi.extensions.api.chat.invite_links package dev.inmo.tgbotapi.extensions.api.chat.invite_links
import korlibs.time.DateTime import com.soywiz.klock.DateTime
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.invite_links.CreateChatInviteLink import dev.inmo.tgbotapi.requests.chat.invite_links.CreateChatInviteLink
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.chat.PublicChat import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
import korlibs.time.TimeSpan
import korlibs.time.days
public suspend fun TelegramBot.createChatInviteLinkUnlimited( suspend fun TelegramBot.createChatInviteLinkUnlimited(
chatId: ChatIdentifier, chatId: ChatIdentifier,
name: String? = null, name: String? = null,
expiration: TelegramDate? = null expiration: TelegramDate? = null
): ChatInviteLinkUnlimited = execute(CreateChatInviteLink.unlimited(chatId, name, expiration)) ) = execute(CreateChatInviteLink.unlimited(chatId, name, expiration))
public suspend fun TelegramBot.createChatInviteLinkUnlimited( suspend fun TelegramBot.createChatInviteLinkUnlimited(
chat: PublicChat, chat: PublicChat,
name: String? = null, name: String? = null,
expiration: TelegramDate? = null, expiration: TelegramDate? = null,
): ChatInviteLinkUnlimited = createChatInviteLinkUnlimited(chat.id, name, expiration) ) = createChatInviteLinkUnlimited(chat.id, name, expiration)
public suspend fun TelegramBot.createChatInviteLinkUnlimited( suspend fun TelegramBot.createChatInviteLinkUnlimited(
chatId: ChatIdentifier, chatId: ChatIdentifier,
expiration: DateTime, expiration: DateTime,
name: String? = null, name: String? = null,
): ChatInviteLinkUnlimited = createChatInviteLinkUnlimited(chatId, name, expiration.toTelegramDate()) ) = createChatInviteLinkUnlimited(chatId, name, expiration.toTelegramDate())
public suspend fun TelegramBot.createChatInviteLinkUnlimited( suspend fun TelegramBot.createChatInviteLinkUnlimited(
chat: PublicChat, chat: PublicChat,
expiration: DateTime, expiration: DateTime,
name: String? = null name: String? = null
): ChatInviteLinkUnlimited = createChatInviteLinkUnlimited(chat.id, name, expiration.toTelegramDate()) ) = createChatInviteLinkUnlimited(chat.id, name, expiration.toTelegramDate())
public suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers( suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers(
chatId: ChatIdentifier, chatId: ChatIdentifier,
membersLimit: MembersLimit, membersLimit: MembersLimit,
name: String? = null, name: String? = null,
expiration: TelegramDate? = null expiration: TelegramDate? = null
): ChatInviteLinkWithLimitedMembers = execute(CreateChatInviteLink.withLimitedMembers(chatId, membersLimit, name, expiration)) ) = execute(CreateChatInviteLink.withLimitedMembers(chatId, membersLimit, name, expiration))
public suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers( suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers(
chat: PublicChat, chat: PublicChat,
membersLimit: MembersLimit, membersLimit: MembersLimit,
name: String? = null, name: String? = null,
expiration: TelegramDate? = null, expiration: TelegramDate? = null,
): ChatInviteLinkWithLimitedMembers = createChatInviteLinkWithLimitedMembers(chat.id, membersLimit, name, expiration) ) = createChatInviteLinkWithLimitedMembers(chat.id, membersLimit, name, expiration)
public suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers( suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers(
chatId: ChatIdentifier, chatId: ChatIdentifier,
membersLimit: MembersLimit, membersLimit: MembersLimit,
expiration: DateTime, expiration: DateTime,
name: String? = null, name: String? = null,
): ChatInviteLinkWithLimitedMembers = createChatInviteLinkWithLimitedMembers(chatId, membersLimit, name, expiration.toTelegramDate()) ) = createChatInviteLinkWithLimitedMembers(chatId, membersLimit, name, expiration.toTelegramDate())
public suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers( suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers(
chat: PublicChat, chat: PublicChat,
membersLimit: MembersLimit, membersLimit: MembersLimit,
expiration: DateTime, expiration: DateTime,
name: String? = null, name: String? = null,
): ChatInviteLinkWithLimitedMembers = createChatInviteLinkWithLimitedMembers(chat.id, membersLimit, name, expiration.toTelegramDate()) ) = createChatInviteLinkWithLimitedMembers(chat.id, membersLimit, name, expiration.toTelegramDate())
public suspend fun TelegramBot.createChatInviteLinkWithJoinRequest( suspend fun TelegramBot.createChatInviteLinkWithJoinRequest(
chatId: ChatIdentifier, chatId: ChatIdentifier,
name: String? = null, name: String? = null,
expiration: TelegramDate? = null expiration: TelegramDate? = null
): ChatInviteLinkWithJoinRequest = execute(CreateChatInviteLink.withJoinRequest(chatId, name, expiration)) ) = execute(CreateChatInviteLink.withJoinRequest(chatId, name, expiration))
public suspend fun TelegramBot.createChatInviteLinkWithJoinRequest( suspend fun TelegramBot.createChatInviteLinkWithJoinRequest(
chat: PublicChat, chat: PublicChat,
name: String? = null, name: String? = null,
expiration: TelegramDate? = null, expiration: TelegramDate? = null,
): ChatInviteLinkWithJoinRequest = createChatInviteLinkWithJoinRequest(chat.id, name, expiration) ) = createChatInviteLinkWithJoinRequest(chat.id, name, expiration)
public suspend fun TelegramBot.createChatInviteLinkWithJoinRequest( suspend fun TelegramBot.createChatInviteLinkWithJoinRequest(
chatId: ChatIdentifier, chatId: ChatIdentifier,
expiration: DateTime, expiration: DateTime,
name: String? = null, name: String? = null,
): ChatInviteLinkWithJoinRequest = createChatInviteLinkWithJoinRequest(chatId, name, expiration.toTelegramDate()) ) = createChatInviteLinkWithJoinRequest(chatId, name, expiration.toTelegramDate())
public suspend fun TelegramBot.createChatInviteLinkWithJoinRequest( suspend fun TelegramBot.createChatInviteLinkWithJoinRequest(
chat: PublicChat, chat: PublicChat,
expiration: DateTime, expiration: DateTime,
name: String? = null, name: String? = null,
): ChatInviteLinkWithJoinRequest = createChatInviteLinkWithJoinRequest(chat.id, name, expiration.toTelegramDate()) ) = createChatInviteLinkWithJoinRequest(chat.id, name, expiration.toTelegramDate())
// Subscriptions
public suspend fun TelegramBot.createChatSubscriptionInviteLink(
chatId: ChatIdentifier,
subscriptionPrice: UInt,
subscriptionPeriod: TimeSpan = 30.days,
name: String? = null,
expirationUnixTimeStamp: TelegramDate? = null,
): ChatInviteLinkUnlimited = execute(CreateChatInviteLink.subscription(chatId, subscriptionPrice, subscriptionPeriod, name, expirationUnixTimeStamp))
public suspend fun TelegramBot.createChatSubscriptionInviteLink(
chat: PublicChat,
subscriptionPrice: UInt,
subscriptionPeriod: TimeSpan = 30.days,
name: String? = null,
expirationUnixTimeStamp: TelegramDate? = null,
): ChatInviteLinkUnlimited = createChatSubscriptionInviteLink(chat.id, subscriptionPrice, subscriptionPeriod, name, expirationUnixTimeStamp)
public suspend fun TelegramBot.createChatSubscriptionInviteLink(
chatId: ChatIdentifier,
subscriptionPrice: UInt,
subscriptionPeriod: TimeSpan = 30.days,
name: String? = null,
expirationUnixTimeStamp: DateTime,
): ChatInviteLinkUnlimited = createChatSubscriptionInviteLink(chatId, subscriptionPrice, subscriptionPeriod, name, expirationUnixTimeStamp.toTelegramDate())
public suspend fun TelegramBot.createChatSubscriptionInviteLink(
chat: PublicChat,
subscriptionPrice: UInt,
subscriptionPeriod: TimeSpan = 30.days,
name: String? = null,
expirationUnixTimeStamp: DateTime,
): ChatInviteLinkUnlimited = createChatSubscriptionInviteLink(chat.id, subscriptionPrice, subscriptionPeriod, name, expirationUnixTimeStamp)
public suspend fun TelegramBot.createChatSubscriptionInviteLink(
chatId: ChatIdentifier,
subscriptionPrice: Int,
subscriptionPeriod: TimeSpan = 30.days,
name: String? = null,
expirationUnixTimeStamp: TelegramDate? = null,
): ChatInviteLinkUnlimited = createChatSubscriptionInviteLink(chatId, subscriptionPrice.toUInt(), subscriptionPeriod, name, expirationUnixTimeStamp)
public suspend fun TelegramBot.createChatSubscriptionInviteLink(
chat: PublicChat,
subscriptionPrice: Int,
subscriptionPeriod: TimeSpan = 30.days,
name: String? = null,
expirationUnixTimeStamp: TelegramDate? = null,
): ChatInviteLinkUnlimited = createChatSubscriptionInviteLink(chat, subscriptionPrice.toUInt(), subscriptionPeriod, name, expirationUnixTimeStamp)
public suspend fun TelegramBot.createChatSubscriptionInviteLink(
chatId: ChatIdentifier,
subscriptionPrice: Int,
subscriptionPeriod: TimeSpan = 30.days,
name: String? = null,
expirationUnixTimeStamp: DateTime,
): ChatInviteLinkUnlimited = createChatSubscriptionInviteLink(chatId, subscriptionPrice.toUInt(), subscriptionPeriod, name, expirationUnixTimeStamp)
public suspend fun TelegramBot.createChatSubscriptionInviteLink(
chat: PublicChat,
subscriptionPrice: Int,
subscriptionPeriod: TimeSpan = 30.days,
name: String? = null,
expirationUnixTimeStamp: DateTime,
): ChatInviteLinkUnlimited = createChatSubscriptionInviteLink(chat, subscriptionPrice.toUInt(), subscriptionPeriod, name, expirationUnixTimeStamp)

View File

@@ -1,42 +1,40 @@
package dev.inmo.tgbotapi.extensions.api.chat.invite_links package dev.inmo.tgbotapi.extensions.api.chat.invite_links
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.invite_links.ApproveChatJoinRequest
import dev.inmo.tgbotapi.requests.chat.invite_links.DeclineChatJoinRequest import dev.inmo.tgbotapi.requests.chat.invite_links.DeclineChatJoinRequest
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.UserId import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
import dev.inmo.tgbotapi.types.chat.ChatJoinRequest
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.User
import dev.inmo.tgbotapi.types.update.ChatJoinRequestUpdate import dev.inmo.tgbotapi.types.update.ChatJoinRequestUpdate
public suspend fun TelegramBot.declineChatJoinRequest( suspend fun TelegramBot.declineChatJoinRequest(
chatId: ChatIdentifier, chatId: ChatIdentifier,
userId: UserId userId: UserId
): Boolean = execute(DeclineChatJoinRequest(chatId, userId)) ) = execute(DeclineChatJoinRequest(chatId, userId))
public suspend fun TelegramBot.declineChatJoinRequest( suspend fun TelegramBot.declineChatJoinRequest(
chat: PublicChat, chat: PublicChat,
userId: UserId userId: UserId
): Boolean = declineChatJoinRequest(chat.id, userId) ) = declineChatJoinRequest(chat.id, userId)
public suspend fun TelegramBot.declineChatJoinRequest( suspend fun TelegramBot.declineChatJoinRequest(
chatId: ChatIdentifier, chatId: ChatIdentifier,
user: User user: User
): Boolean = declineChatJoinRequest(chatId, user.id) ) = declineChatJoinRequest(chatId, user.id)
public suspend fun TelegramBot.declineChatJoinRequest( suspend fun TelegramBot.declineChatJoinRequest(
chat: PublicChat, chat: PublicChat,
user: User user: User
): Boolean = declineChatJoinRequest(chat.id, user.id) ) = declineChatJoinRequest(chat.id, user.id)
public suspend fun TelegramBot.declineChatJoinRequest( suspend fun TelegramBot.declineChatJoinRequest(
chatJoinRequest: ChatJoinRequest chatJoinRequest: ChatJoinRequest
): Boolean = declineChatJoinRequest(chatJoinRequest.chat, chatJoinRequest.user) ) = declineChatJoinRequest(chatJoinRequest.chat, chatJoinRequest.user)
public suspend fun TelegramBot.decline( suspend fun TelegramBot.decline(
chatJoinRequest: ChatJoinRequest chatJoinRequest: ChatJoinRequest
): Boolean = declineChatJoinRequest(chatJoinRequest) ) = declineChatJoinRequest(chatJoinRequest)
public suspend fun TelegramBot.declineChatJoinRequest( suspend fun TelegramBot.declineChatJoinRequest(
chatJoinRequestUpdate: ChatJoinRequestUpdate chatJoinRequestUpdate: ChatJoinRequestUpdate
): Boolean = declineChatJoinRequest(chatJoinRequestUpdate.data) ) = declineChatJoinRequest(chatJoinRequestUpdate.data)

View File

@@ -1,210 +1,183 @@
package dev.inmo.tgbotapi.extensions.api.chat.invite_links package dev.inmo.tgbotapi.extensions.api.chat.invite_links
import korlibs.time.DateTime import com.soywiz.klock.DateTime
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.invite_links.EditChatInviteLink import dev.inmo.tgbotapi.requests.chat.invite_links.EditChatInviteLink
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.chat.PublicChat import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
public suspend fun TelegramBot.editChatInviteLinkUnlimited( suspend fun TelegramBot.editChatInviteLinkUnlimited(
chatId: ChatIdentifier, chatId: ChatIdentifier,
previousLink: String, previousLink: String,
name: String? = null, name: String? = null,
expiration: TelegramDate? = null expiration: TelegramDate? = null
): ChatInviteLinkUnlimited = execute(EditChatInviteLink.unlimited(chatId, previousLink, name, expiration)) ) = execute(EditChatInviteLink.unlimited(chatId, previousLink, name, expiration))
public suspend fun TelegramBot.editChatInviteLinkUnlimited( suspend fun TelegramBot.editChatInviteLinkUnlimited(
chat: PublicChat, chat: PublicChat,
previousLink: String, previousLink: String,
name: String? = null, name: String? = null,
expiration: TelegramDate? = null, expiration: TelegramDate? = null,
): ChatInviteLinkUnlimited = editChatInviteLinkUnlimited(chat.id, previousLink, name, expiration) ) = editChatInviteLinkUnlimited(chat.id, previousLink, name, expiration)
public suspend fun TelegramBot.editChatInviteLinkUnlimited( suspend fun TelegramBot.editChatInviteLinkUnlimited(
chatId: ChatIdentifier, chatId: ChatIdentifier,
previousLink: String, previousLink: String,
expiration: DateTime, expiration: DateTime,
name: String? = null, name: String? = null,
): ChatInviteLinkUnlimited = editChatInviteLinkUnlimited(chatId, previousLink, name , expiration.toTelegramDate()) ) = editChatInviteLinkUnlimited(chatId, previousLink, name , expiration.toTelegramDate())
public suspend fun TelegramBot.editChatInviteLinkUnlimited( suspend fun TelegramBot.editChatInviteLinkUnlimited(
chat: PublicChat, chat: PublicChat,
previousLink: String, previousLink: String,
expiration: DateTime, expiration: DateTime,
name: String? = null, name: String? = null,
): ChatInviteLinkUnlimited = editChatInviteLinkUnlimited(chat.id, previousLink, name , expiration.toTelegramDate()) ) = editChatInviteLinkUnlimited(chat.id, previousLink, name , expiration.toTelegramDate())
public suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers( suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
chatId: ChatIdentifier, chatId: ChatIdentifier,
previousLink: String, previousLink: String,
membersLimit: MembersLimit, membersLimit: MembersLimit,
name: String? = null, name: String? = null,
expiration: TelegramDate? = null expiration: TelegramDate? = null
): ChatInviteLinkWithLimitedMembers = execute(EditChatInviteLink.withLimitedMembers(chatId, previousLink, membersLimit, name, expiration)) ) = execute(EditChatInviteLink.withLimitedMembers(chatId, previousLink, membersLimit, name, expiration))
public suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers( suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
chat: PublicChat, chat: PublicChat,
previousLink: String, previousLink: String,
membersLimit: MembersLimit, membersLimit: MembersLimit,
name: String? = null, name: String? = null,
expiration: TelegramDate? = null, expiration: TelegramDate? = null,
): ChatInviteLinkWithLimitedMembers = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, name, expiration) ) = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, name, expiration)
public suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers( suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
chatId: ChatIdentifier, chatId: ChatIdentifier,
previousLink: String, previousLink: String,
membersLimit: MembersLimit, membersLimit: MembersLimit,
expiration: DateTime, expiration: DateTime,
name: String? = null, name: String? = null,
): ChatInviteLinkWithLimitedMembers = editChatInviteLinkWithLimitedMembers(chatId, previousLink, membersLimit, name , expiration.toTelegramDate()) ) = editChatInviteLinkWithLimitedMembers(chatId, previousLink, membersLimit, name , expiration.toTelegramDate())
public suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers( suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
chat: PublicChat, chat: PublicChat,
previousLink: String, previousLink: String,
membersLimit: MembersLimit, membersLimit: MembersLimit,
expiration: DateTime, expiration: DateTime,
name: String? = null, name: String? = null,
): ChatInviteLinkWithLimitedMembers = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, name , expiration.toTelegramDate()) ) = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, name , expiration.toTelegramDate())
public suspend fun TelegramBot.editChatInviteLinkWithJoinRequest( suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
chatId: ChatIdentifier, chatId: ChatIdentifier,
previousLink: String, previousLink: String,
name: String? = null, name: String? = null,
expiration: TelegramDate? = null expiration: TelegramDate? = null
): ChatInviteLinkWithJoinRequest = execute(EditChatInviteLink.withJoinRequest(chatId, previousLink, name, expiration)) ) = execute(EditChatInviteLink.withJoinRequest(chatId, previousLink, name, expiration))
public suspend fun TelegramBot.editChatInviteLinkWithJoinRequest( suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
chat: PublicChat, chat: PublicChat,
previousLink: String, previousLink: String,
name: String? = null, name: String? = null,
expiration: TelegramDate? = null, expiration: TelegramDate? = null,
): ChatInviteLinkWithJoinRequest = editChatInviteLinkWithJoinRequest(chat.id, previousLink, name, expiration) ) = editChatInviteLinkWithJoinRequest(chat.id, previousLink, name, expiration)
public suspend fun TelegramBot.editChatInviteLinkWithJoinRequest( suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
chatId: ChatIdentifier, chatId: ChatIdentifier,
previousLink: String, previousLink: String,
expiration: DateTime, expiration: DateTime,
name: String? = null, name: String? = null,
): ChatInviteLinkWithJoinRequest = editChatInviteLinkWithJoinRequest(chatId, previousLink, name , expiration.toTelegramDate()) ) = editChatInviteLinkWithJoinRequest(chatId, previousLink, name , expiration.toTelegramDate())
public suspend fun TelegramBot.editChatInviteLinkWithJoinRequest( suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
chat: PublicChat, chat: PublicChat,
previousLink: String, previousLink: String,
expiration: DateTime, expiration: DateTime,
name: String? = null, name: String? = null,
): ChatInviteLinkWithJoinRequest = editChatInviteLinkWithJoinRequest(chat.id, previousLink, name , expiration.toTelegramDate()) ) = editChatInviteLinkWithJoinRequest(chat.id, previousLink, name , expiration.toTelegramDate())
public suspend fun TelegramBot.editChatInviteLinkUnlimited( suspend fun TelegramBot.editChatInviteLinkUnlimited(
chatId: ChatIdentifier, chatId: ChatIdentifier,
previousLink: ChatInviteLink, previousLink: ChatInviteLink,
name: String? = null, name: String? = null,
expiration: TelegramDate? = null expiration: TelegramDate? = null
): ChatInviteLinkUnlimited = editChatInviteLinkUnlimited(chatId, previousLink.inviteLink, name, expiration) ) = editChatInviteLinkUnlimited(chatId, previousLink.inviteLink, name, expiration)
public suspend fun TelegramBot.editChatInviteLinkUnlimited( suspend fun TelegramBot.editChatInviteLinkUnlimited(
chat: PublicChat, chat: PublicChat,
previousLink: ChatInviteLink, previousLink: ChatInviteLink,
name: String? = null, name: String? = null,
expiration: TelegramDate? = null, expiration: TelegramDate? = null,
): ChatInviteLinkUnlimited = editChatInviteLinkUnlimited(chat.id, previousLink, name, expiration) ) = editChatInviteLinkUnlimited(chat.id, previousLink, name, expiration)
public suspend fun TelegramBot.editChatInviteLinkUnlimited( suspend fun TelegramBot.editChatInviteLinkUnlimited(
chatId: ChatIdentifier, chatId: ChatIdentifier,
previousLink: ChatInviteLink, previousLink: ChatInviteLink,
expiration: DateTime, expiration: DateTime,
name: String? = null, name: String? = null,
): ChatInviteLinkUnlimited = editChatInviteLinkUnlimited(chatId, previousLink, name, expiration.toTelegramDate()) ) = editChatInviteLinkUnlimited(chatId, previousLink, name, expiration.toTelegramDate())
public suspend fun TelegramBot.editChatInviteLinkUnlimited( suspend fun TelegramBot.editChatInviteLinkUnlimited(
chat: PublicChat, chat: PublicChat,
previousLink: ChatInviteLink, previousLink: ChatInviteLink,
expiration: DateTime, expiration: DateTime,
name: String? = null, name: String? = null,
): ChatInviteLinkUnlimited = editChatInviteLinkUnlimited(chat.id, previousLink, name , expiration.toTelegramDate()) ) = editChatInviteLinkUnlimited(chat.id, previousLink, name , expiration.toTelegramDate())
public suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers( suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
chatId: ChatIdentifier, chatId: ChatIdentifier,
previousLink: ChatInviteLink, previousLink: ChatInviteLink,
membersLimit: MembersLimit, membersLimit: MembersLimit,
name: String? = null, name: String? = null,
expiration: TelegramDate? = null expiration: TelegramDate? = null
): ChatInviteLinkWithLimitedMembers = editChatInviteLinkWithLimitedMembers(chatId, previousLink.inviteLink, membersLimit, name, expiration) ) = editChatInviteLinkWithLimitedMembers(chatId, previousLink.inviteLink, membersLimit, name, expiration)
public suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers( suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
chat: PublicChat, chat: PublicChat,
previousLink: ChatInviteLink, previousLink: ChatInviteLink,
membersLimit: MembersLimit, membersLimit: MembersLimit,
name: String? = null, name: String? = null,
expiration: TelegramDate? = null, expiration: TelegramDate? = null,
): ChatInviteLinkWithLimitedMembers = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, name, expiration) ) = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, name, expiration)
public suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers( suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
chatId: ChatIdentifier, chatId: ChatIdentifier,
previousLink: ChatInviteLink, previousLink: ChatInviteLink,
membersLimit: MembersLimit, membersLimit: MembersLimit,
expiration: DateTime, expiration: DateTime,
name: String? = null, name: String? = null,
): ChatInviteLinkWithLimitedMembers = editChatInviteLinkWithLimitedMembers(chatId, previousLink, membersLimit, name , expiration.toTelegramDate()) ) = editChatInviteLinkWithLimitedMembers(chatId, previousLink, membersLimit, name , expiration.toTelegramDate())
public suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers( suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
chat: PublicChat, chat: PublicChat,
previousLink: ChatInviteLink, previousLink: ChatInviteLink,
membersLimit: MembersLimit, membersLimit: MembersLimit,
expiration: DateTime, expiration: DateTime,
name: String? = null, name: String? = null,
): ChatInviteLinkWithLimitedMembers = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, name , expiration.toTelegramDate()) ) = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, name , expiration.toTelegramDate())
public suspend fun TelegramBot.editChatInviteLinkWithJoinRequest( suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
chatId: ChatIdentifier, chatId: ChatIdentifier,
previousLink: ChatInviteLink, previousLink: ChatInviteLink,
name: String? = null, name: String? = null,
expiration: TelegramDate? = null expiration: TelegramDate? = null
): ChatInviteLinkWithJoinRequest = editChatInviteLinkWithJoinRequest(chatId, previousLink.inviteLink, name, expiration) ) = editChatInviteLinkWithJoinRequest(chatId, previousLink.inviteLink, name, expiration)
public suspend fun TelegramBot.editChatInviteLinkWithJoinRequest( suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
chat: PublicChat, chat: PublicChat,
previousLink: ChatInviteLink, previousLink: ChatInviteLink,
name: String? = null, name: String? = null,
expiration: TelegramDate? = null, expiration: TelegramDate? = null,
): ChatInviteLinkWithJoinRequest = editChatInviteLinkWithJoinRequest(chat.id, previousLink, name, expiration) ) = editChatInviteLinkWithJoinRequest(chat.id, previousLink, name, expiration)
public suspend fun TelegramBot.editChatInviteLinkWithJoinRequest( suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
chatId: ChatIdentifier, chatId: ChatIdentifier,
previousLink: ChatInviteLink, previousLink: ChatInviteLink,
expiration: DateTime, expiration: DateTime,
name: String? = null, name: String? = null,
): ChatInviteLinkWithJoinRequest = editChatInviteLinkWithJoinRequest(chatId, previousLink, name , expiration.toTelegramDate()) ) = editChatInviteLinkWithJoinRequest(chatId, previousLink, name , expiration.toTelegramDate())
public suspend fun TelegramBot.editChatInviteLinkWithJoinRequest( suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
chat: PublicChat, chat: PublicChat,
previousLink: ChatInviteLink, previousLink: ChatInviteLink,
expiration: DateTime, expiration: DateTime,
name: String? = null, name: String? = null,
): ChatInviteLinkWithJoinRequest = editChatInviteLinkWithJoinRequest(chat.id, previousLink, name , expiration.toTelegramDate()) ) = editChatInviteLinkWithJoinRequest(chat.id, previousLink, name , expiration.toTelegramDate())
// Subscriptions
public suspend fun TelegramBot.editChatSubscriptionInviteLink(
chatId: ChatIdentifier,
previousLink: String,
name: String,
): ChatInviteLinkUnlimited = execute(EditChatInviteLink.subscription(chatId, previousLink, name))
public suspend fun TelegramBot.editChatSubscriptionInviteLink(
chatId: ChatIdentifier,
previousLink: ChatInviteLink,
name: String,
): ChatInviteLinkUnlimited = editChatSubscriptionInviteLink(chatId, previousLink.inviteLink, name)
public suspend fun TelegramBot.editChatSubscriptionInviteLink(
chat: PublicChat,
previousLink: String,
name: String,
): ChatInviteLinkUnlimited = editChatSubscriptionInviteLink(chat.id, previousLink, name)
public suspend fun TelegramBot.editChatSubscriptionInviteLink(
chat: PublicChat,
previousLink: ChatInviteLink,
name: String,
): ChatInviteLinkUnlimited = editChatSubscriptionInviteLink(chat.id, previousLink, name)

View File

@@ -4,25 +4,24 @@ import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.invite_links.RevokeChatInviteLink import dev.inmo.tgbotapi.requests.chat.invite_links.RevokeChatInviteLink
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.ChatInviteLink import dev.inmo.tgbotapi.types.ChatInviteLink
import dev.inmo.tgbotapi.types.SecondaryChatInviteLink import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
import dev.inmo.tgbotapi.types.chat.PublicChat
public suspend fun TelegramBot.revokeChatInviteLink( suspend fun TelegramBot.revokeChatInviteLink(
chatId: ChatIdentifier, chatId: ChatIdentifier,
previousLink: String previousLink: String
): SecondaryChatInviteLink = execute(RevokeChatInviteLink(chatId, previousLink)) ) = execute(RevokeChatInviteLink(chatId, previousLink))
public suspend fun TelegramBot.revokeChatInviteLink( suspend fun TelegramBot.revokeChatInviteLink(
chat: PublicChat, chat: PublicChat,
previousLink: String previousLink: String
): SecondaryChatInviteLink = revokeChatInviteLink(chat.id, previousLink) ) = revokeChatInviteLink(chat.id, previousLink)
public suspend fun TelegramBot.revokeChatInviteLink( suspend fun TelegramBot.revokeChatInviteLink(
chatId: ChatIdentifier, chatId: ChatIdentifier,
previousLink: ChatInviteLink previousLink: ChatInviteLink
): SecondaryChatInviteLink = revokeChatInviteLink(chatId, previousLink.inviteLink) ) = revokeChatInviteLink(chatId, previousLink.inviteLink)
public suspend fun TelegramBot.revokeChatInviteLink( suspend fun TelegramBot.revokeChatInviteLink(
chat: PublicChat, chat: PublicChat,
previousLink: ChatInviteLink previousLink: ChatInviteLink
): SecondaryChatInviteLink = revokeChatInviteLink(chat, previousLink.inviteLink) ) = revokeChatInviteLink(chat, previousLink.inviteLink)

View File

@@ -2,37 +2,33 @@ package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.BanChatMember import dev.inmo.tgbotapi.requests.chat.members.BanChatMember
import dev.inmo.tgbotapi.types.IdChatIdentifier import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
import dev.inmo.tgbotapi.types.TelegramDate
import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.User
public suspend fun TelegramBot.banChatMember( suspend fun TelegramBot.banChatMember(
chatId: ChatIdentifier, chatId: ChatIdentifier,
userId: UserId, userId: UserId,
untilDate: TelegramDate? = null, untilDate: TelegramDate? = null,
revokeMessages: Boolean? = null revokeMessages: Boolean? = null
): Boolean = execute(BanChatMember(chatId, userId, untilDate, revokeMessages)) ) = execute(BanChatMember(chatId, userId, untilDate, revokeMessages))
public suspend fun TelegramBot.banChatMember( suspend fun TelegramBot.banChatMember(
chat: PublicChat, chat: PublicChat,
userId: UserId, userId: UserId,
untilDate: TelegramDate? = null, untilDate: TelegramDate? = null,
revokeMessages: Boolean? = null revokeMessages: Boolean? = null
): Boolean = banChatMember(chat.id, userId, untilDate, revokeMessages) ) = banChatMember(chat.id, userId, untilDate, revokeMessages)
public suspend fun TelegramBot.banChatMember( suspend fun TelegramBot.banChatMember(
chatId: IdChatIdentifier, chatId: ChatId,
user: User, user: User,
untilDate: TelegramDate? = null, untilDate: TelegramDate? = null,
revokeMessages: Boolean? = null revokeMessages: Boolean? = null
): Boolean = banChatMember(chatId, user.id, untilDate, revokeMessages) ) = banChatMember(chatId, user.id, untilDate, revokeMessages)
public suspend fun TelegramBot.banChatMember( suspend fun TelegramBot.banChatMember(
chat: PublicChat, chat: PublicChat,
user: User, user: User,
untilDate: TelegramDate? = null, untilDate: TelegramDate? = null,
revokeMessages: Boolean? = null revokeMessages: Boolean? = null
): Boolean = banChatMember(chat.id, user.id, untilDate, revokeMessages) ) = banChatMember(chat.id, user.id, untilDate, revokeMessages)

View File

@@ -1,27 +1,27 @@
package dev.inmo.tgbotapi.extensions.api.chat.members package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.BanChatMember
import dev.inmo.tgbotapi.requests.chat.members.BanChatSenderChat import dev.inmo.tgbotapi.requests.chat.members.BanChatSenderChat
import dev.inmo.tgbotapi.types.IdChatIdentifier import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
import dev.inmo.tgbotapi.types.chat.PublicChat
public suspend fun TelegramBot.banChatSenderChat( suspend fun TelegramBot.banChatSenderChat(
chatId: ChatIdentifier, chatId: ChatIdentifier,
senderChatId: IdChatIdentifier senderChatId: ChatId
): Boolean = execute(BanChatSenderChat(chatId, senderChatId)) ) = execute(BanChatSenderChat(chatId, senderChatId))
public suspend fun TelegramBot.banChatSenderChat( suspend fun TelegramBot.banChatSenderChat(
chat: PublicChat, chat: PublicChat,
senderChatId: IdChatIdentifier senderChatId: ChatId
): Boolean = banChatSenderChat(chat.id, senderChatId) ) = banChatSenderChat(chat.id, senderChatId)
public suspend fun TelegramBot.banChatSenderChat( suspend fun TelegramBot.banChatSenderChat(
chatId: IdChatIdentifier, chatId: ChatId,
senderChat: PublicChat senderChat: PublicChat
): Boolean = banChatSenderChat(chatId, senderChat.id) ) = banChatSenderChat(chatId, senderChat.id)
public suspend fun TelegramBot.banChatSenderChat( suspend fun TelegramBot.banChatSenderChat(
chat: PublicChat, chat: PublicChat,
senderChat: PublicChat, senderChat: PublicChat,
): Boolean = banChatSenderChat(chat.id, senderChat) ) = banChatSenderChat(chat.id, senderChat)

View File

@@ -2,29 +2,25 @@ package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.GetChatMember import dev.inmo.tgbotapi.requests.chat.members.GetChatMember
import dev.inmo.tgbotapi.types.IdChatIdentifier import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.User
import dev.inmo.tgbotapi.types.chat.member.ChatMember
public suspend fun TelegramBot.getChatMember( suspend fun TelegramBot.getChatMember(
chatId: ChatIdentifier, chatId: ChatIdentifier,
userId: UserId userId: UserId
): ChatMember = execute(GetChatMember(chatId, userId)) ) = execute(GetChatMember(chatId, userId))
public suspend fun TelegramBot.getChatMember( suspend fun TelegramBot.getChatMember(
chat: PublicChat, chat: PublicChat,
userId: UserId userId: UserId
): ChatMember = getChatMember(chat.id, userId) ) = getChatMember(chat.id, userId)
public suspend fun TelegramBot.getChatMember( suspend fun TelegramBot.getChatMember(
chatId: IdChatIdentifier, chatId: ChatId,
user: User user: User
): ChatMember = getChatMember(chatId, user.id) ) = getChatMember(chatId, user.id)
public suspend fun TelegramBot.getChatMember( suspend fun TelegramBot.getChatMember(
chat: PublicChat, chat: PublicChat,
user: User user: User
): ChatMember = getChatMember(chat.id, user.id) ) = getChatMember(chat.id, user.id)

View File

@@ -1,157 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.PromoteChannelAdministrator
import dev.inmo.tgbotapi.requests.chat.members.PromoteChatMember
import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.TelegramDate
import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.User
public suspend fun TelegramBot.promoteChannelAdministrator(
chatId: ChatIdentifier,
userId: UserId,
untilDate: TelegramDate? = null,
isAnonymous: Boolean? = null,
canChangeInfo: Boolean? = null,
canPostMessages: Boolean? = null,
canEditMessages: Boolean? = null,
canDeleteMessages: Boolean? = null,
canInviteUsers: Boolean? = null,
canRestrictMembers: Boolean? = null,
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
canPostStories: Boolean? = null,
canEditStories: Boolean? = null,
canDeleteStories: Boolean? = null
): Boolean = execute(
PromoteChannelAdministrator(
chatId = chatId,
userId = userId,
untilDate = untilDate,
isAnonymous = isAnonymous,
canChangeInfo = canChangeInfo,
canPostMessages = canPostMessages,
canEditMessages = canEditMessages,
canDeleteMessages = canDeleteMessages,
canInviteUsers = canInviteUsers,
canRestrictMembers = canRestrictMembers,
canPromoteMembers = canPromoteMembers,
canManageVideoChats = canManageVideoChats,
canManageChat = canManageChat,
canPostStories = canPostStories,
canEditStories = canEditStories,
canDeleteStories = canDeleteStories
)
)
public suspend fun TelegramBot.promoteChannelAdministrator(
chat: PublicChat,
userId: UserId,
untilDate: TelegramDate? = null,
isAnonymous: Boolean? = null,
canChangeInfo: Boolean? = null,
canPostMessages: Boolean? = null,
canEditMessages: Boolean? = null,
canDeleteMessages: Boolean? = null,
canInviteUsers: Boolean? = null,
canRestrictMembers: Boolean? = null,
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
canPostStories: Boolean? = null,
canEditStories: Boolean? = null,
canDeleteStories: Boolean? = null
): Boolean = promoteChannelAdministrator(
chat.id,
userId,
untilDate = untilDate,
isAnonymous = isAnonymous,
canChangeInfo = canChangeInfo,
canPostMessages = canPostMessages,
canEditMessages = canEditMessages,
canDeleteMessages = canDeleteMessages,
canInviteUsers = canInviteUsers,
canRestrictMembers = canRestrictMembers,
canPromoteMembers = canPromoteMembers,
canManageVideoChats = canManageVideoChats,
canManageChat = canManageChat,
canPostStories = canPostStories,
canEditStories = canEditStories,
canDeleteStories = canDeleteStories
)
public suspend fun TelegramBot.promoteChannelAdministrator(
chatId: IdChatIdentifier,
user: User,
untilDate: TelegramDate? = null,
isAnonymous: Boolean? = null,
canChangeInfo: Boolean? = null,
canPostMessages: Boolean? = null,
canEditMessages: Boolean? = null,
canDeleteMessages: Boolean? = null,
canInviteUsers: Boolean? = null,
canRestrictMembers: Boolean? = null,
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
canPostStories: Boolean? = null,
canEditStories: Boolean? = null,
canDeleteStories: Boolean? = null
): Boolean = promoteChannelAdministrator(
chatId,
user.id,
untilDate = untilDate,
isAnonymous = isAnonymous,
canChangeInfo = canChangeInfo,
canPostMessages = canPostMessages,
canEditMessages = canEditMessages,
canDeleteMessages = canDeleteMessages,
canInviteUsers = canInviteUsers,
canRestrictMembers = canRestrictMembers,
canPromoteMembers = canPromoteMembers,
canManageVideoChats = canManageVideoChats,
canManageChat = canManageChat,
canPostStories = canPostStories,
canEditStories = canEditStories,
canDeleteStories = canDeleteStories
)
public suspend fun TelegramBot.promoteChannelAdministrator(
chat: PublicChat,
user: User,
untilDate: TelegramDate? = null,
isAnonymous: Boolean? = null,
canChangeInfo: Boolean? = null,
canPostMessages: Boolean? = null,
canEditMessages: Boolean? = null,
canDeleteMessages: Boolean? = null,
canInviteUsers: Boolean? = null,
canRestrictMembers: Boolean? = null,
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
canPostStories: Boolean? = null,
canEditStories: Boolean? = null,
canDeleteStories: Boolean? = null
): Boolean = promoteChannelAdministrator(
chat.id,
user.id,
untilDate = untilDate,
isAnonymous = isAnonymous,
canChangeInfo = canChangeInfo,
canPostMessages = canPostMessages,
canEditMessages = canEditMessages,
canDeleteMessages = canDeleteMessages,
canInviteUsers = canInviteUsers,
canRestrictMembers = canRestrictMembers,
canPromoteMembers = canPromoteMembers,
canManageVideoChats = canManageVideoChats,
canManageChat = canManageChat,
canPostStories = canPostStories,
canEditStories = canEditStories,
canDeleteStories = canDeleteStories
)

View File

@@ -1,116 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.PromoteChatMember
import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.TelegramDate
import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.User
public suspend fun TelegramBot.promoteChatAdministrator(
chatId: ChatIdentifier,
userId: UserId,
untilDate: TelegramDate? = null,
isAnonymous: Boolean? = null,
canChangeInfo: Boolean? = null,
canDeleteMessages: Boolean? = null,
canInviteUsers: Boolean? = null,
canRestrictMembers: Boolean? = null,
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
): Boolean = execute(
PromoteChatMember(
chatId,
userId,
untilDate,
isAnonymous,
canChangeInfo,
canDeleteMessages,
canInviteUsers,
canRestrictMembers,
canPromoteMembers,
canManageVideoChats,
canManageChat
)
)
public suspend fun TelegramBot.promoteChatAdministrator(
chat: PublicChat,
userId: UserId,
untilDate: TelegramDate? = null,
isAnonymous: Boolean? = null,
canChangeInfo: Boolean? = null,
canDeleteMessages: Boolean? = null,
canInviteUsers: Boolean? = null,
canRestrictMembers: Boolean? = null,
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
): Boolean = promoteChatAdministrator(
chat.id,
userId,
untilDate,
isAnonymous,
canChangeInfo,
canDeleteMessages,
canInviteUsers,
canRestrictMembers,
canPromoteMembers,
canManageVideoChats,
canManageChat
)
public suspend fun TelegramBot.promoteChatAdministrator(
chatId: IdChatIdentifier,
user: User,
untilDate: TelegramDate? = null,
isAnonymous: Boolean? = null,
canChangeInfo: Boolean? = null,
canDeleteMessages: Boolean? = null,
canInviteUsers: Boolean? = null,
canRestrictMembers: Boolean? = null,
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
): Boolean = promoteChatAdministrator(
chatId,
user.id,
untilDate,
isAnonymous,
canChangeInfo,
canDeleteMessages,
canInviteUsers,
canRestrictMembers,
canPromoteMembers,
canManageVideoChats,
canManageChat
)
public suspend fun TelegramBot.promoteChatAdministrator(
chat: PublicChat,
user: User,
untilDate: TelegramDate? = null,
isAnonymous: Boolean? = null,
canChangeInfo: Boolean? = null,
canDeleteMessages: Boolean? = null,
canInviteUsers: Boolean? = null,
canRestrictMembers: Boolean? = null,
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
): Boolean = promoteChatAdministrator(
chat.id,
user.id,
untilDate,
isAnonymous,
canChangeInfo,
canDeleteMessages,
canInviteUsers,
canRestrictMembers,
canPromoteMembers,
canManageVideoChats,
canManageChat
)

View File

@@ -1,14 +1,11 @@
package dev.inmo.tgbotapi.extensions.api.chat.members package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.micro_utils.common.Warning
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.PromoteChatMember import dev.inmo.tgbotapi.requests.chat.members.PromoteChatMember
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.chat.PublicChat import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
import dev.inmo.tgbotapi.types.chat.User
@Warning("This method is too common. Use it with caution") suspend fun TelegramBot.promoteChatMember(
public suspend fun TelegramBot.promoteChatMember(
chatId: ChatIdentifier, chatId: ChatIdentifier,
userId: UserId, userId: UserId,
untilDate: TelegramDate? = null, untilDate: TelegramDate? = null,
@@ -21,37 +18,28 @@ public suspend fun TelegramBot.promoteChatMember(
canRestrictMembers: Boolean? = null, canRestrictMembers: Boolean? = null,
canPinMessages: Boolean? = null, canPinMessages: Boolean? = null,
canPromoteMembers: Boolean? = null, canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null, canManageVoiceChats: Boolean? = null,
canManageChat: Boolean? = null, canManageChat: Boolean?
canManageTopics: Boolean? = null, ) = execute(
canPostStories: Boolean? = null,
canEditStories: Boolean? = null,
canDeleteStories: Boolean? = null
): Boolean = execute(
PromoteChatMember( PromoteChatMember(
chatId = chatId, chatId,
userId = userId, userId,
untilDate = untilDate, untilDate,
isAnonymous = isAnonymous, isAnonymous,
canChangeInfo = canChangeInfo, canChangeInfo,
canPostMessages = canPostMessages, canPostMessages,
canEditMessages = canEditMessages, canEditMessages,
canDeleteMessages = canDeleteMessages, canDeleteMessages,
canInviteUsers = canInviteUsers, canInviteUsers,
canRestrictMembers = canRestrictMembers, canRestrictMembers,
canPinMessages = canPinMessages, canPinMessages,
canPromoteMembers = canPromoteMembers, canPromoteMembers,
canManageVideoChats = canManageVideoChats, canManageVoiceChats,
canManageChat = canManageChat, canManageChat
canManageTopics = canManageTopics,
canPostStories = canPostStories,
canEditStories = canEditStories,
canDeleteStories = canDeleteStories
) )
) )
@Warning("This method is too common. Use it with caution") suspend fun TelegramBot.promoteChatMember(
public suspend fun TelegramBot.promoteChatMember(
chat: PublicChat, chat: PublicChat,
userId: UserId, userId: UserId,
untilDate: TelegramDate? = null, untilDate: TelegramDate? = null,
@@ -64,36 +52,27 @@ public suspend fun TelegramBot.promoteChatMember(
canRestrictMembers: Boolean? = null, canRestrictMembers: Boolean? = null,
canPinMessages: Boolean? = null, canPinMessages: Boolean? = null,
canPromoteMembers: Boolean? = null, canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null, canManageVoiceChats: Boolean? = null,
canManageChat: Boolean? = null, canManageChat: Boolean? = null
canManageTopics: Boolean? = null, ) = promoteChatMember(
canPostStories: Boolean? = null,
canEditStories: Boolean? = null,
canDeleteStories: Boolean? = null
): Boolean = promoteChatMember(
chat.id, chat.id,
userId, userId,
untilDate = untilDate, untilDate,
isAnonymous = isAnonymous, isAnonymous,
canChangeInfo = canChangeInfo, canChangeInfo,
canPostMessages = canPostMessages, canPostMessages,
canEditMessages = canEditMessages, canEditMessages,
canDeleteMessages = canDeleteMessages, canDeleteMessages,
canInviteUsers = canInviteUsers, canInviteUsers,
canRestrictMembers = canRestrictMembers, canRestrictMembers,
canPinMessages = canPinMessages, canPinMessages,
canPromoteMembers = canPromoteMembers, canPromoteMembers,
canManageVideoChats = canManageVideoChats, canManageVoiceChats,
canManageChat = canManageChat, canManageChat
canManageTopics = canManageTopics,
canPostStories = canPostStories,
canEditStories = canEditStories,
canDeleteStories = canDeleteStories
) )
@Warning("This method is too common. Use it with caution") suspend fun TelegramBot.promoteChatMember(
public suspend fun TelegramBot.promoteChatMember( chatId: ChatId,
chatId: IdChatIdentifier,
user: User, user: User,
untilDate: TelegramDate? = null, untilDate: TelegramDate? = null,
isAnonymous: Boolean? = null, isAnonymous: Boolean? = null,
@@ -105,35 +84,26 @@ public suspend fun TelegramBot.promoteChatMember(
canRestrictMembers: Boolean? = null, canRestrictMembers: Boolean? = null,
canPinMessages: Boolean? = null, canPinMessages: Boolean? = null,
canPromoteMembers: Boolean? = null, canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null, canManageVoiceChats: Boolean? = null,
canManageChat: Boolean? = null, canManageChat: Boolean? = null
canManageTopics: Boolean? = null, ) = promoteChatMember(
canPostStories: Boolean? = null,
canEditStories: Boolean? = null,
canDeleteStories: Boolean? = null
): Boolean = promoteChatMember(
chatId, chatId,
user.id, user.id,
untilDate = untilDate, untilDate,
isAnonymous = isAnonymous, isAnonymous,
canChangeInfo = canChangeInfo, canChangeInfo,
canPostMessages = canPostMessages, canPostMessages,
canEditMessages = canEditMessages, canEditMessages,
canDeleteMessages = canDeleteMessages, canDeleteMessages,
canInviteUsers = canInviteUsers, canInviteUsers,
canRestrictMembers = canRestrictMembers, canRestrictMembers,
canPinMessages = canPinMessages, canPinMessages,
canPromoteMembers = canPromoteMembers, canPromoteMembers,
canManageVideoChats = canManageVideoChats, canManageVoiceChats,
canManageChat = canManageChat, canManageChat
canManageTopics = canManageTopics,
canPostStories = canPostStories,
canEditStories = canEditStories,
canDeleteStories = canDeleteStories
) )
@Warning("This method is too common. Use it with caution") suspend fun TelegramBot.promoteChatMember(
public suspend fun TelegramBot.promoteChatMember(
chat: PublicChat, chat: PublicChat,
user: User, user: User,
untilDate: TelegramDate? = null, untilDate: TelegramDate? = null,
@@ -146,29 +116,21 @@ public suspend fun TelegramBot.promoteChatMember(
canRestrictMembers: Boolean? = null, canRestrictMembers: Boolean? = null,
canPinMessages: Boolean? = null, canPinMessages: Boolean? = null,
canPromoteMembers: Boolean? = null, canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null, canManageVoiceChats: Boolean? = null,
canManageChat: Boolean? = null, canManageChat: Boolean? = null
canManageTopics: Boolean? = null, ) = promoteChatMember(
canPostStories: Boolean? = null,
canEditStories: Boolean? = null,
canDeleteStories: Boolean? = null
): Boolean = promoteChatMember(
chat.id, chat.id,
user.id, user.id,
untilDate = untilDate, untilDate,
isAnonymous = isAnonymous, isAnonymous,
canChangeInfo = canChangeInfo, canChangeInfo,
canPostMessages = canPostMessages, canPostMessages,
canEditMessages = canEditMessages, canEditMessages,
canDeleteMessages = canDeleteMessages, canDeleteMessages,
canInviteUsers = canInviteUsers, canInviteUsers,
canRestrictMembers = canRestrictMembers, canRestrictMembers,
canPinMessages = canPinMessages, canPinMessages,
canPromoteMembers = canPromoteMembers, canPromoteMembers,
canManageVideoChats = canManageVideoChats, canManageVoiceChats,
canManageChat = canManageChat, canManageChat
canManageTopics = canManageTopics,
canPostStories = canPostStories,
canEditStories = canEditStories,
canDeleteStories = canDeleteStories
) )

View File

@@ -1,133 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.PromoteChatMember
import dev.inmo.tgbotapi.requests.chat.members.PromoteSupergroupAdministrator
import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.TelegramDate
import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.User
public suspend fun TelegramBot.promoteSupergroupAdministrator(
chatId: ChatIdentifier,
userId: UserId,
untilDate: TelegramDate? = null,
isAnonymous: Boolean? = null,
canChangeInfo: Boolean? = null,
canDeleteMessages: Boolean? = null,
canInviteUsers: Boolean? = null,
canRestrictMembers: Boolean? = null,
canPinMessages: Boolean? = null,
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
canManageTopics: Boolean? = null,
): Boolean = execute(
PromoteSupergroupAdministrator(
chatId = chatId,
userId = userId,
untilDate = untilDate,
isAnonymous = isAnonymous,
canChangeInfo = canChangeInfo,
canDeleteMessages = canDeleteMessages,
canInviteUsers = canInviteUsers,
canRestrictMembers = canRestrictMembers,
canPinMessages = canPinMessages,
canPromoteMembers = canPromoteMembers,
canManageVideoChats = canManageVideoChats,
canManageChat = canManageChat,
canManageTopics = canManageTopics
)
)
public suspend fun TelegramBot.promoteSupergroupAdministrator(
chat: PublicChat,
userId: UserId,
untilDate: TelegramDate? = null,
isAnonymous: Boolean? = null,
canChangeInfo: Boolean? = null,
canDeleteMessages: Boolean? = null,
canInviteUsers: Boolean? = null,
canRestrictMembers: Boolean? = null,
canPinMessages: Boolean? = null,
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
canManageTopics: Boolean? = null,
): Boolean = promoteSupergroupAdministrator(
chat.id,
userId,
untilDate = untilDate,
isAnonymous = isAnonymous,
canChangeInfo = canChangeInfo,
canDeleteMessages = canDeleteMessages,
canInviteUsers = canInviteUsers,
canRestrictMembers = canRestrictMembers,
canPinMessages = canPinMessages,
canPromoteMembers = canPromoteMembers,
canManageVideoChats = canManageVideoChats,
canManageChat = canManageChat,
canManageTopics = canManageTopics
)
public suspend fun TelegramBot.promoteSupergroupAdministrator(
chatId: IdChatIdentifier,
user: User,
untilDate: TelegramDate? = null,
isAnonymous: Boolean? = null,
canChangeInfo: Boolean? = null,
canDeleteMessages: Boolean? = null,
canInviteUsers: Boolean? = null,
canRestrictMembers: Boolean? = null,
canPinMessages: Boolean? = null,
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
canManageTopics: Boolean? = null,
): Boolean = promoteSupergroupAdministrator(
chatId,
user.id,
untilDate = untilDate,
isAnonymous = isAnonymous,
canChangeInfo = canChangeInfo,
canDeleteMessages = canDeleteMessages,
canInviteUsers = canInviteUsers,
canRestrictMembers = canRestrictMembers,
canPinMessages = canPinMessages,
canPromoteMembers = canPromoteMembers,
canManageVideoChats = canManageVideoChats,
canManageChat = canManageChat,
canManageTopics = canManageTopics
)
public suspend fun TelegramBot.promoteSupergroupAdministrator(
chat: PublicChat,
user: User,
untilDate: TelegramDate? = null,
isAnonymous: Boolean? = null,
canChangeInfo: Boolean? = null,
canDeleteMessages: Boolean? = null,
canInviteUsers: Boolean? = null,
canRestrictMembers: Boolean? = null,
canPinMessages: Boolean? = null,
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
canManageTopics: Boolean? = null,
): Boolean = promoteSupergroupAdministrator(
chat.id,
user.id,
untilDate = untilDate,
isAnonymous = isAnonymous,
canChangeInfo = canChangeInfo,
canDeleteMessages = canDeleteMessages,
canInviteUsers = canInviteUsers,
canRestrictMembers = canRestrictMembers,
canPinMessages = canPinMessages,
canPromoteMembers = canPromoteMembers,
canManageVideoChats = canManageVideoChats,
canManageChat = canManageChat,
canManageTopics = canManageTopics
)

View File

@@ -2,43 +2,35 @@ package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.RestrictChatMember import dev.inmo.tgbotapi.requests.chat.members.RestrictChatMember
import dev.inmo.tgbotapi.types.IdChatIdentifier import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.TelegramDate
import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.chat.ChatPermissions import dev.inmo.tgbotapi.types.chat.ChatPermissions
import dev.inmo.tgbotapi.types.chat.PublicChat import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
import dev.inmo.tgbotapi.types.chat.User
public suspend fun TelegramBot.restrictChatMember( suspend fun TelegramBot.restrictChatMember(
chatId: ChatIdentifier, chatId: ChatIdentifier,
userId: UserId, userId: UserId,
untilDate: TelegramDate? = null, untilDate: TelegramDate? = null,
permissions: ChatPermissions = ChatPermissions(), permissions: ChatPermissions = ChatPermissions()
useIndependentChatPermissions: Boolean? = permissions.isGranular.takeIf { it } ) = execute(RestrictChatMember(chatId, userId, untilDate, permissions))
): Boolean = execute(RestrictChatMember(chatId, userId, untilDate, permissions, useIndependentChatPermissions))
public suspend fun TelegramBot.restrictChatMember( suspend fun TelegramBot.restrictChatMember(
chat: PublicChat, chat: PublicChat,
userId: UserId, userId: UserId,
untilDate: TelegramDate? = null, untilDate: TelegramDate? = null,
permissions: ChatPermissions = ChatPermissions(), permissions: ChatPermissions = ChatPermissions()
useIndependentChatPermissions: Boolean? = permissions.isGranular.takeIf { it } ) = restrictChatMember(chat.id, userId, untilDate, permissions)
): Boolean = restrictChatMember(chat.id, userId, untilDate, permissions, useIndependentChatPermissions)
public suspend fun TelegramBot.restrictChatMember( suspend fun TelegramBot.restrictChatMember(
chatId: IdChatIdentifier, chatId: ChatId,
user: User, user: User,
untilDate: TelegramDate? = null, untilDate: TelegramDate? = null,
permissions: ChatPermissions = ChatPermissions(), permissions: ChatPermissions = ChatPermissions()
useIndependentChatPermissions: Boolean? = permissions.isGranular.takeIf { it } ) = restrictChatMember(chatId, user.id, untilDate, permissions)
): Boolean = restrictChatMember(chatId, user.id, untilDate, permissions, useIndependentChatPermissions)
public suspend fun TelegramBot.restrictChatMember( suspend fun TelegramBot.restrictChatMember(
chat: PublicChat, chat: PublicChat,
user: User, user: User,
untilDate: TelegramDate? = null, untilDate: TelegramDate? = null,
permissions: ChatPermissions = ChatPermissions(), permissions: ChatPermissions = ChatPermissions()
useIndependentChatPermissions: Boolean? = permissions.isGranular.takeIf { it } ) = restrictChatMember(chat.id, user.id, untilDate, permissions)
): Boolean = restrictChatMember(chat.id, user.id, untilDate, permissions, useIndependentChatPermissions)

View File

@@ -2,31 +2,29 @@ package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.SetChatAdministratorCustomTitle import dev.inmo.tgbotapi.requests.chat.members.SetChatAdministratorCustomTitle
import dev.inmo.tgbotapi.types.IdChatIdentifier import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.UserId import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.User
public suspend fun TelegramBot.setChatAdministratorCustomTitle( suspend fun TelegramBot.setChatAdministratorCustomTitle(
chatId: IdChatIdentifier, chatId: ChatId,
userId: UserId, userId: UserId,
customTitle: String customTitle: String
): Boolean = execute(SetChatAdministratorCustomTitle(chatId, userId, customTitle)) ) = execute(SetChatAdministratorCustomTitle(chatId, userId, customTitle))
public suspend fun TelegramBot.setChatAdministratorCustomTitle( suspend fun TelegramBot.setChatAdministratorCustomTitle(
chat: PublicChat, chat: PublicChat,
userId: UserId, userId: UserId,
customTitle: String customTitle: String
): Boolean = setChatAdministratorCustomTitle(chat.id, userId, customTitle) ) = setChatAdministratorCustomTitle(chat.id, userId, customTitle)
public suspend fun TelegramBot.setChatAdministratorCustomTitle( suspend fun TelegramBot.setChatAdministratorCustomTitle(
chatId: IdChatIdentifier, chatId: ChatId,
user: User, user: User,
customTitle: String customTitle: String
): Boolean = setChatAdministratorCustomTitle(chatId, user.id, customTitle) ) = setChatAdministratorCustomTitle(chatId, user.id, customTitle)
public suspend fun TelegramBot.setChatAdministratorCustomTitle( suspend fun TelegramBot.setChatAdministratorCustomTitle(
chat: PublicChat, chat: PublicChat,
user: User, user: User,
customTitle: String customTitle: String
): Boolean = setChatAdministratorCustomTitle(chat.id, user.id, customTitle) ) = setChatAdministratorCustomTitle(chat.id, user.id, customTitle)

View File

@@ -2,33 +2,30 @@ package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.UnbanChatMember import dev.inmo.tgbotapi.requests.chat.members.UnbanChatMember
import dev.inmo.tgbotapi.types.IdChatIdentifier import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.User
public suspend fun TelegramBot.unbanChatMember( suspend fun TelegramBot.unbanChatMember(
chatId: ChatIdentifier, chatId: ChatIdentifier,
userId: UserId, userId: UserId,
onlyIfBanned: Boolean? = null onlyIfBanned: Boolean? = null
): Boolean = execute(UnbanChatMember(chatId, userId, onlyIfBanned)) ) = execute(UnbanChatMember(chatId, userId, onlyIfBanned))
public suspend fun TelegramBot.unbanChatMember( suspend fun TelegramBot.unbanChatMember(
chat: PublicChat, chat: PublicChat,
userId: UserId, userId: UserId,
onlyIfBanned: Boolean? = null onlyIfBanned: Boolean? = null
): Boolean = unbanChatMember(chat.id, userId, onlyIfBanned) ) = unbanChatMember(chat.id, userId, onlyIfBanned)
public suspend fun TelegramBot.unbanChatMember( suspend fun TelegramBot.unbanChatMember(
chatId: IdChatIdentifier, chatId: ChatId,
user: User, user: User,
onlyIfBanned: Boolean? = null onlyIfBanned: Boolean? = null
): Boolean = unbanChatMember(chatId, user.id, onlyIfBanned) ) = unbanChatMember(chatId, user.id, onlyIfBanned)
public suspend fun TelegramBot.unbanChatMember( suspend fun TelegramBot.unbanChatMember(
chat: PublicChat, chat: PublicChat,
user: User, user: User,
onlyIfBanned: Boolean? = null onlyIfBanned: Boolean? = null
): Boolean = unbanChatMember(chat.id, user.id, onlyIfBanned) ) = unbanChatMember(chat.id, user.id, onlyIfBanned)

View File

@@ -1,27 +1,26 @@
package dev.inmo.tgbotapi.extensions.api.chat.members package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.UnbanChatSenderChat import dev.inmo.tgbotapi.requests.chat.members.*
import dev.inmo.tgbotapi.types.IdChatIdentifier import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
import dev.inmo.tgbotapi.types.chat.PublicChat
public suspend fun TelegramBot.unbanChatSenderChat( suspend fun TelegramBot.unbanChatSenderChat(
chatId: ChatIdentifier, chatId: ChatIdentifier,
senderChatId: IdChatIdentifier senderChatId: ChatId
): Boolean = execute(UnbanChatSenderChat(chatId, senderChatId)) ) = execute(UnbanChatSenderChat(chatId, senderChatId))
public suspend fun TelegramBot.unbanChatSenderChat( suspend fun TelegramBot.unbanChatSenderChat(
chat: PublicChat, chat: PublicChat,
senderChatId: IdChatIdentifier senderChatId: ChatId
): Boolean = unbanChatSenderChat(chat.id, senderChatId) ) = unbanChatSenderChat(chat.id, senderChatId)
public suspend fun TelegramBot.unbanChatSenderChat( suspend fun TelegramBot.unbanChatSenderChat(
chatId: IdChatIdentifier, chatId: ChatId,
senderChat: PublicChat senderChat: PublicChat
): Boolean = unbanChatSenderChat(chatId, senderChat.id) ) = unbanChatSenderChat(chatId, senderChat.id)
public suspend fun TelegramBot.unbanChatSenderChat( suspend fun TelegramBot.unbanChatSenderChat(
chat: PublicChat, chat: PublicChat,
senderChat: PublicChat, senderChat: PublicChat,
): Boolean = unbanChatSenderChat(chat.id, senderChat) ) = unbanChatSenderChat(chat.id, senderChat)

View File

@@ -3,12 +3,12 @@ package dev.inmo.tgbotapi.extensions.api.chat.modify
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.modify.DeleteChatPhoto import dev.inmo.tgbotapi.requests.chat.modify.DeleteChatPhoto
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.PublicChat import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
public suspend fun TelegramBot.deleteChatPhoto( suspend fun TelegramBot.deleteChatPhoto(
chatId: ChatIdentifier chatId: ChatIdentifier
): Boolean = execute(DeleteChatPhoto(chatId)) ) = execute(DeleteChatPhoto(chatId))
public suspend fun TelegramBot.deleteChatPhoto( suspend fun TelegramBot.deleteChatPhoto(
chat: PublicChat chat: PublicChat
): Boolean = deleteChatPhoto(chat.id) ) = deleteChatPhoto(chat.id)

View File

@@ -3,28 +3,23 @@ package dev.inmo.tgbotapi.extensions.api.chat.modify
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.modify.PinChatMessage import dev.inmo.tgbotapi.requests.chat.modify.PinChatMessage
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageIdentifier
import dev.inmo.tgbotapi.types.businessConnectionId import dev.inmo.tgbotapi.types.chat.abstracts.Chat
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
public suspend fun TelegramBot.pinChatMessage( suspend fun TelegramBot.pinChatMessage(
chatId: ChatIdentifier, chatId: ChatIdentifier,
messageId: MessageId, messageId: MessageIdentifier,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
disableNotification: Boolean = false disableNotification: Boolean = false
): Boolean = execute(PinChatMessage(chatId, messageId, businessConnectionId, disableNotification)) ) = execute(PinChatMessage(chatId, messageId, disableNotification))
public suspend fun TelegramBot.pinChatMessage( suspend fun TelegramBot.pinChatMessage(
chat: Chat, chat: Chat,
messageId: MessageId, messageId: MessageIdentifier,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
disableNotification: Boolean = false disableNotification: Boolean = false
): Boolean = pinChatMessage(chat.id, messageId, businessConnectionId, disableNotification) ) = pinChatMessage(chat.id, messageId, disableNotification)
public suspend fun TelegramBot.pinChatMessage( suspend fun TelegramBot.pinChatMessage(
message: AccessibleMessage, message: Message,
businessConnectionId: BusinessConnectionId? = message.chat.id.businessConnectionId,
disableNotification: Boolean = false disableNotification: Boolean = false
): Boolean = pinChatMessage(message.chat.id, message.messageId, businessConnectionId, disableNotification) ) = pinChatMessage(message.chat.id, message.messageId, disableNotification)

View File

@@ -3,14 +3,14 @@ package dev.inmo.tgbotapi.extensions.api.chat.modify
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.modify.SetChatDescription import dev.inmo.tgbotapi.requests.chat.modify.SetChatDescription
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.PublicChat import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
public suspend fun TelegramBot.setChatDescription( suspend fun TelegramBot.setChatDescription(
chatId: ChatIdentifier, chatId: ChatIdentifier,
description: String description: String
): Boolean = execute(SetChatDescription(chatId, description)) ) = execute(SetChatDescription(chatId, description))
public suspend fun TelegramBot.setChatDescription( suspend fun TelegramBot.setChatDescription(
chat: PublicChat, chat: PublicChat,
description: String description: String
): Boolean = setChatDescription(chat.id, description) ) = setChatDescription(chat.id, description)

View File

@@ -1,17 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.modify
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.modify.SetChatMenuButton
import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.MenuButton
import dev.inmo.tgbotapi.types.chat.PrivateChat
public suspend fun TelegramBot.setChatMenuButton(
chatId: IdChatIdentifier,
menuButton: MenuButton
): Boolean = execute(SetChatMenuButton(chatId, menuButton))
public suspend fun TelegramBot.setChatMenuButton(
chat: PrivateChat,
menuButton: MenuButton
): Boolean = setChatMenuButton(chat.id, menuButton)

View File

@@ -4,16 +4,14 @@ import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.modify.SetChatPermissions import dev.inmo.tgbotapi.requests.chat.modify.SetChatPermissions
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.ChatPermissions import dev.inmo.tgbotapi.types.chat.ChatPermissions
import dev.inmo.tgbotapi.types.chat.PublicChat import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
public suspend fun TelegramBot.setDefaultChatMembersPermissions( suspend fun TelegramBot.setDefaultChatMembersPermissions(
chatId: ChatIdentifier, chatId: ChatIdentifier,
permissions: ChatPermissions, permissions: ChatPermissions
useIndependentChatPermissions: Boolean? = permissions.isGranular.takeIf { it } ) = execute(SetChatPermissions(chatId, permissions))
): Boolean = execute(SetChatPermissions(chatId, permissions, useIndependentChatPermissions))
public suspend fun TelegramBot.setDefaultChatMembersPermissions( suspend fun TelegramBot.setDefaultChatMembersPermissions(
chat: PublicChat, chat: PublicChat,
permissions: ChatPermissions, permissions: ChatPermissions
useIndependentChatPermissions: Boolean? = permissions.isGranular.takeIf { it } ) = setDefaultChatMembersPermissions(chat.id, permissions)
): Boolean = setDefaultChatMembersPermissions(chat.id, permissions, useIndependentChatPermissions)

View File

@@ -4,14 +4,14 @@ import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
import dev.inmo.tgbotapi.requests.chat.modify.SetChatPhoto import dev.inmo.tgbotapi.requests.chat.modify.SetChatPhoto
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.PublicChat import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
public suspend fun TelegramBot.setChatPhoto( suspend fun TelegramBot.setChatPhoto(
chatId: ChatIdentifier, chatId: ChatIdentifier,
photo: MultipartFile photo: MultipartFile
): Boolean = execute(SetChatPhoto(chatId, photo)) ) = execute(SetChatPhoto(chatId, photo))
public suspend fun TelegramBot.setChatPhoto( suspend fun TelegramBot.setChatPhoto(
chat: PublicChat, chat: PublicChat,
photo: MultipartFile photo: MultipartFile
): Boolean = setChatPhoto(chat.id, photo) ) = setChatPhoto(chat.id, photo)

View File

@@ -3,14 +3,14 @@ package dev.inmo.tgbotapi.extensions.api.chat.modify
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.modify.SetChatTitle import dev.inmo.tgbotapi.requests.chat.modify.SetChatTitle
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.PublicChat import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
public suspend fun TelegramBot.setChatTitle( suspend fun TelegramBot.setChatTitle(
chatId: ChatIdentifier, chatId: ChatIdentifier,
title: String title: String
): Boolean = execute(SetChatTitle(chatId, title)) ) = execute(SetChatTitle(chatId, title))
public suspend fun TelegramBot.setChatTitle( suspend fun TelegramBot.setChatTitle(
chat: PublicChat, chat: PublicChat,
title: String title: String
): Boolean = setChatTitle(chat.id, title) ) = setChatTitle(chat.id, title)

View File

@@ -1,9 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.modify
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.modify.SetDefaultChatMenuButton
import dev.inmo.tgbotapi.types.MenuButton
public suspend fun TelegramBot.setDefaultChatMenuButton(
menuButton: MenuButton
): Boolean = execute(SetDefaultChatMenuButton(menuButton))

Some files were not shown because too many files have changed in this diff Show More