mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-17 04:20:13 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| eb08732938 |
4
.github/FUNDING.yml
vendored
4
.github/FUNDING.yml
vendored
@@ -1,3 +1,5 @@
|
|||||||
# These are supported funding model platforms
|
# These are supported funding model platforms
|
||||||
|
|
||||||
custom: ['https://www.tinkoff.ru/rm/ovsyannikov.aleksey113/ObMJ712472']
|
patreon: InsanusMokrassar
|
||||||
|
|
||||||
|
custom: ['https://paypal.me/InsanusMokrassar?locale.x=ru_RU']
|
||||||
|
|||||||
11
.github/dependabot.yml
vendored
11
.github/dependabot.yml
vendored
@@ -1,11 +0,0 @@
|
|||||||
# To get started with Dependabot version updates, you'll need to specify which
|
|
||||||
# package ecosystems to update and where the package manifests are located.
|
|
||||||
# Please see the documentation for all configuration options:
|
|
||||||
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
|
||||||
|
|
||||||
version: 2
|
|
||||||
updates:
|
|
||||||
- package-ecosystem: "gradle" # See documentation for possible values
|
|
||||||
directory: "/tgbotapi.core" # Location of package manifests
|
|
||||||
schedule:
|
|
||||||
interval: "daily"
|
|
||||||
8
.github/labeler.yml
vendored
8
.github/labeler.yml
vendored
@@ -1,8 +1,6 @@
|
|||||||
api: "TelegramBotAPI-api/**"
|
api: "TelegramBotAPI-extensions-api/**"
|
||||||
utils: "TelegramBotAPI-utils/**"
|
utils: "TelegramBotAPI-extensions-utils/**"
|
||||||
behaviour-builder: "TelegramBotAPI-behaviour_builder/**"
|
core: "TelegramBotAPI/**" # currently not work
|
||||||
behaviour-builder_fsm: "TelegramBotAPI-behaviour_builder-fsm/**"
|
|
||||||
core: "TelegramBotAPI-core/**" # currently not work
|
|
||||||
|
|
||||||
code: "**/*.kt"
|
code: "**/*.kt"
|
||||||
gradle: "**/*.gradle"
|
gradle: "**/*.gradle"
|
||||||
|
|||||||
21
.github/workflows/kdocs.yml
vendored
21
.github/workflows/kdocs.yml
vendored
@@ -1,21 +0,0 @@
|
|||||||
name: Publish KDocs
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
jobs:
|
|
||||||
publishing:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: actions/setup-java@v1
|
|
||||||
with:
|
|
||||||
java-version: 11
|
|
||||||
- name: Build
|
|
||||||
run: ./gradlew dokkaHtml
|
|
||||||
- name: Publish KDocs
|
|
||||||
uses: peaceiris/actions-gh-pages@v3
|
|
||||||
with:
|
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
publish_dir: ./docs/build/dokka/html
|
|
||||||
publish_branch: kdocs
|
|
||||||
1
.github/workflows/label.yml
vendored
1
.github/workflows/label.yml
vendored
@@ -12,7 +12,6 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
triage:
|
triage:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: ${{ github.actor == github.repository_owner }}
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/labeler@v2
|
- uses: actions/labeler@v2
|
||||||
with:
|
with:
|
||||||
|
|||||||
24
.github/workflows/packages_publishing.yml
vendored
24
.github/workflows/packages_publishing.yml
vendored
@@ -1,24 +0,0 @@
|
|||||||
name: Publish package to GitHub Packages
|
|
||||||
on: [push]
|
|
||||||
jobs:
|
|
||||||
publishing:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: actions/setup-java@v1
|
|
||||||
with:
|
|
||||||
java-version: 11
|
|
||||||
- name: Rewrite version
|
|
||||||
run: |
|
|
||||||
branch="`echo "${{ github.ref }}" | grep -o "[^/]*$"`"
|
|
||||||
cat gradle.properties | sed -e "s/^library_version=\([0-9\.]*\)/library_version=\1-branch_$branch-build${{ github.run_number }}/" > gradle.properties.tmp
|
|
||||||
rm gradle.properties
|
|
||||||
mv gradle.properties.tmp gradle.properties
|
|
||||||
- name: Build
|
|
||||||
run: ./gradlew build
|
|
||||||
- name: Publish
|
|
||||||
continue-on-error: true
|
|
||||||
run: ./gradlew publishAllPublicationsToGithubPackagesRepository --no-parallel
|
|
||||||
env:
|
|
||||||
GITHUBPACKAGES_USER: ${{ github.actor }}
|
|
||||||
GITHUBPACKAGES_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
1
.github/write-good.yml
vendored
Normal file
1
.github/write-good.yml
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
spellchecker: true
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -10,5 +10,4 @@ build/
|
|||||||
out/
|
out/
|
||||||
|
|
||||||
local.properties
|
local.properties
|
||||||
kotlin-js-store/
|
|
||||||
secret.gradle
|
secret.gradle
|
||||||
|
|||||||
1290
CHANGELOG.md
1290
CHANGELOG.md
File diff suppressed because it is too large
Load Diff
210
README.md
210
README.md
@@ -1,111 +1,137 @@
|
|||||||
# TelegramBotAPI [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#april-16-2022)
|
# TelegramBotAPI
|
||||||
|
|
||||||
| [](https://github.com/KotlinBy/awesome-kotlin) [](https://github.com/InsanusMokrassar/TelegramBotAPI/actions) [](https://docs.google.com/forms/d/e/1FAIpQLSctdJHT_aEniyYT0-IUAEfo1hsIlezX2owlkEAYX4KPl2V2_A/viewform?usp=sf_link) [](https://t.me/InMoTelegramBotAPI) |
|
| Common info | [](https://github.com/KotlinBy/awesome-kotlin) [](https://travis-ci.com/InsanusMokrassar/TelegramBotAPI) [Small survey](https://forms.gle/2Hex2ynbHWHhi1KY7)|
|
||||||
|:---:|
|
| -------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||||
| [](https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template/generate) [](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/) [](https://tgbotapi.inmo.dev/index.html) [](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) |
|
| Useful links | [](https://t.me/InMoTelegramBotAPI) [](https://tgbotapi.inmo.dev/docs/index.html) [Examples](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/), [Mini tutorial](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) |
|
||||||
|
| TelegramBotAPI Core status | [](https://bintray.com/insanusmokrassar/TelegramBotAPI/tgbotapi.core/_latestVersion) [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.core) |
|
||||||
|
| TelegramBotAPI Extensions status | [](https://bintray.com/insanusmokrassar/TelegramBotAPI/tgbotapi.extensions.api/_latestVersion) [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.api) |
|
||||||
|
| TelegramBotAPI Util Extensions status | [](https://bintray.com/insanusmokrassar/TelegramBotAPI/tgbotapi.extensions.utils/_latestVersion) [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.utils) |
|
||||||
|
| TelegramBotAPI All status | [](https://bintray.com/insanusmokrassar/TelegramBotAPI/tgbotapi/_latestVersion) [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) |
|
||||||
|
|
||||||
Hello! This is a set of libraries for working with Telegram Bot API.
|
**At the time of publication of version `0.28.0` there are errors in serialization plugins like
|
||||||
|
[kotlinx.serialization#1004](https://github.com/Kotlin/kotlinx.serialization/issues/1004). It is possible, that both JVM
|
||||||
|
and JS version may work improperly in some cases with `kotlinx.serialization` version `1.0.0-RC`**
|
||||||
|
|
||||||
## Examples
|
|
||||||
|
|
||||||
There are several things you need to do to launch examples below:
|
It is a complex of libraries for working with `TelegramBotAPI` in type-safe and strict way as much as it possible. In
|
||||||
|
the list of this complex currently next projects:
|
||||||
|
|
||||||
* Add `mavenCentral()` to your project repositories
|
* [TelegramBotAPI Core](tgbotapi.core/README.md) - core of library. In fact it is independent library and can be used alone
|
||||||
* [Maven variant](https://github.com/InsanusMokrassar/TelegramBotAPI/wiki/Including-in-your-project#pomxml)
|
without any additional library
|
||||||
* Add dependency `implementation "dev.inmo:tgbotapi:$tgbotapi_version"`
|
* [TelegramBotAPI API Extensions](tgbotapi.extensions.api/README.md) - contains extensions (mostly for
|
||||||
* Replace `tgbotapi_version` with exact version (see last one in the table above) or put variable with this name in project
|
`RequestsExecutor`), which allows to use the core library in more pleasant way
|
||||||
* Alternative variant for maven [here](https://github.com/InsanusMokrassar/TelegramBotAPI/wiki/Including-in-your-project#telegrambotapi)
|
* [TelegramBotAPI Util Extensions](tgbotapi.extensions.utils/README.md) - contains extensions for more comfortable
|
||||||
|
work with commands, updates and other different things
|
||||||
|
* [TelegramBotAPI](tgbotapi/README.md) - concentration of all previously mentioned libraries
|
||||||
|
|
||||||
More including instructions [available here](https://github.com/InsanusMokrassar/TelegramBotAPI/wiki/Including-in-your-project).
|
Most part of some specific solves or unuseful
|
||||||
Other configuration examples:
|
moments are describing by official [Telegram Bot API](https://core.telegram.org/bots/api).
|
||||||
|
|
||||||
* [For multiplatform](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/tree/master/ResenderBot)
|
## JavaScript notes
|
||||||
* [For JVM](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/blob/master/GetMeBot/build.gradle)
|
|
||||||
|
|
||||||
### Most common example
|
### Versions before `0.28.0`
|
||||||
|
|
||||||
```kotlin
|
In case if you are want to use this library inside of browser, you will need additional settings (thanks for help to [Alexander Nozik](https://research.jetbrains.org/researchers/altavir)):
|
||||||
suspend fun main() {
|
|
||||||
val bot = telegramBot(TOKEN)
|
|
||||||
|
|
||||||
bot.buildBehaviourWithLongPolling {
|
<details>
|
||||||
println(getMe())
|
<summary>Gradle build script help (for versions before 0.28.0)</summary>
|
||||||
|
|
||||||
onCommand("start") {
|
```groovy
|
||||||
reply(it, "Hi:)")
|
dependencies {
|
||||||
}
|
/* ... */
|
||||||
}.join()
|
|
||||||
|
implementation "com.github.insanusmokrassar:TelegramBotAPI:$tgbot_api_version"
|
||||||
|
implementation "com.github.insanusmokrassar:TelegramBotAPI-extensions-api:$tgbot_api_version" // optional
|
||||||
|
implementation "com.github.insanusmokrassar:TelegramBotAPI-extensions-utils:$tgbot_api_version" // optional
|
||||||
|
|
||||||
|
/* Block of dependencies for correct building in browser */
|
||||||
|
implementation(npm("fs"))
|
||||||
|
implementation(npm("bufferutil"))
|
||||||
|
implementation(npm("utf-8-validate"))
|
||||||
|
implementation(npm("abort-controller"))
|
||||||
|
implementation(npm("text-encoding"))
|
||||||
}
|
}
|
||||||
```
|
|
||||||
|
|
||||||
In this example you will see information about this bot at the moment of starting and answer with `Hi:)` every time it
|
/* ... */
|
||||||
gets message `/start`
|
|
||||||
|
|
||||||
### Handling only last messages
|
kotlin {
|
||||||
|
target {
|
||||||
```kotlin
|
browser {
|
||||||
suspend fun main() {
|
/* Block for fix of exception in absence of some functionality, https://github.com/ktorio/ktor/issues/1339 */
|
||||||
val bot = telegramBot(TOKEN)
|
dceTask {
|
||||||
|
dceOptions {
|
||||||
val flowsUpdatesFilter = FlowsUpdatesFilter()
|
keep("ktor-ktor-io.\$\$importsForInline\$\$.ktor-ktor-io.io.ktor.utils.io")
|
||||||
bot.buildBehaviour(flowUpdatesFilter = flowsUpdatesFilter) {
|
}
|
||||||
println(getMe())
|
}
|
||||||
|
|
||||||
onCommand("start") {
|
|
||||||
reply(it, "Hi:)")
|
|
||||||
}
|
|
||||||
|
|
||||||
retrieveAccumulatedUpdates(this).join()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
The main difference with the previous example is that bot will get only last updates (accumulated before bot launch
|
|
||||||
and maybe some updates it got after launch)
|
|
||||||
|
|
||||||
### Build a little bit more complex behaviour
|
|
||||||
|
|
||||||
```kotlin
|
|
||||||
suspend fun main() {
|
|
||||||
val bot = telegramBot(TOKEN)
|
|
||||||
|
|
||||||
bot.buildBehaviourWithLongPolling {
|
|
||||||
println(getMe())
|
|
||||||
|
|
||||||
val nameReplyMarkup = ReplyKeyboardMarkup(
|
|
||||||
matrix {
|
|
||||||
row {
|
|
||||||
+SimpleKeyboardButton("nope")
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
)
|
|
||||||
onCommand("start") {
|
|
||||||
val photo = waitPhoto(
|
|
||||||
SendTextMessage(it.chat.id, "Send me your photo please")
|
|
||||||
).first()
|
|
||||||
|
|
||||||
val name = waitText(
|
|
||||||
SendTextMessage(
|
|
||||||
it.chat.id,
|
|
||||||
"Send me your name or choose \"nope\"",
|
|
||||||
replyMarkup = nameReplyMarkup
|
|
||||||
)
|
|
||||||
).first().text.takeIf { it != "nope" }
|
|
||||||
|
|
||||||
sendPhoto(
|
|
||||||
it.chat,
|
|
||||||
photo.mediaCollection,
|
|
||||||
entities = buildEntities {
|
|
||||||
if (name != null) regular(name) // may be collapsed up to name ?.let(::regular)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}.join()
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### More examples
|
</details>
|
||||||
|
|
||||||
You may find examples in [this project](https://github.com/InsanusMokrassar/TelegramBotAPI-examples). Besides, you are
|
## Ok, where should I start?
|
||||||
always welcome in our [wiki](https://github.com/InsanusMokrassar/TelegramBotAPI/wiki/About-this-project) and
|
|
||||||
[chat](https://t.me/InMoTelegramBotAPIChat).
|

|
||||||
|
|
||||||
|
In most cases, the most simple way will be to implement [TelegramBotAPI](TelegramBotAPI/README.md) - it contains
|
||||||
|
all necessary tools for comfort usage of this library. If you want to exclude some libraries, you can implement just
|
||||||
|
[TelegramBotAPI API Extensions](tgbotapi.extensions.api/README.md),
|
||||||
|
[TelegramBotAPI Util Extensions](tgbotapi.extensions.utils/README.md) or even
|
||||||
|
[TelegramBotAPI Core](tgbotapi.core/README.md).
|
||||||
|
|
||||||
|
If you want to dive deeper in the core of library or develop something for it - welcome to learn more from
|
||||||
|
[TelegramBotAPI Core](tgbotapi.core/README.md) and our [Telegram Chat](https://teleg.one/InMoTelegramBotAPIChat).
|
||||||
|
|
||||||
|
Anyway, all libraries are very typical inside of them. Examples:
|
||||||
|
|
||||||
|
* In `TelegramBotAPI` common request look like `requestsExecutor.execute(SomeRequest())`
|
||||||
|
* `tgbotapi.extensions.api` typical syntax look like `requestsExecutor.someRequest()` (in most cases it would be
|
||||||
|
better to use `bot` name instead of `requestsExecutor`)
|
||||||
|
* `tgbotapi.extensions.utils` will look like `filter.filterBaseMessageUpdates(chatId).filterExactCommands(Regex("^.*$"))...`
|
||||||
|
|
||||||
|
## Build instruction
|
||||||
|
|
||||||
|
If you want to build this project or to contribute, there are several recommendations:
|
||||||
|
|
||||||
|
### Build
|
||||||
|
|
||||||
|
In case if you want to just build project, run next command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./gradlew clean build
|
||||||
|
```
|
||||||
|
|
||||||
|
On windows:
|
||||||
|
|
||||||
|
```
|
||||||
|
gradlew.bat clean build
|
||||||
|
```
|
||||||
|
|
||||||
|
### Publishing for work with your version locally
|
||||||
|
|
||||||
|
In case, if you want to work in your other projects using your modification (or some state) of this library,
|
||||||
|
you can use next code:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./gradlew clean build publishToMavenLocal
|
||||||
|
```
|
||||||
|
|
||||||
|
On windows:
|
||||||
|
|
||||||
|
```
|
||||||
|
gradlew.bat clean build publishToMavenLocal
|
||||||
|
```
|
||||||
|
|
||||||
|
But you must remember, that in this case your local maven repo must be the first one from
|
||||||
|
your project retrieving libraries:
|
||||||
|
|
||||||
|
```groovy
|
||||||
|
repositories {
|
||||||
|
mavenLocal() // that must be the first one
|
||||||
|
jcenter()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Besides, for your own version you can change variable `library_version` in the file [gradle.properties](./gradle.properties).
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
125
TelegramBotAPI.minder
Normal file
125
TelegramBotAPI.minder
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<minder version="1.11.1">
|
||||||
|
<theme name="default" label="Default" index="-1"/>
|
||||||
|
<styles>
|
||||||
|
<style level="0" isset="true" branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="200" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true" connectiondash="dotted" connectionlwidth="2" connectionarrow="fromto" connectionpadding="3" connectionfont="Sans 10" connectiontwidth="100"/>
|
||||||
|
<style level="1" isset="true" branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="200" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true" connectiondash="dotted" connectionlwidth="2" connectionarrow="fromto" connectionpadding="3" connectionfont="Sans 10" connectiontwidth="100"/>
|
||||||
|
<style level="2" isset="true" branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="200" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true" connectiondash="dotted" connectionlwidth="2" connectionarrow="fromto" connectionpadding="3" connectionfont="Sans 10" connectiontwidth="100"/>
|
||||||
|
<style level="3" isset="true" branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="200" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true" connectiondash="dotted" connectionlwidth="2" connectionarrow="fromto" connectionpadding="3" connectionfont="Sans 10" connectiontwidth="100"/>
|
||||||
|
<style level="4" isset="true" branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="200" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true" connectiondash="dotted" connectionlwidth="2" connectionarrow="fromto" connectionpadding="3" connectionfont="Sans 10" connectiontwidth="100"/>
|
||||||
|
<style level="5" isset="true" branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="200" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true" connectiondash="dotted" connectionlwidth="2" connectionarrow="fromto" connectionpadding="3" connectionfont="Sans 10" connectiontwidth="100"/>
|
||||||
|
<style level="6" isset="true" branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="200" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true" connectiondash="dotted" connectionlwidth="2" connectionarrow="fromto" connectionpadding="3" connectionfont="Sans 10" connectiontwidth="100"/>
|
||||||
|
<style level="7" isset="true" branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="200" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true" connectiondash="dotted" connectionlwidth="2" connectionarrow="fromto" connectionpadding="3" connectionfont="Sans 10" connectiontwidth="100"/>
|
||||||
|
<style level="8" isset="true" branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="200" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true" connectiondash="dotted" connectionlwidth="2" connectionarrow="fromto" connectionpadding="3" connectionfont="Sans 10" connectiontwidth="100"/>
|
||||||
|
<style level="9" isset="true" branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="200" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true" connectiondash="dotted" connectionlwidth="2" connectionarrow="fromto" connectionpadding="3" connectionfont="Sans 10" connectiontwidth="100"/>
|
||||||
|
<style level="10" isset="true" branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="200" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true" connectiondash="dotted" connectionlwidth="2" connectionarrow="fromto" connectionpadding="3" connectionfont="Sans 10" connectiontwidth="100"/>
|
||||||
|
</styles>
|
||||||
|
<drawarea x="-320.56697591145837" y="-10.028254191080691" scale="0.75"/>
|
||||||
|
<images/>
|
||||||
|
<nodes>
|
||||||
|
<node id="0" posx="748.88964843749955" posy="119.42341613769531" width="472" height="168" side="top" fold="false" treesize="603" layout="Downwards" group="false">
|
||||||
|
<style branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="439" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true"/>
|
||||||
|
<nodename posx="764.88964843749955" posy="135.42341613769531" maxwidth="488.96484375">
|
||||||
|
<text data="tgbotapi.core Root project with API. It is not recommended to use its requests directly and better to use at least tgbotapi.extensions.api"/>
|
||||||
|
</nodename>
|
||||||
|
<nodenote></nodenote>
|
||||||
|
<nodes>
|
||||||
|
<node id="1" posx="781.88964843749955" posy="387.42341613769531" width="406" height="145" side="bottom" fold="false" treesize="603" color="#68b723" colorroot="true" layout="Downwards" group="false">
|
||||||
|
<style branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="none" nodewidth="394" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true"/>
|
||||||
|
<nodename posx="797.88964843749955" posy="403.42341613769531" maxwidth="419.451171875">
|
||||||
|
<text data="TelegramBotAPI extensions Family of projects which are fully based on TelegramBotAPI and extend its functionality"/>
|
||||||
|
</nodename>
|
||||||
|
<nodenote></nodenote>
|
||||||
|
<nodes>
|
||||||
|
<node id="2" posx="683.38964843749955" posy="632.42341613769531" width="296" height="191" side="bottom" fold="false" treesize="296" color="#68b723" colorroot="true" layout="Downwards" group="false">
|
||||||
|
<style branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="203" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true"/>
|
||||||
|
<nodename posx="699.38964843749955" posy="648.42341613769531" maxwidth="295.90315755208337">
|
||||||
|
<text data="tgbotapi.extensions.api Extensions project for make requests more look like in the Telegram Bot API and give opportunity to use it's easier"/>
|
||||||
|
</nodename>
|
||||||
|
<nodenote></nodenote>
|
||||||
|
</node>
|
||||||
|
<node id="3" posx="979.38964843749955" posy="632.42341613769531" width="307" height="168" side="bottom" fold="false" treesize="307" color="#68b723" colorroot="true" layout="Downwards" group="false">
|
||||||
|
<style branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="286" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true"/>
|
||||||
|
<nodename posx="995.38964843749955" posy="648.42341613769531" maxwidth="299.252197265625">
|
||||||
|
<text data="tgbotapi.extensions.utils Extensions project with utils things which will make easier different operations"/>
|
||||||
|
</nodename>
|
||||||
|
<nodenote></nodenote>
|
||||||
|
</node>
|
||||||
|
</nodes>
|
||||||
|
</node>
|
||||||
|
</nodes>
|
||||||
|
</node>
|
||||||
|
<node id="4" posx="815.52319335937455" posy="948.04447937011719" width="329" height="213" side="top" fold="false" treesize="329" layout="Downwards" group="false">
|
||||||
|
<style branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="388" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true"/>
|
||||||
|
<nodename posx="831.52319335937455" posy="964.04447937011719" maxwidth="394.3671875">
|
||||||
|
<text data="tgbotapi Here included all available TelegramBotAPI libraries: * tgbotapi.core * tgbotapi.extensions.api * tgbotapi.extensions.utils">
|
||||||
|
<color>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="67" end="68" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="84" end="85" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
<range start="111" end="112" extra="rgb(255,0,0)"/>
|
||||||
|
</color>
|
||||||
|
</text>
|
||||||
|
</nodename>
|
||||||
|
<nodenote></nodenote>
|
||||||
|
</node>
|
||||||
|
</nodes>
|
||||||
|
<groups/>
|
||||||
|
<connections>
|
||||||
|
<connection from_id="2" to_id="4" drag_x="905.70642089843705" drag_y="891.23394775390625" color="#777777">
|
||||||
|
<style connectiondash="dotted" connectionlwidth="2" connectionarrow="fromto" connectionpadding="3" connectionfont="Sans 10" connectiontwidth="100"/>
|
||||||
|
<title></title>
|
||||||
|
<note></note>
|
||||||
|
</connection>
|
||||||
|
<connection from_id="3" to_id="4" drag_x="1056.456420898437" drag_y="885.48394775390625" color="#777777">
|
||||||
|
<style connectiondash="dotted" connectionlwidth="2" connectionarrow="fromto" connectionpadding="3" connectionfont="Sans 10" connectiontwidth="100"/>
|
||||||
|
<title></title>
|
||||||
|
<note></note>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
<stickers/>
|
||||||
|
</minder>
|
||||||
20
badges/chat.svg
Normal file
20
badges/chat.svg
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="104" height="20">
|
||||||
|
<linearGradient id="b" x2="0" y2="100%">
|
||||||
|
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||||
|
<stop offset="1" stop-opacity=".1"/>
|
||||||
|
</linearGradient>
|
||||||
|
<clipPath id="a">
|
||||||
|
<rect width="104" height="20" rx="3" fill="#fff"/>
|
||||||
|
</clipPath>
|
||||||
|
<g clip-path="url(#a)">
|
||||||
|
<path fill="#555" d="M0 0h65v20H0z"/>
|
||||||
|
<path fill="#007ec6" d="M35 0h69v20H35z"/>
|
||||||
|
<path fill="url(#b)" d="M0 0h104v20H0z"/>
|
||||||
|
</g>
|
||||||
|
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110">
|
||||||
|
<text x="175" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)">Talk</text>
|
||||||
|
<text x="175" y="140" transform="scale(.1)">Talk</text>
|
||||||
|
<text x="690" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)">Telegram</text>
|
||||||
|
<text x="690" y="140" transform="scale(.1)">Telegram</text>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1018 B |
20
badges/kdocs.svg
Normal file
20
badges/kdocs.svg
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="104" height="20">
|
||||||
|
<linearGradient id="b" x2="0" y2="100%">
|
||||||
|
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||||
|
<stop offset="1" stop-opacity=".1"/>
|
||||||
|
</linearGradient>
|
||||||
|
<clipPath id="a">
|
||||||
|
<rect width="104" height="20" rx="3" fill="#fff"/>
|
||||||
|
</clipPath>
|
||||||
|
<g clip-path="url(#a)">
|
||||||
|
<path fill="#555" d="M0 0h65v20H0z"/>
|
||||||
|
<path fill="#007ec6" d="M45 0h69v20H45z"/>
|
||||||
|
<path fill="url(#b)" d="M0 0h104v20H0z"/>
|
||||||
|
</g>
|
||||||
|
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110">
|
||||||
|
<text x="225" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)">Open</text>
|
||||||
|
<text x="225" y="140" transform="scale(.1)">Open</text>
|
||||||
|
<text x="740" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)">KDocs</text>
|
||||||
|
<text x="740" y="140" transform="scale(.1)">KDocs</text>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1012 B |
13
build.gradle
13
build.gradle
@@ -1,6 +1,7 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
|
jcenter()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven { url "https://plugins.gradle.org/m2/" }
|
maven { url "https://plugins.gradle.org/m2/" }
|
||||||
}
|
}
|
||||||
@@ -8,6 +9,7 @@ buildscript {
|
|||||||
dependencies {
|
dependencies {
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
||||||
|
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version"
|
||||||
classpath "com.github.breadmoirai:github-release:$github_release_plugin_version"
|
classpath "com.github.breadmoirai:github-release:$github_release_plugin_version"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17,17 +19,6 @@ plugins {
|
|||||||
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" apply false
|
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
// temporal crutch until legacy tests will be stabled or legacy target will be removed
|
|
||||||
allprojects {
|
|
||||||
if (it != rootProject.findProject("docs")) {
|
|
||||||
tasks.whenTaskAdded { task ->
|
|
||||||
if(task.name == "jsLegacyBrowserTest" || task.name == "jsLegacyNodeTest") {
|
|
||||||
task.enabled = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getCurrentVersionChangelog() {
|
private String getCurrentVersionChangelog() {
|
||||||
OutputStream changelogDataOS = new ByteArrayOutputStream()
|
OutputStream changelogDataOS = new ByteArrayOutputStream()
|
||||||
exec {
|
exec {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
|
jcenter()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,18 +20,13 @@ plugins {
|
|||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
|
jcenter()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
jvm {
|
jvm()
|
||||||
compilations.main {
|
js(BOTH) {
|
||||||
kotlinOptions {
|
|
||||||
jvmTarget = "1.8"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
js(IR) {
|
|
||||||
browser()
|
browser()
|
||||||
nodejs()
|
nodejs()
|
||||||
}
|
}
|
||||||
@@ -40,33 +36,39 @@ kotlin {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation kotlin('stdlib')
|
implementation kotlin('stdlib')
|
||||||
|
|
||||||
api project(":tgbotapi.core")
|
project.parent.subprojects.forEach {
|
||||||
api project(":tgbotapi.api")
|
if (it != project) {
|
||||||
api project(":tgbotapi.utils")
|
api it
|
||||||
api project(":tgbotapi.behaviour_builder")
|
}
|
||||||
api project(":tgbotapi.behaviour_builder.fsm")
|
}
|
||||||
api project(":tgbotapi")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
jsMain {
|
|
||||||
dependencies {
|
|
||||||
api project(":tgbotapi.webapps")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<SourceDirectorySet> findSourcesWithName(String... approximateNames) {
|
private Closure includeSourcesInDokka(String... approximateNames) {
|
||||||
return parent.subprojects
|
return {
|
||||||
.findAll { it != project }
|
parent.subprojects.forEach {
|
||||||
.collectMany { it.kotlin.sourceSets }
|
if (it != project) {
|
||||||
.findAll { sourceSet -> approximateNames.any {
|
File srcDir = new File(it.projectDir.absolutePath, "src")
|
||||||
nameToFilter -> sourceSet.name.contains(nameToFilter)
|
if (srcDir.exists() && srcDir.isDirectory()) {
|
||||||
|
srcDir.eachFile { file ->
|
||||||
|
if (approximateNames.any { file.name.contains(it) } && file.isDirectory()) {
|
||||||
|
String pathToSrc = file.absolutePath
|
||||||
|
sourceRoot {
|
||||||
|
path = pathToSrc
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}.collect { it.kotlin }
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Object callback = {
|
dokka {
|
||||||
|
outputFormat = 'html'
|
||||||
|
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case project.hasProperty("DOKKA_PATH"):
|
case project.hasProperty("DOKKA_PATH"):
|
||||||
outputDirectory = project.property("DOKKA_PATH").toString()
|
outputDirectory = project.property("DOKKA_PATH").toString()
|
||||||
@@ -76,35 +78,19 @@ Object callback = {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
dokkaSourceSets {
|
multiplatform {
|
||||||
configureEach {
|
global {
|
||||||
skipDeprecated.set(true)
|
skipDeprecated = true
|
||||||
|
|
||||||
sourceLink {
|
sourceLink {
|
||||||
localDirectory.set(file("./"))
|
path = "./"
|
||||||
remoteUrl.set(new URL("https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/"))
|
url = "https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/"
|
||||||
remoteLineSuffix.set("#L")
|
lineSuffix = "#L"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
named("commonMain") {
|
common(includeSourcesInDokka("commonMain"))
|
||||||
sourceRoots.setFrom(findSourcesWithName("commonMain"))
|
js(includeSourcesInDokka("jsMain"/*, "commonMain"*/))
|
||||||
}
|
jvm(includeSourcesInDokka("jvmMain"/*, "commonMain"*/))
|
||||||
|
|
||||||
named("jsMain") {
|
|
||||||
sourceRoots.setFrom(findSourcesWithName("jsMain"))
|
|
||||||
}
|
|
||||||
|
|
||||||
named("jvmMain") {
|
|
||||||
sourceRoots.setFrom(findSourcesWithName("jvmMain"))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.dokkaGfm(callback)
|
|
||||||
tasks.dokkaHtml(callback)
|
|
||||||
|
|
||||||
java {
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
|
dokka_version=0.10.1
|
||||||
|
|
||||||
org.gradle.jvmargs=-Xmx1024m
|
org.gradle.jvmargs=-Xmx1024m
|
||||||
|
|||||||
@@ -1,25 +1,21 @@
|
|||||||
org.gradle.jvmargs=-Xmx2048m
|
org.gradle.jvmargs=-Xmx1024m
|
||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
org.gradle.parallel=true
|
org.gradle.parallel=true
|
||||||
kotlin.js.generate.externals=true
|
kotlin.js.generate.externals=true
|
||||||
kotlin.incremental=true
|
kotlin.incremental=true
|
||||||
kotlin.incremental.js=true
|
kotlin.incremental.js=true
|
||||||
|
|
||||||
kotlin_version=1.6.21
|
kotlin_version=1.4.10
|
||||||
kotlin_coroutines_version=1.6.1
|
kotlin_coroutines_version=1.3.9
|
||||||
kotlin_serialisation_runtime_version=1.3.3
|
kotlin_serialisation_runtime_version=1.0.0
|
||||||
korlibs_version=2.7.0
|
klock_version=1.12.1
|
||||||
uuid_version=0.4.0
|
uuid_version=0.2.2
|
||||||
ktor_version=2.0.1
|
ktor_version=1.4.1
|
||||||
|
|
||||||
micro_utils_version=0.10.5
|
|
||||||
|
|
||||||
javax_activation_version=1.1.1
|
javax_activation_version=1.1.1
|
||||||
|
|
||||||
|
|
||||||
dokka_version=1.6.21
|
|
||||||
|
|
||||||
library_group=dev.inmo
|
library_group=dev.inmo
|
||||||
library_version=2.0.0
|
library_version=0.29.1
|
||||||
|
|
||||||
github_release_plugin_version=2.3.7
|
gradle_bintray_plugin_version=1.8.5
|
||||||
|
github_release_plugin_version=2.2.12
|
||||||
|
|||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
|
|||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
|
||||||
|
|||||||
@@ -1,79 +0,0 @@
|
|||||||
apply plugin: 'maven-publish'
|
|
||||||
|
|
||||||
task javadocsJar(type: Jar) {
|
|
||||||
classifier = '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('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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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/TelegramBotAPI"},{"name":"sonatype","url":"https://oss.sonatype.org/service/local/staging/deploy/maven2/"}],"gpgSigning":{"type":"dev.inmo.kmppscriptbuilder.core.models.GpgSigning.Optional"}}}
|
|
||||||
@@ -1,97 +0,0 @@
|
|||||||
# Exceptions handling
|
|
||||||
|
|
||||||
Unfortunatelly, exceptions handling in this library is a bit difficult in some places, but that have at least two reasons: flexibility and usability.
|
|
||||||
|
|
||||||
## "In place" handling
|
|
||||||
|
|
||||||
In case you know, where exceptions are happening, you may use several tools for exceptions catching:
|
|
||||||
|
|
||||||
* Catching with result
|
|
||||||
* Catching with callback
|
|
||||||
|
|
||||||
### Catching with result
|
|
||||||
|
|
||||||
If you prefer to receive `Result` objects instead of some weird callbacks, you may use the next syntax:
|
|
||||||
|
|
||||||
```kotlin
|
|
||||||
safelyWithResult {
|
|
||||||
// do something
|
|
||||||
}.onSuccess { // will be called if everything is right
|
|
||||||
// handle success
|
|
||||||
}.onFailure { // will be called if something went wrong
|
|
||||||
// handle error
|
|
||||||
it.printStackTrace()
|
|
||||||
}.getOrThrow() // will return value or throw exception
|
|
||||||
```
|
|
||||||
|
|
||||||
### Catching with callback
|
|
||||||
|
|
||||||
Also there is more simple (in some cases) way to handle exceptions with callbacks:
|
|
||||||
|
|
||||||
```kotlin
|
|
||||||
safely(
|
|
||||||
{
|
|
||||||
// handle error
|
|
||||||
it.printStackTrace()
|
|
||||||
null // return value
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
// do something
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Bonus: different types of handling
|
|
||||||
|
|
||||||
There are two types of handling:
|
|
||||||
|
|
||||||
* Just safely - when you are using something to obviously retrieve value or throw exception. When handling callback has been skipped, it will throw exception by default. For example:
|
|
||||||
```kotlin
|
|
||||||
safely(
|
|
||||||
{
|
|
||||||
it.printStackTrace()
|
|
||||||
"error"
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
error("Hi :)") // emulate exception throwing
|
|
||||||
"ok"
|
|
||||||
} // result will be with type String
|
|
||||||
```
|
|
||||||
* Safely without exceptions - almost the same as `safely`, but this type by default allow to return nullable value (when exception was thrown) instead of just throwing (as with `safely`):
|
|
||||||
```kotlin
|
|
||||||
safelyWithouExceptions {
|
|
||||||
// do something
|
|
||||||
} // will returns nullable result type
|
|
||||||
```
|
|
||||||
|
|
||||||
## Global exceptions handling
|
|
||||||
|
|
||||||
The most simple way to configure exceptions handling is to change `CoroutineContext` when you are creating your `CoroutineScope` for bot processing:
|
|
||||||
|
|
||||||
```kotlin
|
|
||||||
val bot = telegramBot("TOKEN")
|
|
||||||
|
|
||||||
bot.buildBehaviour (
|
|
||||||
scope = scope,
|
|
||||||
defaultExceptionsHandler = {
|
|
||||||
it.printStackTrace()
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
OR
|
|
||||||
|
|
||||||
```kotlin
|
|
||||||
val bot = telegramBotWithBehaviour (
|
|
||||||
"TOKEN",
|
|
||||||
scope = scope,
|
|
||||||
defaultExceptionsHandler = {
|
|
||||||
it.printStackTrace()
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Here we have used `ContextSafelyExceptionHandler` class. It will pass default handling of exceptions and will call the block in most cases when something inside of your bot logic has thrown exception.
|
|
||||||
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 80 KiB |
@@ -1,21 +1,5 @@
|
|||||||
pluginManagement {
|
|
||||||
resolutionStrategy {
|
|
||||||
eachPlugin {
|
|
||||||
if (requested.id.id == "org.jetbrains.dokka") {
|
|
||||||
useModule("org.jetbrains.dokka:dokka-gradle-plugin:${requested.version}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
repositories {
|
|
||||||
gradlePluginPortal()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
include ":tgbotapi.core"
|
include ":tgbotapi.core"
|
||||||
include ":tgbotapi.api"
|
include ":tgbotapi.extensions.api"
|
||||||
include ":tgbotapi.utils"
|
include ":tgbotapi.extensions.utils"
|
||||||
include ":tgbotapi.behaviour_builder"
|
|
||||||
include ":tgbotapi.behaviour_builder.fsm"
|
|
||||||
include ":tgbotapi"
|
include ":tgbotapi"
|
||||||
include ":tgbotapi.webapps"
|
|
||||||
include ":docs"
|
include ":docs"
|
||||||
|
|||||||
@@ -1,116 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.ktor.telegramBot
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
|
||||||
import dev.inmo.tgbotapi.utils.telegramBotAPIDefaultUrl
|
|
||||||
import io.ktor.client.HttpClient
|
|
||||||
import io.ktor.client.HttpClientConfig
|
|
||||||
import io.ktor.client.engine.*
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows to create bot using bot [urlsKeeper] and already prepared [client]
|
|
||||||
*/
|
|
||||||
fun telegramBot(
|
|
||||||
urlsKeeper: TelegramAPIUrlsKeeper,
|
|
||||||
client: HttpClient = HttpClient()
|
|
||||||
): TelegramBot = telegramBot(urlsKeeper) {
|
|
||||||
this.client = client
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows to create bot using bot [urlsKeeper] and specify [HttpClientEngineFactory] by passing [clientFactory] param and optionally
|
|
||||||
* configure it with [clientConfig]
|
|
||||||
*/
|
|
||||||
@Suppress("NOTHING_TO_INLINE")
|
|
||||||
inline fun <T: HttpClientEngineConfig> telegramBot(
|
|
||||||
urlsKeeper: TelegramAPIUrlsKeeper,
|
|
||||||
clientFactory: HttpClientEngineFactory<T>,
|
|
||||||
noinline clientConfig: HttpClientConfig<T>.() -> Unit = {}
|
|
||||||
) = telegramBot(
|
|
||||||
urlsKeeper,
|
|
||||||
HttpClient(clientFactory, clientConfig)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows to create bot using bot [urlsKeeper] and specify [HttpClientEngine] by passing [clientEngine] param and optionally
|
|
||||||
* configure [HttpClient] using [clientConfig]
|
|
||||||
*/
|
|
||||||
@Suppress("NOTHING_TO_INLINE")
|
|
||||||
inline fun telegramBot(
|
|
||||||
urlsKeeper: TelegramAPIUrlsKeeper,
|
|
||||||
clientEngine: HttpClientEngine,
|
|
||||||
noinline clientConfig: HttpClientConfig<*>.() -> Unit = {}
|
|
||||||
) = telegramBot(
|
|
||||||
urlsKeeper,
|
|
||||||
HttpClient(clientEngine, clientConfig)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows to create bot using bot [urlsKeeper] and specify [HttpClientEngine] by configuring [HttpClient] using
|
|
||||||
* [clientConfig]
|
|
||||||
*/
|
|
||||||
@Suppress("NOTHING_TO_INLINE")
|
|
||||||
inline fun telegramBot(
|
|
||||||
urlsKeeper: TelegramAPIUrlsKeeper,
|
|
||||||
noinline clientConfig: HttpClientConfig<*>.() -> Unit
|
|
||||||
) = telegramBot(
|
|
||||||
urlsKeeper,
|
|
||||||
HttpClient(clientConfig)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows to create bot using bot [token], [apiUrl] (for custom api servers) and already prepared [client]
|
|
||||||
*/
|
|
||||||
@Suppress("NOTHING_TO_INLINE")
|
|
||||||
inline fun telegramBot(
|
|
||||||
token: String,
|
|
||||||
apiUrl: String = telegramBotAPIDefaultUrl,
|
|
||||||
testServer: Boolean = false,
|
|
||||||
client: HttpClient = HttpClient()
|
|
||||||
): TelegramBot = telegramBot(TelegramAPIUrlsKeeper(token, testServer, apiUrl), client)
|
|
||||||
|
|
||||||
@Suppress("NOTHING_TO_INLINE")
|
|
||||||
inline fun <T: HttpClientEngineConfig> telegramBot(
|
|
||||||
token: String,
|
|
||||||
clientFactory: HttpClientEngineFactory<T>,
|
|
||||||
apiUrl: String = telegramBotAPIDefaultUrl,
|
|
||||||
testServer: Boolean = false,
|
|
||||||
noinline clientConfig: HttpClientConfig<T>.() -> Unit = {}
|
|
||||||
) = telegramBot(
|
|
||||||
TelegramAPIUrlsKeeper(token, testServer, apiUrl),
|
|
||||||
clientFactory,
|
|
||||||
clientConfig
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows to create bot using bot [token] and specify [HttpClientEngine] by passing [clientEngine] param and optionally
|
|
||||||
* configure [HttpClient] using [clientConfig]
|
|
||||||
*/
|
|
||||||
@Suppress("NOTHING_TO_INLINE")
|
|
||||||
inline fun telegramBot(
|
|
||||||
token: String,
|
|
||||||
clientEngine: HttpClientEngine,
|
|
||||||
apiUrl: String = telegramBotAPIDefaultUrl,
|
|
||||||
testServer: Boolean = false,
|
|
||||||
noinline clientConfig: HttpClientConfig<*>.() -> Unit = {}
|
|
||||||
) = telegramBot(
|
|
||||||
TelegramAPIUrlsKeeper(token, testServer, apiUrl),
|
|
||||||
clientEngine,
|
|
||||||
clientConfig
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows to create bot using bot [token] and [apiUrl] and specify [HttpClientEngine] by configuring [HttpClient] using
|
|
||||||
* [clientConfig]
|
|
||||||
*/
|
|
||||||
@Suppress("NOTHING_TO_INLINE")
|
|
||||||
inline fun telegramBot(
|
|
||||||
token: String,
|
|
||||||
apiUrl: String = telegramBotAPIDefaultUrl,
|
|
||||||
testServer: Boolean = false,
|
|
||||||
noinline clientConfig: HttpClientConfig<*>.() -> Unit
|
|
||||||
) = telegramBot(
|
|
||||||
TelegramAPIUrlsKeeper(token, testServer, apiUrl),
|
|
||||||
clientConfig
|
|
||||||
)
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.local.Close
|
|
||||||
|
|
||||||
@Suppress("unused")
|
|
||||||
suspend inline fun TelegramBot.close() = execute(Close)
|
|
||||||
@@ -1,287 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api
|
|
||||||
|
|
||||||
import com.soywiz.klock.DateTime
|
|
||||||
import com.soywiz.klock.TimeSpan
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.edit.location.live.stopLiveLocation
|
|
||||||
import dev.inmo.tgbotapi.requests.send.SendLiveLocation
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
|
||||||
import dev.inmo.tgbotapi.types.location.LiveLocation
|
|
||||||
import dev.inmo.tgbotapi.types.location.StaticLocation
|
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
|
||||||
import dev.inmo.tgbotapi.types.message.content.LocationContent
|
|
||||||
import io.ktor.utils.io.core.Closeable
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import kotlin.math.ceil
|
|
||||||
|
|
||||||
val defaultLivePeriodDelayMillis = (livePeriodLimit.last - 60L) * 1000L
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see startLiveLocation
|
|
||||||
*/
|
|
||||||
class LiveLocationProvider internal constructor(
|
|
||||||
private val requestsExecutor: TelegramBot,
|
|
||||||
scope: CoroutineScope,
|
|
||||||
autoCloseTimeDelay: Double,
|
|
||||||
initMessage: ContentMessage<LocationContent>
|
|
||||||
) : Closeable {
|
|
||||||
private val doWhenClose = {
|
|
||||||
scope.launch {
|
|
||||||
requestsExecutor.stopLiveLocation(message)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private val autoCloseTime = DateTime.now() + TimeSpan(autoCloseTimeDelay)
|
|
||||||
val leftUntilCloseMillis: TimeSpan
|
|
||||||
get() = autoCloseTime - DateTime.now()
|
|
||||||
|
|
||||||
var isClosed: Boolean = false
|
|
||||||
private set
|
|
||||||
get() = field || leftUntilCloseMillis.millisecondsLong < 0L
|
|
||||||
|
|
||||||
private var message: ContentMessage<LocationContent> = initMessage
|
|
||||||
val lastLocation: LiveLocation
|
|
||||||
get() = message.content.location as LiveLocation
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
|
||||||
* as a builder for that
|
|
||||||
*/
|
|
||||||
suspend fun updateLocation(
|
|
||||||
location: LiveLocation,
|
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
): LiveLocation {
|
|
||||||
if (!isClosed) {
|
|
||||||
message = requestsExecutor.editLiveLocation(
|
|
||||||
message,
|
|
||||||
location,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
return lastLocation
|
|
||||||
} else {
|
|
||||||
error("LiveLocation is closed")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun close() {
|
|
||||||
if (isClosed) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
isClosed = true
|
|
||||||
doWhenClose()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.startLiveLocation(
|
|
||||||
scope: CoroutineScope,
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
latitude: Double,
|
|
||||||
longitude: Double,
|
|
||||||
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
|
|
||||||
initHorizontalAccuracy: Meters? = null,
|
|
||||||
initHeading: Degrees? = null,
|
|
||||||
initProximityAlertRadius: Meters? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
): LiveLocationProvider {
|
|
||||||
val liveTimeAsDouble = liveTimeMillis.toDouble()
|
|
||||||
val locationMessage = execute(
|
|
||||||
SendLiveLocation(
|
|
||||||
chatId,
|
|
||||||
latitude,
|
|
||||||
longitude,
|
|
||||||
ceil(liveTimeAsDouble / 1000).toInt(),
|
|
||||||
initHorizontalAccuracy,
|
|
||||||
initHeading,
|
|
||||||
initProximityAlertRadius,
|
|
||||||
disableNotification,
|
|
||||||
protectContent,
|
|
||||||
replyToMessageId,
|
|
||||||
allowSendingWithoutReply,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
return LiveLocationProvider(
|
|
||||||
this,
|
|
||||||
scope,
|
|
||||||
liveTimeAsDouble,
|
|
||||||
locationMessage
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.startLiveLocation(
|
|
||||||
scope: CoroutineScope,
|
|
||||||
chat: Chat,
|
|
||||||
latitude: Double,
|
|
||||||
longitude: Double,
|
|
||||||
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
|
|
||||||
initHorizontalAccuracy: Meters? = null,
|
|
||||||
initHeading: Degrees? = null,
|
|
||||||
initProximityAlertRadius: Meters? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
): LiveLocationProvider = startLiveLocation(
|
|
||||||
scope,
|
|
||||||
chat.id,
|
|
||||||
latitude,
|
|
||||||
longitude,
|
|
||||||
liveTimeMillis,
|
|
||||||
initHorizontalAccuracy,
|
|
||||||
initHeading,
|
|
||||||
initProximityAlertRadius,
|
|
||||||
disableNotification,
|
|
||||||
protectContent,
|
|
||||||
replyToMessageId,
|
|
||||||
allowSendingWithoutReply,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.startLiveLocation(
|
|
||||||
scope: CoroutineScope,
|
|
||||||
chatId: ChatId,
|
|
||||||
location: StaticLocation,
|
|
||||||
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
|
|
||||||
initHorizontalAccuracy: Meters? = null,
|
|
||||||
initHeading: Degrees? = null,
|
|
||||||
initProximityAlertRadius: Meters? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
): LiveLocationProvider = startLiveLocation(
|
|
||||||
scope,
|
|
||||||
chatId,
|
|
||||||
location.latitude,
|
|
||||||
location.longitude,
|
|
||||||
liveTimeMillis,
|
|
||||||
initHorizontalAccuracy,
|
|
||||||
initHeading,
|
|
||||||
initProximityAlertRadius,
|
|
||||||
disableNotification,
|
|
||||||
protectContent,
|
|
||||||
replyToMessageId,
|
|
||||||
allowSendingWithoutReply,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.startLiveLocation(
|
|
||||||
scope: CoroutineScope,
|
|
||||||
chat: Chat,
|
|
||||||
location: StaticLocation,
|
|
||||||
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
|
|
||||||
initHorizontalAccuracy: Meters? = null,
|
|
||||||
initHeading: Degrees? = null,
|
|
||||||
initProximityAlertRadius: Meters? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
): LiveLocationProvider = startLiveLocation(
|
|
||||||
scope,
|
|
||||||
chat.id,
|
|
||||||
location.latitude,
|
|
||||||
location.longitude,
|
|
||||||
liveTimeMillis,
|
|
||||||
initHorizontalAccuracy,
|
|
||||||
initHeading,
|
|
||||||
initProximityAlertRadius,
|
|
||||||
disableNotification,
|
|
||||||
protectContent,
|
|
||||||
replyToMessageId,
|
|
||||||
allowSendingWithoutReply,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.replyWithLiveLocation(
|
|
||||||
to: Message,
|
|
||||||
scope: CoroutineScope,
|
|
||||||
latitude: Double,
|
|
||||||
longitude: Double,
|
|
||||||
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
|
|
||||||
initHorizontalAccuracy: Meters? = null,
|
|
||||||
initHeading: Degrees? = null,
|
|
||||||
initProximityAlertRadius: Meters? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = startLiveLocation(
|
|
||||||
scope,
|
|
||||||
to.chat,
|
|
||||||
latitude,
|
|
||||||
longitude,
|
|
||||||
liveTimeMillis,
|
|
||||||
initHorizontalAccuracy,
|
|
||||||
initHeading,
|
|
||||||
initProximityAlertRadius,
|
|
||||||
disableNotification,
|
|
||||||
protectContent,
|
|
||||||
to.messageId,
|
|
||||||
allowSendingWithoutReply,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.replyWithLiveLocation(
|
|
||||||
to: Message,
|
|
||||||
scope: CoroutineScope,
|
|
||||||
location: StaticLocation,
|
|
||||||
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
|
|
||||||
initHorizontalAccuracy: Meters? = null,
|
|
||||||
initHeading: Degrees? = null,
|
|
||||||
initProximityAlertRadius: Meters? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = startLiveLocation(
|
|
||||||
scope,
|
|
||||||
to.chat,
|
|
||||||
location,
|
|
||||||
liveTimeMillis,
|
|
||||||
initHorizontalAccuracy,
|
|
||||||
initHeading,
|
|
||||||
initProximityAlertRadius,
|
|
||||||
disableNotification,
|
|
||||||
protectContent,
|
|
||||||
to.messageId,
|
|
||||||
allowSendingWithoutReply,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.local.LogOut
|
|
||||||
|
|
||||||
suspend inline fun TelegramBot.logOut() = execute(LogOut)
|
|
||||||
@@ -1,16 +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
|
|
||||||
|
|
||||||
suspend fun TelegramBot.answerWebAppQuery(
|
|
||||||
webAppQueryId: WebAppQueryId,
|
|
||||||
result: InlineQueryResult
|
|
||||||
) = execute(AnswerWebAppQuery(webAppQueryId, result))
|
|
||||||
|
|
||||||
suspend fun TelegramBot.answer(
|
|
||||||
webAppQueryId: WebAppQueryId,
|
|
||||||
result: InlineQueryResult
|
|
||||||
) = execute(AnswerWebAppQuery(webAppQueryId, result))
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.bot
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.bot.ClearMyDefaultAdministratorRights
|
|
||||||
|
|
||||||
suspend fun TelegramBot.clearMyDefaultAdministratorRights(
|
|
||||||
forChannels: Boolean? = null
|
|
||||||
) = execute(ClearMyDefaultAdministratorRights(forChannels))
|
|
||||||
|
|
||||||
suspend fun TelegramBot.clearMyDefaultAdministratorRightsForChannels() = clearMyDefaultAdministratorRights(forChannels = true)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.clearMyDefaultAdministratorRightsForGroupsAndSupergroups() = clearMyDefaultAdministratorRights(forChannels = false)
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.bot
|
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.bot.DeleteMyCommands
|
|
||||||
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
|
||||||
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
|
||||||
|
|
||||||
suspend fun TelegramBot.deleteMyCommands(
|
|
||||||
scope: BotCommandScope = BotCommandScopeDefault,
|
|
||||||
languageCode: IetfLanguageCode?
|
|
||||||
) = execute(DeleteMyCommands(scope, languageCode))
|
|
||||||
|
|
||||||
suspend fun TelegramBot.deleteMyCommands(
|
|
||||||
scope: BotCommandScope = BotCommandScopeDefault,
|
|
||||||
languageCode: String? = null
|
|
||||||
) = deleteMyCommands(scope, languageCode ?.let(::IetfLanguageCode))
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.bot
|
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
|
|
||||||
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
|
||||||
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
|
||||||
|
|
||||||
suspend fun TelegramBot.getMyCommands(
|
|
||||||
scope: BotCommandScope = BotCommandScopeDefault,
|
|
||||||
languageCode: IetfLanguageCode? = null
|
|
||||||
) = execute(GetMyCommands(scope, languageCode))
|
|
||||||
|
|
||||||
suspend fun TelegramBot.getMyCommands(
|
|
||||||
scope: BotCommandScope = BotCommandScopeDefault,
|
|
||||||
languageCode: String?
|
|
||||||
) = getMyCommands(scope, languageCode ?.let(::IetfLanguageCode))
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.bot
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.bot.GetMyDefaultAdministratorRights
|
|
||||||
|
|
||||||
suspend fun TelegramBot.getMyDefaultAdministratorRights(
|
|
||||||
forChannels: Boolean? = null
|
|
||||||
) = execute(GetMyDefaultAdministratorRights(forChannels))
|
|
||||||
|
|
||||||
suspend fun TelegramBot.getMyDefaultAdministratorRightsForChannels() = getMyDefaultAdministratorRights(forChannels = true)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.getMyDefaultAdministratorRightsForGroupsAndSupergroups() = getMyDefaultAdministratorRights(forChannels = false)
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.bot
|
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.bot.SetMyCommands
|
|
||||||
import dev.inmo.tgbotapi.types.BotCommand
|
|
||||||
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
|
||||||
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
|
||||||
|
|
||||||
suspend fun TelegramBot.setMyCommands(
|
|
||||||
commands: List<BotCommand>,
|
|
||||||
scope: BotCommandScope = BotCommandScopeDefault,
|
|
||||||
languageCode: IetfLanguageCode?
|
|
||||||
) = execute(SetMyCommands(commands, scope, languageCode))
|
|
||||||
|
|
||||||
suspend fun TelegramBot.setMyCommands(
|
|
||||||
vararg commands: BotCommand,
|
|
||||||
scope: BotCommandScope = BotCommandScopeDefault,
|
|
||||||
languageCode: IetfLanguageCode?
|
|
||||||
) = setMyCommands(commands.toList(), scope, languageCode)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.setMyCommands(
|
|
||||||
commands: List<BotCommand>,
|
|
||||||
scope: BotCommandScope = BotCommandScopeDefault,
|
|
||||||
languageCode: String? = null
|
|
||||||
) = setMyCommands(commands, scope, languageCode ?.let(::IetfLanguageCode))
|
|
||||||
|
|
||||||
suspend fun TelegramBot.setMyCommands(
|
|
||||||
vararg commands: BotCommand,
|
|
||||||
scope: BotCommandScope = BotCommandScopeDefault,
|
|
||||||
languageCode: String? = null
|
|
||||||
) = setMyCommands(commands.toList(), scope, languageCode)
|
|
||||||
@@ -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.ChatAdministratorRightsImpl
|
|
||||||
|
|
||||||
suspend fun TelegramBot.setMyDefaultAdministratorRights(
|
|
||||||
rights: ChatAdministratorRightsImpl,
|
|
||||||
forChannels: Boolean? = null
|
|
||||||
) = execute(SetMyDefaultAdministratorRights(rights, forChannels))
|
|
||||||
|
|
||||||
suspend fun TelegramBot.setMyDefaultAdministratorRightsForChannels(
|
|
||||||
rights: ChatAdministratorRightsImpl
|
|
||||||
) = setMyDefaultAdministratorRights(rights, forChannels = true)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.setMyDefaultAdministratorRightsForGroupsAndSupergroups(
|
|
||||||
rights: ChatAdministratorRightsImpl
|
|
||||||
) = setMyDefaultAdministratorRights(rights, forChannels = false)
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.chat.get
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.chat.get.GetChatMemberCount
|
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.chat.PublicChat
|
|
||||||
|
|
||||||
suspend fun TelegramBot.getChatMemberCount(
|
|
||||||
chatId: ChatIdentifier
|
|
||||||
) = execute(GetChatMemberCount(chatId))
|
|
||||||
|
|
||||||
suspend fun TelegramBot.getChatMemberCount(
|
|
||||||
chat: PublicChat
|
|
||||||
) = getChatMemberCount(chat.id)
|
|
||||||
@@ -1,14 +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.*
|
|
||||||
import dev.inmo.tgbotapi.types.chat.PrivateChat
|
|
||||||
|
|
||||||
suspend fun TelegramBot.getChatMenuButton(
|
|
||||||
chatId: ChatId
|
|
||||||
) = execute(GetChatMenuButton(chatId))
|
|
||||||
|
|
||||||
suspend fun TelegramBot.getChatMenuButton(
|
|
||||||
chat: PrivateChat
|
|
||||||
) = getChatMenuButton(chat.id)
|
|
||||||
@@ -1,8 +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.requests.chat.modify.SetDefaultChatMenuButton
|
|
||||||
import dev.inmo.tgbotapi.types.MenuButton
|
|
||||||
|
|
||||||
suspend fun TelegramBot.getDefaultChatMenuButton() = execute(GetDefaultChatMenuButton)
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.chat.invite_links
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.chat.invite_links.ApproveChatJoinRequest
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
|
||||||
import dev.inmo.tgbotapi.types.chat.*
|
|
||||||
import dev.inmo.tgbotapi.types.chat.User
|
|
||||||
import dev.inmo.tgbotapi.types.update.ChatJoinRequestUpdate
|
|
||||||
|
|
||||||
suspend fun TelegramBot.approveChatJoinRequest(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
userId: UserId
|
|
||||||
) = execute(ApproveChatJoinRequest(chatId, userId))
|
|
||||||
|
|
||||||
suspend fun TelegramBot.approveChatJoinRequest(
|
|
||||||
chat: PublicChat,
|
|
||||||
userId: UserId
|
|
||||||
) = approveChatJoinRequest(chat.id, userId)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.approveChatJoinRequest(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
user: User
|
|
||||||
) = approveChatJoinRequest(chatId, user.id)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.approveChatJoinRequest(
|
|
||||||
chat: PublicChat,
|
|
||||||
user: User
|
|
||||||
) = approveChatJoinRequest(chat.id, user.id)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.approveChatJoinRequest(
|
|
||||||
chatJoinRequest: ChatJoinRequest
|
|
||||||
) = approveChatJoinRequest(chatJoinRequest.chat, chatJoinRequest.user)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.approve(
|
|
||||||
chatJoinRequest: ChatJoinRequest
|
|
||||||
) = approveChatJoinRequest(chatJoinRequest)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.approveChatJoinRequest(
|
|
||||||
chatJoinRequestUpdate: ChatJoinRequestUpdate
|
|
||||||
) = approveChatJoinRequest(chatJoinRequestUpdate.data)
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.chat.invite_links
|
|
||||||
|
|
||||||
import com.soywiz.klock.DateTime
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.chat.invite_links.CreateChatInviteLink
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
|
||||||
import dev.inmo.tgbotapi.types.chat.PublicChat
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createChatInviteLinkUnlimited(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
name: String? = null,
|
|
||||||
expiration: TelegramDate? = null
|
|
||||||
) = execute(CreateChatInviteLink.unlimited(chatId, name, expiration))
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createChatInviteLinkUnlimited(
|
|
||||||
chat: PublicChat,
|
|
||||||
name: String? = null,
|
|
||||||
expiration: TelegramDate? = null,
|
|
||||||
) = createChatInviteLinkUnlimited(chat.id, name, expiration)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createChatInviteLinkUnlimited(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
expiration: DateTime,
|
|
||||||
name: String? = null,
|
|
||||||
) = createChatInviteLinkUnlimited(chatId, name, expiration.toTelegramDate())
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createChatInviteLinkUnlimited(
|
|
||||||
chat: PublicChat,
|
|
||||||
expiration: DateTime,
|
|
||||||
name: String? = null
|
|
||||||
) = createChatInviteLinkUnlimited(chat.id, name, expiration.toTelegramDate())
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
membersLimit: MembersLimit,
|
|
||||||
name: String? = null,
|
|
||||||
expiration: TelegramDate? = null
|
|
||||||
) = execute(CreateChatInviteLink.withLimitedMembers(chatId, membersLimit, name, expiration))
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers(
|
|
||||||
chat: PublicChat,
|
|
||||||
membersLimit: MembersLimit,
|
|
||||||
name: String? = null,
|
|
||||||
expiration: TelegramDate? = null,
|
|
||||||
) = createChatInviteLinkWithLimitedMembers(chat.id, membersLimit, name, expiration)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
membersLimit: MembersLimit,
|
|
||||||
expiration: DateTime,
|
|
||||||
name: String? = null,
|
|
||||||
) = createChatInviteLinkWithLimitedMembers(chatId, membersLimit, name, expiration.toTelegramDate())
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers(
|
|
||||||
chat: PublicChat,
|
|
||||||
membersLimit: MembersLimit,
|
|
||||||
expiration: DateTime,
|
|
||||||
name: String? = null,
|
|
||||||
) = createChatInviteLinkWithLimitedMembers(chat.id, membersLimit, name, expiration.toTelegramDate())
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createChatInviteLinkWithJoinRequest(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
name: String? = null,
|
|
||||||
expiration: TelegramDate? = null
|
|
||||||
) = execute(CreateChatInviteLink.withJoinRequest(chatId, name, expiration))
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createChatInviteLinkWithJoinRequest(
|
|
||||||
chat: PublicChat,
|
|
||||||
name: String? = null,
|
|
||||||
expiration: TelegramDate? = null,
|
|
||||||
) = createChatInviteLinkWithJoinRequest(chat.id, name, expiration)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createChatInviteLinkWithJoinRequest(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
expiration: DateTime,
|
|
||||||
name: String? = null,
|
|
||||||
) = createChatInviteLinkWithJoinRequest(chatId, name, expiration.toTelegramDate())
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createChatInviteLinkWithJoinRequest(
|
|
||||||
chat: PublicChat,
|
|
||||||
expiration: DateTime,
|
|
||||||
name: String? = null,
|
|
||||||
) = createChatInviteLinkWithJoinRequest(chat.id, name, expiration.toTelegramDate())
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.chat.invite_links
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.chat.invite_links.DeclineChatJoinRequest
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
|
||||||
import dev.inmo.tgbotapi.types.chat.*
|
|
||||||
import dev.inmo.tgbotapi.types.chat.User
|
|
||||||
import dev.inmo.tgbotapi.types.update.ChatJoinRequestUpdate
|
|
||||||
|
|
||||||
suspend fun TelegramBot.declineChatJoinRequest(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
userId: UserId
|
|
||||||
) = execute(DeclineChatJoinRequest(chatId, userId))
|
|
||||||
|
|
||||||
suspend fun TelegramBot.declineChatJoinRequest(
|
|
||||||
chat: PublicChat,
|
|
||||||
userId: UserId
|
|
||||||
) = declineChatJoinRequest(chat.id, userId)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.declineChatJoinRequest(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
user: User
|
|
||||||
) = declineChatJoinRequest(chatId, user.id)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.declineChatJoinRequest(
|
|
||||||
chat: PublicChat,
|
|
||||||
user: User
|
|
||||||
) = declineChatJoinRequest(chat.id, user.id)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.declineChatJoinRequest(
|
|
||||||
chatJoinRequest: ChatJoinRequest
|
|
||||||
) = declineChatJoinRequest(chatJoinRequest.chat, chatJoinRequest.user)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.decline(
|
|
||||||
chatJoinRequest: ChatJoinRequest
|
|
||||||
) = declineChatJoinRequest(chatJoinRequest)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.declineChatJoinRequest(
|
|
||||||
chatJoinRequestUpdate: ChatJoinRequestUpdate
|
|
||||||
) = declineChatJoinRequest(chatJoinRequestUpdate.data)
|
|
||||||
@@ -1,183 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.chat.invite_links
|
|
||||||
|
|
||||||
import com.soywiz.klock.DateTime
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.chat.invite_links.EditChatInviteLink
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
|
||||||
import dev.inmo.tgbotapi.types.chat.PublicChat
|
|
||||||
|
|
||||||
suspend fun TelegramBot.editChatInviteLinkUnlimited(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
previousLink: String,
|
|
||||||
name: String? = null,
|
|
||||||
expiration: TelegramDate? = null
|
|
||||||
) = execute(EditChatInviteLink.unlimited(chatId, previousLink, name, expiration))
|
|
||||||
|
|
||||||
suspend fun TelegramBot.editChatInviteLinkUnlimited(
|
|
||||||
chat: PublicChat,
|
|
||||||
previousLink: String,
|
|
||||||
name: String? = null,
|
|
||||||
expiration: TelegramDate? = null,
|
|
||||||
) = editChatInviteLinkUnlimited(chat.id, previousLink, name, expiration)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.editChatInviteLinkUnlimited(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
previousLink: String,
|
|
||||||
expiration: DateTime,
|
|
||||||
name: String? = null,
|
|
||||||
) = editChatInviteLinkUnlimited(chatId, previousLink, name , expiration.toTelegramDate())
|
|
||||||
|
|
||||||
suspend fun TelegramBot.editChatInviteLinkUnlimited(
|
|
||||||
chat: PublicChat,
|
|
||||||
previousLink: String,
|
|
||||||
expiration: DateTime,
|
|
||||||
name: String? = null,
|
|
||||||
) = editChatInviteLinkUnlimited(chat.id, previousLink, name , expiration.toTelegramDate())
|
|
||||||
|
|
||||||
suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
previousLink: String,
|
|
||||||
membersLimit: MembersLimit,
|
|
||||||
name: String? = null,
|
|
||||||
expiration: TelegramDate? = null
|
|
||||||
) = execute(EditChatInviteLink.withLimitedMembers(chatId, previousLink, membersLimit, name, expiration))
|
|
||||||
|
|
||||||
suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
|
|
||||||
chat: PublicChat,
|
|
||||||
previousLink: String,
|
|
||||||
membersLimit: MembersLimit,
|
|
||||||
name: String? = null,
|
|
||||||
expiration: TelegramDate? = null,
|
|
||||||
) = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, name, expiration)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
previousLink: String,
|
|
||||||
membersLimit: MembersLimit,
|
|
||||||
expiration: DateTime,
|
|
||||||
name: String? = null,
|
|
||||||
) = editChatInviteLinkWithLimitedMembers(chatId, previousLink, membersLimit, name , expiration.toTelegramDate())
|
|
||||||
|
|
||||||
suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
|
|
||||||
chat: PublicChat,
|
|
||||||
previousLink: String,
|
|
||||||
membersLimit: MembersLimit,
|
|
||||||
expiration: DateTime,
|
|
||||||
name: String? = null,
|
|
||||||
) = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, name , expiration.toTelegramDate())
|
|
||||||
|
|
||||||
suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
previousLink: String,
|
|
||||||
name: String? = null,
|
|
||||||
expiration: TelegramDate? = null
|
|
||||||
) = execute(EditChatInviteLink.withJoinRequest(chatId, previousLink, name, expiration))
|
|
||||||
|
|
||||||
suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
|
|
||||||
chat: PublicChat,
|
|
||||||
previousLink: String,
|
|
||||||
name: String? = null,
|
|
||||||
expiration: TelegramDate? = null,
|
|
||||||
) = editChatInviteLinkWithJoinRequest(chat.id, previousLink, name, expiration)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
previousLink: String,
|
|
||||||
expiration: DateTime,
|
|
||||||
name: String? = null,
|
|
||||||
) = editChatInviteLinkWithJoinRequest(chatId, previousLink, name , expiration.toTelegramDate())
|
|
||||||
|
|
||||||
suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
|
|
||||||
chat: PublicChat,
|
|
||||||
previousLink: String,
|
|
||||||
expiration: DateTime,
|
|
||||||
name: String? = null,
|
|
||||||
) = editChatInviteLinkWithJoinRequest(chat.id, previousLink, name , expiration.toTelegramDate())
|
|
||||||
|
|
||||||
suspend fun TelegramBot.editChatInviteLinkUnlimited(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
previousLink: ChatInviteLink,
|
|
||||||
name: String? = null,
|
|
||||||
expiration: TelegramDate? = null
|
|
||||||
) = editChatInviteLinkUnlimited(chatId, previousLink.inviteLink, name, expiration)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.editChatInviteLinkUnlimited(
|
|
||||||
chat: PublicChat,
|
|
||||||
previousLink: ChatInviteLink,
|
|
||||||
name: String? = null,
|
|
||||||
expiration: TelegramDate? = null,
|
|
||||||
) = editChatInviteLinkUnlimited(chat.id, previousLink, name, expiration)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.editChatInviteLinkUnlimited(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
previousLink: ChatInviteLink,
|
|
||||||
expiration: DateTime,
|
|
||||||
name: String? = null,
|
|
||||||
) = editChatInviteLinkUnlimited(chatId, previousLink, name, expiration.toTelegramDate())
|
|
||||||
|
|
||||||
suspend fun TelegramBot.editChatInviteLinkUnlimited(
|
|
||||||
chat: PublicChat,
|
|
||||||
previousLink: ChatInviteLink,
|
|
||||||
expiration: DateTime,
|
|
||||||
name: String? = null,
|
|
||||||
) = editChatInviteLinkUnlimited(chat.id, previousLink, name , expiration.toTelegramDate())
|
|
||||||
|
|
||||||
suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
previousLink: ChatInviteLink,
|
|
||||||
membersLimit: MembersLimit,
|
|
||||||
name: String? = null,
|
|
||||||
expiration: TelegramDate? = null
|
|
||||||
) = editChatInviteLinkWithLimitedMembers(chatId, previousLink.inviteLink, membersLimit, name, expiration)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
|
|
||||||
chat: PublicChat,
|
|
||||||
previousLink: ChatInviteLink,
|
|
||||||
membersLimit: MembersLimit,
|
|
||||||
name: String? = null,
|
|
||||||
expiration: TelegramDate? = null,
|
|
||||||
) = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, name, expiration)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
previousLink: ChatInviteLink,
|
|
||||||
membersLimit: MembersLimit,
|
|
||||||
expiration: DateTime,
|
|
||||||
name: String? = null,
|
|
||||||
) = editChatInviteLinkWithLimitedMembers(chatId, previousLink, membersLimit, name , expiration.toTelegramDate())
|
|
||||||
|
|
||||||
suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
|
|
||||||
chat: PublicChat,
|
|
||||||
previousLink: ChatInviteLink,
|
|
||||||
membersLimit: MembersLimit,
|
|
||||||
expiration: DateTime,
|
|
||||||
name: String? = null,
|
|
||||||
) = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, name , expiration.toTelegramDate())
|
|
||||||
|
|
||||||
suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
previousLink: ChatInviteLink,
|
|
||||||
name: String? = null,
|
|
||||||
expiration: TelegramDate? = null
|
|
||||||
) = editChatInviteLinkWithJoinRequest(chatId, previousLink.inviteLink, name, expiration)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
|
|
||||||
chat: PublicChat,
|
|
||||||
previousLink: ChatInviteLink,
|
|
||||||
name: String? = null,
|
|
||||||
expiration: TelegramDate? = null,
|
|
||||||
) = editChatInviteLinkWithJoinRequest(chat.id, previousLink, name, expiration)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
previousLink: ChatInviteLink,
|
|
||||||
expiration: DateTime,
|
|
||||||
name: String? = null,
|
|
||||||
) = editChatInviteLinkWithJoinRequest(chatId, previousLink, name , expiration.toTelegramDate())
|
|
||||||
|
|
||||||
suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
|
|
||||||
chat: PublicChat,
|
|
||||||
previousLink: ChatInviteLink,
|
|
||||||
expiration: DateTime,
|
|
||||||
name: String? = null,
|
|
||||||
) = editChatInviteLinkWithJoinRequest(chat.id, previousLink, name , expiration.toTelegramDate())
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.chat.invite_links
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.chat.invite_links.RevokeChatInviteLink
|
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.ChatInviteLink
|
|
||||||
import dev.inmo.tgbotapi.types.chat.PublicChat
|
|
||||||
|
|
||||||
suspend fun TelegramBot.revokeChatInviteLink(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
previousLink: String
|
|
||||||
) = execute(RevokeChatInviteLink(chatId, previousLink))
|
|
||||||
|
|
||||||
suspend fun TelegramBot.revokeChatInviteLink(
|
|
||||||
chat: PublicChat,
|
|
||||||
previousLink: String
|
|
||||||
) = revokeChatInviteLink(chat.id, previousLink)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.revokeChatInviteLink(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
previousLink: ChatInviteLink
|
|
||||||
) = revokeChatInviteLink(chatId, previousLink.inviteLink)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.revokeChatInviteLink(
|
|
||||||
chat: PublicChat,
|
|
||||||
previousLink: ChatInviteLink
|
|
||||||
) = revokeChatInviteLink(chat, previousLink.inviteLink)
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.chat.members
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.chat.members.BanChatMember
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
|
||||||
import dev.inmo.tgbotapi.types.chat.PublicChat
|
|
||||||
import dev.inmo.tgbotapi.types.chat.User
|
|
||||||
|
|
||||||
suspend fun TelegramBot.banChatMember(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
userId: UserId,
|
|
||||||
untilDate: TelegramDate? = null,
|
|
||||||
revokeMessages: Boolean? = null
|
|
||||||
) = execute(BanChatMember(chatId, userId, untilDate, revokeMessages))
|
|
||||||
|
|
||||||
suspend fun TelegramBot.banChatMember(
|
|
||||||
chat: PublicChat,
|
|
||||||
userId: UserId,
|
|
||||||
untilDate: TelegramDate? = null,
|
|
||||||
revokeMessages: Boolean? = null
|
|
||||||
) = banChatMember(chat.id, userId, untilDate, revokeMessages)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.banChatMember(
|
|
||||||
chatId: ChatId,
|
|
||||||
user: User,
|
|
||||||
untilDate: TelegramDate? = null,
|
|
||||||
revokeMessages: Boolean? = null
|
|
||||||
) = banChatMember(chatId, user.id, untilDate, revokeMessages)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.banChatMember(
|
|
||||||
chat: PublicChat,
|
|
||||||
user: User,
|
|
||||||
untilDate: TelegramDate? = null,
|
|
||||||
revokeMessages: Boolean? = null
|
|
||||||
) = banChatMember(chat.id, user.id, untilDate, revokeMessages)
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.chat.members
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.chat.members.BanChatSenderChat
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
|
||||||
import dev.inmo.tgbotapi.types.chat.PublicChat
|
|
||||||
|
|
||||||
suspend fun TelegramBot.banChatSenderChat(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
senderChatId: ChatId
|
|
||||||
) = execute(BanChatSenderChat(chatId, senderChatId))
|
|
||||||
|
|
||||||
suspend fun TelegramBot.banChatSenderChat(
|
|
||||||
chat: PublicChat,
|
|
||||||
senderChatId: ChatId
|
|
||||||
) = banChatSenderChat(chat.id, senderChatId)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.banChatSenderChat(
|
|
||||||
chatId: ChatId,
|
|
||||||
senderChat: PublicChat
|
|
||||||
) = banChatSenderChat(chatId, senderChat.id)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.banChatSenderChat(
|
|
||||||
chat: PublicChat,
|
|
||||||
senderChat: PublicChat,
|
|
||||||
) = banChatSenderChat(chat.id, senderChat)
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.chat.members
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.chat.members.UnbanChatMember
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
|
||||||
import dev.inmo.tgbotapi.types.chat.PublicChat
|
|
||||||
import dev.inmo.tgbotapi.types.chat.User
|
|
||||||
|
|
||||||
suspend fun TelegramBot.unbanChatMember(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
userId: UserId,
|
|
||||||
onlyIfBanned: Boolean? = null
|
|
||||||
) = execute(UnbanChatMember(chatId, userId, onlyIfBanned))
|
|
||||||
|
|
||||||
suspend fun TelegramBot.unbanChatMember(
|
|
||||||
chat: PublicChat,
|
|
||||||
userId: UserId,
|
|
||||||
onlyIfBanned: Boolean? = null
|
|
||||||
) = unbanChatMember(chat.id, userId, onlyIfBanned)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.unbanChatMember(
|
|
||||||
chatId: ChatId,
|
|
||||||
user: User,
|
|
||||||
onlyIfBanned: Boolean? = null
|
|
||||||
) = unbanChatMember(chatId, user.id, onlyIfBanned)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.unbanChatMember(
|
|
||||||
chat: PublicChat,
|
|
||||||
user: User,
|
|
||||||
onlyIfBanned: Boolean? = null
|
|
||||||
) = unbanChatMember(chat.id, user.id, onlyIfBanned)
|
|
||||||
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.chat.members
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.chat.members.*
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
|
||||||
import dev.inmo.tgbotapi.types.chat.PublicChat
|
|
||||||
|
|
||||||
suspend fun TelegramBot.unbanChatSenderChat(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
senderChatId: ChatId
|
|
||||||
) = execute(UnbanChatSenderChat(chatId, senderChatId))
|
|
||||||
|
|
||||||
suspend fun TelegramBot.unbanChatSenderChat(
|
|
||||||
chat: PublicChat,
|
|
||||||
senderChatId: ChatId
|
|
||||||
) = unbanChatSenderChat(chat.id, senderChatId)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.unbanChatSenderChat(
|
|
||||||
chatId: ChatId,
|
|
||||||
senderChat: PublicChat
|
|
||||||
) = unbanChatSenderChat(chatId, senderChat.id)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.unbanChatSenderChat(
|
|
||||||
chat: PublicChat,
|
|
||||||
senderChat: PublicChat,
|
|
||||||
) = unbanChatSenderChat(chat.id, senderChat)
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.chat.modify
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.chat.modify.*
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
|
||||||
import dev.inmo.tgbotapi.types.chat.PrivateChat
|
|
||||||
|
|
||||||
suspend fun TelegramBot.setChatMenuButton(
|
|
||||||
chatId: ChatId,
|
|
||||||
menuButton: MenuButton
|
|
||||||
) = execute(SetChatMenuButton(chatId, menuButton))
|
|
||||||
|
|
||||||
suspend fun TelegramBot.setChatMenuButton(
|
|
||||||
chat: PrivateChat,
|
|
||||||
menuButton: MenuButton
|
|
||||||
) = setChatMenuButton(chat.id, menuButton)
|
|
||||||
@@ -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
|
|
||||||
|
|
||||||
suspend fun TelegramBot.setDefaultChatMenuButton(
|
|
||||||
menuButton: MenuButton
|
|
||||||
) = execute(SetDefaultChatMenuButton(menuButton))
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.chat.modify
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.chat.modify.UnpinAllChatMessages
|
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
|
||||||
|
|
||||||
suspend fun TelegramBot.unpinAllChatMessages(
|
|
||||||
chatId: ChatIdentifier
|
|
||||||
) = execute(UnpinAllChatMessages(chatId))
|
|
||||||
|
|
||||||
suspend fun TelegramBot.unpinAllChatMessages(
|
|
||||||
chat: Chat
|
|
||||||
) = unpinAllChatMessages(chat.id)
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.chat.modify
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.chat.modify.UnpinChatMessage
|
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
|
||||||
|
|
||||||
suspend fun TelegramBot.unpinChatMessage(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
messageId: MessageIdentifier? = null
|
|
||||||
) = execute(UnpinChatMessage(chatId, messageId))
|
|
||||||
|
|
||||||
suspend fun TelegramBot.unpinChatMessage(
|
|
||||||
chat: Chat,
|
|
||||||
messageId: MessageIdentifier? = null
|
|
||||||
) = unpinChatMessage(chat.id, messageId)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.unpinChatMessage(
|
|
||||||
message: Message
|
|
||||||
) = unpinChatMessage(message.chat.id, message.messageId)
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.edit.caption
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.abstracts.TextedWithTextSources
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.edit.caption.EditChatMessageCaption
|
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.TextSource
|
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
|
||||||
import dev.inmo.tgbotapi.types.message.content.MediaContent
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
|
||||||
* as a builder for that
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.editMessageCaption(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
messageId: MessageIdentifier,
|
|
||||||
text: String,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
EditChatMessageCaption(chatId, messageId, text, parseMode, replyMarkup)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
|
||||||
* as a builder for that
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.editMessageCaption(
|
|
||||||
chat: Chat,
|
|
||||||
messageId: MessageIdentifier,
|
|
||||||
text: String,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) = editMessageCaption(chat.id, messageId, text, parseMode, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
|
||||||
* as a builder for that
|
|
||||||
*/
|
|
||||||
suspend fun <T> TelegramBot.editMessageCaption(
|
|
||||||
message: ContentMessage<T>,
|
|
||||||
text: String,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
): ContentMessage<MediaContent> where T : TextedWithTextSources, T : MediaContent {
|
|
||||||
return editMessageCaption(message.chat.id, message.messageId, text, parseMode, replyMarkup)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
|
||||||
* as a builder for that
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.editMessageCaption(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
messageId: MessageIdentifier,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
EditChatMessageCaption(chatId, messageId, entities, replyMarkup)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
|
||||||
* as a builder for that
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.editMessageCaption(
|
|
||||||
chat: Chat,
|
|
||||||
messageId: MessageIdentifier,
|
|
||||||
entities: List<TextSource>,
|
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) = editMessageCaption(chat.id, messageId, entities, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
|
||||||
* as a builder for that
|
|
||||||
*/
|
|
||||||
suspend fun <T> TelegramBot.editMessageCaption(
|
|
||||||
message: ContentMessage<T>,
|
|
||||||
entities: List<TextSource>,
|
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
): ContentMessage<MediaContent> where T : TextedWithTextSources, T : MediaContent {
|
|
||||||
return editMessageCaption(message.chat.id, message.messageId, entities, replyMarkup)
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.edit.caption
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.edit.caption.EditInlineMessageCaption
|
|
||||||
import dev.inmo.tgbotapi.types.InlineMessageIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
|
||||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
|
||||||
* as a builder for that
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.editMessageCaption(
|
|
||||||
inlineMessageId: InlineMessageIdentifier,
|
|
||||||
text: String,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) = execute(EditInlineMessageCaption(inlineMessageId, text, parseMode, replyMarkup))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
|
||||||
* as a builder for that
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.editMessageCaption(
|
|
||||||
inlineMessageId: InlineMessageIdentifier,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) = execute(EditInlineMessageCaption(inlineMessageId, entities, replyMarkup))
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.edit.location.live
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.edit.location.live.EditChatMessageLiveLocation
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
|
||||||
import dev.inmo.tgbotapi.types.location.LiveLocation
|
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
|
||||||
import dev.inmo.tgbotapi.types.message.content.LocationContent
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
|
||||||
* as a builder for that
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.editLiveLocation(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
messageId: MessageIdentifier,
|
|
||||||
latitude: Double,
|
|
||||||
longitude: Double,
|
|
||||||
horizontalAccuracy: Meters? = null,
|
|
||||||
heading: Degrees? = null,
|
|
||||||
proximityAlertRadius: Meters? = null,
|
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
EditChatMessageLiveLocation(
|
|
||||||
chatId, messageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
|
||||||
* as a builder for that
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.editLiveLocation(
|
|
||||||
chat: Chat,
|
|
||||||
messageId: MessageIdentifier,
|
|
||||||
latitude: Double,
|
|
||||||
longitude: Double,
|
|
||||||
horizontalAccuracy: Meters? = null,
|
|
||||||
heading: Degrees? = null,
|
|
||||||
proximityAlertRadius: Meters? = null,
|
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) = editLiveLocation(chat.id, messageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
|
||||||
* as a builder for that
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.editLiveLocation(
|
|
||||||
message: ContentMessage<LocationContent>,
|
|
||||||
latitude: Double,
|
|
||||||
longitude: Double,
|
|
||||||
horizontalAccuracy: Meters? = null,
|
|
||||||
heading: Degrees? = null,
|
|
||||||
proximityAlertRadius: Meters? = null,
|
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) = editLiveLocation(message.chat, message.messageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
|
||||||
* as a builder for that
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.editLiveLocation(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
messageId: MessageIdentifier,
|
|
||||||
location: LiveLocation,
|
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
EditChatMessageLiveLocation(
|
|
||||||
chatId, messageId, location.latitude, location.longitude, location.horizontalAccuracy, location.heading, location.proximityAlertRadius, replyMarkup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
|
||||||
* as a builder for that
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.editLiveLocation(
|
|
||||||
chat: Chat,
|
|
||||||
messageId: MessageIdentifier,
|
|
||||||
location: LiveLocation,
|
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) = editLiveLocation(chat.id, messageId, location.latitude, location.longitude, location.horizontalAccuracy, location.heading, location.proximityAlertRadius, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
|
||||||
* as a builder for that
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.editLiveLocation(
|
|
||||||
message: ContentMessage<LocationContent>,
|
|
||||||
location: LiveLocation,
|
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) = editLiveLocation(message.chat, message.messageId, location.latitude, location.longitude, location.horizontalAccuracy, location.heading, location.proximityAlertRadius, replyMarkup)
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.edit.location.live
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.edit.location.live.EditInlineMessageLiveLocation
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
|
||||||
import dev.inmo.tgbotapi.types.location.LiveLocation
|
|
||||||
|
|
||||||
suspend fun TelegramBot.editLiveLocation(
|
|
||||||
inlineMessageId: InlineMessageIdentifier,
|
|
||||||
latitude: Double,
|
|
||||||
longitude: Double,
|
|
||||||
horizontalAccuracy: Meters? = null,
|
|
||||||
heading: Degrees? = null,
|
|
||||||
proximityAlertRadius: Meters? = null,
|
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
EditInlineMessageLiveLocation(
|
|
||||||
inlineMessageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
suspend fun TelegramBot.editLiveLocation(
|
|
||||||
inlineMessageId: InlineMessageIdentifier,
|
|
||||||
location: LiveLocation,
|
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) = editLiveLocation(inlineMessageId, location.latitude, location.longitude, location.horizontalAccuracy, location.heading, location.proximityAlertRadius, replyMarkup)
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.edit.text
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.edit.text.EditChatMessageText
|
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
|
||||||
import dev.inmo.tgbotapi.types.message.content.TextContent
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
|
||||||
* as a builder for that
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.editMessageText(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
messageId: MessageIdentifier,
|
|
||||||
text: String,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableWebPagePreview: Boolean? = null,
|
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
EditChatMessageText(chatId, messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
|
||||||
* as a builder for that
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.editMessageText(
|
|
||||||
chat: Chat,
|
|
||||||
messageId: MessageIdentifier,
|
|
||||||
text: String,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableWebPagePreview: Boolean? = null,
|
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) = editMessageText(chat.id, messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
|
||||||
* as a builder for that
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.editMessageText(
|
|
||||||
message: ContentMessage<TextContent>,
|
|
||||||
text: String,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableWebPagePreview: Boolean? = null,
|
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) = editMessageText(message.chat.id, message.messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
|
||||||
* as a builder for that
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.editMessageText(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
messageId: MessageIdentifier,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableWebPagePreview: Boolean? = null,
|
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
EditChatMessageText(chatId, messageId, entities, disableWebPagePreview, replyMarkup)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
|
||||||
* as a builder for that
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.editMessageText(
|
|
||||||
chat: Chat,
|
|
||||||
messageId: MessageIdentifier,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableWebPagePreview: Boolean? = null,
|
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) = editMessageText(chat.id, messageId, entities, disableWebPagePreview, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
|
||||||
* as a builder for that
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.editMessageText(
|
|
||||||
message: ContentMessage<TextContent>,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableWebPagePreview: Boolean? = null,
|
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) = editMessageText(message.chat.id, message.messageId, entities, disableWebPagePreview, replyMarkup)
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.edit.text
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.edit.text.EditInlineMessageText
|
|
||||||
import dev.inmo.tgbotapi.types.InlineMessageIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
|
||||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
|
||||||
* as a builder for that
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.editMessageText(
|
|
||||||
inlineMessageId: InlineMessageIdentifier,
|
|
||||||
text: String,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableWebPagePreview: Boolean? = null,
|
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) = execute(EditInlineMessageText(inlineMessageId, text, parseMode, disableWebPagePreview, replyMarkup))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
|
||||||
* as a builder for that
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.editMessageText(
|
|
||||||
inlineMessageId: InlineMessageIdentifier,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableWebPagePreview: Boolean? = null,
|
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) = execute(EditInlineMessageText(inlineMessageId, entities, disableWebPagePreview, replyMarkup))
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.files
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.get.getFileAdditionalInfo
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
|
||||||
import dev.inmo.tgbotapi.types.files.PathedFile
|
|
||||||
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
|
|
||||||
import dev.inmo.tgbotapi.types.message.content.MediaContent
|
|
||||||
|
|
||||||
suspend fun TelegramBot.downloadFileStream(
|
|
||||||
filePath: String
|
|
||||||
) = downloadFileStreamAllocator(filePath).invoke()
|
|
||||||
|
|
||||||
suspend fun TelegramBot.downloadFileStream(
|
|
||||||
pathedFile: PathedFile
|
|
||||||
) = downloadFileStream(pathedFile.filePath)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.downloadFileStream(
|
|
||||||
fileId: FileId
|
|
||||||
) = downloadFileStream(getFileAdditionalInfo(fileId))
|
|
||||||
|
|
||||||
suspend fun TelegramBot.downloadFileStream(
|
|
||||||
file: TelegramMediaFile
|
|
||||||
) = downloadFileStream(getFileAdditionalInfo(file))
|
|
||||||
|
|
||||||
suspend fun TelegramBot.downloadFileStream(
|
|
||||||
file: MediaContent
|
|
||||||
) = downloadFileStream(getFileAdditionalInfo(file.media))
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.files
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.get.getFileAdditionalInfo
|
|
||||||
import dev.inmo.tgbotapi.requests.DownloadFileStream
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
|
||||||
import dev.inmo.tgbotapi.types.files.PathedFile
|
|
||||||
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
|
|
||||||
import dev.inmo.tgbotapi.types.message.content.MediaContent
|
|
||||||
|
|
||||||
suspend fun TelegramBot.downloadFileStreamAllocator(
|
|
||||||
filePath: String
|
|
||||||
) = execute(DownloadFileStream(filePath))
|
|
||||||
|
|
||||||
suspend fun TelegramBot.downloadFileStreamAllocator(
|
|
||||||
pathedFile: PathedFile
|
|
||||||
) = downloadFileStreamAllocator(pathedFile.filePath)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.downloadFileStreamAllocator(
|
|
||||||
fileId: FileId
|
|
||||||
) = downloadFileStreamAllocator(getFileAdditionalInfo(fileId))
|
|
||||||
|
|
||||||
suspend fun TelegramBot.downloadFileStreamAllocator(
|
|
||||||
file: TelegramMediaFile
|
|
||||||
) = downloadFileStreamAllocator(getFileAdditionalInfo(file))
|
|
||||||
|
|
||||||
suspend fun TelegramBot.downloadFileStreamAllocator(
|
|
||||||
file: MediaContent
|
|
||||||
) = downloadFileStreamAllocator(getFileAdditionalInfo(file.media))
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.passport
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.SetPassportDataErrors
|
|
||||||
import dev.inmo.tgbotapi.types.chat.User
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.message.PassportMessage
|
|
||||||
import dev.inmo.tgbotapi.types.passport.PassportData
|
|
||||||
import dev.inmo.tgbotapi.types.passport.PassportElementError
|
|
||||||
import dev.inmo.tgbotapi.types.passport.encrypted.abstracts.EncryptedPassportElement
|
|
||||||
import dev.inmo.tgbotapi.utils.passport.Decryptor
|
|
||||||
|
|
||||||
suspend fun TelegramBot.setPassportDataErrors(
|
|
||||||
userId: UserId,
|
|
||||||
errors: List<PassportElementError>
|
|
||||||
) = execute(SetPassportDataErrors(userId, errors))
|
|
||||||
suspend fun TelegramBot.setPassportDataErrors(
|
|
||||||
user: User,
|
|
||||||
errors: List<PassportElementError>
|
|
||||||
) = setPassportDataErrors(user.id, errors)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.setPassportDataErrors(
|
|
||||||
userId: UserId,
|
|
||||||
passportData: PassportData,
|
|
||||||
decryptor: Decryptor,
|
|
||||||
mapper: suspend Decryptor.(EncryptedPassportElement) -> PassportElementError
|
|
||||||
): Boolean = setPassportDataErrors(
|
|
||||||
userId,
|
|
||||||
passportData.data.map { decryptor.mapper(it) }.also {
|
|
||||||
if (it.isEmpty()) {
|
|
||||||
return@setPassportDataErrors false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
suspend fun TelegramBot.setPassportDataErrors(
|
|
||||||
user: User,
|
|
||||||
passportData: PassportData,
|
|
||||||
decryptor: Decryptor,
|
|
||||||
mapper: suspend Decryptor.(EncryptedPassportElement) -> PassportElementError
|
|
||||||
) = setPassportDataErrors(user.id, passportData, decryptor, mapper)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.setPassportDataErrors(
|
|
||||||
passportMessage: PassportMessage,
|
|
||||||
decryptor: Decryptor,
|
|
||||||
mapper: suspend Decryptor.(EncryptedPassportElement) -> PassportElementError
|
|
||||||
) = setPassportDataErrors(passportMessage.user, passportMessage.passportData, decryptor, mapper)
|
|
||||||
@@ -1,210 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.send
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.send.CopyMessage
|
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.copyMessage(
|
|
||||||
fromChatId: ChatIdentifier,
|
|
||||||
toChatId: ChatIdentifier,
|
|
||||||
messageId: MessageIdentifier,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
CopyMessage(fromChatId, toChatId, messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.copyMessage(
|
|
||||||
fromChat: Chat,
|
|
||||||
toChatId: ChatIdentifier,
|
|
||||||
messageId: MessageIdentifier,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = copyMessage(fromChat.id, toChatId, messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.copyMessage(
|
|
||||||
fromChatId: ChatIdentifier,
|
|
||||||
toChat: Chat,
|
|
||||||
messageId: MessageIdentifier,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = copyMessage(fromChatId, toChat.id, messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.copyMessage(
|
|
||||||
fromChat: Chat,
|
|
||||||
toChat: Chat,
|
|
||||||
messageId: MessageIdentifier,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = copyMessage(fromChat.id, toChat.id, messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.copyMessage(
|
|
||||||
toChatId: ChatIdentifier,
|
|
||||||
message: Message,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = copyMessage(message.chat, toChatId, message.messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.copyMessage(
|
|
||||||
toChat: Chat,
|
|
||||||
message: Message,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = copyMessage(message.chat, toChat, message.messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.copyMessage(
|
|
||||||
fromChatId: ChatIdentifier,
|
|
||||||
toChatId: ChatIdentifier,
|
|
||||||
messageId: MessageIdentifier,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
CopyMessage(fromChatId, toChatId, messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.copyMessage(
|
|
||||||
fromChat: Chat,
|
|
||||||
toChatId: ChatIdentifier,
|
|
||||||
messageId: MessageIdentifier,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = copyMessage(fromChat.id, toChatId, messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.copyMessage(
|
|
||||||
fromChatId: ChatIdentifier,
|
|
||||||
toChat: Chat,
|
|
||||||
messageId: MessageIdentifier,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = copyMessage(fromChatId, toChat.id, messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.copyMessage(
|
|
||||||
fromChat: Chat,
|
|
||||||
toChat: Chat,
|
|
||||||
messageId: MessageIdentifier,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = copyMessage(fromChat.id, toChat.id, messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.copyMessage(
|
|
||||||
toChatId: ChatIdentifier,
|
|
||||||
message: Message,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = copyMessage(message.chat, toChatId, message.messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.copyMessage(
|
|
||||||
toChat: Chat,
|
|
||||||
message: Message,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = copyMessage(message.chat, toChat, message.messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
@@ -1,173 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.send
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.send.media.sendMediaGroup
|
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.media.*
|
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
|
||||||
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
|
|
||||||
import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send media group via [sendMediaGroup] extension with edited [entities] of first [messages] element. Other elements
|
|
||||||
* will be copied as they are
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.copyMessages(
|
|
||||||
toChatId: ChatIdentifier,
|
|
||||||
messages: List<MediaGroupMessage<MediaGroupContent>>,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null
|
|
||||||
): List<MediaGroupMessage<MediaGroupContent>> {
|
|
||||||
val first = messages.first().content.toMediaGroupMemberTelegramMedia().let {
|
|
||||||
if (text != null) {
|
|
||||||
when (it) {
|
|
||||||
is TelegramMediaAudio -> it.copy(text = text, parseMode = parseMode)
|
|
||||||
is TelegramMediaDocument -> it.copy(text = text, parseMode = parseMode)
|
|
||||||
is TelegramMediaPhoto -> it.copy(text = text, parseMode = parseMode)
|
|
||||||
is TelegramMediaVideo -> it.copy(text = text, parseMode = parseMode)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
it
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return sendMediaGroup(
|
|
||||||
toChatId,
|
|
||||||
listOf(first) + messages.drop(1).map {
|
|
||||||
it.content.toMediaGroupMemberTelegramMedia()
|
|
||||||
},
|
|
||||||
disableNotification,
|
|
||||||
protectContent,
|
|
||||||
replyToMessageId,
|
|
||||||
allowSendingWithoutReply
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send media group via [sendMediaGroup] extension with edited [entities] of first [messages] element. Other elements
|
|
||||||
* will be copied as they are
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.copyMessages(
|
|
||||||
toChat: Chat,
|
|
||||||
messages: List<MediaGroupMessage<MediaGroupContent>>,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null
|
|
||||||
) = copyMessages(toChat.id, messages, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send media group via [sendMediaGroup] extension with edited [entities] of first [messages] element. Other elements
|
|
||||||
* will be copied as they are
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.copyMessages(
|
|
||||||
toChat: ChatIdentifier,
|
|
||||||
update: SentMediaGroupUpdate,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null
|
|
||||||
) = copyMessages(toChat, update.data, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send media group via [sendMediaGroup] extension with edited [entities] of first [messages] element. Other elements
|
|
||||||
* will be copied as they are
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.copyMessages(
|
|
||||||
toChat: Chat,
|
|
||||||
update: SentMediaGroupUpdate,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null
|
|
||||||
) = copyMessages(toChat.id, update, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send media group via [sendMediaGroup] extension with edited [entities] of first [messages] element. Other elements
|
|
||||||
* will be copied as they are
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.copyMessages(
|
|
||||||
toChatId: ChatIdentifier,
|
|
||||||
messages: List<MediaGroupMessage<MediaGroupContent>>,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null
|
|
||||||
): List<MediaGroupMessage<MediaGroupContent>> {
|
|
||||||
val first = messages.first().content.toMediaGroupMemberTelegramMedia().let {
|
|
||||||
when (it) {
|
|
||||||
is TelegramMediaAudio -> TelegramMediaAudio(it.file, entities, it.duration, it.performer, it.title, it.thumb)
|
|
||||||
is TelegramMediaDocument -> TelegramMediaDocument(it.file, entities, it.thumb, it.disableContentTypeDetection)
|
|
||||||
is TelegramMediaPhoto -> TelegramMediaPhoto(it.file, entities)
|
|
||||||
is TelegramMediaVideo -> TelegramMediaVideo(it.file, entities, it.width, it.height, it.duration, it.thumb)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return sendMediaGroup(
|
|
||||||
toChatId,
|
|
||||||
listOf(first) + messages.drop(1).map {
|
|
||||||
it.content.toMediaGroupMemberTelegramMedia()
|
|
||||||
},
|
|
||||||
disableNotification,
|
|
||||||
protectContent,
|
|
||||||
replyToMessageId,
|
|
||||||
allowSendingWithoutReply
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send media group via [sendMediaGroup] extension with edited [entities] of first [messages] element. Other elements
|
|
||||||
* will be copied as they are
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.copyMessages(
|
|
||||||
toChat: Chat,
|
|
||||||
messages: List<MediaGroupMessage<MediaGroupContent>>,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null
|
|
||||||
) = copyMessages(toChat.id, messages, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send media group via [sendMediaGroup] extension with edited [entities] of first [messages] element. Other elements
|
|
||||||
* will be copied as they are
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.copyMessages(
|
|
||||||
toChat: ChatIdentifier,
|
|
||||||
update: SentMediaGroupUpdate,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null
|
|
||||||
) = copyMessages(toChat, update.data, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send media group via [sendMediaGroup] extension with edited [entities] of first [messages] element. Other elements
|
|
||||||
* will be copied as they are
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.copyMessages(
|
|
||||||
toChat: Chat,
|
|
||||||
update: SentMediaGroupUpdate,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null
|
|
||||||
) = copyMessages(toChat.id, update, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply)
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,224 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.send
|
|
||||||
|
|
||||||
import dev.inmo.micro_utils.coroutines.safelyWithResult
|
|
||||||
import dev.inmo.micro_utils.coroutines.safelyWithoutExceptions
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.send.SendAction
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
|
||||||
import dev.inmo.tgbotapi.types.actions.*
|
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
|
||||||
import kotlinx.coroutines.*
|
|
||||||
import kotlin.contracts.*
|
|
||||||
import kotlin.coroutines.coroutineContext
|
|
||||||
|
|
||||||
private const val refreshTime: MilliSeconds = (botActionActualityTime - 1) * 1000L
|
|
||||||
typealias TelegramBotActionCallback<T> = suspend TelegramBot.() -> T
|
|
||||||
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
suspend fun <T> TelegramBot.withAction(
|
|
||||||
actionRequest: SendAction,
|
|
||||||
block: TelegramBotActionCallback<T>
|
|
||||||
): T {
|
|
||||||
contract {
|
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
||||||
}
|
|
||||||
val botActionJob = CoroutineScope(coroutineContext).launch {
|
|
||||||
while (isActive) {
|
|
||||||
delay(refreshTime)
|
|
||||||
safelyWithoutExceptions {
|
|
||||||
execute(actionRequest)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val result = safelyWithResult { block() }
|
|
||||||
botActionJob.cancel()
|
|
||||||
return result.getOrThrow()
|
|
||||||
}
|
|
||||||
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
suspend fun <T> TelegramBot.withAction(
|
|
||||||
chatId: ChatId,
|
|
||||||
action: BotAction,
|
|
||||||
block: TelegramBotActionCallback<T>
|
|
||||||
): T {
|
|
||||||
contract {
|
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
||||||
}
|
|
||||||
return withAction(
|
|
||||||
SendAction(chatId, action),
|
|
||||||
block
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
suspend fun <T> TelegramBot.withAction(
|
|
||||||
chat: Chat,
|
|
||||||
action: BotAction,
|
|
||||||
block: TelegramBotActionCallback<T>
|
|
||||||
): T {
|
|
||||||
contract {
|
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
||||||
}
|
|
||||||
return withAction(
|
|
||||||
chat.id,
|
|
||||||
action,
|
|
||||||
block
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
suspend fun <T> TelegramBot.withTypingAction(chatId: ChatId, block: TelegramBotActionCallback<T>) : T {
|
|
||||||
contract {
|
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
||||||
}
|
|
||||||
return withAction(chatId, TypingAction, block)
|
|
||||||
}
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
suspend fun <T> TelegramBot.withUploadPhotoAction(chatId: ChatId, block: TelegramBotActionCallback<T>) : T {
|
|
||||||
contract {
|
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
||||||
}
|
|
||||||
return withAction(chatId, UploadPhotoAction, block)
|
|
||||||
}
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
suspend fun <T> TelegramBot.withRecordVideoAction(chatId: ChatId, block: TelegramBotActionCallback<T>) : T {
|
|
||||||
contract {
|
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
||||||
}
|
|
||||||
return withAction(chatId, RecordVideoAction, block)
|
|
||||||
}
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
suspend fun <T> TelegramBot.withUploadVideoAction(chatId: ChatId, block: TelegramBotActionCallback<T>) : T {
|
|
||||||
contract {
|
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
||||||
}
|
|
||||||
return withAction(chatId, UploadVideoAction, block)
|
|
||||||
}
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
suspend fun <T> TelegramBot.withRecordVoiceAction(chatId: ChatId, block: TelegramBotActionCallback<T>) : T {
|
|
||||||
contract {
|
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
||||||
}
|
|
||||||
return withAction(chatId, RecordVoiceAction, block)
|
|
||||||
}
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
suspend fun <T> TelegramBot.withUploadVoiceAction(chatId: ChatId, block: TelegramBotActionCallback<T>) : T {
|
|
||||||
contract {
|
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
||||||
}
|
|
||||||
return withAction(chatId, UploadVoiceAction, block)
|
|
||||||
}
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
suspend fun <T> TelegramBot.withUploadDocumentAction(chatId: ChatId, block: TelegramBotActionCallback<T>) : T {
|
|
||||||
contract {
|
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
||||||
}
|
|
||||||
return withAction(chatId, UploadDocumentAction, block)
|
|
||||||
}
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
suspend fun <T> TelegramBot.withFindLocationAction(chatId: ChatId, block: TelegramBotActionCallback<T>) : T {
|
|
||||||
contract {
|
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
||||||
}
|
|
||||||
return withAction(chatId, FindLocationAction, block)
|
|
||||||
}
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
suspend fun <T> TelegramBot.withRecordVideoNoteAction(chatId: ChatId, block: TelegramBotActionCallback<T>) : T {
|
|
||||||
contract {
|
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
||||||
}
|
|
||||||
return withAction(chatId, RecordVideoNoteAction, block)
|
|
||||||
}
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
suspend fun <T> TelegramBot.withUploadVideoNoteAction(chatId: ChatId, block: TelegramBotActionCallback<T>) : T {
|
|
||||||
contract {
|
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
||||||
}
|
|
||||||
return withAction(chatId, UploadVideoNoteAction, block)
|
|
||||||
}
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
suspend fun <T> TelegramBot.withChooseStickerAction(chatId: ChatId, block: TelegramBotActionCallback<T>) : T {
|
|
||||||
contract {
|
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
||||||
}
|
|
||||||
return withAction(chatId, ChooseStickerAction, block)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
suspend fun <T> TelegramBot.withTypingAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
|
||||||
contract {
|
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
||||||
}
|
|
||||||
return withAction(chat, TypingAction, block)
|
|
||||||
}
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
suspend fun <T> TelegramBot.withUploadPhotoAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
|
||||||
contract {
|
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
||||||
}
|
|
||||||
return withAction(chat, UploadPhotoAction, block)
|
|
||||||
}
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
suspend fun <T> TelegramBot.withRecordVideoAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
|
||||||
contract {
|
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
||||||
}
|
|
||||||
return withAction(chat, RecordVideoAction, block)
|
|
||||||
}
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
suspend fun <T> TelegramBot.withUploadVideoAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
|
||||||
contract {
|
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
||||||
}
|
|
||||||
return withAction(chat, UploadVideoAction, block)
|
|
||||||
}
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
suspend fun <T> TelegramBot.withRecordVoiceAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
|
||||||
contract {
|
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
||||||
}
|
|
||||||
return withAction(chat, RecordVoiceAction, block)
|
|
||||||
}
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
suspend fun <T> TelegramBot.withUploadVoiceAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
|
||||||
contract {
|
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
||||||
}
|
|
||||||
return withAction(chat, UploadVoiceAction, block)
|
|
||||||
}
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
suspend fun <T> TelegramBot.withUploadDocumentAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
|
||||||
contract {
|
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
||||||
}
|
|
||||||
return withAction(chat, UploadDocumentAction, block)
|
|
||||||
}
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
suspend fun <T> TelegramBot.withFindLocationAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
|
||||||
contract {
|
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
||||||
}
|
|
||||||
return withAction(chat, FindLocationAction, block)
|
|
||||||
}
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
suspend fun <T> TelegramBot.withRecordVideoNoteAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
|
||||||
contract {
|
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
||||||
}
|
|
||||||
return withAction(chat, RecordVideoNoteAction, block)
|
|
||||||
}
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
suspend fun <T> TelegramBot.withUploadVideoNoteAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
|
||||||
contract {
|
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
||||||
}
|
|
||||||
return withAction(chat, UploadVideoNoteAction, block)
|
|
||||||
}
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
|
||||||
suspend fun <T> TelegramBot.withChooseStickerAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
|
||||||
contract {
|
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
||||||
}
|
|
||||||
return withAction(chat, ChooseStickerAction, block)
|
|
||||||
}
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.send
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.send.SendContact
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendContact(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
phoneNumber: String,
|
|
||||||
firstName: String,
|
|
||||||
lastName: String? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
SendContact(
|
|
||||||
chatId, phoneNumber, firstName, lastName, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendContact(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
contact: Contact,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
SendContact(
|
|
||||||
chatId, contact, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendContact(
|
|
||||||
chat: Chat,
|
|
||||||
phoneNumber: String,
|
|
||||||
firstName: String,
|
|
||||||
lastName: String? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendContact(
|
|
||||||
chat.id, phoneNumber, firstName, lastName, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendContact(
|
|
||||||
chat: Chat,
|
|
||||||
contact: Contact,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendContact(
|
|
||||||
chat.id, contact, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
||||||
)
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.send
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.send.SendDice
|
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
|
||||||
import dev.inmo.tgbotapi.types.dice.DiceAnimationType
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendDice(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
animationType: DiceAnimationType? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
SendDice(chatId, animationType, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendDice(
|
|
||||||
chat: Chat,
|
|
||||||
animationType: DiceAnimationType? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendDice(chat.id, animationType, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
@@ -1,163 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.send
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.send.SendStaticLocation
|
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
|
||||||
import dev.inmo.tgbotapi.types.location.StaticLocation
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendLocation(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
latitude: Double,
|
|
||||||
longitude: Double,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
SendStaticLocation(
|
|
||||||
chatId,
|
|
||||||
latitude,
|
|
||||||
longitude,
|
|
||||||
disableNotification = disableNotification,
|
|
||||||
protectContent = protectContent,
|
|
||||||
allowSendingWithoutReply = allowSendingWithoutReply,
|
|
||||||
replyToMessageId = replyToMessageId,
|
|
||||||
replyMarkup = replyMarkup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendLocation(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
location: StaticLocation,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendLocation(
|
|
||||||
chatId,
|
|
||||||
location.latitude,
|
|
||||||
location.longitude,
|
|
||||||
disableNotification,
|
|
||||||
protectContent,
|
|
||||||
allowSendingWithoutReply,
|
|
||||||
replyToMessageId,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendLocation(
|
|
||||||
chat: Chat,
|
|
||||||
latitude: Double,
|
|
||||||
longitude: Double,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendLocation(
|
|
||||||
chat.id,
|
|
||||||
latitude,
|
|
||||||
longitude,
|
|
||||||
disableNotification,
|
|
||||||
protectContent,
|
|
||||||
allowSendingWithoutReply,
|
|
||||||
replyToMessageId,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendLocation(
|
|
||||||
chat: Chat,
|
|
||||||
location: StaticLocation,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendLocation(
|
|
||||||
chat.id,
|
|
||||||
location.latitude,
|
|
||||||
location.longitude,
|
|
||||||
disableNotification,
|
|
||||||
protectContent,
|
|
||||||
allowSendingWithoutReply,
|
|
||||||
replyToMessageId,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendStaticLocation(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
latitude: Double,
|
|
||||||
longitude: Double,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendLocation(chatId, latitude, longitude, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendStaticLocation(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
location: StaticLocation,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendLocation(chatId, location.latitude, location.longitude, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendStaticLocation(
|
|
||||||
chat: Chat,
|
|
||||||
latitude: Double,
|
|
||||||
longitude: Double,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendLocation(chat.id, latitude, longitude, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendStaticLocation(
|
|
||||||
chat: Chat,
|
|
||||||
location: StaticLocation,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendLocation(chat.id, location.latitude, location.longitude, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup)
|
|
||||||
@@ -1,144 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.send
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.send.SendTextMessage
|
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendMessage(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
text: String,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableWebPagePreview: Boolean? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
SendTextMessage(chatId, text, parseMode, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendTextMessage(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
text: String,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableWebPagePreview: Boolean? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendMessage(
|
|
||||||
chatId, text, parseMode, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendMessage(
|
|
||||||
chat: Chat,
|
|
||||||
text: String,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableWebPagePreview: Boolean? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendMessage(chat.id, text, parseMode, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendTextMessage(
|
|
||||||
chat: Chat,
|
|
||||||
text: String,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableWebPagePreview: Boolean? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendTextMessage(chat.id, text, parseMode, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendMessage(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableWebPagePreview: Boolean? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
SendTextMessage(chatId, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendTextMessage(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableWebPagePreview: Boolean? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendMessage(
|
|
||||||
chatId, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendMessage(
|
|
||||||
chat: Chat,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableWebPagePreview: Boolean? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendMessage(chat.id, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendTextMessage(
|
|
||||||
chat: Chat,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableWebPagePreview: Boolean? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendTextMessage(chat.id, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
@@ -1,199 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.send
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.send.SendVenue
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
|
||||||
import dev.inmo.tgbotapi.types.location.StaticLocation
|
|
||||||
import dev.inmo.tgbotapi.types.venue.Venue
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendVenue(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
latitude: Double,
|
|
||||||
longitude: Double,
|
|
||||||
title: String,
|
|
||||||
address: String,
|
|
||||||
foursquareId: FoursquareId? = null,
|
|
||||||
foursquareType: FoursquareType? = null,
|
|
||||||
googlePlaceId: GooglePlaceId? = null,
|
|
||||||
googlePlaceType: GooglePlaceType? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
SendVenue(
|
|
||||||
chatId = chatId,
|
|
||||||
latitude = latitude,
|
|
||||||
longitude = longitude,
|
|
||||||
title = title,
|
|
||||||
address = address,
|
|
||||||
foursquareId = foursquareId,
|
|
||||||
foursquareType = foursquareType,
|
|
||||||
googlePlaceId = googlePlaceId,
|
|
||||||
googlePlaceType = googlePlaceType,
|
|
||||||
disableNotification = disableNotification,
|
|
||||||
protectContent = protectContent,
|
|
||||||
replyToMessageId = replyToMessageId,
|
|
||||||
allowSendingWithoutReply = allowSendingWithoutReply,
|
|
||||||
replyMarkup = replyMarkup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendVenue(
|
|
||||||
chat: Chat,
|
|
||||||
latitude: Double,
|
|
||||||
longitude: Double,
|
|
||||||
title: String,
|
|
||||||
address: String,
|
|
||||||
foursquareId: FoursquareId? = null,
|
|
||||||
foursquareType: FoursquareType? = null,
|
|
||||||
googlePlaceId: GooglePlaceId? = null,
|
|
||||||
googlePlaceType: GooglePlaceType? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendVenue(
|
|
||||||
chatId = chat.id,
|
|
||||||
latitude = latitude,
|
|
||||||
longitude = longitude,
|
|
||||||
title = title,
|
|
||||||
address = address,
|
|
||||||
foursquareId = foursquareId,
|
|
||||||
foursquareType = foursquareType,
|
|
||||||
googlePlaceId = googlePlaceId,
|
|
||||||
googlePlaceType = googlePlaceType,
|
|
||||||
disableNotification = disableNotification,
|
|
||||||
protectContent = protectContent,
|
|
||||||
replyToMessageId = replyToMessageId,
|
|
||||||
allowSendingWithoutReply = allowSendingWithoutReply,
|
|
||||||
replyMarkup = replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendVenue(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
location: StaticLocation,
|
|
||||||
title: String,
|
|
||||||
address: String,
|
|
||||||
foursquareId: FoursquareId? = null,
|
|
||||||
foursquareType: FoursquareType? = null,
|
|
||||||
googlePlaceId: GooglePlaceId? = null,
|
|
||||||
googlePlaceType: GooglePlaceType? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendVenue(
|
|
||||||
chatId = chatId,
|
|
||||||
latitude = location.latitude,
|
|
||||||
longitude = location.longitude,
|
|
||||||
title = title,
|
|
||||||
address = address,
|
|
||||||
foursquareId = foursquareId,
|
|
||||||
foursquareType = foursquareType,
|
|
||||||
googlePlaceId = googlePlaceId,
|
|
||||||
googlePlaceType = googlePlaceType,
|
|
||||||
disableNotification = disableNotification,
|
|
||||||
protectContent = protectContent,
|
|
||||||
replyToMessageId = replyToMessageId,
|
|
||||||
allowSendingWithoutReply = allowSendingWithoutReply,
|
|
||||||
replyMarkup = replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendVenue(
|
|
||||||
chat: Chat,
|
|
||||||
location: StaticLocation,
|
|
||||||
title: String,
|
|
||||||
address: String,
|
|
||||||
foursquareId: FoursquareId? = null,
|
|
||||||
foursquareType: FoursquareType? = null,
|
|
||||||
googlePlaceId: GooglePlaceId? = null,
|
|
||||||
googlePlaceType: GooglePlaceType? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendVenue(
|
|
||||||
chatId = chat.id,
|
|
||||||
latitude = location.latitude,
|
|
||||||
longitude = location.longitude,
|
|
||||||
title = title,
|
|
||||||
address = address,
|
|
||||||
foursquareId = foursquareId,
|
|
||||||
foursquareType = foursquareType,
|
|
||||||
googlePlaceId = googlePlaceId,
|
|
||||||
googlePlaceType = googlePlaceType,
|
|
||||||
disableNotification = disableNotification,
|
|
||||||
protectContent = protectContent,
|
|
||||||
replyToMessageId = replyToMessageId,
|
|
||||||
allowSendingWithoutReply = allowSendingWithoutReply,
|
|
||||||
replyMarkup = replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendVenue(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
venue: Venue,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
SendVenue(
|
|
||||||
chatId = chatId,
|
|
||||||
venue = venue,
|
|
||||||
disableNotification = disableNotification,
|
|
||||||
protectContent = protectContent,
|
|
||||||
replyToMessageId = replyToMessageId,
|
|
||||||
allowSendingWithoutReply = allowSendingWithoutReply,
|
|
||||||
replyMarkup = replyMarkup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendVenue(
|
|
||||||
chat: Chat,
|
|
||||||
venue: Venue,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendVenue(
|
|
||||||
chatId = chat.id,
|
|
||||||
venue = venue,
|
|
||||||
disableNotification = disableNotification,
|
|
||||||
protectContent = protectContent,
|
|
||||||
replyToMessageId = replyToMessageId,
|
|
||||||
allowSendingWithoutReply = allowSendingWithoutReply,
|
|
||||||
replyMarkup = replyMarkup
|
|
||||||
)
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.send.games
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.send.games.SendGame
|
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
|
||||||
import dev.inmo.tgbotapi.types.games.Game
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendGame(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
gameShortName: String,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
SendGame(
|
|
||||||
chatId, gameShortName, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendGame(
|
|
||||||
chat: Chat,
|
|
||||||
gameShortName: String,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendGame(
|
|
||||||
chat.id, gameShortName, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendGame(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
game: Game,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendGame(
|
|
||||||
chatId, game.title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendGame(
|
|
||||||
chat: Chat,
|
|
||||||
game: Game,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendGame(
|
|
||||||
chat.id, game.title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
||||||
)
|
|
||||||
@@ -1,200 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.send.media
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
|
||||||
import dev.inmo.tgbotapi.requests.send.media.SendAnimation
|
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
|
||||||
import dev.inmo.tgbotapi.types.files.AnimationFile
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendAnimation(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
animation: InputFile,
|
|
||||||
thumb: InputFile? = null,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
duration: Long? = null,
|
|
||||||
width: Int? = null,
|
|
||||||
height: Int? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
SendAnimation(
|
|
||||||
chatId,
|
|
||||||
animation,
|
|
||||||
thumb,
|
|
||||||
text,
|
|
||||||
parseMode,
|
|
||||||
duration,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
disableNotification,
|
|
||||||
protectContent,
|
|
||||||
replyToMessageId,
|
|
||||||
allowSendingWithoutReply,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendAnimation(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
animation: AnimationFile,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
duration: Long? = null,
|
|
||||||
width: Int? = null,
|
|
||||||
height: Int? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendAnimation(
|
|
||||||
chatId, animation.fileId, animation.thumb ?.fileId, text, parseMode, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendAnimation(
|
|
||||||
chat: Chat,
|
|
||||||
animation: InputFile,
|
|
||||||
thumb: InputFile? = null,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
duration: Long? = null,
|
|
||||||
width: Int? = null,
|
|
||||||
height: Int? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendAnimation(chat.id, animation, thumb, text, parseMode, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendAnimation(
|
|
||||||
chat: Chat,
|
|
||||||
animation: AnimationFile,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
duration: Long? = null,
|
|
||||||
width: Int? = null,
|
|
||||||
height: Int? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendAnimation(chat.id, animation, text, parseMode, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendAnimation(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
animation: InputFile,
|
|
||||||
thumb: InputFile? = null,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
duration: Long? = null,
|
|
||||||
width: Int? = null,
|
|
||||||
height: Int? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
SendAnimation(
|
|
||||||
chatId,
|
|
||||||
animation,
|
|
||||||
thumb,
|
|
||||||
entities,
|
|
||||||
duration,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
disableNotification,
|
|
||||||
protectContent,
|
|
||||||
replyToMessageId,
|
|
||||||
allowSendingWithoutReply,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendAnimation(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
animation: AnimationFile,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
duration: Long? = null,
|
|
||||||
width: Int? = null,
|
|
||||||
height: Int? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendAnimation(
|
|
||||||
chatId, animation.fileId, animation.thumb ?.fileId, entities, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendAnimation(
|
|
||||||
chat: Chat,
|
|
||||||
animation: InputFile,
|
|
||||||
thumb: InputFile? = null,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
duration: Long? = null,
|
|
||||||
width: Int? = null,
|
|
||||||
height: Int? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendAnimation(chat.id, animation, thumb, entities, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendAnimation(
|
|
||||||
chat: Chat,
|
|
||||||
animation: AnimationFile,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
duration: Long? = null,
|
|
||||||
width: Int? = null,
|
|
||||||
height: Int? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendAnimation(chat.id, animation, entities, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
@@ -1,188 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.send.media
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
|
||||||
import dev.inmo.tgbotapi.requests.send.media.SendAudio
|
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
|
||||||
import dev.inmo.tgbotapi.types.files.AudioFile
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendAudio(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
audio: InputFile,
|
|
||||||
thumb: InputFile? = null,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
duration: Long? = null,
|
|
||||||
performer: String? = null,
|
|
||||||
title: String? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
SendAudio(
|
|
||||||
chatId,
|
|
||||||
audio,
|
|
||||||
thumb,
|
|
||||||
text,
|
|
||||||
parseMode,
|
|
||||||
duration,
|
|
||||||
performer,
|
|
||||||
title,
|
|
||||||
disableNotification,
|
|
||||||
protectContent,
|
|
||||||
replyToMessageId,
|
|
||||||
allowSendingWithoutReply,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendAudio(
|
|
||||||
chat: Chat,
|
|
||||||
audio: InputFile,
|
|
||||||
thumb: InputFile? = null,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
duration: Long? = null,
|
|
||||||
performer: String? = null,
|
|
||||||
title: String? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendAudio(chat.id, audio, thumb, text, parseMode, duration, performer, title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendAudio(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
audio: AudioFile,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
title: String? = audio.title,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendAudio(chatId, audio.fileId, audio.thumb ?.fileId, text, parseMode, audio.duration, audio.performer, title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendAudio(
|
|
||||||
chat: Chat,
|
|
||||||
audio: AudioFile,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
title: String? = audio.title,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendAudio(chat.id, audio, text, parseMode, title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.sendAudio(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
audio: InputFile,
|
|
||||||
thumb: InputFile? = null,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
duration: Long? = null,
|
|
||||||
performer: String? = null,
|
|
||||||
title: String? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
SendAudio(
|
|
||||||
chatId,
|
|
||||||
audio,
|
|
||||||
thumb,
|
|
||||||
entities,
|
|
||||||
duration,
|
|
||||||
performer,
|
|
||||||
title,
|
|
||||||
disableNotification,
|
|
||||||
protectContent,
|
|
||||||
replyToMessageId,
|
|
||||||
allowSendingWithoutReply,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.sendAudio(
|
|
||||||
chat: Chat,
|
|
||||||
audio: InputFile,
|
|
||||||
thumb: InputFile? = null,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
duration: Long? = null,
|
|
||||||
performer: String? = null,
|
|
||||||
title: String? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendAudio(chat.id, audio, thumb, entities, duration, performer, title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.sendAudio(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
audio: AudioFile,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
title: String? = audio.title,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendAudio(chatId, audio.fileId, audio.thumb ?.fileId, entities, audio.duration, audio.performer, title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.sendAudio(
|
|
||||||
chat: Chat,
|
|
||||||
audio: AudioFile,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
title: String? = audio.title,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendAudio(chat.id, audio, entities, title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
@@ -1,179 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.send.media
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
|
||||||
import dev.inmo.tgbotapi.requests.send.media.SendDocument
|
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
|
||||||
import dev.inmo.tgbotapi.types.files.DocumentFile
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendDocument(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
document: InputFile,
|
|
||||||
thumb: InputFile? = null,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null,
|
|
||||||
disableContentTypeDetection: Boolean? = null
|
|
||||||
) = execute(
|
|
||||||
SendDocument(
|
|
||||||
chatId,
|
|
||||||
document,
|
|
||||||
thumb,
|
|
||||||
text,
|
|
||||||
parseMode,
|
|
||||||
disableNotification,
|
|
||||||
protectContent,
|
|
||||||
replyToMessageId,
|
|
||||||
allowSendingWithoutReply,
|
|
||||||
replyMarkup,
|
|
||||||
disableContentTypeDetection
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendDocument(
|
|
||||||
chat: Chat,
|
|
||||||
document: InputFile,
|
|
||||||
thumb: InputFile? = null,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null,
|
|
||||||
disableContentTypeDetection: Boolean? = null
|
|
||||||
) = sendDocument(chat.id, document, thumb, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendDocument(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
document: DocumentFile,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null,
|
|
||||||
disableContentTypeDetection: Boolean? = null
|
|
||||||
) = sendDocument(
|
|
||||||
chatId, document.fileId, document.thumb ?.fileId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendDocument(
|
|
||||||
chat: Chat,
|
|
||||||
document: DocumentFile,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null,
|
|
||||||
disableContentTypeDetection: Boolean? = null
|
|
||||||
) = sendDocument(chat.id, document, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.sendDocument(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
document: InputFile,
|
|
||||||
thumb: InputFile? = null,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null,
|
|
||||||
disableContentTypeDetection: Boolean? = null
|
|
||||||
) = execute(
|
|
||||||
SendDocument(
|
|
||||||
chatId,
|
|
||||||
document,
|
|
||||||
thumb,
|
|
||||||
entities,
|
|
||||||
disableNotification,
|
|
||||||
protectContent,
|
|
||||||
replyToMessageId,
|
|
||||||
allowSendingWithoutReply,
|
|
||||||
replyMarkup,
|
|
||||||
disableContentTypeDetection
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.sendDocument(
|
|
||||||
chat: Chat,
|
|
||||||
document: InputFile,
|
|
||||||
thumb: InputFile? = null,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null,
|
|
||||||
disableContentTypeDetection: Boolean? = null
|
|
||||||
) = sendDocument(chat.id, document, thumb, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.sendDocument(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
document: DocumentFile,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null,
|
|
||||||
disableContentTypeDetection: Boolean? = null
|
|
||||||
) = sendDocument(
|
|
||||||
chatId, document.fileId, document.thumb ?.fileId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.sendDocument(
|
|
||||||
chat: Chat,
|
|
||||||
document: DocumentFile,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null,
|
|
||||||
disableContentTypeDetection: Boolean? = null
|
|
||||||
) = sendDocument(chat.id, document, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection)
|
|
||||||
@@ -1,258 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.send.media
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.send.media.*
|
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.media.*
|
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
|
||||||
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
|
|
||||||
import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent
|
|
||||||
import dev.inmo.tgbotapi.types.message.content.AudioContent
|
|
||||||
import dev.inmo.tgbotapi.types.message.content.DocumentContent
|
|
||||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
|
||||||
import kotlin.jvm.JvmName
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see SendMediaGroup
|
|
||||||
*/
|
|
||||||
@RiskFeature(rawSendingMediaGroupsWarning)
|
|
||||||
suspend fun TelegramBot.sendMediaGroup(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
media: List<MediaGroupMemberTelegramMedia>,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null
|
|
||||||
) = execute(
|
|
||||||
SendMediaGroup<MediaGroupContent>(
|
|
||||||
chatId, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see SendMediaGroup
|
|
||||||
*/
|
|
||||||
@RiskFeature(rawSendingMediaGroupsWarning)
|
|
||||||
suspend fun TelegramBot.sendMediaGroup(
|
|
||||||
chat: Chat,
|
|
||||||
media: List<MediaGroupMemberTelegramMedia>,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null
|
|
||||||
) = sendMediaGroup(
|
|
||||||
chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see SendMediaGroup
|
|
||||||
*/
|
|
||||||
@RiskFeature(rawSendingMediaGroupsWarning)
|
|
||||||
@JvmName("sendMedaGroupByContent")
|
|
||||||
suspend fun TelegramBot.sendMediaGroup(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
media: List<MediaGroupContent>,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null
|
|
||||||
) = sendMediaGroup(
|
|
||||||
chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see SendMediaGroup
|
|
||||||
*/
|
|
||||||
@RiskFeature(rawSendingMediaGroupsWarning)
|
|
||||||
@JvmName("sendMedaGroupByContent")
|
|
||||||
suspend fun TelegramBot.sendMediaGroup(
|
|
||||||
chat: Chat,
|
|
||||||
media: List<MediaGroupContent>,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null
|
|
||||||
) = sendMediaGroup(
|
|
||||||
chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see SendPlaylist
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendPlaylist(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
media: List<AudioMediaGroupMemberTelegramMedia>,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null
|
|
||||||
) = execute(
|
|
||||||
SendPlaylist(
|
|
||||||
chatId, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see SendPlaylist
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendPlaylist(
|
|
||||||
chat: Chat,
|
|
||||||
media: List<AudioMediaGroupMemberTelegramMedia>,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null
|
|
||||||
) = sendPlaylist(
|
|
||||||
chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see SendPlaylist
|
|
||||||
*/
|
|
||||||
@JvmName("sendPlaylistByContent")
|
|
||||||
suspend fun TelegramBot.sendPlaylist(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
media: List<AudioContent>,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null
|
|
||||||
) = sendPlaylist(
|
|
||||||
chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see SendPlaylist
|
|
||||||
*/
|
|
||||||
@JvmName("sendPlaylistByContent")
|
|
||||||
suspend fun TelegramBot.sendPlaylist(
|
|
||||||
chat: Chat,
|
|
||||||
media: List<AudioContent>,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null
|
|
||||||
) = sendPlaylist(
|
|
||||||
chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see SendDocumentsGroup
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendDocumentsGroup(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
media: List<DocumentMediaGroupMemberTelegramMedia>,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null
|
|
||||||
) = execute(
|
|
||||||
SendDocumentsGroup(
|
|
||||||
chatId, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see SendDocumentsGroup
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendDocumentsGroup(
|
|
||||||
chat: Chat,
|
|
||||||
media: List<DocumentMediaGroupMemberTelegramMedia>,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null
|
|
||||||
) = sendDocumentsGroup(
|
|
||||||
chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see SendDocumentsGroup
|
|
||||||
*/
|
|
||||||
@JvmName("sendDocumentsByContent")
|
|
||||||
suspend fun TelegramBot.sendDocumentsGroup(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
media: List<DocumentContent>,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null
|
|
||||||
) = sendDocumentsGroup(
|
|
||||||
chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see SendDocumentsGroup
|
|
||||||
*/
|
|
||||||
@JvmName("sendDocumentsByContent")
|
|
||||||
suspend fun TelegramBot.sendDocumentsGroup(
|
|
||||||
chat: Chat,
|
|
||||||
media: List<DocumentContent>,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null
|
|
||||||
) = sendDocumentsGroup(
|
|
||||||
chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see SendVisualMediaGroup
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendVisualMediaGroup(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
media: List<VisualMediaGroupMemberTelegramMedia>,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null
|
|
||||||
) = execute(
|
|
||||||
SendVisualMediaGroup(
|
|
||||||
chatId, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see SendVisualMediaGroup
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendVisualMediaGroup(
|
|
||||||
chat: Chat,
|
|
||||||
media: List<VisualMediaGroupMemberTelegramMedia>,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null
|
|
||||||
) = sendVisualMediaGroup(
|
|
||||||
chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see SendVisualMediaGroup
|
|
||||||
*/
|
|
||||||
@JvmName("sendVisualMediaGroupByContent")
|
|
||||||
suspend fun TelegramBot.sendVisualMediaGroup(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
media: List<VisualMediaGroupContent>,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null
|
|
||||||
) = sendVisualMediaGroup(
|
|
||||||
chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see SendVisualMediaGroup
|
|
||||||
*/
|
|
||||||
@JvmName("sendVisualMediaGroupByContent")
|
|
||||||
suspend fun TelegramBot.sendVisualMediaGroup(
|
|
||||||
chat: Chat,
|
|
||||||
media: List<VisualMediaGroupContent>,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null
|
|
||||||
) = sendVisualMediaGroup(
|
|
||||||
chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
|
|
||||||
)
|
|
||||||
@@ -1,222 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.send.media
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
|
||||||
import dev.inmo.tgbotapi.requests.send.media.SendPhoto
|
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
|
||||||
import dev.inmo.tgbotapi.types.files.*
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendPhoto(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
fileId: InputFile,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
SendPhoto(
|
|
||||||
chatId,
|
|
||||||
fileId,
|
|
||||||
text,
|
|
||||||
parseMode,
|
|
||||||
disableNotification,
|
|
||||||
protectContent,
|
|
||||||
replyToMessageId,
|
|
||||||
allowSendingWithoutReply,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendPhoto(
|
|
||||||
chat: Chat,
|
|
||||||
fileId: InputFile,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendPhoto(chat.id, fileId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendPhoto(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
photo: Photo,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendPhoto(
|
|
||||||
chat: Chat,
|
|
||||||
photo: Photo,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendPhoto(chat.id, photo, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendPhoto(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
photoSize: PhotoSize,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendPhoto(chatId, photoSize.fileId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendPhoto(
|
|
||||||
chat: Chat,
|
|
||||||
photoSize: PhotoSize,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendPhoto(chat.id, photoSize, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.sendPhoto(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
fileId: InputFile,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
SendPhoto(
|
|
||||||
chatId,
|
|
||||||
fileId,
|
|
||||||
entities,
|
|
||||||
disableNotification,
|
|
||||||
protectContent,
|
|
||||||
replyToMessageId,
|
|
||||||
allowSendingWithoutReply,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.sendPhoto(
|
|
||||||
chat: Chat,
|
|
||||||
fileId: InputFile,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendPhoto(chat.id, fileId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.sendPhoto(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
photo: Photo,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.sendPhoto(
|
|
||||||
chat: Chat,
|
|
||||||
photo: Photo,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendPhoto(chat.id, photo, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.sendPhoto(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
photoSize: PhotoSize,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendPhoto(chatId, photoSize.fileId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.sendPhoto(
|
|
||||||
chat: Chat,
|
|
||||||
photoSize: PhotoSize,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendPhoto(chat.id, photoSize, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.send.media
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
|
||||||
import dev.inmo.tgbotapi.requests.send.media.SendSticker
|
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
|
||||||
import dev.inmo.tgbotapi.types.files.Sticker
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendSticker(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
sticker: InputFile,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
SendSticker(chatId, sticker, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendSticker(
|
|
||||||
chat: Chat,
|
|
||||||
sticker: InputFile,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendSticker(chat.id, sticker, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendSticker(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
sticker: Sticker,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendSticker(chatId, sticker.fileId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendSticker(
|
|
||||||
chat: Chat,
|
|
||||||
sticker: Sticker,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendSticker(chat, sticker.fileId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
@@ -1,187 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.send.media
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
|
||||||
import dev.inmo.tgbotapi.requests.send.media.SendVideo
|
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
|
||||||
import dev.inmo.tgbotapi.types.files.VideoFile
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendVideo(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
video: InputFile,
|
|
||||||
thumb: InputFile? = null,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
duration: Long? = null,
|
|
||||||
width: Int? = null,
|
|
||||||
height: Int? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
SendVideo(
|
|
||||||
chatId,
|
|
||||||
video,
|
|
||||||
thumb,
|
|
||||||
text,
|
|
||||||
parseMode,
|
|
||||||
duration,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
null,
|
|
||||||
disableNotification,
|
|
||||||
protectContent,
|
|
||||||
replyToMessageId,
|
|
||||||
allowSendingWithoutReply,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendVideo(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
video: VideoFile,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendVideo(chatId, video.fileId, video.thumb ?.fileId, text, parseMode, video.duration, video.width, video.height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendVideo(
|
|
||||||
chat: Chat,
|
|
||||||
video: InputFile,
|
|
||||||
thumb: InputFile? = null,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
duration: Long? = null,
|
|
||||||
width: Int? = null,
|
|
||||||
height: Int? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendVideo(chat.id, video, thumb, text, parseMode, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendVideo(
|
|
||||||
chat: Chat,
|
|
||||||
video: VideoFile,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendVideo(chat.id, video, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.sendVideo(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
video: InputFile,
|
|
||||||
thumb: InputFile? = null,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
duration: Long? = null,
|
|
||||||
width: Int? = null,
|
|
||||||
height: Int? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
SendVideo(
|
|
||||||
chatId,
|
|
||||||
video,
|
|
||||||
thumb,
|
|
||||||
entities,
|
|
||||||
duration,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
null,
|
|
||||||
disableNotification,
|
|
||||||
protectContent,
|
|
||||||
replyToMessageId,
|
|
||||||
allowSendingWithoutReply,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.sendVideo(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
video: VideoFile,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendVideo(chatId, video.fileId, video.thumb ?.fileId, entities, video.duration, video.width, video.height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.sendVideo(
|
|
||||||
chat: Chat,
|
|
||||||
video: InputFile,
|
|
||||||
thumb: InputFile? = null,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
duration: Long? = null,
|
|
||||||
width: Int? = null,
|
|
||||||
height: Int? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendVideo(chat.id, video, thumb, entities, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.sendVideo(
|
|
||||||
chat: Chat,
|
|
||||||
video: VideoFile,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendVideo(chat.id, video, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.send.media
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
|
||||||
import dev.inmo.tgbotapi.requests.send.media.SendVideoNote
|
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
|
||||||
import dev.inmo.tgbotapi.types.files.VideoNoteFile
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendVideoNote(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
videoNote: InputFile,
|
|
||||||
thumb: InputFile? = null,
|
|
||||||
duration: Long? = null,
|
|
||||||
size: Int? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
SendVideoNote(
|
|
||||||
chatId,
|
|
||||||
videoNote,
|
|
||||||
thumb,
|
|
||||||
duration,
|
|
||||||
size,
|
|
||||||
disableNotification,
|
|
||||||
protectContent,
|
|
||||||
replyToMessageId,
|
|
||||||
allowSendingWithoutReply,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendVideoNote(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
videoNote: VideoNoteFile,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendVideoNote(
|
|
||||||
chatId, videoNote.fileId, videoNote.thumb ?.fileId, videoNote.duration, videoNote.width, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendVideoNote(
|
|
||||||
chat: Chat,
|
|
||||||
videoNote: InputFile,
|
|
||||||
thumb: InputFile? = null,
|
|
||||||
duration: Long? = null,
|
|
||||||
size: Int? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendVideoNote(chat.id, videoNote, thumb, duration, size, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendVideoNote(
|
|
||||||
chat: Chat,
|
|
||||||
videoNote: VideoNoteFile,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendVideoNote(chat.id, videoNote, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
@@ -1,169 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.send.media
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
|
||||||
import dev.inmo.tgbotapi.requests.send.media.SendVoice
|
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
|
||||||
import dev.inmo.tgbotapi.types.files.VoiceFile
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendVoice(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
voice: InputFile,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
duration: Long? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
SendVoice(
|
|
||||||
chatId,
|
|
||||||
voice,
|
|
||||||
text,
|
|
||||||
parseMode,
|
|
||||||
duration,
|
|
||||||
disableNotification,
|
|
||||||
protectContent,
|
|
||||||
replyToMessageId,
|
|
||||||
allowSendingWithoutReply,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendVoice(
|
|
||||||
chat: Chat,
|
|
||||||
voice: InputFile,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
duration: Long? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendVoice(chat.id, voice, text, parseMode, duration, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendVoice(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
voice: VoiceFile,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendVoice(
|
|
||||||
chatId, voice.fileId, text, parseMode, voice.duration, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendVoice(
|
|
||||||
chat: Chat,
|
|
||||||
voice: VoiceFile,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendVoice(chat.id, voice, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.sendVoice(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
voice: InputFile,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
duration: Long? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
SendVoice(
|
|
||||||
chatId,
|
|
||||||
voice,
|
|
||||||
entities,
|
|
||||||
duration,
|
|
||||||
disableNotification,
|
|
||||||
protectContent,
|
|
||||||
replyToMessageId,
|
|
||||||
allowSendingWithoutReply,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.sendVoice(
|
|
||||||
chat: Chat,
|
|
||||||
voice: InputFile,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
duration: Long? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendVoice(chat.id, voice, entities, duration, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.sendVoice(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
voice: VoiceFile,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendVoice(
|
|
||||||
chatId, voice.fileId, entities, voice.duration, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
||||||
)
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.sendVoice(
|
|
||||||
chat: Chat,
|
|
||||||
voice: VoiceFile,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendVoice(chat.id, voice, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
@@ -1,287 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.send.polls
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.send.polls.SendQuizPoll
|
|
||||||
import dev.inmo.tgbotapi.requests.send.polls.SendRegularPoll
|
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
|
||||||
import dev.inmo.tgbotapi.types.polls.*
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendRegularPoll(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
question: String,
|
|
||||||
options: List<String>,
|
|
||||||
isAnonymous: Boolean = true,
|
|
||||||
isClosed: Boolean = false,
|
|
||||||
allowMultipleAnswers: Boolean = false,
|
|
||||||
closeInfo: ScheduledCloseInfo? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
SendRegularPoll(
|
|
||||||
chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendRegularPoll(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
poll: RegularPoll,
|
|
||||||
isClosed: Boolean = false,
|
|
||||||
question: String = poll.question,
|
|
||||||
options: List<String> = poll.options.map { it.text },
|
|
||||||
isAnonymous: Boolean = poll.isAnonymous,
|
|
||||||
allowMultipleAnswers: Boolean = poll.allowMultipleAnswers,
|
|
||||||
closeInfo: ScheduledCloseInfo? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendRegularPoll(chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendRegularPoll(
|
|
||||||
chat: Chat,
|
|
||||||
question: String,
|
|
||||||
options: List<String>,
|
|
||||||
isAnonymous: Boolean = true,
|
|
||||||
isClosed: Boolean = false,
|
|
||||||
allowMultipleAnswers: Boolean = false,
|
|
||||||
closeInfo: ScheduledCloseInfo? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendRegularPoll(
|
|
||||||
chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendRegularPoll(
|
|
||||||
chat: Chat,
|
|
||||||
poll: RegularPoll,
|
|
||||||
isClosed: Boolean = false,
|
|
||||||
question: String = poll.question,
|
|
||||||
options: List<String> = poll.options.map { it.text },
|
|
||||||
isAnonymous: Boolean = poll.isAnonymous,
|
|
||||||
allowMultipleAnswers: Boolean = poll.allowMultipleAnswers,
|
|
||||||
closeInfo: ScheduledCloseInfo? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendRegularPoll(
|
|
||||||
chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendQuizPoll(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
question: String,
|
|
||||||
options: List<String>,
|
|
||||||
correctOptionId: Int,
|
|
||||||
isAnonymous: Boolean = true,
|
|
||||||
isClosed: Boolean = false,
|
|
||||||
explanation: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
closeInfo: ScheduledCloseInfo? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
SendQuizPoll(
|
|
||||||
chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendQuizPoll(
|
|
||||||
chat: Chat,
|
|
||||||
question: String,
|
|
||||||
options: List<String>,
|
|
||||||
correctOptionId: Int,
|
|
||||||
isAnonymous: Boolean = true,
|
|
||||||
isClosed: Boolean = false,
|
|
||||||
explanation: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
closeInfo: ScheduledCloseInfo? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendQuizPoll(
|
|
||||||
chat.id, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendQuizPoll(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
isClosed: Boolean = false,
|
|
||||||
quizPoll: QuizPoll,
|
|
||||||
question: String = quizPoll.question,
|
|
||||||
options: List<String> = quizPoll.options.map { it.text },
|
|
||||||
correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"),
|
|
||||||
isAnonymous: Boolean = quizPoll.isAnonymous,
|
|
||||||
explanation: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
closeInfo: ScheduledCloseInfo? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendQuizPoll(
|
|
||||||
chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.sendQuizPoll(
|
|
||||||
chat: Chat,
|
|
||||||
isClosed: Boolean = false,
|
|
||||||
quizPoll: QuizPoll,
|
|
||||||
question: String = quizPoll.question,
|
|
||||||
options: List<String> = quizPoll.options.map { it.text },
|
|
||||||
correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"),
|
|
||||||
isAnonymous: Boolean = quizPoll.isAnonymous,
|
|
||||||
explanation: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
closeInfo: ScheduledCloseInfo? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendQuizPoll(
|
|
||||||
chat.id, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.sendQuizPoll(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
question: String,
|
|
||||||
options: List<String>,
|
|
||||||
correctOptionId: Int,
|
|
||||||
isAnonymous: Boolean = true,
|
|
||||||
isClosed: Boolean = false,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
closeInfo: ScheduledCloseInfo? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = execute(
|
|
||||||
SendQuizPoll(
|
|
||||||
chatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.sendQuizPoll(
|
|
||||||
chat: Chat,
|
|
||||||
question: String,
|
|
||||||
options: List<String>,
|
|
||||||
correctOptionId: Int,
|
|
||||||
isAnonymous: Boolean = true,
|
|
||||||
isClosed: Boolean = false,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
closeInfo: ScheduledCloseInfo? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendQuizPoll(
|
|
||||||
chat.id, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.sendQuizPoll(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
isClosed: Boolean = false,
|
|
||||||
quizPoll: QuizPoll,
|
|
||||||
question: String = quizPoll.question,
|
|
||||||
options: List<String> = quizPoll.options.map { it.text },
|
|
||||||
correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"),
|
|
||||||
isAnonymous: Boolean = quizPoll.isAnonymous,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
closeInfo: ScheduledCloseInfo? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendQuizPoll(
|
|
||||||
chatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.sendQuizPoll(
|
|
||||||
chat: Chat,
|
|
||||||
isClosed: Boolean = false,
|
|
||||||
quizPoll: QuizPoll,
|
|
||||||
question: String = quizPoll.question,
|
|
||||||
options: List<String> = quizPoll.options.map { it.text },
|
|
||||||
correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"),
|
|
||||||
isAnonymous: Boolean = quizPoll.isAnonymous,
|
|
||||||
entities: TextSourcesList,
|
|
||||||
closeInfo: ScheduledCloseInfo? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = sendQuizPoll(
|
|
||||||
chat.id, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
||||||
)
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.AddVideoStickerToSet
|
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addVideoStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = execute(
|
|
||||||
AddVideoStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addVideoStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = execute(
|
|
||||||
AddVideoStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addVideoStickerToSet(
|
|
||||||
user: CommonUser,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addVideoStickerToSet(
|
|
||||||
user.id, stickerSetName, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addVideoStickerToSet(
|
|
||||||
user: CommonUser,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addVideoStickerToSet(
|
|
||||||
user.id, stickerSetName, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addVideoStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSet: StickerSet,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addVideoStickerToSet(
|
|
||||||
userId, stickerSet.name, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addVideoStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSet: StickerSet,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addVideoStickerToSet(
|
|
||||||
userId, stickerSet.name, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addVideoStickerToSet(
|
|
||||||
user: CommonUser,
|
|
||||||
stickerSet: StickerSet,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addVideoStickerToSet(
|
|
||||||
user.id, stickerSet.name, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addVideoStickerToSet(
|
|
||||||
user: CommonUser,
|
|
||||||
stickerSet: StickerSet,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addVideoStickerToSet(
|
|
||||||
user.id, stickerSet.name, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.CreateNewVideoStickerSet
|
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewVideoStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = execute(
|
|
||||||
CreateNewVideoStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewVideoStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = execute(
|
|
||||||
CreateNewVideoStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewVideoStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = createNewVideoStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis, containsMasks, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewVideoStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = createNewVideoStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis, containsMasks, maskPosition
|
|
||||||
)
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.files
|
|
||||||
|
|
||||||
import dev.inmo.micro_utils.coroutines.doOutsideOfCoroutine
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.get.getFileAdditionalInfo
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
|
||||||
import dev.inmo.tgbotapi.types.files.PathedFile
|
|
||||||
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
|
|
||||||
import dev.inmo.tgbotapi.types.message.content.MediaContent
|
|
||||||
import io.ktor.util.cio.use
|
|
||||||
import io.ktor.util.cio.writeChannel
|
|
||||||
import io.ktor.utils.io.copyTo
|
|
||||||
import kotlinx.coroutines.job
|
|
||||||
import java.io.File
|
|
||||||
import kotlin.coroutines.coroutineContext
|
|
||||||
|
|
||||||
suspend fun TelegramBot.downloadFile(
|
|
||||||
filePath: String,
|
|
||||||
destFile: File
|
|
||||||
): File {
|
|
||||||
val readChannel = downloadFileStream(filePath)
|
|
||||||
|
|
||||||
destFile.deleteRecursively()
|
|
||||||
destFile.parentFile.mkdirs()
|
|
||||||
doOutsideOfCoroutine { destFile.createNewFile() }
|
|
||||||
|
|
||||||
destFile.writeChannel(coroutineContext.job).use {
|
|
||||||
readChannel.copyTo(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
return destFile
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun TelegramBot.downloadFile(
|
|
||||||
pathedFile: PathedFile,
|
|
||||||
destFile: File
|
|
||||||
) = downloadFile(
|
|
||||||
pathedFile.filePath,
|
|
||||||
destFile
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.downloadFile(
|
|
||||||
fileId: FileId,
|
|
||||||
destFile: File
|
|
||||||
) = downloadFile(
|
|
||||||
getFileAdditionalInfo(fileId),
|
|
||||||
destFile
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.downloadFile(
|
|
||||||
file: TelegramMediaFile,
|
|
||||||
destFile: File
|
|
||||||
): File = downloadFile(
|
|
||||||
getFileAdditionalInfo(file),
|
|
||||||
destFile
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.downloadFile(
|
|
||||||
file: MediaContent,
|
|
||||||
destFile: File
|
|
||||||
) = downloadFile(
|
|
||||||
getFileAdditionalInfo(file.media),
|
|
||||||
destFile
|
|
||||||
)
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
# TelegramBotAPI Behaviour Builder FSM Extensions
|
|
||||||
|
|
||||||
[](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.behaviour_builder.fsm)
|
|
||||||
|
|
||||||
## What is it?
|
|
||||||
|
|
||||||
|
|
||||||
This extension has been created to integrate finite state machine in [BehaviourBuilder](../tgbotapi.behaviour_builder/README.md).
|
|
||||||
In case you wish to use some custom store for steps (states), you may extend `StatesManager` or use `DefaultStatesManager`
|
|
||||||
with custom `DefaultStatesManagerRepo`. See [Examples repo](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/tree/master/FSMBot)
|
|
||||||
to get more info and see how it works on base level.
|
|
||||||
|
|
||||||
Lets see several examples:
|
|
||||||
|
|
||||||
```kotlin
|
|
||||||
data class StateRealization(override val context: ChatId) : State
|
|
||||||
|
|
||||||
bot.telegramBotWithBehaviourAndFSMAndStartLongPolling(TOKEN) {
|
|
||||||
strictlyOn<StateRealization> {
|
|
||||||
// here your logic of state
|
|
||||||
it // you must return from state handler some other state as a result of this one or null if you want to complete the chain
|
|
||||||
}
|
|
||||||
|
|
||||||
onCommand("start") {
|
|
||||||
startChain(StateRealization(it.chat.id)) // starting of chain with StateRealization state
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Currently, for the states there is only one restriction - your state must implements `State` interface and override `context` to define it. It may be important that `context` will be used under the hood for comparison with contexts of other states in some situations in it may be important to correctly realize `equals` method.
|
|
||||||
|
|
||||||
It is important, that all other methods are the same as for [BehaviourBuilder](../tgbotapi.behaviour_builder/README.md).
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
mavenLocal()
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
||||||
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
id "org.jetbrains.kotlin.multiplatform"
|
|
||||||
id "org.jetbrains.kotlin.plugin.serialization"
|
|
||||||
}
|
|
||||||
|
|
||||||
project.version = "$library_version"
|
|
||||||
project.group = "$library_group"
|
|
||||||
project.description = "Behaviour Builder extension with built-in FSM"
|
|
||||||
|
|
||||||
apply from: "../publish.gradle"
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenLocal()
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
kotlin {
|
|
||||||
jvm {
|
|
||||||
compilations.main {
|
|
||||||
kotlinOptions {
|
|
||||||
jvmTarget = "1.8"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
js(IR) {
|
|
||||||
browser()
|
|
||||||
nodejs()
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets {
|
|
||||||
commonMain {
|
|
||||||
dependencies {
|
|
||||||
implementation kotlin('stdlib')
|
|
||||||
api project(":tgbotapi.behaviour_builder")
|
|
||||||
api "dev.inmo:micro_utils.fsm.common:$micro_utils_version"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
java {
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
|
||||||
}
|
|
||||||
@@ -1,237 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.behaviour_builder
|
|
||||||
|
|
||||||
import dev.inmo.micro_utils.coroutines.*
|
|
||||||
import dev.inmo.micro_utils.fsm.common.*
|
|
||||||
import dev.inmo.micro_utils.fsm.common.utils.StateHandlingErrorHandler
|
|
||||||
import dev.inmo.micro_utils.fsm.common.utils.defaultStateHandlingErrorHandler
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers_registrar.TriggersHolder
|
|
||||||
import kotlinx.coroutines.*
|
|
||||||
import kotlinx.coroutines.channels.BufferOverflow
|
|
||||||
import kotlinx.coroutines.flow.*
|
|
||||||
import kotlin.reflect.KClass
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interface which combine [BehaviourContext] and [StatesMachine]. Subcontext of triggers and states contexts must have
|
|
||||||
* one common flow of updates and must not lose updates between updates
|
|
||||||
*
|
|
||||||
* @see DefaultBehaviourContextWithFSM
|
|
||||||
* @see buildBehaviourWithFSM
|
|
||||||
*/
|
|
||||||
interface BehaviourContextWithFSM<T : State> : BehaviourContext, StatesMachine<T> {
|
|
||||||
suspend fun start() = start(this)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add NON STRICT [handler] to list of available in future [BehaviourContextWithFSM]. Non strict means that
|
|
||||||
* for input [State] will be used [KClass.isInstance] and any inheritor of [kClass] will pass this requirement
|
|
||||||
*
|
|
||||||
* @see BehaviourWithFSMStateHandlerHolder
|
|
||||||
* @see onStateOrSubstate
|
|
||||||
*/
|
|
||||||
fun <I : T> add(kClass: KClass<I>, strict: Boolean = false, handler: BehaviourWithFSMStateHandler<I, T>)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add STRICT [handler] to list of available in future [BehaviourContextWithFSM]. Strict means that
|
|
||||||
* for input [State] will be used [State]::class == [kClass] and any [State] with exactly the same type will pass
|
|
||||||
* requirements
|
|
||||||
*
|
|
||||||
* @see BehaviourWithFSMStateHandlerHolder
|
|
||||||
* @see strictlyOn
|
|
||||||
*/
|
|
||||||
fun <I : T> addStrict(kClass: KClass<I>, handler: BehaviourWithFSMStateHandler<I, T>) = add(kClass, strict = true, handler)
|
|
||||||
|
|
||||||
override fun copy(
|
|
||||||
bot: TelegramBot,
|
|
||||||
scope: CoroutineScope,
|
|
||||||
broadcastChannelsSize: Int,
|
|
||||||
onBufferOverflow: BufferOverflow,
|
|
||||||
upstreamUpdatesFlow: Flow<Update>?,
|
|
||||||
triggersHolder: TriggersHolder
|
|
||||||
): BehaviourContextWithFSM<T>
|
|
||||||
|
|
||||||
fun copy(
|
|
||||||
bot: TelegramBot = this.bot,
|
|
||||||
scope: CoroutineScope = this.scope,
|
|
||||||
broadcastChannelsSize: Int = 100,
|
|
||||||
onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND,
|
|
||||||
upstreamUpdatesFlow: Flow<Update>? = null,
|
|
||||||
triggersHolder: TriggersHolder = this.triggersHolder,
|
|
||||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler()
|
|
||||||
): BehaviourContextWithFSM<T> = copy(
|
|
||||||
bot,
|
|
||||||
scope,
|
|
||||||
broadcastChannelsSize,
|
|
||||||
onBufferOverflow,
|
|
||||||
upstreamUpdatesFlow,
|
|
||||||
triggersHolder
|
|
||||||
)
|
|
||||||
|
|
||||||
fun copy(
|
|
||||||
bot: TelegramBot = this.bot,
|
|
||||||
scope: CoroutineScope = this.scope,
|
|
||||||
broadcastChannelsSize: Int = 100,
|
|
||||||
onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND,
|
|
||||||
upstreamUpdatesFlow: Flow<Update>? = null,
|
|
||||||
triggersHolder: TriggersHolder = this.triggersHolder,
|
|
||||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
|
||||||
updatesFilter: BehaviourContextAndTypeReceiver<Boolean, Update>? = null
|
|
||||||
): BehaviourContextWithFSM<T> = copy(
|
|
||||||
bot,
|
|
||||||
scope,
|
|
||||||
broadcastChannelsSize,
|
|
||||||
onBufferOverflow,
|
|
||||||
upstreamUpdatesFlow,
|
|
||||||
triggersHolder,
|
|
||||||
onStateHandlingErrorHandler
|
|
||||||
)
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
operator fun <T : State> invoke(
|
|
||||||
behaviourContext: BehaviourContext,
|
|
||||||
handlers: List<BehaviourWithFSMStateHandlerHolder<*, T>>,
|
|
||||||
statesManager: StatesManager<T>,
|
|
||||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler()
|
|
||||||
) = DefaultBehaviourContextWithFSM<T>(behaviourContext, statesManager, handlers, onStateHandlingErrorHandler)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add NON STRICT [handler] to list of available in future [BehaviourContextWithFSM]. Non strict means that
|
|
||||||
* for input [State] will be used [KClass.isInstance] and any inheritor of [kClass] will pass this requirement
|
|
||||||
*
|
|
||||||
* @see BehaviourWithFSMStateHandlerHolder
|
|
||||||
* @see BehaviourContextWithFSM.add
|
|
||||||
*/
|
|
||||||
@Suppress("MemberVisibilityCanBePrivate")
|
|
||||||
inline fun <reified I : O, O: State> BehaviourContextWithFSM<O>.onStateOrSubstate(handler: BehaviourWithFSMStateHandler<I, O>) = add(I::class, strict = false, handler)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add STRICT [handler] to list of available in future [BehaviourContextWithFSM]. Strict means that
|
|
||||||
* for input [State] will be used [State]::class == [kClass] and any [State] with exactly the same type will pass
|
|
||||||
* requirements
|
|
||||||
*
|
|
||||||
* @see BehaviourWithFSMStateHandlerHolder
|
|
||||||
* @see BehaviourContextWithFSM.addStrict
|
|
||||||
*/
|
|
||||||
@Suppress("MemberVisibilityCanBePrivate")
|
|
||||||
inline fun <reified I : O, O: State> BehaviourContextWithFSM<O>.strictlyOn(handler: BehaviourWithFSMStateHandler<I, O>) = addStrict(I::class, handler)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default realization of [BehaviourContextWithFSM]. It uses [behaviourContext] as a base for this object as
|
|
||||||
* [BehaviourContext], but managing substates contexts updates for avoiding of updates lost between states
|
|
||||||
* @param onStateHandlingErrorHandler Will be used in case if state handling has not been successfully completed in [launchStateHandling]
|
|
||||||
*/
|
|
||||||
class DefaultBehaviourContextWithFSM<T : State>(
|
|
||||||
private val behaviourContext: BehaviourContext,
|
|
||||||
private val statesManager: StatesManager<T>,
|
|
||||||
private val handlers: List<BehaviourWithFSMStateHandlerHolder<*, T>>,
|
|
||||||
private val onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler()
|
|
||||||
) : BehaviourContext by behaviourContext, BehaviourContextWithFSM<T> {
|
|
||||||
private val updatesFlows = mutableMapOf<Any, DefaultBehaviourContextWithFSM<T>>()
|
|
||||||
private val additionalHandlers = mutableListOf<BehaviourWithFSMStateHandlerHolder<*, T>>()
|
|
||||||
private var actualHandlersList = additionalHandlers + handlers
|
|
||||||
|
|
||||||
override suspend fun launchStateHandling(state: T, handlers: List<CheckableHandlerHolder<in T, T>>): T? {
|
|
||||||
return launchStateHandling(state, handlers, onStateHandlingErrorHandler)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getSubContext(context: Any) = updatesFlows.getOrPut(context) {
|
|
||||||
createSubContext()
|
|
||||||
}
|
|
||||||
|
|
||||||
override suspend fun StatesMachine<in T>.handleState(state: T): T? {
|
|
||||||
return getSubContext(
|
|
||||||
state.context
|
|
||||||
).launchStateHandling(
|
|
||||||
state,
|
|
||||||
actualHandlersList
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <I : T> add(kClass: KClass<I>, strict: Boolean, handler: BehaviourWithFSMStateHandler<I, T>) {
|
|
||||||
additionalHandlers.add(BehaviourWithFSMStateHandlerHolder(kClass, strict, handler))
|
|
||||||
actualHandlersList = additionalHandlers + handlers
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun start(scope: CoroutineScope): Job = scope.launchSafelyWithoutExceptions {
|
|
||||||
val statePerformer: suspend (T) -> Unit = { state: T ->
|
|
||||||
val newState = getSubContext(state.context).launchStateHandling(state, actualHandlersList)
|
|
||||||
if (newState != null) {
|
|
||||||
statesManager.update(state, newState)
|
|
||||||
} else {
|
|
||||||
statesManager.endChain(state)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
statesManager.onStartChain.subscribeSafelyWithoutExceptions(this) {
|
|
||||||
launch { statePerformer(it) }
|
|
||||||
}
|
|
||||||
statesManager.onChainStateUpdated.subscribeSafelyWithoutExceptions(this) { (old, new) ->
|
|
||||||
if (old.context != new.context) {
|
|
||||||
updatesFlows.remove(old.context)
|
|
||||||
}
|
|
||||||
launch { statePerformer(new) }
|
|
||||||
}
|
|
||||||
statesManager.onEndChain.subscribeSafelyWithoutExceptions(this) {
|
|
||||||
updatesFlows.remove(it.context)
|
|
||||||
}
|
|
||||||
|
|
||||||
statesManager.getActiveStates().forEach {
|
|
||||||
launch { statePerformer(it) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Add NON STRICT [handler] to list of available in future [BehaviourContextWithFSM]. Non strict means that
|
|
||||||
* for input [State] will be used [KClass.isInstance] and any inheritor of [kClass] will pass this requirement
|
|
||||||
*
|
|
||||||
* @see BehaviourWithFSMStateHandlerHolder
|
|
||||||
* @see BehaviourContextWithFSM.add
|
|
||||||
*/
|
|
||||||
@Suppress("MemberVisibilityCanBePrivate")
|
|
||||||
inline fun <reified I : T> onStateOrSubstate(handler: BehaviourWithFSMStateHandler<I, T>) = add(I::class, strict = false, handler)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add STRICT [handler] to list of available in future [BehaviourContextWithFSM]. Strict means that
|
|
||||||
* for input [State] will be used [State]::class == [kClass] and any [State] with exactly the same type will pass
|
|
||||||
* requirements
|
|
||||||
*
|
|
||||||
* @see BehaviourWithFSMStateHandlerHolder
|
|
||||||
* @see BehaviourContextWithFSM.addStrict
|
|
||||||
*/
|
|
||||||
@Suppress("MemberVisibilityCanBePrivate")
|
|
||||||
inline fun <reified I : T> strictlyOn(handler: BehaviourWithFSMStateHandler<I, T>) = addStrict(I::class, handler)
|
|
||||||
|
|
||||||
override suspend fun startChain(state: T) {
|
|
||||||
statesManager.startChain(state)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun copy(
|
|
||||||
bot: TelegramBot,
|
|
||||||
scope: CoroutineScope,
|
|
||||||
broadcastChannelsSize: Int,
|
|
||||||
onBufferOverflow: BufferOverflow,
|
|
||||||
upstreamUpdatesFlow: Flow<Update>?,
|
|
||||||
triggersHolder: TriggersHolder
|
|
||||||
): DefaultBehaviourContextWithFSM<T> = BehaviourContextWithFSM(
|
|
||||||
behaviourContext.copy(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, triggersHolder),
|
|
||||||
handlers,
|
|
||||||
statesManager,
|
|
||||||
onStateHandlingErrorHandler
|
|
||||||
)
|
|
||||||
|
|
||||||
override fun copy(
|
|
||||||
bot: TelegramBot,
|
|
||||||
scope: CoroutineScope,
|
|
||||||
broadcastChannelsSize: Int,
|
|
||||||
onBufferOverflow: BufferOverflow,
|
|
||||||
upstreamUpdatesFlow: Flow<Update>?,
|
|
||||||
triggersHolder: TriggersHolder,
|
|
||||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T>
|
|
||||||
): DefaultBehaviourContextWithFSM<T> = BehaviourContextWithFSM(
|
|
||||||
behaviourContext.copy(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, triggersHolder),
|
|
||||||
handlers,
|
|
||||||
statesManager,
|
|
||||||
onStateHandlingErrorHandler
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,144 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.behaviour_builder
|
|
||||||
|
|
||||||
import dev.inmo.micro_utils.coroutines.*
|
|
||||||
import dev.inmo.micro_utils.fsm.common.*
|
|
||||||
import dev.inmo.micro_utils.fsm.common.managers.DefaultStatesManager
|
|
||||||
import dev.inmo.micro_utils.fsm.common.managers.InMemoryDefaultStatesManagerRepo
|
|
||||||
import dev.inmo.micro_utils.fsm.common.utils.StateHandlingErrorHandler
|
|
||||||
import dev.inmo.micro_utils.fsm.common.utils.defaultStateHandlingErrorHandler
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.longPolling
|
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
|
||||||
import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter
|
|
||||||
import kotlinx.coroutines.*
|
|
||||||
import kotlinx.coroutines.flow.Flow
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates [BehaviourContextWithFSM] via creating of [DefaultBehaviourContext] with [this] as [TelegramBot],
|
|
||||||
* [scope] as target scope for that [DefaultBehaviourContext] and [upstreamUpdatesFlow]. Pass [statesManager]
|
|
||||||
* to customize some internal logic of states changes. Pass [presetHandlers] in case you have some list of
|
|
||||||
* [BehaviourWithFSMStateHandlerHolder] with presets.
|
|
||||||
*
|
|
||||||
* !!! WARNING !!! This method WILL NOT call [BehaviourContextWithFSM.start] of result object and WILL NOT
|
|
||||||
* start any updates retrieving. See [buildBehaviourWithFSMAndStartLongPolling] or
|
|
||||||
* [telegramBotWithBehaviourAndFSMAndStartLongPolling] in case you wish to start [longPolling] automatically
|
|
||||||
*/
|
|
||||||
suspend fun <T : State> TelegramBot.buildBehaviourWithFSM(
|
|
||||||
upstreamUpdatesFlow: Flow<Update>? = null,
|
|
||||||
scope: CoroutineScope = defaultCoroutineScopeProvider(),
|
|
||||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
|
||||||
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
|
||||||
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
|
||||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
|
||||||
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
|
|
||||||
): DefaultBehaviourContextWithFSM<T> = BehaviourContextWithFSM(
|
|
||||||
DefaultBehaviourContext(
|
|
||||||
this,
|
|
||||||
defaultExceptionsHandler ?.let { scope + ContextSafelyExceptionHandler(it) } ?: scope,
|
|
||||||
upstreamUpdatesFlow = upstreamUpdatesFlow
|
|
||||||
),
|
|
||||||
presetHandlers,
|
|
||||||
statesManager,
|
|
||||||
onStateHandlingErrorHandler
|
|
||||||
).apply { block() }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Use [buildBehaviourWithFSM] to create [BehaviourContextWithFSM] and launch getting of updates
|
|
||||||
* using [longPolling]. For [longPolling] will be used result [BehaviourContextWithFSM] for both parameters
|
|
||||||
* flowsUpdatesFilter and scope
|
|
||||||
*/
|
|
||||||
suspend fun <T : State> TelegramBot.buildBehaviourWithFSMAndStartLongPolling(
|
|
||||||
upstreamUpdatesFlow: Flow<Update>? = null,
|
|
||||||
scope: CoroutineScope = defaultCoroutineScopeProvider(),
|
|
||||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
|
||||||
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
|
||||||
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
|
||||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
|
||||||
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
|
|
||||||
): Pair<DefaultBehaviourContextWithFSM<T>, Job> = buildBehaviourWithFSM(
|
|
||||||
upstreamUpdatesFlow,
|
|
||||||
scope,
|
|
||||||
defaultExceptionsHandler,
|
|
||||||
statesManager,
|
|
||||||
presetHandlers,
|
|
||||||
onStateHandlingErrorHandler,
|
|
||||||
block
|
|
||||||
).run {
|
|
||||||
this to scope.launch {
|
|
||||||
start()
|
|
||||||
longPolling(flowsUpdatesFilter, scope = scope)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates [BehaviourContextWithFSM] via creating of [DefaultBehaviourContext] with [this] as [TelegramBot],
|
|
||||||
* [scope] as target scope for that [DefaultBehaviourContext] and [FlowsUpdatesFilter.allUpdatesFlow] of
|
|
||||||
* [flowUpdatesFilter] as [DefaultBehaviourContext.upstreamUpdatesFlow]. Pass [statesManager]
|
|
||||||
* to customize some internal logic of states changes. Pass [presetHandlers] in case you have some list of
|
|
||||||
* [BehaviourWithFSMStateHandlerHolder] with presets.
|
|
||||||
* Use this method in case you wish to make some additional actions with [flowUpdatesFilter].
|
|
||||||
*
|
|
||||||
* !!! WARNING !!! This method WILL NOT call [BehaviourContextWithFSM.start] of result object and WILL NOT
|
|
||||||
* start any updates retrieving. See [buildBehaviourWithFSMAndStartLongPolling] or
|
|
||||||
* [telegramBotWithBehaviourAndFSMAndStartLongPolling] in case you wish to start [longPolling] automatically
|
|
||||||
*
|
|
||||||
* @see BehaviourContext
|
|
||||||
* @see BehaviourContextWithFSM
|
|
||||||
* @see longPolling
|
|
||||||
* @see BehaviourContextWithFSM.strictlyOn
|
|
||||||
* @see BehaviourContextWithFSM.onStateOrSubstate
|
|
||||||
*/
|
|
||||||
suspend fun <T : State> TelegramBot.buildBehaviourWithFSM(
|
|
||||||
flowUpdatesFilter: FlowsUpdatesFilter,
|
|
||||||
scope: CoroutineScope = defaultCoroutineScopeProvider(),
|
|
||||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
|
||||||
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
|
||||||
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
|
||||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
|
||||||
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
|
|
||||||
): DefaultBehaviourContextWithFSM<T> = BehaviourContextWithFSM(
|
|
||||||
DefaultBehaviourContext(
|
|
||||||
this,
|
|
||||||
defaultExceptionsHandler ?.let { scope + ContextSafelyExceptionHandler(it) } ?: scope,
|
|
||||||
upstreamUpdatesFlow = flowUpdatesFilter.allUpdatesFlow
|
|
||||||
),
|
|
||||||
presetHandlers,
|
|
||||||
statesManager,
|
|
||||||
onStateHandlingErrorHandler
|
|
||||||
).apply { block() }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Use [buildBehaviourWithFSM] to create [BehaviourContextWithFSM] and launch getting of updates
|
|
||||||
* using [longPolling]. For [longPolling] will be used result [BehaviourContextWithFSM] for both parameters
|
|
||||||
* flowsUpdatesFilter and scope
|
|
||||||
*
|
|
||||||
* @see buildBehaviourWithFSMAndStartLongPolling
|
|
||||||
* @see BehaviourContext
|
|
||||||
* @see longPolling
|
|
||||||
* @see BehaviourContextWithFSM.strictlyOn
|
|
||||||
* @see BehaviourContextWithFSM.onStateOrSubstate
|
|
||||||
*/
|
|
||||||
suspend fun <T : State> TelegramBot.buildBehaviourWithFSMAndStartLongPolling(
|
|
||||||
scope: CoroutineScope = defaultCoroutineScopeProvider(),
|
|
||||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
|
||||||
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
|
||||||
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
|
||||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
|
||||||
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
|
|
||||||
) = FlowsUpdatesFilter().let {
|
|
||||||
buildBehaviourWithFSM(
|
|
||||||
it,
|
|
||||||
scope,
|
|
||||||
defaultExceptionsHandler,
|
|
||||||
statesManager,
|
|
||||||
presetHandlers,
|
|
||||||
onStateHandlingErrorHandler,
|
|
||||||
block
|
|
||||||
).run {
|
|
||||||
start()
|
|
||||||
longPolling(
|
|
||||||
flowsUpdatesFilter,
|
|
||||||
scope = scope
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.behaviour_builder
|
|
||||||
|
|
||||||
import dev.inmo.micro_utils.fsm.common.*
|
|
||||||
|
|
||||||
fun interface BehaviourWithFSMStateHandler<I : O, O : State> : StatesHandler<I, O> {
|
|
||||||
suspend fun BehaviourContextWithFSM<in O>.handleState(state: I): O?
|
|
||||||
|
|
||||||
override suspend fun StatesMachine<in O>.handleState(state: I): O? = if (this is BehaviourContextWithFSM) {
|
|
||||||
handleState(state)
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.behaviour_builder
|
|
||||||
|
|
||||||
import dev.inmo.micro_utils.fsm.common.*
|
|
||||||
import kotlin.reflect.KClass
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Special holder for [BehaviourContextWithFSM]. This holder helps [BehaviourContextWithFSM] to understand whether it
|
|
||||||
* can handle input [State] with [delegateTo] or not
|
|
||||||
*
|
|
||||||
* @param inputKlass This [KClass] will be used to compare input [State] type and declare ability of [delegateTo] to
|
|
||||||
* handle incoming [State]. See [checkHandleable] for more info
|
|
||||||
* @param strict This flag will be used in [checkHandleable] to choose strategy of checking incoming [State]
|
|
||||||
* @param delegateTo This handler will be called in case [checkHandleable] returns true with class caster incoming
|
|
||||||
* [State] in [handleState]
|
|
||||||
*/
|
|
||||||
class BehaviourWithFSMStateHandlerHolder<I : O, O : State>(
|
|
||||||
private val inputKlass: KClass<I>,
|
|
||||||
private val strict: Boolean = false,
|
|
||||||
private val delegateTo: BehaviourWithFSMStateHandler<I, O>
|
|
||||||
) : CheckableHandlerHolder<O, O>, BehaviourWithFSMStateHandler<O, O> {
|
|
||||||
/**
|
|
||||||
* Check ability of [delegateTo] to handle this [state]
|
|
||||||
*
|
|
||||||
* @return When [state]::class exactly equals to [inputKlass] will always return true. Otherwise when [strict]
|
|
||||||
* mode is disabled, will be used [KClass.isInstance] of [inputKlass] for checking
|
|
||||||
*/
|
|
||||||
override suspend fun checkHandleable(state: O): Boolean = state::class == inputKlass || (!strict && inputKlass.isInstance(state))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handling of state :)
|
|
||||||
*/
|
|
||||||
override suspend fun BehaviourContextWithFSM<in O>.handleState(state: O): O? = with(delegateTo) {
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
|
||||||
handleState(state as I)
|
|
||||||
}
|
|
||||||
|
|
||||||
override suspend fun StatesMachine<in O>.handleState(state: O): O? = with(delegateTo) {
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
|
||||||
handleState(state as I)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline fun <reified I : O, O : State> BehaviourWithFSMStateHandlerHolder(
|
|
||||||
strict: Boolean = false,
|
|
||||||
delegateTo: BehaviourWithFSMStateHandler<I, O>
|
|
||||||
) = BehaviourWithFSMStateHandlerHolder(I::class, strict, delegateTo)
|
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.behaviour_builder
|
|
||||||
|
|
||||||
import dev.inmo.micro_utils.coroutines.ExceptionHandler
|
|
||||||
import dev.inmo.micro_utils.fsm.common.State
|
|
||||||
import dev.inmo.micro_utils.fsm.common.StatesManager
|
|
||||||
import dev.inmo.micro_utils.fsm.common.managers.DefaultStatesManager
|
|
||||||
import dev.inmo.micro_utils.fsm.common.managers.InMemoryDefaultStatesManagerRepo
|
|
||||||
import dev.inmo.micro_utils.fsm.common.utils.StateHandlingErrorHandler
|
|
||||||
import dev.inmo.micro_utils.fsm.common.utils.defaultStateHandlingErrorHandler
|
|
||||||
import dev.inmo.tgbotapi.bot.ktor.KtorRequestsExecutorBuilder
|
|
||||||
import dev.inmo.tgbotapi.bot.ktor.telegramBot
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingOfUpdatesByLongPolling
|
|
||||||
import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter
|
|
||||||
import dev.inmo.tgbotapi.utils.telegramBotAPIDefaultUrl
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
|
||||||
import kotlinx.coroutines.Job
|
|
||||||
import kotlin.coroutines.coroutineContext
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create bot using [telegramBot] and start listening for updates using [buildBehaviourWithFSM].
|
|
||||||
* Use this method in case you wish to make some additional actions with [flowsUpdatesFilter].
|
|
||||||
*
|
|
||||||
* **WARNING** This method WILL NOT launch any listening of updates. Use something like
|
|
||||||
* [startGettingOfUpdatesByLongPolling] or tools for work with webhooks
|
|
||||||
*
|
|
||||||
* @return Created bot which has been used to create [BehaviourContext] via [buildBehaviourWithFSM]
|
|
||||||
*
|
|
||||||
* @see [BehaviourContext]
|
|
||||||
* @see [buildBehaviourWithFSM]
|
|
||||||
* @see startGettingOfUpdatesByLongPolling
|
|
||||||
*/
|
|
||||||
suspend fun <T : State> telegramBotWithBehaviourAndFSM(
|
|
||||||
token: String,
|
|
||||||
flowsUpdatesFilter: FlowsUpdatesFilter,
|
|
||||||
scope: CoroutineScope? = null,
|
|
||||||
apiUrl: String = telegramBotAPIDefaultUrl,
|
|
||||||
builder: KtorRequestsExecutorBuilder.() -> Unit = {},
|
|
||||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
|
||||||
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
|
||||||
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
|
||||||
testServer: Boolean = false,
|
|
||||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
|
||||||
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
|
|
||||||
): TelegramBot = telegramBot(
|
|
||||||
token,
|
|
||||||
apiUrl,
|
|
||||||
testServer,
|
|
||||||
builder
|
|
||||||
).apply {
|
|
||||||
buildBehaviourWithFSMAndStartLongPolling(
|
|
||||||
flowsUpdatesFilter.allUpdatesFlow,
|
|
||||||
scope ?: CoroutineScope(coroutineContext),
|
|
||||||
defaultExceptionsHandler,
|
|
||||||
statesManager,
|
|
||||||
presetHandlers,
|
|
||||||
onStateHandlingErrorHandler,
|
|
||||||
block
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create bot using [telegramBot] and start listening for updates using [buildBehaviourWithFSMAndStartLongPolling]. This
|
|
||||||
* method will launch updates retrieving via long polling inside of [buildBehaviourWithFSMAndStartLongPolling]
|
|
||||||
*
|
|
||||||
* @return Pair of [TelegramBot] and [Job]. This [Job] can be used to stop listening updates in your [block] you passed
|
|
||||||
* here
|
|
||||||
*
|
|
||||||
* @see BehaviourContext
|
|
||||||
* @see buildBehaviourWithFSMAndStartLongPolling
|
|
||||||
* @see startGettingOfUpdatesByLongPolling
|
|
||||||
*/
|
|
||||||
suspend fun <T : State> telegramBotWithBehaviourAndFSMAndStartLongPolling(
|
|
||||||
token: String,
|
|
||||||
scope: CoroutineScope? = null,
|
|
||||||
apiUrl: String = telegramBotAPIDefaultUrl,
|
|
||||||
builder: KtorRequestsExecutorBuilder.() -> Unit = {},
|
|
||||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
|
||||||
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
|
||||||
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
|
||||||
testServer: Boolean = false,
|
|
||||||
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
|
||||||
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
|
|
||||||
): Pair<TelegramBot, Job> {
|
|
||||||
return telegramBot(
|
|
||||||
token,
|
|
||||||
apiUrl,
|
|
||||||
testServer,
|
|
||||||
builder
|
|
||||||
).let {
|
|
||||||
it to it.buildBehaviourWithFSMAndStartLongPolling (
|
|
||||||
scope ?: CoroutineScope(coroutineContext),
|
|
||||||
defaultExceptionsHandler,
|
|
||||||
statesManager,
|
|
||||||
presetHandlers,
|
|
||||||
onStateHandlingErrorHandler,
|
|
||||||
block
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
# TelegramBotAPI Behaviour Builder Extensions
|
|
||||||
|
|
||||||
[](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.behaviour_builder)
|
|
||||||
|
|
||||||
## What is it?
|
|
||||||
|
|
||||||
This extension was created to make it more simple to build bot steps handling. Usually, you must use something like:
|
|
||||||
|
|
||||||
```kotlin
|
|
||||||
val bot = telegramBot(TOKEN)
|
|
||||||
bot.startGettingFlowsUpdatesByLongPolling {
|
|
||||||
messagesFlow.subscribeSafelyWithoutExceptions {
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
// here I already tired to write this example 😫
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
This library offer other way to do a lot of routine in more simple way:
|
|
||||||
|
|
||||||
```kotlin
|
|
||||||
telegramBotWithBehaviour(token) {
|
|
||||||
onCommand("start".regex) {
|
|
||||||
execute(SendTextMessage(it.chat.id, "This bot can ...")) // replaceable with reply(it, "This bot can ...") when you are using `tgbotapi.extensions.api`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Triggers
|
|
||||||
|
|
||||||
In terminology of this project the `Triggers` are things which have no initial message, may have own filter for incoming
|
|
||||||
messages and filter messages for context which will be used in subcontext. Full syntax with `onText` as an example:
|
|
||||||
|
|
||||||
```kotlin
|
|
||||||
telegramBotWithBehaviour(TOKEN) {
|
|
||||||
onText(
|
|
||||||
includeFilterByChatInBehaviourSubContext = true, // if false - last lambda will receive all messages instead of filtered by chat messages
|
|
||||||
additionalFilter = { message: CommonMessage<TextContent> ->
|
|
||||||
// here you may check incoming message for any requirements before it will be passed to the main lambda
|
|
||||||
}
|
|
||||||
) { message: CommonMessage<TextContent> -> // this here is `BehaviourContext`
|
|
||||||
// here put your actions and additional waiters
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Waiters
|
|
||||||
|
|
||||||
Waiters targeted to get some content "here and now", they must be used inside some trigger main lambda:
|
|
||||||
|
|
||||||
```kotlin
|
|
||||||
telegramBotWithBehaviour(TOKEN) {
|
|
||||||
onCommand("start") { message: CommonMessage<TextContent> ->
|
|
||||||
val userPhotos = waitPhoto(
|
|
||||||
SendTextMessage(it.chat.id, "Ok, send me some photo, please"), // init request, can be any `Request` object
|
|
||||||
{ update: Update -> // That is update which is NOT passed requirements. In current context we expect some photo, but received something else
|
|
||||||
SendTextMessage(it.chat.id, "Excuse me, but I can accept only photos") // it could be null
|
|
||||||
},
|
|
||||||
2, // some count of photos
|
|
||||||
includeMediaGroups = true, // if false, messages related to some media group will be skipped and recognized as incorrect
|
|
||||||
) { message: CommonMessate<PhotoContent> -> // this method is optional and you can use it in case you want to add some additional requirements checks
|
|
||||||
message.content // return null if message didn't passed requirements
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.behaviour_builder
|
|
||||||
|
|
||||||
import dev.inmo.micro_utils.coroutines.ContextSafelyExceptionHandler
|
|
||||||
import dev.inmo.micro_utils.coroutines.ExceptionHandler
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.longPolling
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingOfUpdatesByLongPolling
|
|
||||||
import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter
|
|
||||||
import dev.inmo.tgbotapi.utils.PreviewFeature
|
|
||||||
import kotlinx.coroutines.*
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This function is used in [buildBehaviour] extensions to provide default [CoroutineScope] and allow to avoid all
|
|
||||||
* unnecessary parameters except of block
|
|
||||||
*/
|
|
||||||
expect var defaultCoroutineScopeProvider: () -> CoroutineScope
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Use this method in case you wish to make some additional actions with [flowUpdatesFilter].
|
|
||||||
*
|
|
||||||
* **WARNING** This method WILL NOT launch any listening of updates. Use something like
|
|
||||||
* [startGettingOfUpdatesByLongPolling] or tools for work with webhooks
|
|
||||||
*
|
|
||||||
* @see [BehaviourContext]
|
|
||||||
* @see startGettingOfUpdatesByLongPolling
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.buildBehaviour(
|
|
||||||
flowUpdatesFilter: FlowsUpdatesFilter = FlowsUpdatesFilter(),
|
|
||||||
scope: CoroutineScope = defaultCoroutineScopeProvider(),
|
|
||||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
|
||||||
block: BehaviourContextReceiver<Unit>
|
|
||||||
): BehaviourContext = BehaviourContext(
|
|
||||||
this,
|
|
||||||
scope.let {
|
|
||||||
if (defaultExceptionsHandler == null) {
|
|
||||||
it
|
|
||||||
} else {
|
|
||||||
it + ContextSafelyExceptionHandler(defaultExceptionsHandler)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
flowUpdatesFilter
|
|
||||||
).apply {
|
|
||||||
block()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Use this method to build bot behaviour and run it via long polling. In case you wish to get [FlowsUpdatesFilter] for
|
|
||||||
* additional manipulations, you must provide external [FlowsUpdatesFilter] in other [buildBehaviour] function.
|
|
||||||
*
|
|
||||||
* @see buildBehaviour
|
|
||||||
* @see BehaviourContext
|
|
||||||
* @see startGettingOfUpdatesByLongPolling
|
|
||||||
*/
|
|
||||||
suspend fun TelegramBot.buildBehaviourWithLongPolling(
|
|
||||||
scope: CoroutineScope = defaultCoroutineScopeProvider(),
|
|
||||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
|
||||||
block: BehaviourContextReceiver<Unit>
|
|
||||||
): Job {
|
|
||||||
val behaviourContext = buildBehaviour(
|
|
||||||
scope = scope,
|
|
||||||
defaultExceptionsHandler = defaultExceptionsHandler,
|
|
||||||
block = block
|
|
||||||
)
|
|
||||||
return longPolling(
|
|
||||||
behaviourContext,
|
|
||||||
scope = behaviourContext
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,214 +0,0 @@
|
|||||||
@file:Suppress("NOTHING_TO_INLINE")
|
|
||||||
|
|
||||||
package dev.inmo.tgbotapi.extensions.behaviour_builder
|
|
||||||
|
|
||||||
import dev.inmo.micro_utils.coroutines.*
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers_registrar.TriggersHolder
|
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
|
||||||
import dev.inmo.tgbotapi.updateshandlers.*
|
|
||||||
import kotlinx.coroutines.*
|
|
||||||
import kotlinx.coroutines.channels.BufferOverflow
|
|
||||||
import kotlinx.coroutines.flow.*
|
|
||||||
|
|
||||||
typealias CustomBehaviourContextReceiver<BC, T> = suspend BC.() -> T
|
|
||||||
typealias BehaviourContextReceiver<T> = CustomBehaviourContextReceiver<BehaviourContext, T>
|
|
||||||
typealias CustomBehaviourContextAndTypeReceiver<BC, T, I> = suspend BC.(I) -> T
|
|
||||||
typealias BehaviourContextAndTypeReceiver<T, I> = CustomBehaviourContextAndTypeReceiver<BehaviourContext, T, I>
|
|
||||||
typealias CustomBehaviourContextAndTwoTypesReceiver<BC, T, I1, I2> = suspend BC.(I1, I2) -> T
|
|
||||||
typealias BehaviourContextAndTwoTypesReceiver<T, I1, I2> = CustomBehaviourContextAndTwoTypesReceiver<BehaviourContext, T, I1, I2>
|
|
||||||
inline fun <T> BehaviourContextReceiver(noinline block: BehaviourContextReceiver<T>) = block
|
|
||||||
inline fun <BC, T> CustomBehaviourContextReceiver(noinline block: CustomBehaviourContextReceiver<BC, T>) = block
|
|
||||||
inline fun <T, I> BehaviourContextAndTypeReceiver(noinline block: BehaviourContextAndTypeReceiver<T, I>) = block
|
|
||||||
inline fun <T, I1, I2> BehaviourContextAndTwoTypesReceiver(noinline block: BehaviourContextAndTwoTypesReceiver<T, I1, I2>) = block
|
|
||||||
internal inline fun <BC, T, I1, I2> CustomBehaviourContextAndTwoTypesReceiver<BC, T, I1, I2>.toOneType(
|
|
||||||
i1: I1,
|
|
||||||
): CustomBehaviourContextAndTypeReceiver<BC, T, I2> = { invoke(this, i1, it) }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class contains all necessary tools for work with bots and especially [buildBehaviour]
|
|
||||||
*
|
|
||||||
* @see DefaultBehaviourContext
|
|
||||||
*/
|
|
||||||
interface BehaviourContext : FlowsUpdatesFilter, TelegramBot, CoroutineScope {
|
|
||||||
val bot: TelegramBot
|
|
||||||
get() = this
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Will be used for creating of some subscriptions inside of methods, updates listening and different other things
|
|
||||||
* in context of working with [CoroutineScope] and coroutines.
|
|
||||||
*/
|
|
||||||
val scope: CoroutineScope
|
|
||||||
get() = this
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This parameter will be used to subscribe on different types of update
|
|
||||||
*/
|
|
||||||
val flowsUpdatesFilter: FlowsUpdatesFilter
|
|
||||||
get() = this
|
|
||||||
|
|
||||||
val triggersHolder: TriggersHolder
|
|
||||||
|
|
||||||
fun copy(
|
|
||||||
bot: TelegramBot = this.bot,
|
|
||||||
scope: CoroutineScope = this.scope,
|
|
||||||
broadcastChannelsSize: Int = 100,
|
|
||||||
onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND,
|
|
||||||
upstreamUpdatesFlow: Flow<Update>? = null,
|
|
||||||
triggersHolder: TriggersHolder = TriggersHolder()
|
|
||||||
): BehaviourContext
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param updatesFilter unused
|
|
||||||
*/
|
|
||||||
@Deprecated("Do not use this method")
|
|
||||||
fun copy(
|
|
||||||
bot: TelegramBot = this.bot,
|
|
||||||
scope: CoroutineScope = this.scope,
|
|
||||||
broadcastChannelsSize: Int = 100,
|
|
||||||
onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND,
|
|
||||||
upstreamUpdatesFlow: Flow<Update>? = null,
|
|
||||||
triggersHolder: TriggersHolder = TriggersHolder(),
|
|
||||||
updatesFilter: BehaviourContextAndTypeReceiver<Boolean, Update>? = null
|
|
||||||
): BehaviourContext = copy(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, triggersHolder)
|
|
||||||
}
|
|
||||||
|
|
||||||
class DefaultBehaviourContext(
|
|
||||||
override val bot: TelegramBot,
|
|
||||||
override val scope: CoroutineScope,
|
|
||||||
broadcastChannelsSize: Int = 100,
|
|
||||||
onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND,
|
|
||||||
private val upstreamUpdatesFlow: Flow<Update>? = null,
|
|
||||||
override val triggersHolder: TriggersHolder = TriggersHolder(),
|
|
||||||
@Deprecated("This parameter is not used anymore")
|
|
||||||
private val updatesFilter: BehaviourContextAndTypeReceiver<Boolean, Update>? = null
|
|
||||||
) : AbstractFlowsUpdatesFilter(), TelegramBot by bot, CoroutineScope by scope, BehaviourContext {
|
|
||||||
|
|
||||||
private val additionalUpdatesSharedFlow = MutableSharedFlow<Update>(0, broadcastChannelsSize, onBufferOverflow)
|
|
||||||
override val allUpdatesFlow: Flow<Update> = (additionalUpdatesSharedFlow.asSharedFlow()).let {
|
|
||||||
if (upstreamUpdatesFlow != null) {
|
|
||||||
var lastHandledUpdate = -1L
|
|
||||||
(it + upstreamUpdatesFlow).filter {
|
|
||||||
(it.updateId > lastHandledUpdate).also { passed -> if (passed) { lastHandledUpdate = it.updateId } }
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
it
|
|
||||||
}
|
|
||||||
}.accumulatorFlow(scope)
|
|
||||||
override val asUpdateReceiver: UpdateReceiver<Update> = additionalUpdatesSharedFlow::emit
|
|
||||||
|
|
||||||
override fun copy(
|
|
||||||
bot: TelegramBot,
|
|
||||||
scope: CoroutineScope,
|
|
||||||
broadcastChannelsSize: Int,
|
|
||||||
onBufferOverflow: BufferOverflow,
|
|
||||||
upstreamUpdatesFlow: Flow<Update>?,
|
|
||||||
triggersHolder: TriggersHolder
|
|
||||||
): DefaultBehaviourContext = DefaultBehaviourContext(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, triggersHolder)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun BehaviourContext(
|
|
||||||
bot: TelegramBot,
|
|
||||||
scope: CoroutineScope,
|
|
||||||
flowsUpdatesFilter: FlowsUpdatesFilter = FlowsUpdatesFilter(),
|
|
||||||
triggersHolder: TriggersHolder = TriggersHolder(),
|
|
||||||
) = DefaultBehaviourContext(bot, scope, upstreamUpdatesFlow = flowsUpdatesFilter.allUpdatesFlow, triggersHolder = triggersHolder)
|
|
||||||
|
|
||||||
inline fun <T> BehaviourContext(
|
|
||||||
bot: TelegramBot,
|
|
||||||
scope: CoroutineScope,
|
|
||||||
flowsUpdatesFilter: FlowsUpdatesFilter = FlowsUpdatesFilter(),
|
|
||||||
triggersHolder: TriggersHolder = TriggersHolder(),
|
|
||||||
crossinline block: BehaviourContext.() -> T
|
|
||||||
) = DefaultBehaviourContext(bot, scope, upstreamUpdatesFlow = flowsUpdatesFilter.allUpdatesFlow, triggersHolder = triggersHolder).run(block)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates new [BehaviourContext] using its [BehaviourContext.copy] method
|
|
||||||
*
|
|
||||||
* @param updatesFilter This param will not be used anymore
|
|
||||||
*/
|
|
||||||
fun <BC : BehaviourContext> BC.createSubContext(
|
|
||||||
scope: CoroutineScope = LinkedSupervisorScope(),
|
|
||||||
triggersHolder: TriggersHolder = this.triggersHolder,
|
|
||||||
updatesUpstreamFlow: Flow<Update> = allUpdatesFlow,
|
|
||||||
) = copy(
|
|
||||||
scope = scope,
|
|
||||||
upstreamUpdatesFlow = updatesUpstreamFlow,
|
|
||||||
triggersHolder = triggersHolder
|
|
||||||
) as BC
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates new [BehaviourContext] using its [BehaviourContext.copy] method
|
|
||||||
*
|
|
||||||
* @param updatesFilter This param will not be used anymore
|
|
||||||
*/
|
|
||||||
@Deprecated("It is not recommended to use updates filter anymore")
|
|
||||||
fun <BC : BehaviourContext> BC.createSubContext(
|
|
||||||
scope: CoroutineScope = LinkedSupervisorScope(),
|
|
||||||
triggersHolder: TriggersHolder = this.triggersHolder,
|
|
||||||
updatesUpstreamFlow: Flow<Update> = allUpdatesFlow,
|
|
||||||
updatesFilter: CustomBehaviourContextAndTypeReceiver<BC, Boolean, Update>?,
|
|
||||||
) = createSubContext(scope, triggersHolder, updatesUpstreamFlow)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Launch [behaviourContextReceiver] in context of [this] as [BehaviourContext] and as [kotlin.coroutines.CoroutineContext]
|
|
||||||
*
|
|
||||||
* @param stopOnCompletion ___FALSE BY DEFAULT___. Will stop [this] in case if passed true
|
|
||||||
*/
|
|
||||||
suspend fun <T, BC : BehaviourContext> BC.doInContext(
|
|
||||||
stopOnCompletion: Boolean = false,
|
|
||||||
behaviourContextReceiver: CustomBehaviourContextReceiver<BC, T>
|
|
||||||
): T {
|
|
||||||
return withContext(coroutineContext) {
|
|
||||||
behaviourContextReceiver().also { if (stopOnCompletion) stop() }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates new one [BehaviourContext] using [createSubContext] and launches [behaviourContextReceiver] in a new context
|
|
||||||
* using [doInContext]
|
|
||||||
*
|
|
||||||
* @param stopOnCompletion ___TRUE BY DEFAULT___
|
|
||||||
*/
|
|
||||||
suspend fun <T, BC : BehaviourContext> BC.createSubContextAndDoWithUpdatesFilter(
|
|
||||||
scope: CoroutineScope = LinkedSupervisorScope(),
|
|
||||||
triggersHolder: TriggersHolder = this.triggersHolder,
|
|
||||||
updatesUpstreamFlow: Flow<Update> = allUpdatesFlow,
|
|
||||||
stopOnCompletion: Boolean = true,
|
|
||||||
behaviourContextReceiver: CustomBehaviourContextReceiver<BC, T>
|
|
||||||
): T {
|
|
||||||
return createSubContext(
|
|
||||||
scope,
|
|
||||||
triggersHolder,
|
|
||||||
updatesUpstreamFlow
|
|
||||||
).doInContext(
|
|
||||||
stopOnCompletion,
|
|
||||||
behaviourContextReceiver
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates new one [BehaviourContext] using [createSubContext] and launches [behaviourContextReceiver] in a new context
|
|
||||||
* using [doInContext]
|
|
||||||
*
|
|
||||||
* @param stopOnCompletion ___TRUE BY DEFAULT___
|
|
||||||
* @param updatesFilter Is not used anymore
|
|
||||||
*/
|
|
||||||
@Deprecated("It is not recommended to use updates filter anymore")
|
|
||||||
suspend fun <T, BC : BehaviourContext> BC.createSubContextAndDoWithUpdatesFilter(
|
|
||||||
scope: CoroutineScope = LinkedSupervisorScope(),
|
|
||||||
triggersHolder: TriggersHolder = this.triggersHolder,
|
|
||||||
updatesUpstreamFlow: Flow<Update> = allUpdatesFlow,
|
|
||||||
updatesFilter: CustomBehaviourContextAndTypeReceiver<BC, Boolean, Update>?,
|
|
||||||
stopOnCompletion: Boolean = true,
|
|
||||||
behaviourContextReceiver: CustomBehaviourContextReceiver<BC, T>
|
|
||||||
): T {
|
|
||||||
return createSubContextAndDoWithUpdatesFilter(
|
|
||||||
scope, triggersHolder, updatesUpstreamFlow, stopOnCompletion, behaviourContextReceiver
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method will cancel ALL subsequent contexts, expectations and waiters
|
|
||||||
*/
|
|
||||||
fun BehaviourContext.stop() = scope.cancel()
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.behaviour_builder
|
|
||||||
|
|
||||||
import dev.inmo.micro_utils.coroutines.ExceptionHandler
|
|
||||||
import dev.inmo.tgbotapi.bot.ktor.KtorRequestsExecutorBuilder
|
|
||||||
import dev.inmo.tgbotapi.bot.ktor.telegramBot
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingOfUpdatesByLongPolling
|
|
||||||
import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter
|
|
||||||
import dev.inmo.tgbotapi.utils.telegramBotAPIDefaultUrl
|
|
||||||
import kotlinx.coroutines.*
|
|
||||||
import kotlin.coroutines.coroutineContext
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create bot using [telegramBot] and start listening for updates using [buildBehaviour].
|
|
||||||
* Use this method in case you wish to make some additional actions with [flowsUpdatesFilter].
|
|
||||||
*
|
|
||||||
* **WARNING** This method WILL NOT launch any listening of updates. Use something like
|
|
||||||
* [startGettingOfUpdatesByLongPolling] or tools for work with webhooks
|
|
||||||
*
|
|
||||||
* @return Created bot which has been used to create [BehaviourContext] via [buildBehaviour]
|
|
||||||
*
|
|
||||||
* @see [BehaviourContext]
|
|
||||||
* @see [buildBehaviour]
|
|
||||||
* @see startGettingOfUpdatesByLongPolling
|
|
||||||
*/
|
|
||||||
suspend fun telegramBotWithBehaviour(
|
|
||||||
token: String,
|
|
||||||
flowsUpdatesFilter: FlowsUpdatesFilter = FlowsUpdatesFilter(),
|
|
||||||
scope: CoroutineScope? = null,
|
|
||||||
apiUrl: String = telegramBotAPIDefaultUrl,
|
|
||||||
builder: KtorRequestsExecutorBuilder.() -> Unit = {},
|
|
||||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
|
||||||
testServer: Boolean = false,
|
|
||||||
block: BehaviourContextReceiver<Unit>
|
|
||||||
): TelegramBot = telegramBot(
|
|
||||||
token,
|
|
||||||
apiUrl,
|
|
||||||
testServer,
|
|
||||||
builder
|
|
||||||
).apply {
|
|
||||||
buildBehaviour(
|
|
||||||
flowsUpdatesFilter,
|
|
||||||
scope ?: CoroutineScope(coroutineContext),
|
|
||||||
defaultExceptionsHandler,
|
|
||||||
block
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create bot using [telegramBot] and start listening for updates using [buildBehaviourWithLongPolling].
|
|
||||||
* Use this method in case you wish to make some additional actions with [flowsUpdatesFilter].
|
|
||||||
*
|
|
||||||
* **WARNING** This method WILL launch updates listening inside of calling [buildBehaviourWithLongPolling]
|
|
||||||
*
|
|
||||||
* @return Pair of [TelegramBot] and [Job]. This [Job] can be used to stop listening updates in your [block] you passed
|
|
||||||
* here
|
|
||||||
*
|
|
||||||
* @see [BehaviourContext]
|
|
||||||
* @see buildBehaviourWithLongPolling
|
|
||||||
* @see startGettingOfUpdatesByLongPolling
|
|
||||||
*/
|
|
||||||
suspend fun telegramBotWithBehaviourAndLongPolling(
|
|
||||||
token: String,
|
|
||||||
scope: CoroutineScope? = null,
|
|
||||||
apiUrl: String = telegramBotAPIDefaultUrl,
|
|
||||||
builder: KtorRequestsExecutorBuilder.() -> Unit = {},
|
|
||||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
|
||||||
testServer: Boolean = false,
|
|
||||||
block: BehaviourContextReceiver<Unit>
|
|
||||||
): Pair<TelegramBot, Job> {
|
|
||||||
return telegramBot(
|
|
||||||
token,
|
|
||||||
apiUrl,
|
|
||||||
testServer,
|
|
||||||
builder
|
|
||||||
).let {
|
|
||||||
it to it.buildBehaviourWithLongPolling(
|
|
||||||
scope ?: CoroutineScope(coroutineContext),
|
|
||||||
defaultExceptionsHandler,
|
|
||||||
block
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.behaviour_builder
|
|
||||||
|
|
||||||
import dev.inmo.micro_utils.coroutines.DeferredAction
|
|
||||||
import dev.inmo.micro_utils.coroutines.invokeFirstOf
|
|
||||||
import kotlinx.coroutines.Deferred
|
|
||||||
import kotlinx.coroutines.async
|
|
||||||
|
|
||||||
suspend fun <T> BehaviourContext.parallel(
|
|
||||||
action: BehaviourContextReceiver<T>
|
|
||||||
) = async {
|
|
||||||
action()
|
|
||||||
}
|
|
||||||
|
|
||||||
inline infix fun <T, O> Deferred<T>.withAction(noinline callback: suspend (T) -> O) = DeferredAction(this, callback)
|
|
||||||
|
|
||||||
inline fun <T> Deferred<T>.asAction() = DeferredAction(this) { it }
|
|
||||||
|
|
||||||
suspend fun <O> BehaviourContext.oneOfActions(
|
|
||||||
deferredActions: Iterable<DeferredAction<*, O>>
|
|
||||||
) = deferredActions.invokeFirstOf(scope)
|
|
||||||
|
|
||||||
suspend fun <O> BehaviourContext.oneOfActions(
|
|
||||||
vararg deferredActions: DeferredAction<*, O>
|
|
||||||
) = this@oneOfActions.oneOfActions(deferredActions.toList())
|
|
||||||
|
|
||||||
suspend fun <O> BehaviourContext.oneOf(
|
|
||||||
deferredActions: Iterable<Deferred<O>>
|
|
||||||
) = oneOfActions(deferredActions.map { it.asAction() })
|
|
||||||
|
|
||||||
suspend fun <O> BehaviourContext.oneOf(
|
|
||||||
vararg deferredActions: Deferred<O>
|
|
||||||
) = oneOf(deferredActions.toList())
|
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
|
||||||
|
|
||||||
import dev.inmo.micro_utils.coroutines.safelyWithResult
|
|
||||||
import dev.inmo.micro_utils.coroutines.safelyWithoutExceptions
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.flatten
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
|
||||||
import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter
|
|
||||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
|
||||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
|
||||||
import kotlinx.coroutines.CancellationException
|
|
||||||
import kotlinx.coroutines.flow.*
|
|
||||||
|
|
||||||
private val cancelledByFilterException = CancellationException("Cancelled by filter precreatedException")
|
|
||||||
|
|
||||||
typealias RequestBuilder<T> = suspend (Update) -> Request<T>
|
|
||||||
typealias NullableRequestBuilder<T> = suspend (Update) -> Request<T>?
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param initRequest If not null, this request will be sent by [bot] before returning value
|
|
||||||
* @param errorFactory If set, this factory will be used to produce requests in case when user have sent incorrect data
|
|
||||||
* @param cancelRequestFactory If set, this factory will be used to produce requests in case when it is required to say
|
|
||||||
* user that chain of scenario has been cancelled
|
|
||||||
* @param cancelTrigger When this trigger returns true, chain is cancelled
|
|
||||||
* @param filter It is main param, which will be called on each update. When it return not null, result will be returned
|
|
||||||
* as is, but when it returns null, then will be called [cancelTrigger] (if it will return true - [cancelRequestFactory]
|
|
||||||
* will be called too), [errorFactory] and then will be returned null
|
|
||||||
*/
|
|
||||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
|
||||||
suspend fun <T> FlowsUpdatesFilter.expectFlow(
|
|
||||||
bot: TelegramBot,
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
cancelRequestFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
cancelTrigger: suspend (Update) -> Boolean = { cancelRequestFactory(it) != null },
|
|
||||||
filter: suspend (Update) -> List<T>
|
|
||||||
): Flow<T> {
|
|
||||||
val flow = allUpdatesFlow.map {
|
|
||||||
val result = safelyWithResult { filter(it) }
|
|
||||||
if (result.isFailure || result.getOrThrow().isEmpty()) {
|
|
||||||
if (cancelTrigger(it)) {
|
|
||||||
cancelRequestFactory(it) ?.also {
|
|
||||||
safelyWithResult { bot.execute(it) }
|
|
||||||
throw cancelledByFilterException
|
|
||||||
}
|
|
||||||
}
|
|
||||||
errorFactory(it) ?.also { errorRequest ->
|
|
||||||
safelyWithoutExceptions { bot.execute(errorRequest) }
|
|
||||||
}
|
|
||||||
emptyList()
|
|
||||||
} else {
|
|
||||||
result.getOrThrow()
|
|
||||||
}
|
|
||||||
}.flatten()
|
|
||||||
initRequest ?.also { safelyWithoutExceptions { bot.execute(initRequest) } }
|
|
||||||
return flow
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param initRequest If not null, this request will be sent by [bot] before returning value
|
|
||||||
* @param errorFactory If set, this factory will be used to produce requests in case when user have sent incorrect data
|
|
||||||
* @param cancelRequestFactory If set, this factory will be used to produce requests in case when it is required to say
|
|
||||||
* user that chain of scenario has been cancelled
|
|
||||||
* @param cancelTrigger When this trigger returns true, chain is cancelled
|
|
||||||
* @param filter It is main param, which will be called on each update. When it return not null, result will be returned
|
|
||||||
* as is, but when it returns null, then will be called [cancelTrigger] (if it will return true - [cancelRequestFactory]
|
|
||||||
* will be called too), [errorFactory] and then will be returned null
|
|
||||||
*/
|
|
||||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
|
||||||
suspend fun <T> BehaviourContext.expectFlow(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
cancelRequestFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
cancelTrigger: suspend (Update) -> Boolean = { cancelRequestFactory(it) != null },
|
|
||||||
filter: suspend (Update) -> List<T>
|
|
||||||
) = flowsUpdatesFilter.expectFlow(bot, initRequest, errorFactory, cancelRequestFactory, cancelTrigger, filter)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param initRequest If not null, this request will be sent by [bot] before returning value
|
|
||||||
* @param errorFactory If set, this factory will be used to produce requests in case when user have sent incorrect data
|
|
||||||
* @param cancelRequestFactory If set, this factory will be used to produce requests in case when it is required to say
|
|
||||||
* user that chain of scenario has been cancelled
|
|
||||||
* @param cancelTrigger When this trigger returns true, chain is cancelled
|
|
||||||
* @param filter It is main param, which will be called on each update. When it return not null, result will be returned
|
|
||||||
* as is, but when it returns null, then will be called [cancelTrigger] (if it will return true - [cancelRequestFactory]
|
|
||||||
* will be called too), [errorFactory] and then will be returned null
|
|
||||||
*/
|
|
||||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
|
||||||
suspend fun <T> FlowsUpdatesFilter.expectOne(
|
|
||||||
bot: TelegramBot,
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
cancelRequestFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
cancelTrigger: suspend (Update) -> Boolean = { cancelRequestFactory(it) != null },
|
|
||||||
filter: suspend (Update) -> T?
|
|
||||||
): T = expectFlow(bot, initRequest, errorFactory, cancelRequestFactory, cancelTrigger) {
|
|
||||||
listOfNotNull(filter.invoke(it))
|
|
||||||
}.first()
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param initRequest If not null, this request will be sent by [bot] before returning value
|
|
||||||
* @param errorFactory If set, this factory will be used to produce requests in case when user have sent incorrect data
|
|
||||||
* @param cancelRequestFactory If set, this factory will be used to produce requests in case when it is required to say
|
|
||||||
* user that chain of scenario has been cancelled
|
|
||||||
* @param cancelTrigger When this trigger returns true, chain is cancelled
|
|
||||||
* @param filter It is main param, which will be called on each update. When it return not null, result will be returned
|
|
||||||
* as is, but when it returns null, then will be called [cancelTrigger] (if it will return true - [cancelRequestFactory]
|
|
||||||
* will be called too), [errorFactory] and then will be returned null
|
|
||||||
*/
|
|
||||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
|
||||||
suspend fun <T> BehaviourContext.expectOne(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
cancelRequestFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
cancelTrigger: suspend (Update) -> Boolean = { cancelRequestFactory(it) != null },
|
|
||||||
filter: suspend (Update) -> T?
|
|
||||||
) = flowsUpdatesFilter.expectOne(bot, initRequest, errorFactory, cancelRequestFactory, cancelTrigger, filter)
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
@file:Suppress("unused")
|
|
||||||
|
|
||||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asCallbackQueryUpdate
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
|
||||||
import dev.inmo.tgbotapi.types.queries.callback.*
|
|
||||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
|
||||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
|
||||||
import kotlinx.coroutines.flow.Flow
|
|
||||||
import kotlinx.coroutines.flow.toList
|
|
||||||
|
|
||||||
typealias CallbackQueryMapper<T> = suspend T.() -> T?
|
|
||||||
|
|
||||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
|
||||||
suspend inline fun <reified O> BehaviourContext.waitCallbackQueries(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
noinline errorFactory: NullableRequestBuilder<*> = { null }
|
|
||||||
): Flow<O> = expectFlow(
|
|
||||||
initRequest,
|
|
||||||
errorFactory
|
|
||||||
) {
|
|
||||||
(it.asCallbackQueryUpdate() ?.data as O).let(::listOfNotNull)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
suspend fun BehaviourContext.waitDataCallbackQuery(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
|
||||||
) = waitCallbackQueries<DataCallbackQuery>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitGameShortNameCallbackQuery(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
|
||||||
) = waitCallbackQueries<GameShortNameCallbackQuery>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitInlineMessageIdCallbackQuery(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
|
||||||
) = waitCallbackQueries<InlineMessageIdCallbackQuery>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitInlineMessageIdDataCallbackQuery(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
|
||||||
) = waitCallbackQueries<InlineMessageIdDataCallbackQuery>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitInlineMessageIdGameShortNameCallbackQuery(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
|
||||||
) = waitCallbackQueries<InlineMessageIdGameShortNameCallbackQuery>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitMessageCallbackQuery(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
|
||||||
) = waitCallbackQueries<MessageCallbackQuery>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitMessageDataCallbackQuery(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
|
||||||
) = waitCallbackQueries<MessageDataCallbackQuery>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitMessageGameShortNameCallbackQuery(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
|
||||||
) = waitCallbackQueries<MessageGameShortNameCallbackQuery>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitUnknownCallbackQuery(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
|
||||||
) = waitCallbackQueries<UnknownCallbackQueryType>(initRequest, errorFactory)
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asChatJoinRequestUpdate
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
|
||||||
import dev.inmo.tgbotapi.types.chat.ChatJoinRequest
|
|
||||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
|
||||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
|
||||||
import kotlinx.coroutines.flow.Flow
|
|
||||||
import kotlinx.coroutines.flow.toList
|
|
||||||
|
|
||||||
typealias ChatJoinRequestsMapper = suspend ChatJoinRequest.() -> ChatJoinRequest?
|
|
||||||
|
|
||||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
|
||||||
suspend inline fun <reified O> BehaviourContext.internalWaitChatJoinRequests(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
noinline errorFactory: NullableRequestBuilder<*> = { null }
|
|
||||||
): Flow<O> = expectFlow(
|
|
||||||
initRequest,
|
|
||||||
errorFactory
|
|
||||||
) {
|
|
||||||
(it.asChatJoinRequestUpdate() ?.data as? O).let(::listOfNotNull)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
suspend fun BehaviourContext.waitChatJoinRequests(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
|
||||||
) : Flow<ChatJoinRequest> = internalWaitChatJoinRequests(
|
|
||||||
initRequest,
|
|
||||||
errorFactory
|
|
||||||
)
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
|
||||||
import dev.inmo.tgbotapi.types.chat.member.ChatMemberUpdated
|
|
||||||
import dev.inmo.tgbotapi.types.update.CommonChatMemberUpdatedUpdate
|
|
||||||
import dev.inmo.tgbotapi.types.update.MyChatMemberUpdatedUpdate
|
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.ChatMemberUpdatedUpdate
|
|
||||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
|
||||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
|
||||||
import kotlinx.coroutines.flow.Flow
|
|
||||||
import kotlinx.coroutines.flow.toList
|
|
||||||
|
|
||||||
typealias ChatMemberUpdatedMapper<T> = suspend T.() -> T?
|
|
||||||
|
|
||||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
|
||||||
suspend inline fun <reified O : ChatMemberUpdatedUpdate> BehaviourContext.waitChatMemberUpdatedWithFilter(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
noinline errorFactory: NullableRequestBuilder<*> = { null }
|
|
||||||
): Flow<ChatMemberUpdated> = expectFlow(
|
|
||||||
initRequest,
|
|
||||||
errorFactory
|
|
||||||
) {
|
|
||||||
(it as? O) ?.data.let(::listOfNotNull)
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun BehaviourContext.waitChatMemberUpdated(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
) = waitChatMemberUpdatedWithFilter<ChatMemberUpdatedUpdate>(initRequest, errorFactory)
|
|
||||||
|
|
||||||
suspend fun BehaviourContext.waitCommonChatMemberUpdated(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
) = waitChatMemberUpdatedWithFilter<CommonChatMemberUpdatedUpdate>(initRequest, errorFactory)
|
|
||||||
|
|
||||||
suspend fun BehaviourContext.waitMyChatMemberUpdated(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
|
||||||
) = waitChatMemberUpdatedWithFilter<MyChatMemberUpdatedUpdate>(initRequest, errorFactory)
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asChosenInlineResultUpdate
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.*
|
|
||||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
|
||||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
|
||||||
import kotlinx.coroutines.flow.Flow
|
|
||||||
import kotlinx.coroutines.flow.toList
|
|
||||||
|
|
||||||
typealias ChosenInlineResultMapper<T> = suspend T.() -> T?
|
|
||||||
|
|
||||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
|
||||||
suspend inline fun <reified O> BehaviourContext.waitChosenInlineResults(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
noinline errorFactory: NullableRequestBuilder<*> = { null }
|
|
||||||
): Flow<O> = expectFlow(
|
|
||||||
initRequest,
|
|
||||||
errorFactory
|
|
||||||
) {
|
|
||||||
(it.asChosenInlineResultUpdate() ?.data as? O).let(::listOfNotNull)
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun BehaviourContext.waitChosenInlineResult(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
|
||||||
) = waitChosenInlineResults<ChosenInlineResult>(initRequest, errorFactory)
|
|
||||||
|
|
||||||
suspend fun BehaviourContext.waitLocationChosenInlineResult(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
|
||||||
) = waitChosenInlineResults<LocationChosenInlineResult>(initRequest, errorFactory)
|
|
||||||
|
|
||||||
suspend fun BehaviourContext.waitBaseChosenInlineResult(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
|
||||||
) = waitChosenInlineResults<BaseChosenInlineResult>(initRequest, errorFactory)
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user