mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-19 13:55:57 +00:00
Compare commits
76 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7af5ab17b7 | |||
| 0fec35f0dc | |||
| ee81f49a75 | |||
| 807952201b | |||
| 5d6ba0f59e | |||
| 3a61b522ab | |||
| 83304023a6 | |||
| f62e13aaca | |||
| ae1fb25336 | |||
| 4e3ea6cd80 | |||
| 148203eabf | |||
| 4465b573ca | |||
| f0dda60630 | |||
| 47135a1b65 | |||
| d8f830c60f | |||
| 226b8dee21 | |||
| a109771d20 | |||
| c028434f30 | |||
| d5c6ce32bb | |||
| d92cac5e07 | |||
| 9b21b5290c | |||
| 13ca63d27d | |||
| ad917dda1b | |||
| 7b1344e9c8 | |||
| c4fbd2f1c6 | |||
| c90bcea42c | |||
| e75c93d626 | |||
| 58dcbe8751 | |||
| 17806cde25 | |||
| f147a3d620 | |||
| 9eb6008a73 | |||
| f7d2c8bbd2 | |||
| f42cf78969 | |||
| 9a14932511 | |||
| 149ecf175b | |||
| 2049fea82a | |||
| 40d94cca70 | |||
| c8ad68ea69 | |||
| c66d64adbc | |||
| b475976ff1 | |||
| ea8db5b851 | |||
| af2fabf1ca | |||
| abc0457a36 | |||
| 8dbdbdee13 | |||
| 0c31379ff5 | |||
| 3b3cf81aaa | |||
| 1642075a75 | |||
| 760c9f2916 | |||
| 219238cf19 | |||
| 762087fc09 | |||
| 142fae1ede | |||
| 95abc72bf3 | |||
| 1d37a7446c | |||
| 7d35114b5d | |||
| 75f4226772 | |||
| 96d980cb8a | |||
| ed077ae1bc | |||
| 9540797ffc | |||
| 217b01994e | |||
| 6b89c94ef1 | |||
| e25ce57f6a | |||
| 530394fd15 | |||
| 3e891d50fd | |||
| adf5fd6288 | |||
| e7a2dc51aa | |||
| 399793243b | |||
| 3801025ff1 | |||
| 0ad2d9afc4 | |||
| a303700b56 | |||
| 42bf896f7a | |||
| 0bce522101 | |||
| 3c75d6a2c7 | |||
| 93eebe37ce | |||
| f893803939 | |||
| 0b92edc05e | |||
| 190d83b22b |
96
CHANGELOG.md
96
CHANGELOG.md
@@ -1,5 +1,101 @@
|
||||
# TelegramBotAPI changelog
|
||||
|
||||
## 0.35.8
|
||||
|
||||
* `Common`:
|
||||
* `Version`:
|
||||
* `MicroUtils`: `0.5.24` -> `0.5.25`
|
||||
* `UUID`: `0.3.0` -> `0.3.1`
|
||||
* `Core`:
|
||||
* `MultipartRequestCallFactory` now will use file name as multipart `filename` parameter instead of generated
|
||||
filename
|
||||
* New extension `MPPFile#asMultipartFile`
|
||||
* `API`
|
||||
* Fixes in `TelegramBot#withAction`
|
||||
* `Behaviour Builder`:
|
||||
* New extensions `BehaviourContext#commandWithArgs` and `BehaviourContext#onCommandWithArgs`
|
||||
|
||||
## 0.35.7
|
||||
|
||||
* `Common`:
|
||||
* `Version`:
|
||||
* `Kotlin`: `1.5.21` -> `1.5.30`
|
||||
* `Klock`: `2.3.3` -> `2.4.1`
|
||||
* `Ktor`: `1.6.2` -> `1.6.3`
|
||||
* `Coroutines`: `1.5.1` -> `1.5.2`
|
||||
* `MicroUtils`: `0.5.21` -> `0.5.24`
|
||||
|
||||
## 0.35.6
|
||||
|
||||
* `Common`:
|
||||
* `Version`:
|
||||
* `Klock`: `2.3.1` -> `2.3.3`
|
||||
* `MicroUtils`: `0.5.19` -> `0.5.21`
|
||||
* `Core`:
|
||||
* All `FlowsUpdatesFilter` flows have been renamed and updated
|
||||
* `Utils`:
|
||||
* Extensions `allSentMessagesFlow` and `allSentMediaGroupsFlow` have been deprecated
|
||||
|
||||
## 0.35.5
|
||||
|
||||
**MIME TYPES FOR REQUESTS HAVE BEEN DEPRECATED DUE TO REDUNDANCY OF MIME TYPES IN FILES SENDING**
|
||||
|
||||
* `Core`:
|
||||
* Several new extensions `ByteReadChannel#asStorageFile` and `ByteReadChannelAllocator#asStorageFile`
|
||||
* Several new extensions `ByteArray#asMultipartFile`, `ByteReadChannel#asMultipartFile` and
|
||||
`ByteReadChannelAllocator#asMultipartFile`
|
||||
* New extension `StorageFile#asMultipartFile`
|
||||
* `API`:
|
||||
* New extensions `TelegramBot#downloadFile` for writing of incoming bytes to the file
|
||||
* New extensions `TelegramBot#downloadFileStream` and `TelegramBot#downloadFileStreamAllocator` for getting of input
|
||||
streams instead of whole bytes arrays
|
||||
* Old extensions `TelegramBot#downloadFile` has been replaced to the new package. Migration: replace in your project
|
||||
`import dev.inmo.tgbotapi.extensions.api.downloadFile` with `import dev.inmo.tgbotapi.extensions.api.files.downloadFile`
|
||||
* `PathedFile#filename` extension has been deprecated, and new property `PathedFile#fileName` has been included
|
||||
directly in `PathedFile`
|
||||
* `Utils`:
|
||||
* Add several functions `convertToStorageFile` and extensions `TelegramBot#convertToStorageFile`
|
||||
|
||||
## 0.35.4 Hotfix
|
||||
|
||||
* `Common`:
|
||||
* `Version`:
|
||||
* `MicroUtils`: `0.5.18` -> `0.5.19`
|
||||
|
||||
## 0.35.3
|
||||
|
||||
* `Common`:
|
||||
* `Version`:
|
||||
* `Klock`: `2.2.0` -> `2.3.1`
|
||||
* `Ktor`: `1.6.1` -> `1.6.2`
|
||||
* `MicroUtils`: `0.5.16` -> `0.5.18`
|
||||
* `Core`:
|
||||
* **`SimpleRequestCallFactory` and `MultipartRequestCallFactory` became a classes instead of objects to avoid
|
||||
collisions in different bots**
|
||||
* Support of strongly-typed ietf language codes has been added
|
||||
* `API`:
|
||||
* New extension `TelegramBot#downloadFile` for any `MediaContent`
|
||||
* `Behaviour Builder`:
|
||||
* New provider `defaultCoroutineScopeProvider`
|
||||
* Now it is not necessary to provide `CoroutineScope` to `TelegramBot#buildBehaviour`
|
||||
extension
|
||||
* New `TelegramBot#buildBehaviour` extension with `FlowUpdatesFilter` and `CoroutineScope` with
|
||||
default `CoroutineScope`
|
||||
* New typealias `SimpleFilter` for unifying triggers filter signatures
|
||||
* All waiters got real filters (`SimpleFilter`) and rename old filters as mappers
|
||||
* New extensions for `Any`: `as`/`when`/`require` for `WithOptionalLanguageCode` and `WithLanguageCode`
|
||||
|
||||
## 0.35.2
|
||||
|
||||
* `Common`:
|
||||
* `Version`:
|
||||
* `Kotlin`: `1.5.20` -> `1.5.21`
|
||||
* `Coroutines`: `1.5.0` -> `1.5.1`
|
||||
* `Serialization`: `1.2.1` -> `1.2.2`
|
||||
* `Klock`: `2.1.2` -> `2.2.0`
|
||||
* `Ktor`: `1.6.0` -> `1.6.1`
|
||||
* `MicroUtils`: `0.5.15` -> `0.5.16`
|
||||
|
||||
## 0.35.1
|
||||
|
||||
* `Common`:
|
||||
|
||||
@@ -2,6 +2,15 @@
|
||||
|
||||
# TelegramBotAPI
|
||||
|
||||
- [TelegramBotAPI](#telegrambotapi)
|
||||
* [Examples](#examples)
|
||||
+ [Most common example](#most-common-example)
|
||||
+ [Handling only last messages](#handling-only-last-messages)
|
||||
+ [Build a little bit more complex behaviour](#build-a-little-bit-more-complex-behaviour)
|
||||
+ [More examples](#more-examples)
|
||||
|
||||
<small><i><a href='http://ecotrust-canada.github.io/markdown-toc/'>Table of contents generated with markdown-toc</a></i></small>
|
||||
|
||||
Hello! This is a set of libraries for working with Telegram Bot API.
|
||||
|
||||
| Common info | [](https://github.com/KotlinBy/awesome-kotlin) [](https://github.com/InsanusMokrassar/TelegramBotAPI/actions) [Small survey](https://forms.gle/2Hex2ynbHWHhi1KY7)|
|
||||
|
||||
1
TelegramBotAPI.drawio
Normal file
1
TelegramBotAPI.drawio
Normal file
File diff suppressed because one or more lines are too long
@@ -1,311 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<minder version="1.11.3">
|
||||
<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="-950.47548925255796" y="-49.650554065281653" scale="0.5"/>
|
||||
<images/>
|
||||
<nodes>
|
||||
<node id="0" posx="1378.798161778599" posy="159.04571601189673" width="472" height="168" side="top" fold="false" treesize="743" 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="1394.798161778599" posy="175.04571601189673" 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="1411.798161778599" posy="427.04571601189673" width="406" height="145" side="bottom" fold="false" treesize="743" 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="1427.798161778599" posy="443.04571601189673" 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="1247.298161778599" posy="672.04571601189673" 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="1263.298161778599" posy="688.04571601189673" 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="1609.298161778599" posy="672.04571601189673" width="307" height="168" side="bottom" fold="false" treesize="439" 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="1625.298161778599" posy="688.04571601189673" maxwidth="299.252197265625">
|
||||
<text data="tgbotapi.extensions.utils Extensions project with utils things which will make easier different operations"/>
|
||||
</nodename>
|
||||
<nodenote></nodenote>
|
||||
<nodes>
|
||||
<node id="4" posx="1543.298161778599" posy="940.04571601189673" width="439" height="122" side="bottom" fold="false" treesize="439" color="#68b723" colorroot="false" layout="Downwards" group="false">
|
||||
<style branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="387" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true"/>
|
||||
<nodename posx="1559.298161778599" posy="956.04571601189673" maxwidth="408.97932942708348">
|
||||
<text data="tgbotapi.extensions.behaviour_builder Extension project for building bot behaviour via special dsl"/>
|
||||
</nodename>
|
||||
<nodenote></nodenote>
|
||||
</node>
|
||||
</nodes>
|
||||
</node>
|
||||
</nodes>
|
||||
</node>
|
||||
</nodes>
|
||||
</node>
|
||||
<node id="5" posx="1391.8445078072455" posy="1155.6062730594231" width="461" height="236" side="bottom" fold="false" treesize="461" layout="Downwards" group="false">
|
||||
<style branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="430" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true"/>
|
||||
<nodename posx="1407.8445078072455" posy="1171.6062730594231" maxwidth="453.885498046875">
|
||||
<text data="tgbotapi Here included all available TelegramBotAPI libraries: * tgbotapi.core * tgbotapi.extensions.api * tgbotapi.extensions.utils * tgbotapi.extensions.behaviour_builder">
|
||||
<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="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="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="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="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="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="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)"/>
|
||||
<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)"/>
|
||||
<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)"/>
|
||||
<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="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
<range start="139" end="140" extra="rgb(255,0,0)"/>
|
||||
</color>
|
||||
</text>
|
||||
</nodename>
|
||||
<nodenote></nodenote>
|
||||
</node>
|
||||
</nodes>
|
||||
<groups/>
|
||||
<connections>
|
||||
<connection from_id="2" to_id="5" drag_x="1475.8213347929195" drag_y="1014.8259945356604" color="#777777">
|
||||
<style connectiondash="dotted" connectionlwidth="2" connectionarrow="fromto" connectionpadding="3" connectionfont="Sans 10" connectiontwidth="100"/>
|
||||
<title></title>
|
||||
<note></note>
|
||||
</connection>
|
||||
<connection from_id="4" to_id="5" drag_x="1691.5447998046875" drag_y="1107.00439453125" 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="5" drag_x="1483.48876953125" drag_y="896.18115234375">
|
||||
<style connectiondash="dotted" connectionlwidth="2" connectionarrow="fromto" connectionpadding="3" connectionfont="Sans 10" connectiontwidth="100"/>
|
||||
<title></title>
|
||||
<note></note>
|
||||
</connection>
|
||||
</connections>
|
||||
<stickers/>
|
||||
</minder>
|
||||
@@ -1,3 +1,3 @@
|
||||
dokka_version=1.4.32
|
||||
dokka_version=1.5.0
|
||||
|
||||
org.gradle.jvmargs=-Xmx1024m
|
||||
|
||||
@@ -5,18 +5,18 @@ kotlin.js.generate.externals=true
|
||||
kotlin.incremental=true
|
||||
kotlin.incremental.js=true
|
||||
|
||||
kotlin_version=1.5.20
|
||||
kotlin_coroutines_version=1.5.0
|
||||
kotlin_serialisation_runtime_version=1.2.1
|
||||
klock_version=2.1.2
|
||||
uuid_version=0.3.0
|
||||
ktor_version=1.6.0
|
||||
kotlin_version=1.5.30
|
||||
kotlin_coroutines_version=1.5.2
|
||||
kotlin_serialisation_runtime_version=1.2.2
|
||||
klock_version=2.4.1
|
||||
uuid_version=0.3.1
|
||||
ktor_version=1.6.3
|
||||
|
||||
micro_utils_version=0.5.15
|
||||
micro_utils_version=0.5.25
|
||||
|
||||
javax_activation_version=1.1.1
|
||||
|
||||
library_group=dev.inmo
|
||||
library_version=0.35.1
|
||||
library_version=0.35.8
|
||||
|
||||
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
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
|
||||
|
||||
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 9.0 KiB |
@@ -2,6 +2,20 @@
|
||||
|
||||
[](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.core)
|
||||
|
||||
- [TelegramBotAPI Core](#telegrambotapi-core)
|
||||
* [What is it?](#what-is-it-)
|
||||
* [Compatibility](#compatibility)
|
||||
* [How to implement library?](#how-to-implement-library-)
|
||||
+ [Maven](#maven)
|
||||
+ [Gradle](#gradle)
|
||||
* [How to work with library?](#how-to-work-with-library-)
|
||||
+ [Types](#types)
|
||||
+ [Requests](#requests)
|
||||
+ [RequestsExecutor](#requestsexecutor)
|
||||
+ [Passport](#passport)
|
||||
|
||||
<small><i><a href='http://ecotrust-canada.github.io/markdown-toc/'>Table of contents generated with markdown-toc</a></i></small>
|
||||
|
||||
## What is it?
|
||||
|
||||
Library for Object-Oriented and type-safe work with Telegram Bot API. Most part of some specific solves or unuseful
|
||||
|
||||
@@ -51,6 +51,7 @@ kotlin {
|
||||
api "dev.inmo:micro_utils.serialization.base64:$micro_utils_version"
|
||||
api "dev.inmo:micro_utils.serialization.encapsulator:$micro_utils_version"
|
||||
api "dev.inmo:micro_utils.serialization.typed_serializer:$micro_utils_version"
|
||||
api "dev.inmo:micro_utils.language_codes:$micro_utils_version"
|
||||
|
||||
api "io.ktor:ktor-client-core:$ktor_version"
|
||||
}
|
||||
|
||||
@@ -42,6 +42,14 @@ inline fun telegramBot(
|
||||
crossinline builder: KtorRequestsExecutorBuilder.() -> Unit = {}
|
||||
): TelegramBot = telegramBot(TelegramAPIUrlsKeeper(token, apiUrl), builder)
|
||||
|
||||
@RiskFeature
|
||||
fun createTelegramBotDefaultKtorCallRequestsFactories() = listOf(
|
||||
SimpleRequestCallFactory(),
|
||||
MultipartRequestCallFactory(),
|
||||
DownloadFileRequestCallFactory,
|
||||
DownloadFileChannelRequestCallFactory
|
||||
)
|
||||
|
||||
class KtorRequestsExecutor(
|
||||
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
||||
client: HttpClient = HttpClient(),
|
||||
@@ -52,7 +60,7 @@ class KtorRequestsExecutor(
|
||||
) : BaseRequestsExecutor(telegramAPIUrlsKeeper) {
|
||||
private val callsFactories: List<KtorCallFactory> = callsFactories.run {
|
||||
if (!excludeDefaultFactories) {
|
||||
this + listOf(SimpleRequestCallFactory, MultipartRequestCallFactory, DownloadFileRequestCallFactory)
|
||||
this + createTelegramBotDefaultKtorCallRequestsFactories()
|
||||
} else {
|
||||
this
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package dev.inmo.tgbotapi.bot.Ktor.base
|
||||
|
||||
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
||||
import dev.inmo.tgbotapi.bot.Ktor.KtorCallFactory
|
||||
import dev.inmo.tgbotapi.requests.DownloadFileStream
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.utils.ByteReadChannelAllocator
|
||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.call.receive
|
||||
import io.ktor.client.request.get
|
||||
import io.ktor.client.statement.HttpStatement
|
||||
import io.ktor.utils.io.*
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlin.coroutines.coroutineContext
|
||||
|
||||
object DownloadFileChannelRequestCallFactory : KtorCallFactory {
|
||||
override suspend fun <T : Any> makeCall(
|
||||
client: HttpClient,
|
||||
urlsKeeper: TelegramAPIUrlsKeeper,
|
||||
request: Request<T>,
|
||||
jsonFormatter: Json
|
||||
): T? = (request as? DownloadFileStream) ?.let {
|
||||
val fullUrl = urlsKeeper.createFileLinkUrl(it.filePath)
|
||||
|
||||
ByteReadChannelAllocator {
|
||||
val scope = CoroutineScope(coroutineContext)
|
||||
val outChannel = ByteChannel()
|
||||
scope.launchSafelyWithoutExceptions {
|
||||
client.get<HttpStatement>(fullUrl).execute { httpResponse ->
|
||||
val channel: ByteReadChannel = httpResponse.receive()
|
||||
channel.copyAndClose(outChannel)
|
||||
}
|
||||
}
|
||||
outChannel
|
||||
} as T
|
||||
}
|
||||
}
|
||||
@@ -16,9 +16,9 @@ object DownloadFileRequestCallFactory : KtorCallFactory {
|
||||
request: Request<T>,
|
||||
jsonFormatter: Json
|
||||
): T? = (request as? DownloadFile) ?.let {
|
||||
val fullUrl = "${urlsKeeper.fileBaseUrl}/${it.filePath}"
|
||||
val fullUrl = urlsKeeper.createFileLinkUrl(it.filePath)
|
||||
|
||||
return safely {
|
||||
safely {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
client.get<ByteArray>(fullUrl) as T // always ByteArray
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.inmo.tgbotapi.bot.Ktor.base
|
||||
|
||||
import dev.inmo.tgbotapi.bot.Ktor.KtorCallFactory
|
||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||
import dev.inmo.tgbotapi.utils.mapWithCommonValues
|
||||
@@ -9,7 +10,7 @@ import io.ktor.client.request.forms.formData
|
||||
import io.ktor.http.Headers
|
||||
import io.ktor.http.HttpHeaders
|
||||
|
||||
object MultipartRequestCallFactory : AbstractRequestCallFactory() {
|
||||
class MultipartRequestCallFactory : AbstractRequestCallFactory() {
|
||||
override fun <T : Any> prepareCallBody(
|
||||
client: HttpClient,
|
||||
urlsKeeper: TelegramAPIUrlsKeeper,
|
||||
@@ -23,8 +24,7 @@ object MultipartRequestCallFactory : AbstractRequestCallFactory() {
|
||||
is MultipartFile -> appendInput(
|
||||
key,
|
||||
Headers.build {
|
||||
append(HttpHeaders.ContentType, value.mimeType)
|
||||
append(HttpHeaders.ContentDisposition, "filename=${value.fileId}")
|
||||
append(HttpHeaders.ContentDisposition, "filename=${value.filename}")
|
||||
},
|
||||
block = value.file::input
|
||||
)
|
||||
@@ -35,4 +35,7 @@ object MultipartRequestCallFactory : AbstractRequestCallFactory() {
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@Deprecated("Use class MultipartRequestCallFactory() constructor call instead of just MultipartRequestCallFactory")
|
||||
companion object : KtorCallFactory by MultipartRequestCallFactory()
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
package dev.inmo.tgbotapi.bot.Ktor.base
|
||||
|
||||
import dev.inmo.tgbotapi.bot.Ktor.KtorCallFactory
|
||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.http.ContentType
|
||||
import io.ktor.http.content.TextContent
|
||||
|
||||
object SimpleRequestCallFactory : AbstractRequestCallFactory() {
|
||||
class SimpleRequestCallFactory : AbstractRequestCallFactory() {
|
||||
override fun <T : Any> prepareCallBody(
|
||||
client: HttpClient,
|
||||
urlsKeeper: TelegramAPIUrlsKeeper,
|
||||
@@ -19,4 +20,7 @@ object SimpleRequestCallFactory : AbstractRequestCallFactory() {
|
||||
ContentType.Application.Json
|
||||
)
|
||||
}
|
||||
|
||||
@Deprecated("Use class SimpleRequestCallFactory() constructor call instead of just SimpleRequestCallFactory")
|
||||
companion object : KtorCallFactory by SimpleRequestCallFactory()
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.inmo.tgbotapi.requests
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.utils.ByteReadChannelAllocator
|
||||
import dev.inmo.tgbotapi.utils.ByteReadChannelAllocatorDeserializationStrategy
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
|
||||
class DownloadFileStream(
|
||||
val filePath: String
|
||||
) : Request<ByteReadChannelAllocator> {
|
||||
override fun method(): String = filePath
|
||||
override val resultDeserializer: DeserializationStrategy<ByteReadChannelAllocator>
|
||||
get() = ByteReadChannelAllocatorDeserializationStrategy
|
||||
|
||||
}
|
||||
@@ -1,13 +1,26 @@
|
||||
package dev.inmo.tgbotapi.requests.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.StorageFile
|
||||
import dev.inmo.micro_utils.common.MPPFile
|
||||
import dev.inmo.tgbotapi.utils.*
|
||||
import io.ktor.utils.io.ByteReadChannel
|
||||
import io.ktor.utils.io.core.Input
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.descriptors.*
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
/**
|
||||
* Common type for all files in Telegram Bot API which can be sent via requests like [dev.inmo.tgbotapi.requests.send.media.SendDocument].
|
||||
* You may use methods like [MPPFile.asMultipartFile] when you want to send files from your file system, but you should
|
||||
* remember about [restrictions][https://core.telegram.org/bots/api#sending-files] in Telegram for bots. In case you
|
||||
* wish to send file by its url, use [FileId] and pass your url as [FileId.fileId]
|
||||
*
|
||||
* @see MPPFile.asMultipartFile
|
||||
* @see ByteArray.asMultipartFile
|
||||
* @see ByteReadChannel.asMultipartFile
|
||||
* @see ByteReadChannelAllocator.asMultipartFile
|
||||
*/
|
||||
@Serializable(InputFileSerializer::class)
|
||||
sealed class InputFile {
|
||||
abstract val fileId: String
|
||||
@@ -42,12 +55,38 @@ object InputFileSerializer : KSerializer<InputFile> {
|
||||
// TODO:: add checks for files size
|
||||
/**
|
||||
* Contains info about file for sending
|
||||
*
|
||||
* @see asMultipartFile
|
||||
*/
|
||||
@Serializable(InputFileSerializer::class)
|
||||
data class MultipartFile (
|
||||
val file: StorageFile,
|
||||
val mimeType: String = file.storageFileInfo.contentType,
|
||||
val filename: String = file.storageFileInfo.fileName
|
||||
) : InputFile() {
|
||||
override val fileId: String = file.storageFileInfo.generateCustomName()
|
||||
|
||||
@Deprecated("This constructor is redundant. Use constructor without mime type")
|
||||
constructor(file: StorageFile, mimeType: String, filename: String): this(file, filename)
|
||||
}
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE", "unused")
|
||||
inline fun StorageFile.asMultipartFile() = MultipartFile(this)
|
||||
|
||||
@Deprecated("This method is redundant. Use asMultipartFile without mime type")
|
||||
@Suppress("NOTHING_TO_INLINE", "unused")
|
||||
inline fun ByteArray.asMultipartFile(
|
||||
fileName: String,
|
||||
mimeType: MimeType
|
||||
) = MultipartFile(asStorageFile(fileName))
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE", "unused")
|
||||
suspend inline fun ByteReadChannel.asMultipartFile(
|
||||
fileName: String
|
||||
) = MultipartFile(asStorageFile(fileName))
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE", "unused")
|
||||
suspend inline fun ByteReadChannelAllocator.asMultipartFile(
|
||||
fileName: String
|
||||
) = this.invoke().asMultipartFile(fileName)
|
||||
|
||||
expect suspend fun MPPFile.asMultipartFile(): MultipartFile
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package dev.inmo.tgbotapi.requests.bot
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
||||
|
||||
sealed interface MyCommandsRequest<T : Any> : SimpleRequest<T> {
|
||||
sealed interface MyCommandsRequest<T : Any> : SimpleRequest<T>, WithOptionalLanguageCode {
|
||||
val scope: BotCommandScope
|
||||
val languageCode: String?
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package dev.inmo.tgbotapi.requests.bot
|
||||
|
||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
||||
import dev.inmo.tgbotapi.types.commands.*
|
||||
import dev.inmo.tgbotapi.types.languageCodeField
|
||||
import dev.inmo.tgbotapi.types.scopeField
|
||||
@@ -12,11 +14,20 @@ data class DeleteMyCommands(
|
||||
@Serializable(BotCommandScopeSerializer::class)
|
||||
override val scope: BotCommandScope = BotCommandScopeDefault,
|
||||
@SerialName(languageCodeField)
|
||||
override val languageCode: String? = null
|
||||
@Serializable(IetfLanguageCodeSerializer::class)
|
||||
override val ietfLanguageCode: IetfLanguageCode? = null
|
||||
) : MyCommandsRequest<Boolean> {
|
||||
override fun method(): String = "deleteMyCommands"
|
||||
override val requestSerializer: SerializationStrategy<DeleteMyCommands> = serializer()
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean> = Boolean.serializer()
|
||||
|
||||
constructor(
|
||||
scope: BotCommandScope = BotCommandScopeDefault,
|
||||
languageCode: String?
|
||||
) : this(
|
||||
scope,
|
||||
languageCode ?.let(::IetfLanguageCode)
|
||||
)
|
||||
|
||||
companion object : MyCommandsRequest<Boolean> by DeleteMyCommands()
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package dev.inmo.tgbotapi.requests.bot
|
||||
|
||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.commands.*
|
||||
import kotlinx.serialization.*
|
||||
@@ -13,7 +15,8 @@ data class GetMyCommands(
|
||||
@Serializable(BotCommandScopeSerializer::class)
|
||||
override val scope: BotCommandScope = BotCommandScopeDefault,
|
||||
@SerialName(languageCodeField)
|
||||
override val languageCode: String? = null
|
||||
@Serializable(IetfLanguageCodeSerializer::class)
|
||||
override val ietfLanguageCode: IetfLanguageCode? = null
|
||||
) : MyCommandsRequest<List<BotCommand>> {
|
||||
override fun method(): String = "getMyCommands"
|
||||
override val resultDeserializer: DeserializationStrategy<List<BotCommand>>
|
||||
@@ -21,5 +24,13 @@ data class GetMyCommands(
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
|
||||
constructor(
|
||||
scope: BotCommandScope = BotCommandScopeDefault,
|
||||
languageCode: String?
|
||||
) : this(
|
||||
scope,
|
||||
languageCode ?.let(::IetfLanguageCode)
|
||||
)
|
||||
|
||||
companion object : MyCommandsRequest<List<BotCommand>> by GetMyCommands()
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package dev.inmo.tgbotapi.requests.bot
|
||||
|
||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.commands.*
|
||||
import kotlinx.serialization.*
|
||||
@@ -13,7 +15,8 @@ class SetMyCommands(
|
||||
@Serializable(BotCommandScopeSerializer::class)
|
||||
override val scope: BotCommandScope = BotCommandScopeDefault,
|
||||
@SerialName(languageCodeField)
|
||||
override val languageCode: String? = null
|
||||
@Serializable(IetfLanguageCodeSerializer::class)
|
||||
override val ietfLanguageCode: IetfLanguageCode? = null
|
||||
) : MyCommandsRequest<Boolean> {
|
||||
override fun method(): String = "setMyCommands"
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
@@ -21,6 +24,16 @@ class SetMyCommands(
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
|
||||
constructor(
|
||||
commands: List<BotCommand>,
|
||||
scope: BotCommandScope = BotCommandScopeDefault,
|
||||
languageCode: String?
|
||||
) : this(
|
||||
commands,
|
||||
scope,
|
||||
languageCode ?.let(::IetfLanguageCode)
|
||||
)
|
||||
|
||||
init {
|
||||
if (commands.size !in botCommandsLimit) {
|
||||
error("Bot commands list size able to be in range $botCommandsLimit, but incoming size is ${commands.size}")
|
||||
|
||||
@@ -5,12 +5,12 @@ import dev.inmo.tgbotapi.requests.edit.media.MediaContentMessageResultDeserializ
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import kotlinx.serialization.*
|
||||
|
||||
const val editMessageCaptionMethod = "editMessageCaption"
|
||||
|
||||
@@ -4,10 +4,10 @@ import dev.inmo.tgbotapi.requests.edit.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import kotlinx.serialization.*
|
||||
|
||||
fun EditInlineMessageCaption(
|
||||
|
||||
@@ -5,12 +5,12 @@ import dev.inmo.tgbotapi.requests.send.TextContentMessageResultDeserializer
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import kotlinx.serialization.*
|
||||
|
||||
const val editMessageTextMethod = "editMessageText"
|
||||
|
||||
@@ -4,10 +4,10 @@ import dev.inmo.tgbotapi.requests.edit.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import kotlinx.serialization.*
|
||||
|
||||
fun EditInlineMessageText(
|
||||
|
||||
@@ -7,10 +7,10 @@ import dev.inmo.tgbotapi.requests.send.abstracts.ReplyingMarkupSendMessageReques
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import kotlinx.serialization.*
|
||||
|
||||
fun CopyMessage(
|
||||
|
||||
@@ -5,13 +5,13 @@ import dev.inmo.tgbotapi.requests.send.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||
import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.utils.throwRangeError
|
||||
import kotlinx.serialization.*
|
||||
|
||||
|
||||
@@ -6,13 +6,13 @@ import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||
import dev.inmo.tgbotapi.types.message.content.media.AnimationContent
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.utils.mapOfNotNull
|
||||
import dev.inmo.tgbotapi.utils.throwRangeError
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@@ -7,13 +7,13 @@ import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||
import dev.inmo.tgbotapi.types.message.content.media.AudioContent
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.utils.mapOfNotNull
|
||||
import dev.inmo.tgbotapi.utils.throwRangeError
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@@ -6,13 +6,13 @@ import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||
import dev.inmo.tgbotapi.types.message.content.media.DocumentContent
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.utils.mapOfNotNull
|
||||
import dev.inmo.tgbotapi.utils.throwRangeError
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@@ -6,13 +6,13 @@ import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||
import dev.inmo.tgbotapi.types.message.content.media.PhotoContent
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.utils.throwRangeError
|
||||
import kotlinx.serialization.*
|
||||
|
||||
|
||||
@@ -6,13 +6,13 @@ import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||
import dev.inmo.tgbotapi.types.message.content.media.VideoContent
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.utils.mapOfNotNull
|
||||
import dev.inmo.tgbotapi.utils.throwRangeError
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@@ -6,13 +6,13 @@ import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||
import dev.inmo.tgbotapi.types.message.content.media.VoiceContent
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.utils.mapOfNotNull
|
||||
import dev.inmo.tgbotapi.utils.throwRangeError
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@@ -7,13 +7,13 @@ import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||
import dev.inmo.tgbotapi.types.message.content.PollContent
|
||||
import dev.inmo.tgbotapi.types.polls.*
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import kotlinx.serialization.*
|
||||
|
||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<PollContent>> = TelegramBotAPIMessageDeserializationStrategyClass()
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.FromUser
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.InlineMessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.InlineQueryIdentifier
|
||||
|
||||
sealed interface ChosenInlineResult : FromUser {
|
||||
val resultId: InlineQueryIdentifier //chosen temporary, can be changed
|
||||
|
||||
@@ -7,10 +7,10 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.files.abstracts.mimeTypeField
|
||||
import dev.inmo.tgbotapi.utils.MimeType
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.utils.MimeType
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.utils.MimeType
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.files.abstracts.mimeTypeField
|
||||
import dev.inmo.tgbotapi.utils.MimeType
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@ import dev.inmo.tgbotapi.CommonAbstracts.types.DisableWebPagePreview
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ import dev.inmo.tgbotapi.requests.abstracts.fileIdToSend
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@ import dev.inmo.tgbotapi.requests.abstracts.fileIdToSend
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.files.AudioFile
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import kotlinx.serialization.*
|
||||
|
||||
internal const val audioInputMediaType = "audio"
|
||||
|
||||
@@ -4,10 +4,10 @@ import dev.inmo.tgbotapi.requests.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.files.DocumentFile
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import kotlinx.serialization.*
|
||||
|
||||
internal const val documentInputMediaType = "document"
|
||||
|
||||
@@ -5,10 +5,10 @@ import dev.inmo.tgbotapi.requests.abstracts.fileIdToSend
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.files.PhotoSize
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import kotlinx.serialization.*
|
||||
|
||||
internal const val photoInputMediaType = "photo"
|
||||
|
||||
@@ -5,9 +5,9 @@ import dev.inmo.tgbotapi.requests.abstracts.fileIdToSend
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import kotlinx.serialization.*
|
||||
|
||||
internal const val videoInputMediaType = "video"
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package dev.inmo.tgbotapi.types
|
||||
|
||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
||||
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.PrivateChat
|
||||
import dev.inmo.tgbotapi.types.chat.extended.ExtendedPrivateChatImpl
|
||||
import dev.inmo.tgbotapi.utils.*
|
||||
@@ -22,8 +25,17 @@ data class CommonUser(
|
||||
@SerialName(usernameField)
|
||||
override val username: Username? = null,
|
||||
@SerialName(languageCodeField)
|
||||
val languageCode: String? = null
|
||||
) : User()
|
||||
@Serializable(IetfLanguageCodeSerializer::class)
|
||||
override val ietfLanguageCode: IetfLanguageCode? = null
|
||||
) : User(), WithOptionalLanguageCode {
|
||||
constructor(
|
||||
id: UserId,
|
||||
firstName: String,
|
||||
lastName: String = "",
|
||||
username: Username? = null,
|
||||
languageCode: String
|
||||
) : this(id, firstName, lastName, username, IetfLanguageCode(languageCode))
|
||||
}
|
||||
|
||||
@PreviewFeature
|
||||
typealias ExtendedUser = ExtendedPrivateChatImpl
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package dev.inmo.tgbotapi.types.abstracts
|
||||
|
||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
||||
|
||||
interface WithOptionalLanguageCode {
|
||||
val ietfLanguageCode: IetfLanguageCode?
|
||||
|
||||
val languageCode: String?
|
||||
get() = ietfLanguageCode ?.code
|
||||
}
|
||||
|
||||
@@ -5,8 +5,7 @@ import dev.inmo.tgbotapi.types.FileUniqueId
|
||||
import dev.inmo.tgbotapi.types.fileUniqueIdField
|
||||
import dev.inmo.tgbotapi.types.files.abstracts.*
|
||||
import dev.inmo.tgbotapi.utils.*
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
data class PathedFile(
|
||||
@@ -18,8 +17,14 @@ data class PathedFile(
|
||||
val filePath: String,
|
||||
@SerialName(fileSizeField)
|
||||
override val fileSize: Long? = null
|
||||
): TelegramMediaFile
|
||||
): TelegramMediaFile {
|
||||
@Transient
|
||||
val fileName: FileName by lazy(LazyThreadSafetyMode.PUBLICATION) {
|
||||
filePath.filenameFromUrl
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("Use fileName property instead", ReplaceWith("fileName"))
|
||||
val PathedFile.filename: FileName
|
||||
get() = filePath.filenameFromUrl
|
||||
fun TelegramAPIUrlsKeeper.resolveFileURL(file: PathedFile): String = "$fileBaseUrl/${file.filePath}"
|
||||
|
||||
@@ -14,24 +14,79 @@ interface FlowsUpdatesFilter : UpdatesFilter {
|
||||
val allUpdatesFlow: Flow<Update>
|
||||
val allUpdatesWithoutMediaGroupsGroupingFlow: Flow<Update>
|
||||
|
||||
val messagesFlow: Flow<MessageUpdate>
|
||||
val messageMediaGroupsFlow: Flow<MessageMediaGroupUpdate>
|
||||
val editedMessagesFlow: Flow<EditMessageUpdate>
|
||||
val editedMessageMediaGroupsFlow: Flow<EditMessageMediaGroupUpdate>
|
||||
val channelPostsFlow: Flow<ChannelPostUpdate>
|
||||
val channelPostMediaGroupsFlow: Flow<ChannelPostMediaGroupUpdate>
|
||||
val editedChannelPostsFlow: Flow<EditChannelPostUpdate>
|
||||
val editedChannelPostMediaGroupsFlow: Flow<EditChannelPostMediaGroupUpdate>
|
||||
val chosenInlineResultsFlow: Flow<ChosenInlineResultUpdate>
|
||||
val inlineQueriesFlow: Flow<InlineQueryUpdate>
|
||||
val callbackQueriesFlow: Flow<CallbackQueryUpdate>
|
||||
val shippingQueriesFlow: Flow<ShippingQueryUpdate>
|
||||
val preCheckoutQueriesFlow: Flow<PreCheckoutQueryUpdate>
|
||||
val pollsFlow: Flow<PollUpdate>
|
||||
val pollAnswersFlow: Flow<PollAnswerUpdate>
|
||||
val chatMemberUpdatesFlow: Flow<CommonChatMemberUpdatedUpdate>
|
||||
val myChatMemberUpdatesFlow: Flow<MyChatMemberUpdatedUpdate>
|
||||
val unknownUpdatesFlow: Flow<UnknownUpdate>
|
||||
|
||||
@Deprecated("Renamed", ReplaceWith("messagesFlow"))
|
||||
val messageFlow: Flow<MessageUpdate>
|
||||
get() = messagesFlow
|
||||
@Deprecated("Renamed", ReplaceWith("messageMediaGroupsFlow"))
|
||||
val messageMediaGroupFlow: Flow<MessageMediaGroupUpdate>
|
||||
get() = messageMediaGroupsFlow
|
||||
@Deprecated("Renamed", ReplaceWith("editedMessagesFlow"))
|
||||
val editedMessageFlow: Flow<EditMessageUpdate>
|
||||
get() = editedMessagesFlow
|
||||
@Deprecated("Renamed", ReplaceWith("editedMessageMediaGroupsFlow"))
|
||||
val editedMessageMediaGroupFlow: Flow<EditMessageMediaGroupUpdate>
|
||||
get() = editedMessageMediaGroupsFlow
|
||||
@Deprecated("Renamed", ReplaceWith("channelPostsFlow"))
|
||||
val channelPostFlow: Flow<ChannelPostUpdate>
|
||||
get() = channelPostsFlow
|
||||
@Deprecated("Renamed", ReplaceWith("channelPostMediaGroupsFlow"))
|
||||
val channelPostMediaGroupFlow: Flow<ChannelPostMediaGroupUpdate>
|
||||
get() = channelPostMediaGroupsFlow
|
||||
@Deprecated("Renamed", ReplaceWith("editedChannelPostsFlow"))
|
||||
val editedChannelPostFlow: Flow<EditChannelPostUpdate>
|
||||
get() = editedChannelPostsFlow
|
||||
@Deprecated("Renamed", ReplaceWith("editedChannelPostMediaGroupsFlow"))
|
||||
val editedChannelPostMediaGroupFlow: Flow<EditChannelPostMediaGroupUpdate>
|
||||
get() = editedChannelPostMediaGroupsFlow
|
||||
@Deprecated("Renamed", ReplaceWith("chosenInlineResultsFlow"))
|
||||
val chosenInlineResultFlow: Flow<ChosenInlineResultUpdate>
|
||||
get() = chosenInlineResultsFlow
|
||||
@Deprecated("Renamed", ReplaceWith("inlineQueriesFlow"))
|
||||
val inlineQueryFlow: Flow<InlineQueryUpdate>
|
||||
get() = inlineQueriesFlow
|
||||
@Deprecated("Renamed", ReplaceWith("callbackQueriesFlow"))
|
||||
val callbackQueryFlow: Flow<CallbackQueryUpdate>
|
||||
get() = callbackQueriesFlow
|
||||
@Deprecated("Renamed", ReplaceWith("shippingQueriesFlow"))
|
||||
val shippingQueryFlow: Flow<ShippingQueryUpdate>
|
||||
get() = shippingQueriesFlow
|
||||
@Deprecated("Renamed", ReplaceWith("preCheckoutQueriesFlow"))
|
||||
val preCheckoutQueryFlow: Flow<PreCheckoutQueryUpdate>
|
||||
get() = preCheckoutQueriesFlow
|
||||
@Deprecated("Renamed", ReplaceWith("pollsFlow"))
|
||||
val pollFlow: Flow<PollUpdate>
|
||||
get() = pollsFlow
|
||||
@Deprecated("Renamed", ReplaceWith("pollAnswersFlow"))
|
||||
val pollAnswerFlow: Flow<PollAnswerUpdate>
|
||||
get() = pollAnswersFlow
|
||||
@Deprecated("Renamed", ReplaceWith("chatMemberUpdatesFlow"))
|
||||
val chatMemberUpdatedFlow: Flow<CommonChatMemberUpdatedUpdate>
|
||||
get() = chatMemberUpdatesFlow
|
||||
@Deprecated("Renamed", ReplaceWith("myChatMemberUpdatesFlow"))
|
||||
val myChatMemberUpdatedFlow: Flow<MyChatMemberUpdatedUpdate>
|
||||
get() = myChatMemberUpdatesFlow
|
||||
@Deprecated("Renamed", ReplaceWith("unknownUpdatesFlow"))
|
||||
val unknownUpdateTypeFlow: Flow<UnknownUpdate>
|
||||
get() = unknownUpdatesFlow
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,22 +118,22 @@ class DefaultFlowsUpdatesFilter(
|
||||
updatesSharedFlow.emit(it)
|
||||
}
|
||||
|
||||
override val messageFlow: Flow<MessageUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val messageMediaGroupFlow: Flow<MessageMediaGroupUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val editedMessageFlow: Flow<EditMessageUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val editedMessageMediaGroupFlow: Flow<EditMessageMediaGroupUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val channelPostFlow: Flow<ChannelPostUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val channelPostMediaGroupFlow: Flow<ChannelPostMediaGroupUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val editedChannelPostFlow: Flow<EditChannelPostUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val editedChannelPostMediaGroupFlow: Flow<EditChannelPostMediaGroupUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val chosenInlineResultFlow: Flow<ChosenInlineResultUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val inlineQueryFlow: Flow<InlineQueryUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val callbackQueryFlow: Flow<CallbackQueryUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val shippingQueryFlow: Flow<ShippingQueryUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val preCheckoutQueryFlow: Flow<PreCheckoutQueryUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val pollFlow: Flow<PollUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val pollAnswerFlow: Flow<PollAnswerUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val chatMemberUpdatedFlow: Flow<CommonChatMemberUpdatedUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val myChatMemberUpdatedFlow: Flow<MyChatMemberUpdatedUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val unknownUpdateTypeFlow: Flow<UnknownUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val messagesFlow: Flow<MessageUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val messageMediaGroupsFlow: Flow<MessageMediaGroupUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val editedMessagesFlow: Flow<EditMessageUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val editedMessageMediaGroupsFlow: Flow<EditMessageMediaGroupUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val channelPostsFlow: Flow<ChannelPostUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val channelPostMediaGroupsFlow: Flow<ChannelPostMediaGroupUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val editedChannelPostsFlow: Flow<EditChannelPostUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val editedChannelPostMediaGroupsFlow: Flow<EditChannelPostMediaGroupUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val chosenInlineResultsFlow: Flow<ChosenInlineResultUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val inlineQueriesFlow: Flow<InlineQueryUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val callbackQueriesFlow: Flow<CallbackQueryUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val shippingQueriesFlow: Flow<ShippingQueryUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val preCheckoutQueriesFlow: Flow<PreCheckoutQueryUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val pollsFlow: Flow<PollUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val pollAnswersFlow: Flow<PollAnswerUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val chatMemberUpdatesFlow: Flow<CommonChatMemberUpdatedUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val myChatMemberUpdatesFlow: Flow<MyChatMemberUpdatedUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
override val unknownUpdatesFlow: Flow<UnknownUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
}
|
||||
|
||||
@@ -12,9 +12,7 @@ package dev.inmo.tgbotapi.utils
|
||||
AnnotationTarget.PROPERTY_GETTER,
|
||||
AnnotationTarget.PROPERTY_SETTER,
|
||||
AnnotationTarget.FUNCTION,
|
||||
AnnotationTarget.TYPE,
|
||||
AnnotationTarget.TYPEALIAS,
|
||||
AnnotationTarget.TYPE_PARAMETER
|
||||
AnnotationTarget.TYPEALIAS
|
||||
)
|
||||
annotation class PreviewFeature
|
||||
|
||||
@@ -31,8 +29,6 @@ const val lowLevelRiskFeatureMessage = "This method is low-level and not recomme
|
||||
AnnotationTarget.PROPERTY_GETTER,
|
||||
AnnotationTarget.PROPERTY_SETTER,
|
||||
AnnotationTarget.FUNCTION,
|
||||
AnnotationTarget.TYPE,
|
||||
AnnotationTarget.TYPEALIAS,
|
||||
AnnotationTarget.TYPE_PARAMETER
|
||||
AnnotationTarget.TYPEALIAS
|
||||
)
|
||||
annotation class RiskFeature(val message: String = lowLevelRiskFeatureMessage)
|
||||
|
||||
@@ -8,4 +8,11 @@ object BuiltinMimeTypes {
|
||||
object Video {
|
||||
val MP4 = buildMimeType("video/mp4")
|
||||
}
|
||||
object Text {
|
||||
val Html = buildMimeType("text/html")
|
||||
}
|
||||
object Application {
|
||||
val Zip = buildMimeType("application/zip")
|
||||
val Pdf = buildMimeType("application/pdf")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package dev.inmo.tgbotapi.utils
|
||||
|
||||
import dev.inmo.micro_utils.common.ByteArrayAllocatorSerializer
|
||||
import io.ktor.utils.io.ByteReadChannel
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
fun interface ByteReadChannelAllocator {
|
||||
suspend operator fun invoke(): ByteReadChannel
|
||||
}
|
||||
|
||||
object ByteReadChannelAllocatorDeserializationStrategy : DeserializationStrategy<ByteReadChannelAllocator> {
|
||||
override val descriptor: SerialDescriptor = ByteArrayAllocatorSerializer.descriptor
|
||||
|
||||
override fun deserialize(decoder: Decoder): ByteReadChannelAllocator {
|
||||
val byteArrayAllocator = ByteArrayAllocatorSerializer.deserialize(decoder)
|
||||
return ByteReadChannelAllocator { ByteReadChannel(byteArrayAllocator()) }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package dev.inmo.tgbotapi.utils
|
||||
|
||||
import io.ktor.utils.io.ByteReadChannel
|
||||
import io.ktor.utils.io.core.Input
|
||||
|
||||
expect suspend fun ByteReadChannel.asInput(): Input
|
||||
@@ -1,6 +1,7 @@
|
||||
package dev.inmo.tgbotapi.utils
|
||||
|
||||
import com.benasher44.uuid.uuid4
|
||||
import io.ktor.utils.io.*
|
||||
import io.ktor.utils.io.core.ByteReadPacket
|
||||
import io.ktor.utils.io.core.Input
|
||||
import kotlinx.serialization.Serializable
|
||||
@@ -13,9 +14,14 @@ import kotlinx.serialization.Serializable
|
||||
*/
|
||||
@Serializable
|
||||
data class StorageFileInfo(
|
||||
val contentType: String,
|
||||
val fileName: String
|
||||
) {
|
||||
@Deprecated("This constructor is redundant. Use constructor without mime type")
|
||||
constructor(
|
||||
contentType: String,
|
||||
fileName: String
|
||||
): this(fileName)
|
||||
|
||||
/**
|
||||
* This methods is required for random generation of name for keeping warranties about unique file name
|
||||
*/
|
||||
@@ -39,19 +45,55 @@ data class StorageFile(
|
||||
get() = inputSource()
|
||||
}
|
||||
|
||||
@Deprecated("This constructor is redundant. Use constructor without mime type")
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun StorageFile(
|
||||
fileName: String,
|
||||
bytes: ByteArray,
|
||||
mimeType: MimeType
|
||||
) = StorageFile(
|
||||
StorageFileInfo(mimeType.raw, fileName)
|
||||
StorageFileInfo(fileName)
|
||||
) {
|
||||
ByteReadPacket(bytes)
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun StorageFile(
|
||||
fileName: String,
|
||||
bytes: ByteArray
|
||||
) = StorageFile(
|
||||
StorageFileInfo(fileName)
|
||||
) {
|
||||
ByteReadPacket(bytes)
|
||||
}
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
suspend inline fun StorageFile(
|
||||
fileName: String,
|
||||
byteReadChannel: ByteReadChannel
|
||||
) = StorageFile(
|
||||
StorageFileInfo(fileName),
|
||||
byteReadChannel.asInput().let { { it } }
|
||||
)
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE", "unused")
|
||||
inline fun ByteArray.asStorageFile(fileName: String, mimeType: MimeType) = StorageFile(fileName, this, mimeType)
|
||||
inline fun ByteArray.asStorageFile(
|
||||
fileName: String
|
||||
) = StorageFile(fileName, this)
|
||||
|
||||
@Deprecated("This constructor is redundant. Use constructor without mime type")
|
||||
@Suppress("NOTHING_TO_INLINE", "unused")
|
||||
inline fun ByteArray.asStorageFile(
|
||||
fileName: String,
|
||||
mimeType: MimeType
|
||||
) = asStorageFile(fileName)
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE", "unused")
|
||||
suspend inline fun ByteReadChannel.asStorageFile(
|
||||
fileName: String
|
||||
) = StorageFile(fileName, this)
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE", "unused")
|
||||
suspend inline fun ByteReadChannelAllocator.asStorageFile(
|
||||
fileName: String
|
||||
) = this.invoke().asStorageFile(fileName)
|
||||
|
||||
@@ -26,4 +26,6 @@ class TelegramAPIUrlsKeeper(
|
||||
commonAPIUrl = "$correctedHost/bot$token"
|
||||
fileBaseUrl = "$correctedHost/file/bot$token"
|
||||
}
|
||||
|
||||
fun createFileLinkUrl(filePath: String) = "${fileBaseUrl}/$filePath"
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package dev.inmo.tgbotapi.utils.internal
|
||||
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.MultilevelTextSource
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.link
|
||||
import dev.inmo.tgbotapi.utils.extensions.*
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package dev.inmo.tgbotapi.requests.abstracts
|
||||
|
||||
import dev.inmo.micro_utils.common.*
|
||||
import io.ktor.utils.io.ByteReadChannel
|
||||
|
||||
actual suspend fun MPPFile.asMultipartFile(): MultipartFile = ByteReadChannel(bytes()).asMultipartFile(
|
||||
filename.name
|
||||
)
|
||||
@@ -0,0 +1,8 @@
|
||||
package dev.inmo.tgbotapi.utils
|
||||
|
||||
import io.ktor.util.toByteArray
|
||||
import io.ktor.utils.io.ByteReadChannel
|
||||
import io.ktor.utils.io.core.ByteReadPacket
|
||||
import io.ktor.utils.io.core.Input
|
||||
|
||||
actual suspend fun ByteReadChannel.asInput(): Input = ByteReadPacket(toByteArray())
|
||||
@@ -0,0 +1,5 @@
|
||||
package dev.inmo.tgbotapi.requests.abstracts
|
||||
|
||||
import dev.inmo.micro_utils.common.MPPFile
|
||||
|
||||
actual suspend fun MPPFile.asMultipartFile(): MultipartFile = toInputFile()
|
||||
@@ -1,7 +1,8 @@
|
||||
package dev.inmo.tgbotapi.types
|
||||
|
||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
||||
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||
import java.util.*
|
||||
|
||||
fun CommonUser.javaLocale(): Locale? = languageCode ?.let {
|
||||
Locale.forLanguageTag(it)
|
||||
}
|
||||
fun IetfLanguageCode?.javaLocale() = this ?.code ?.let { Locale.forLanguageTag(it) }
|
||||
fun WithOptionalLanguageCode?.javaLocale() = this ?.ietfLanguageCode ?.javaLocale()
|
||||
|
||||
@@ -7,10 +7,7 @@ import java.nio.file.Files
|
||||
fun StorageFile(
|
||||
file: File
|
||||
) = StorageFile(
|
||||
StorageFileInfo(
|
||||
Files.probeContentType(file.toPath()),
|
||||
file.name
|
||||
)
|
||||
StorageFileInfo(file.name)
|
||||
) {
|
||||
file.inputStream().asInput()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package dev.inmo.tgbotapi.utils
|
||||
|
||||
import io.ktor.utils.io.ByteReadChannel
|
||||
import io.ktor.utils.io.core.Input
|
||||
import io.ktor.utils.io.jvm.javaio.toInputStream
|
||||
import io.ktor.utils.io.streams.asInput
|
||||
import kotlinx.coroutines.job
|
||||
import kotlin.coroutines.coroutineContext
|
||||
|
||||
actual suspend fun ByteReadChannel.asInput(): Input = toInputStream(coroutineContext.job).asInput()
|
||||
@@ -1,8 +1,19 @@
|
||||
# TelegramBotAPI extensions
|
||||
|
||||
[ ](https://bintray.com/insanusmokrassar/TelegramBotAPI/tgbotapi.extensions.api/_latestVersion)
|
||||
[](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.api)
|
||||
|
||||
- [TelegramBotAPI extensions](#telegrambotapi-extensions)
|
||||
* [What is it?](#what-is-it)
|
||||
* [Compatibility](#compatibility)
|
||||
* [How to implement library?](#how-to-implement-library)
|
||||
+ [Maven](#maven)
|
||||
+ [Gradle](#gradle)
|
||||
* [Example of usage and comparison with `TelegramBotAPI`](#example-of-usage-and-comparison-with-telegrambotapi)
|
||||
* [Updates](#updates)
|
||||
+ [Alternative way](#alternative-way)
|
||||
|
||||
<small><i><a href='http://ecotrust-canada.github.io/markdown-toc/'>Table of contents generated with markdown-toc</a></i></small>
|
||||
|
||||
## What is it?
|
||||
|
||||
It is wrapper library for [TelegramBotAPI Core](../tgbotapi.core/README.md). Here you can find extensions for
|
||||
|
||||
@@ -1,32 +1,33 @@
|
||||
package dev.inmo.tgbotapi.extensions.api
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.extensions.api.get.getFileAdditionalInfo
|
||||
import dev.inmo.tgbotapi.requests.DownloadFile
|
||||
import dev.inmo.tgbotapi.extensions.api.files.downloadFile
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.types.files.PathedFile
|
||||
import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
|
||||
|
||||
@Deprecated("Replaced", ReplaceWith("downloadFile", "dev.inmo.tgbotapi.extensions.api.files.downloadFile"))
|
||||
suspend fun TelegramBot.downloadFile(
|
||||
filePath: String
|
||||
): ByteArray = execute(
|
||||
DownloadFile(filePath)
|
||||
)
|
||||
): ByteArray = downloadFile(filePath)
|
||||
|
||||
@Deprecated("Replaced", ReplaceWith("downloadFile", "dev.inmo.tgbotapi.extensions.api.files.downloadFile"))
|
||||
suspend fun TelegramBot.downloadFile(
|
||||
pathedFile: PathedFile
|
||||
): ByteArray = execute(
|
||||
DownloadFile(pathedFile.filePath)
|
||||
)
|
||||
): ByteArray = downloadFile(pathedFile)
|
||||
|
||||
@Deprecated("Replaced", ReplaceWith("downloadFile", "dev.inmo.tgbotapi.extensions.api.files.downloadFile"))
|
||||
suspend fun TelegramBot.downloadFile(
|
||||
fileId: FileId
|
||||
): ByteArray = downloadFile(
|
||||
getFileAdditionalInfo(fileId)
|
||||
)
|
||||
): ByteArray = downloadFile(fileId)
|
||||
|
||||
@Deprecated("Replaced", ReplaceWith("downloadFile", "dev.inmo.tgbotapi.extensions.api.files.downloadFile"))
|
||||
suspend fun TelegramBot.downloadFile(
|
||||
file: TelegramMediaFile
|
||||
): ByteArray = downloadFile(
|
||||
getFileAdditionalInfo(file)
|
||||
)
|
||||
): ByteArray = downloadFile(file)
|
||||
|
||||
@Deprecated("Replaced", ReplaceWith("downloadFile", "dev.inmo.tgbotapi.extensions.api.files.downloadFile"))
|
||||
suspend fun TelegramBot.downloadFile(
|
||||
file: MediaContent
|
||||
): ByteArray = downloadFile(file)
|
||||
|
||||
@@ -21,6 +21,10 @@ 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,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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
|
||||
@@ -7,5 +8,10 @@ import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
||||
|
||||
suspend fun TelegramBot.deleteMyCommands(
|
||||
scope: BotCommandScope = BotCommandScopeDefault,
|
||||
languageCode: String? = null
|
||||
languageCode: IetfLanguageCode?
|
||||
) = execute(DeleteMyCommands(scope, languageCode))
|
||||
|
||||
suspend fun TelegramBot.deleteMyCommands(
|
||||
scope: BotCommandScope = BotCommandScopeDefault,
|
||||
languageCode: String? = null
|
||||
) = deleteMyCommands(scope, languageCode ?.let(::IetfLanguageCode))
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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
|
||||
@@ -7,5 +8,10 @@ import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
||||
|
||||
suspend fun TelegramBot.getMyCommands(
|
||||
scope: BotCommandScope = BotCommandScopeDefault,
|
||||
languageCode: String? = null
|
||||
languageCode: IetfLanguageCode? = null
|
||||
) = execute(GetMyCommands(scope, languageCode))
|
||||
|
||||
suspend fun TelegramBot.getMyCommands(
|
||||
scope: BotCommandScope = BotCommandScopeDefault,
|
||||
languageCode: String? = null
|
||||
) = getMyCommands(scope, languageCode ?.let(::IetfLanguageCode))
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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
|
||||
@@ -9,9 +10,21 @@ import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
||||
suspend fun TelegramBot.setMyCommands(
|
||||
commands: List<BotCommand>,
|
||||
scope: BotCommandScope = BotCommandScopeDefault,
|
||||
languageCode: String? = null
|
||||
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,
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
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.DownloadFile
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.types.files.PathedFile
|
||||
import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
|
||||
|
||||
suspend fun TelegramBot.downloadFile(
|
||||
filePath: String
|
||||
): ByteArray = execute(
|
||||
DownloadFile(filePath)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.downloadFile(
|
||||
pathedFile: PathedFile
|
||||
): ByteArray = downloadFile(
|
||||
pathedFile.filePath
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.downloadFile(
|
||||
fileId: FileId
|
||||
): ByteArray = downloadFile(
|
||||
getFileAdditionalInfo(fileId)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.downloadFile(
|
||||
file: TelegramMediaFile
|
||||
): ByteArray = downloadFile(
|
||||
getFileAdditionalInfo(file)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.downloadFile(
|
||||
file: MediaContent
|
||||
): ByteArray = downloadFile(
|
||||
getFileAdditionalInfo(file.media)
|
||||
)
|
||||
@@ -0,0 +1,29 @@
|
||||
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.abstracts.TelegramMediaFile
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.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))
|
||||
@@ -0,0 +1,29 @@
|
||||
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.abstracts.TelegramMediaFile
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.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))
|
||||
@@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.requests.get.GetFile
|
||||
import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
|
||||
|
||||
suspend fun TelegramBot.getFileAdditionalInfo(
|
||||
fileId: FileId
|
||||
@@ -14,3 +15,7 @@ suspend fun TelegramBot.getFileAdditionalInfo(
|
||||
suspend fun TelegramBot.getFileAdditionalInfo(
|
||||
file: TelegramMediaFile
|
||||
) = getFileAdditionalInfo(file.fileId)
|
||||
|
||||
suspend fun TelegramBot.getFileAdditionalInfo(
|
||||
content: MediaContent
|
||||
) = getFileAdditionalInfo(content.media)
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.send
|
||||
|
||||
import dev.inmo.micro_utils.coroutines.safely
|
||||
import dev.inmo.micro_utils.coroutines.safelyWithoutExceptions
|
||||
import dev.inmo.micro_utils.coroutines.*
|
||||
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.abstracts.Chat
|
||||
import kotlinx.coroutines.*
|
||||
import kotlin.coroutines.coroutineContext
|
||||
|
||||
private const val refreshTime: MilliSeconds = (botActionActualityTime - 1) * 1000L
|
||||
typealias TelegramBotActionCallback<T> = suspend TelegramBot.() -> T
|
||||
@@ -16,8 +16,7 @@ suspend fun <T> TelegramBot.withAction(
|
||||
actionRequest: SendAction,
|
||||
block: TelegramBotActionCallback<T>
|
||||
): T {
|
||||
val botActionJob = supervisorScope {
|
||||
launch {
|
||||
val botActionJob = CoroutineScope(coroutineContext).launch {
|
||||
while (isActive) {
|
||||
delay(refreshTime)
|
||||
safelyWithoutExceptions {
|
||||
@@ -25,12 +24,9 @@ suspend fun <T> TelegramBot.withAction(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return try {
|
||||
safely { block() }
|
||||
} finally {
|
||||
val result = safelyWithResult { block() }
|
||||
botActionJob.cancel()
|
||||
}
|
||||
return result.getOrThrow()
|
||||
}
|
||||
|
||||
suspend fun <T> TelegramBot.withAction(
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
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.abstracts.TelegramMediaFile
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.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,5 +1,16 @@
|
||||
# TelegramBotAPI Behaviour Builder Extensions
|
||||
|
||||
[](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.behaviour_builder)
|
||||
|
||||
- [TelegramBotAPI Behaviour Builder Extensions](#telegrambotapi-behaviour-builder-extensions)
|
||||
* [What is it?](#what-is-it)
|
||||
* [Triggers](#triggers)
|
||||
* [Waiters](#waiters)
|
||||
|
||||
<small><i><a href='http://ecotrust-canada.github.io/markdown-toc/'>Table of contents generated with markdown-toc</a></i></small>
|
||||
|
||||
## What is it?
|
||||
|
||||
This extension was created to make it more simple to build bot steps handling. Usually, you must use something like:
|
||||
|
||||
```kotlin
|
||||
|
||||
@@ -10,6 +10,42 @@ import dev.inmo.tgbotapi.utils.PreviewFeature
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.plus
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
@PreviewFeature
|
||||
@Deprecated("Parameters has been reordered. Replace scope and flowUpdatesFilter for correct order")
|
||||
suspend fun TelegramBot.buildBehaviour(
|
||||
scope: CoroutineScope,
|
||||
flowUpdatesFilter: FlowsUpdatesFilter,
|
||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||
block: BehaviourContextReceiver<Unit>
|
||||
) {
|
||||
BehaviourContext(
|
||||
this,
|
||||
scope.let {
|
||||
if (defaultExceptionsHandler == null) {
|
||||
it
|
||||
} else {
|
||||
it + ContextSafelyExceptionHandler(defaultExceptionsHandler)
|
||||
}
|
||||
},
|
||||
flowUpdatesFilter
|
||||
).block()
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method in case you wish to make some additional actions with [flowUpdatesFilter].
|
||||
*
|
||||
@@ -21,8 +57,8 @@ import kotlinx.coroutines.plus
|
||||
*/
|
||||
@PreviewFeature
|
||||
suspend fun TelegramBot.buildBehaviour(
|
||||
scope: CoroutineScope,
|
||||
flowUpdatesFilter: FlowsUpdatesFilter,
|
||||
scope: CoroutineScope = defaultCoroutineScopeProvider(),
|
||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||
block: BehaviourContextReceiver<Unit>
|
||||
) {
|
||||
@@ -49,7 +85,7 @@ suspend fun TelegramBot.buildBehaviour(
|
||||
*/
|
||||
@PreviewFeature
|
||||
suspend fun TelegramBot.buildBehaviour(
|
||||
scope: CoroutineScope,
|
||||
scope: CoroutineScope = defaultCoroutineScopeProvider(),
|
||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||
block: BehaviourContextReceiver<Unit>
|
||||
) = FlowsUpdatesFilter().let {
|
||||
|
||||
@@ -10,6 +10,7 @@ import kotlinx.coroutines.flow.filter
|
||||
|
||||
typealias BehaviourContextReceiver<T> = suspend BehaviourContext.() -> T
|
||||
typealias BehaviourContextAndTypeReceiver<T, I> = suspend BehaviourContext.(I) -> T
|
||||
typealias BehaviourContextAndTwoTypesReceiver<T, I1, I2> = suspend BehaviourContext.(I1, I2) -> T
|
||||
|
||||
/**
|
||||
* This class contains all necessary tools for work with bots and especially for [buildBehaviour]
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
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.CallbackQuery.*
|
||||
@@ -14,13 +15,19 @@ private suspend fun <O> BehaviourContext.waitCallbackQueries(
|
||||
count: Int = 1,
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
filter: SimpleFilter<CallbackQuery>? = null,
|
||||
mapper: suspend CallbackQuery.() -> O?
|
||||
): List<O> = expectFlow(
|
||||
initRequest,
|
||||
count,
|
||||
errorFactory
|
||||
) {
|
||||
it.asCallbackQueryUpdate() ?.data ?.mapper().let(::listOfNotNull)
|
||||
val data = it.asCallbackQueryUpdate() ?.data
|
||||
if (data != null && (filter == null || filter(data))) {
|
||||
data.mapper().let(::listOfNotNull)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}.toList().toList()
|
||||
|
||||
|
||||
@@ -28,17 +35,23 @@ private suspend inline fun <reified T : CallbackQuery> BehaviourContext.waitCall
|
||||
count: Int = 1,
|
||||
initRequest: Request<*>? = null,
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||
noinline filter: CallbackQueryMapper<T>? = null
|
||||
noinline filter: SimpleFilter<T>? = null,
|
||||
noinline mapper: CallbackQueryMapper<T>? = null
|
||||
) : List<T> = waitCallbackQueries<T>(
|
||||
count,
|
||||
initRequest,
|
||||
errorFactory
|
||||
errorFactory,
|
||||
filter ?.let {
|
||||
{
|
||||
(it as? T) ?.let { filter(it) } == true
|
||||
}
|
||||
}
|
||||
) {
|
||||
if (this is T) {
|
||||
if (filter == null) {
|
||||
if (mapper == null) {
|
||||
this
|
||||
} else {
|
||||
filter(this)
|
||||
mapper(this)
|
||||
}
|
||||
} else {
|
||||
null
|
||||
@@ -50,53 +63,62 @@ suspend fun BehaviourContext.waitDataCallbackQuery(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: CallbackQueryMapper<DataCallbackQuery>? = null
|
||||
) = waitCallbacks(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<DataCallbackQuery>? = null,
|
||||
mapper: CallbackQueryMapper<DataCallbackQuery>? = null
|
||||
) = waitCallbacks(count, initRequest, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitGameShortNameCallbackQuery(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: CallbackQueryMapper<GameShortNameCallbackQuery>? = null
|
||||
) = waitCallbacks(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<GameShortNameCallbackQuery>? = null,
|
||||
mapper: CallbackQueryMapper<GameShortNameCallbackQuery>? = null
|
||||
) = waitCallbacks(count, initRequest, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitInlineMessageIdCallbackQuery(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: CallbackQueryMapper<InlineMessageIdCallbackQuery>? = null
|
||||
) = waitCallbacks(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<InlineMessageIdCallbackQuery>? = null,
|
||||
mapper: CallbackQueryMapper<InlineMessageIdCallbackQuery>? = null
|
||||
) = waitCallbacks(count, initRequest, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitInlineMessageIdDataCallbackQuery(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: CallbackQueryMapper<InlineMessageIdDataCallbackQuery>? = null
|
||||
) = waitCallbacks(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<InlineMessageIdDataCallbackQuery>? = null,
|
||||
mapper: CallbackQueryMapper<InlineMessageIdDataCallbackQuery>? = null
|
||||
) = waitCallbacks(count, initRequest, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitInlineMessageIdGameShortNameCallbackQuery(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: CallbackQueryMapper<InlineMessageIdGameShortNameCallbackQuery>? = null
|
||||
) = waitCallbacks(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<InlineMessageIdGameShortNameCallbackQuery>? = null,
|
||||
mapper: CallbackQueryMapper<InlineMessageIdGameShortNameCallbackQuery>? = null
|
||||
) = waitCallbacks(count, initRequest, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitMessageCallbackQuery(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: CallbackQueryMapper<MessageCallbackQuery>? = null
|
||||
) = waitCallbacks(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<MessageCallbackQuery>? = null,
|
||||
mapper: CallbackQueryMapper<MessageCallbackQuery>? = null
|
||||
) = waitCallbacks(count, initRequest, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitMessageDataCallbackQuery(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: CallbackQueryMapper<MessageDataCallbackQuery>? = null
|
||||
) = waitCallbacks(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<MessageDataCallbackQuery>? = null,
|
||||
mapper: CallbackQueryMapper<MessageDataCallbackQuery>? = null
|
||||
) = waitCallbacks(count, initRequest, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitMessageGameShortNameCallbackQuery(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: CallbackQueryMapper<MessageGameShortNameCallbackQuery>? = null
|
||||
) = waitCallbacks(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<MessageGameShortNameCallbackQuery>? = null,
|
||||
mapper: CallbackQueryMapper<MessageGameShortNameCallbackQuery>? = null
|
||||
) = waitCallbacks(count, initRequest, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitUnknownCallbackQuery(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: CallbackQueryMapper<UnknownCallbackQueryType>? = null
|
||||
) = waitCallbacks(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<UnknownCallbackQueryType>? = null,
|
||||
mapper: CallbackQueryMapper<UnknownCallbackQueryType>? = null
|
||||
) = waitCallbacks(count, initRequest, errorFactory, filter, mapper)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
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.ChatMemberUpdated
|
||||
import dev.inmo.tgbotapi.types.update.CommonChatMemberUpdatedUpdate
|
||||
@@ -14,29 +15,37 @@ private suspend inline fun <reified T : ChatMemberUpdatedUpdate> BehaviourContex
|
||||
count: Int = 1,
|
||||
initRequest: Request<*>? = null,
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||
noinline filter: SimpleFilter<T>? = null,
|
||||
noinline mapper: ChatMemberUpdatedMapper<ChatMemberUpdated>
|
||||
): List<ChatMemberUpdated> = expectFlow(
|
||||
initRequest,
|
||||
count,
|
||||
errorFactory
|
||||
) {
|
||||
(it as? T) ?.data.let(::listOfNotNull)
|
||||
val casted = (it as? T) ?: return@expectFlow emptyList()
|
||||
if (filter == null || filter(casted)) {
|
||||
casted.data.mapper().let(::listOfNotNull)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}.toList().toList()
|
||||
|
||||
private suspend inline fun <reified T : ChatMemberUpdatedUpdate> BehaviourContext.waitChatMemberUpdatedWithFilter(
|
||||
count: Int = 1,
|
||||
initRequest: Request<*>? = null,
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||
noinline filter: ChatMemberUpdatedMapper<ChatMemberUpdated>? = null
|
||||
noinline filter: SimpleFilter<T>? = null,
|
||||
noinline mapper: ChatMemberUpdatedMapper<ChatMemberUpdated>? = null
|
||||
) : List<ChatMemberUpdated> = waitChatMemberUpdated<T>(
|
||||
count,
|
||||
initRequest,
|
||||
errorFactory
|
||||
errorFactory,
|
||||
filter,
|
||||
) {
|
||||
if (filter == null) {
|
||||
if (mapper == null) {
|
||||
this
|
||||
} else {
|
||||
filter(this)
|
||||
mapper(this)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,19 +53,22 @@ suspend fun BehaviourContext.waitChatMemberUpdated(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: ChatMemberUpdatedMapper<ChatMemberUpdated>? = null
|
||||
) = waitChatMemberUpdatedWithFilter<ChatMemberUpdatedUpdate>(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<ChatMemberUpdatedUpdate>? = null,
|
||||
mapper: ChatMemberUpdatedMapper<ChatMemberUpdated>? = null
|
||||
) = waitChatMemberUpdatedWithFilter<ChatMemberUpdatedUpdate>(count, initRequest, errorFactory, filter, mapper)
|
||||
|
||||
suspend fun BehaviourContext.waitCommonChatMemberUpdated(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: ChatMemberUpdatedMapper<ChatMemberUpdated>? = null
|
||||
) = waitChatMemberUpdatedWithFilter<CommonChatMemberUpdatedUpdate>(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<CommonChatMemberUpdatedUpdate>? = null,
|
||||
mapper: ChatMemberUpdatedMapper<ChatMemberUpdated>? = null
|
||||
) = waitChatMemberUpdatedWithFilter<CommonChatMemberUpdatedUpdate>(count, initRequest, errorFactory, filter, mapper)
|
||||
|
||||
suspend fun BehaviourContext.waitMyChatMemberUpdated(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: ChatMemberUpdatedMapper<ChatMemberUpdated>? = null
|
||||
) = waitChatMemberUpdatedWithFilter<MyChatMemberUpdatedUpdate>(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<MyChatMemberUpdatedUpdate>? = null,
|
||||
mapper: ChatMemberUpdatedMapper<ChatMemberUpdated>? = null
|
||||
) = waitChatMemberUpdatedWithFilter<MyChatMemberUpdatedUpdate>(count, initRequest, errorFactory, filter, mapper)
|
||||
|
||||
@@ -4,13 +4,16 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.micro_utils.coroutines.safelyWithoutExceptions
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.utils.*
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.withContent
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.*
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.message.content.media.*
|
||||
import dev.inmo.tgbotapi.types.message.payments.InvoiceContent
|
||||
import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.SentMediaGroupUpdate
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate
|
||||
import kotlinx.coroutines.flow.toList
|
||||
|
||||
typealias CommonMessageToContentMapper<T> = suspend CommonMessage<T>.() -> T?
|
||||
@@ -20,18 +23,32 @@ private suspend fun <O> BehaviourContext.waitCommonMessage(
|
||||
initRequest: Request<*>? = null,
|
||||
includeMediaGroups: Boolean = true,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
filter: SimpleFilter<CommonMessage<MessageContent>>? = null,
|
||||
mapper: suspend CommonMessage<MessageContent>.() -> O?
|
||||
): List<O> = expectFlow(
|
||||
initRequest,
|
||||
count,
|
||||
errorFactory
|
||||
) {
|
||||
val messages = when (it) {
|
||||
is SentMediaGroupUpdate -> {
|
||||
if (includeMediaGroups) {
|
||||
it.asSentMediaGroupUpdate() ?.data ?.mapNotNull {
|
||||
(it as CommonMessage<MessageContent>).mapper()
|
||||
} ?.let { return@expectFlow it }
|
||||
it.data.map { it as CommonMessage<MessageContent> }
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
is BaseSentMessageUpdate -> listOf(it.data)
|
||||
else -> return@expectFlow emptyList()
|
||||
}
|
||||
messages.mapNotNull { message ->
|
||||
val asCommonMessage = message as CommonMessage<MessageContent>
|
||||
if (filter == null || filter(asCommonMessage)) {
|
||||
asCommonMessage.mapper()
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
it.asBaseSentMessageUpdate() ?.data ?.asCommonMessage() ?.mapper().let(::listOfNotNull)
|
||||
}.toList().toList()
|
||||
|
||||
private suspend inline fun <reified T : MessageContent> BehaviourContext.waitContent(
|
||||
@@ -39,20 +56,26 @@ private suspend inline fun <reified T : MessageContent> BehaviourContext.waitCon
|
||||
initRequest: Request<*>? = null,
|
||||
includeMediaGroups: Boolean = true,
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||
noinline filter: CommonMessageToContentMapper<T>? = null
|
||||
noinline filter: SimpleFilter<CommonMessage<T>>? = null,
|
||||
noinline mapper: CommonMessageToContentMapper<T>? = null
|
||||
) : List<T> = waitCommonMessage<T>(
|
||||
count,
|
||||
initRequest,
|
||||
includeMediaGroups,
|
||||
errorFactory
|
||||
errorFactory,
|
||||
filter ?.let {
|
||||
{
|
||||
it.withContent<T>() ?.let { filter(it) } == true
|
||||
}
|
||||
}
|
||||
) {
|
||||
if (content is T) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val message = (this as CommonMessage<T>)
|
||||
if (filter == null) {
|
||||
if (mapper == null) {
|
||||
message.content
|
||||
} else {
|
||||
safelyWithoutExceptions { filter(message) }
|
||||
safelyWithoutExceptions { mapper(message) }
|
||||
}
|
||||
} else {
|
||||
null
|
||||
@@ -64,140 +87,162 @@ suspend fun BehaviourContext.waitContentMessage(
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = true,
|
||||
filter: CommonMessageToContentMapper<MessageContent>? = null
|
||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter)
|
||||
filter: SimpleFilter<CommonMessage<MessageContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<MessageContent>? = null
|
||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitContact(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: CommonMessageToContentMapper<ContactContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter)
|
||||
filter: SimpleFilter<CommonMessage<ContactContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<ContactContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitDice(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: CommonMessageToContentMapper<DiceContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter)
|
||||
filter: SimpleFilter<CommonMessage<DiceContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<DiceContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitGame(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: CommonMessageToContentMapper<GameContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter)
|
||||
filter: SimpleFilter<CommonMessage<GameContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<GameContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitLocation(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: CommonMessageToContentMapper<LocationContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter)
|
||||
filter: SimpleFilter<CommonMessage<LocationContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<LocationContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitPoll(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: CommonMessageToContentMapper<PollContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter)
|
||||
filter: SimpleFilter<CommonMessage<PollContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<PollContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitText(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: CommonMessageToContentMapper<TextContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter)
|
||||
filter: SimpleFilter<CommonMessage<TextContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<TextContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitVenue(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: CommonMessageToContentMapper<VenueContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter)
|
||||
filter: SimpleFilter<CommonMessage<VenueContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<VenueContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitAudioMediaGroupContent(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = true,
|
||||
filter: CommonMessageToContentMapper<AudioMediaGroupContent>? = null
|
||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter)
|
||||
filter: SimpleFilter<CommonMessage<AudioMediaGroupContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<AudioMediaGroupContent>? = null
|
||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitDocumentMediaGroupContent(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = true,
|
||||
filter: CommonMessageToContentMapper<DocumentMediaGroupContent>? = null
|
||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter)
|
||||
filter: SimpleFilter<CommonMessage<DocumentMediaGroupContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<DocumentMediaGroupContent>? = null
|
||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitMedia(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = false,
|
||||
filter: CommonMessageToContentMapper<MediaContent>? = null
|
||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter)
|
||||
filter: SimpleFilter<CommonMessage<MediaContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<MediaContent>? = null
|
||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitAnyMediaGroupContent(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = true,
|
||||
filter: CommonMessageToContentMapper<MediaGroupContent>? = null
|
||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter)
|
||||
filter: SimpleFilter<CommonMessage<MediaGroupContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<MediaGroupContent>? = null
|
||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitVisualMediaGroupContent(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = true,
|
||||
filter: CommonMessageToContentMapper<VisualMediaGroupContent>? = null
|
||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter)
|
||||
filter: SimpleFilter<CommonMessage<VisualMediaGroupContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<VisualMediaGroupContent>? = null
|
||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitAnimation(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: CommonMessageToContentMapper<AnimationContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter)
|
||||
filter: SimpleFilter<CommonMessage<AnimationContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<AnimationContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitAudio(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = false,
|
||||
filter: CommonMessageToContentMapper<AudioContent>? = null
|
||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter)
|
||||
filter: SimpleFilter<CommonMessage<AudioContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<AudioContent>? = null
|
||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitDocument(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = false,
|
||||
filter: CommonMessageToContentMapper<DocumentContent>? = null
|
||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter)
|
||||
filter: SimpleFilter<CommonMessage<DocumentContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<DocumentContent>? = null
|
||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitPhoto(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = false,
|
||||
filter: CommonMessageToContentMapper<PhotoContent>? = null
|
||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter)
|
||||
filter: SimpleFilter<CommonMessage<PhotoContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<PhotoContent>? = null
|
||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitSticker(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: CommonMessageToContentMapper<StickerContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter)
|
||||
filter: SimpleFilter<CommonMessage<StickerContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<StickerContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitVideo(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
includeMediaGroups: Boolean = false,
|
||||
filter: CommonMessageToContentMapper<VideoContent>? = null
|
||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter)
|
||||
filter: SimpleFilter<CommonMessage<VideoContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<VideoContent>? = null
|
||||
) = waitContent(count, initRequest, includeMediaGroups, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitVideoNote(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: CommonMessageToContentMapper<VideoNoteContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter)
|
||||
filter: SimpleFilter<CommonMessage<VideoNoteContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<VideoNoteContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitVoice(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: CommonMessageToContentMapper<VoiceContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter)
|
||||
filter: SimpleFilter<CommonMessage<VoiceContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<VoiceContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitInvoice(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: CommonMessageToContentMapper<InvoiceContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter)
|
||||
filter: SimpleFilter<CommonMessage<InvoiceContent>>? = null,
|
||||
mapper: CommonMessageToContentMapper<InvoiceContent>? = null
|
||||
) = waitContent(count, initRequest, false, errorFactory, filter, mapper)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
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.asBaseSentMessageUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.asChatEventMessage
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
@@ -18,13 +19,19 @@ private suspend fun <O> BehaviourContext.waitEventMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<ChatEventMessage<ChatEvent>>? = null,
|
||||
mapper: suspend ChatEventMessage<ChatEvent>.() -> O?
|
||||
): List<O> = expectFlow(
|
||||
initRequest,
|
||||
count,
|
||||
errorFactory
|
||||
) {
|
||||
it.asBaseSentMessageUpdate() ?.data ?.asChatEventMessage() ?.mapper().let(::listOfNotNull)
|
||||
val data = it.asBaseSentMessageUpdate() ?.data ?.asChatEventMessage()
|
||||
if (data != null && (filter == null || filter(data))) {
|
||||
data.mapper().let(::listOfNotNull)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}.toList().toList()
|
||||
|
||||
|
||||
@@ -32,19 +39,25 @@ private suspend inline fun <reified T : ChatEvent> BehaviourContext.waitEvents(
|
||||
count: Int = 1,
|
||||
initRequest: Request<*>? = null,
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||
noinline filter: EventMessageToEventMapper<T>? = null
|
||||
noinline filter: SimpleFilter<ChatEventMessage<T>>? = null,
|
||||
noinline mapper: EventMessageToEventMapper<T>? = null
|
||||
) : List<T> = waitEventMessages<T>(
|
||||
initRequest,
|
||||
errorFactory,
|
||||
count
|
||||
count,
|
||||
filter ?.let {
|
||||
{
|
||||
(it.chatEvent as? T) ?.let { filter(it as ChatEventMessage<T>) } == true
|
||||
}
|
||||
}
|
||||
) {
|
||||
if (chatEvent is T) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val message = (this as ChatEventMessage<T>)
|
||||
if (filter == null) {
|
||||
if (mapper == null) {
|
||||
message.chatEvent
|
||||
} else {
|
||||
filter(message)
|
||||
mapper(message)
|
||||
}
|
||||
} else {
|
||||
null
|
||||
@@ -55,124 +68,144 @@ suspend fun BehaviourContext.waitChannelEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: EventMessageToEventMapper<ChannelEvent>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<ChatEventMessage<ChannelEvent>>? = null,
|
||||
mapper: EventMessageToEventMapper<ChannelEvent>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
|
||||
suspend fun BehaviourContext.waitChatEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: EventMessageToEventMapper<ChatEvent>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<ChatEventMessage<ChatEvent>>? = null,
|
||||
mapper: EventMessageToEventMapper<ChatEvent>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
|
||||
suspend fun BehaviourContext.waitVoiceChatEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: EventMessageToEventMapper<VoiceChatEvent>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<ChatEventMessage<VoiceChatEvent>>? = null,
|
||||
mapper: EventMessageToEventMapper<VoiceChatEvent>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitVoiceChatStartedEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: EventMessageToEventMapper<VoiceChatStarted>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<ChatEventMessage<VoiceChatStarted>>? = null,
|
||||
mapper: EventMessageToEventMapper<VoiceChatStarted>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitVoiceChatEndedEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: EventMessageToEventMapper<VoiceChatEnded>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<ChatEventMessage<VoiceChatEnded>>? = null,
|
||||
mapper: EventMessageToEventMapper<VoiceChatEnded>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitVoiceChatParticipantsInvitedEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: EventMessageToEventMapper<VoiceChatParticipantsInvited>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<ChatEventMessage<VoiceChatParticipantsInvited>>? = null,
|
||||
mapper: EventMessageToEventMapper<VoiceChatParticipantsInvited>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
|
||||
suspend fun BehaviourContext.waitMessageAutoDeleteTimerChangedEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: EventMessageToEventMapper<MessageAutoDeleteTimerChanged>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<ChatEventMessage<MessageAutoDeleteTimerChanged>>? = null,
|
||||
mapper: EventMessageToEventMapper<MessageAutoDeleteTimerChanged>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
|
||||
suspend fun BehaviourContext.waitCommonEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: EventMessageToEventMapper<CommonEvent>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<ChatEventMessage<CommonEvent>>? = null,
|
||||
mapper: EventMessageToEventMapper<CommonEvent>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitGroupEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: EventMessageToEventMapper<GroupEvent>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<ChatEventMessage<GroupEvent>>? = null,
|
||||
mapper: EventMessageToEventMapper<GroupEvent>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitSupergroupEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: EventMessageToEventMapper<SupergroupEvent>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<ChatEventMessage<SupergroupEvent>>? = null,
|
||||
mapper: EventMessageToEventMapper<SupergroupEvent>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
|
||||
suspend fun BehaviourContext.waitChannelChatCreatedEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: EventMessageToEventMapper<ChannelChatCreated>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<ChatEventMessage<ChannelChatCreated>>? = null,
|
||||
mapper: EventMessageToEventMapper<ChannelChatCreated>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitDeleteChatPhotoEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: EventMessageToEventMapper<DeleteChatPhoto>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<ChatEventMessage<DeleteChatPhoto>>? = null,
|
||||
mapper: EventMessageToEventMapper<DeleteChatPhoto>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitGroupChatCreatedEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: EventMessageToEventMapper<GroupChatCreated>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<ChatEventMessage<GroupChatCreated>>? = null,
|
||||
mapper: EventMessageToEventMapper<GroupChatCreated>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitLeftChatMemberEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: EventMessageToEventMapper<LeftChatMember>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<ChatEventMessage<LeftChatMember>>? = null,
|
||||
mapper: EventMessageToEventMapper<LeftChatMember>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitNewChatPhotoEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: EventMessageToEventMapper<NewChatPhoto>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<ChatEventMessage<NewChatPhoto>>? = null,
|
||||
mapper: EventMessageToEventMapper<NewChatPhoto>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitNewChatMembersEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: EventMessageToEventMapper<NewChatMembers>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<ChatEventMessage<NewChatMembers>>? = null,
|
||||
mapper: EventMessageToEventMapper<NewChatMembers>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitNewChatTitleEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: EventMessageToEventMapper<NewChatTitle>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<ChatEventMessage<NewChatTitle>>? = null,
|
||||
mapper: EventMessageToEventMapper<NewChatTitle>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitPinnedMessageEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: EventMessageToEventMapper<PinnedMessage>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<ChatEventMessage<PinnedMessage>>? = null,
|
||||
mapper: EventMessageToEventMapper<PinnedMessage>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitProximityAlertTriggeredEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: EventMessageToEventMapper<ProximityAlertTriggered>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<ChatEventMessage<ProximityAlertTriggered>>? = null,
|
||||
mapper: EventMessageToEventMapper<ProximityAlertTriggered>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitSupergroupChatCreatedEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: EventMessageToEventMapper<SupergroupChatCreated>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<ChatEventMessage<SupergroupChatCreated>>? = null,
|
||||
mapper: EventMessageToEventMapper<SupergroupChatCreated>? = null
|
||||
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
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.asInlineQueryUpdate
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.query.*
|
||||
@@ -12,13 +13,19 @@ private suspend fun <O> BehaviourContext.waitInlineQueries(
|
||||
count: Int = 1,
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
filter: SimpleFilter<InlineQuery>? = null,
|
||||
mapper: suspend InlineQuery.() -> O?
|
||||
): List<O> = expectFlow(
|
||||
initRequest,
|
||||
count,
|
||||
errorFactory
|
||||
) {
|
||||
it.asInlineQueryUpdate() ?.data ?.mapper().let(::listOfNotNull)
|
||||
val data = it.asInlineQueryUpdate() ?.data
|
||||
if (data != null && (filter == null || filter(data))) {
|
||||
data.mapper().let(::listOfNotNull)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}.toList().toList()
|
||||
|
||||
|
||||
@@ -26,17 +33,23 @@ private suspend inline fun <reified T : InlineQuery> BehaviourContext.waitInline
|
||||
count: Int = 1,
|
||||
initRequest: Request<*>? = null,
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||
noinline filter: InlineQueryMapper<T>? = null
|
||||
noinline filter: SimpleFilter<T>? = null,
|
||||
noinline mapper: InlineQueryMapper<T>? = null
|
||||
) : List<T> = waitInlineQueries<T>(
|
||||
count,
|
||||
initRequest,
|
||||
errorFactory
|
||||
errorFactory,
|
||||
filter ?.let {
|
||||
{
|
||||
(it as? T) ?.let { casted -> filter(casted) } == true
|
||||
}
|
||||
}
|
||||
) {
|
||||
if (this is T) {
|
||||
if (filter == null) {
|
||||
if (mapper == null) {
|
||||
this
|
||||
} else {
|
||||
filter(this)
|
||||
mapper(this)
|
||||
}
|
||||
} else {
|
||||
null
|
||||
@@ -47,18 +60,21 @@ suspend fun BehaviourContext.waitAnyInlineQuery(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: InlineQueryMapper<InlineQuery>? = null
|
||||
) = waitInlines(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<InlineQuery>? = null,
|
||||
mapper: InlineQueryMapper<InlineQuery>? = null
|
||||
) = waitInlines(count, initRequest, errorFactory, filter, mapper)
|
||||
|
||||
suspend fun BehaviourContext.waitBaseInlineQuery(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: InlineQueryMapper<BaseInlineQuery>? = null
|
||||
) = waitInlines(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<BaseInlineQuery>? = null,
|
||||
mapper: InlineQueryMapper<BaseInlineQuery>? = null
|
||||
) = waitInlines(count, initRequest, errorFactory, filter, mapper)
|
||||
suspend fun BehaviourContext.waitLocationInlineQuery(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: InlineQueryMapper<LocationInlineQuery>? = null
|
||||
) = waitInlines(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<LocationInlineQuery>? = null,
|
||||
mapper: InlineQueryMapper<LocationInlineQuery>? = null
|
||||
) = waitInlines(count, initRequest, errorFactory, filter, mapper)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
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.asMessageUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.asPassportMessage
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
@@ -17,30 +18,38 @@ suspend fun <O> BehaviourContext.waitPassportMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: SimpleFilter<PassportMessage>? = null,
|
||||
mapper: suspend PassportMessage.() -> O?
|
||||
): List<O> = expectFlow(
|
||||
initRequest,
|
||||
count,
|
||||
errorFactory
|
||||
) {
|
||||
it.asMessageUpdate() ?.data ?.asPassportMessage() ?.mapper().let(::listOfNotNull)
|
||||
val data = it.asMessageUpdate() ?.data ?.asPassportMessage() ?: return@expectFlow emptyList()
|
||||
if (filter == null || filter(data)) {
|
||||
data.mapper().let(::listOfNotNull)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}.toList().toList()
|
||||
|
||||
suspend inline fun <reified T : EncryptedPassportElement> BehaviourContext.waitPassportMessagesWith(
|
||||
count: Int = 1,
|
||||
initRequest: Request<*>? = null,
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||
noinline filter: PassportMessageMapper? = null
|
||||
noinline filter: SimpleFilter<PassportMessage>? = null,
|
||||
noinline mapper: PassportMessageMapper? = null
|
||||
) : List<PassportData> = waitPassportMessages(
|
||||
initRequest,
|
||||
errorFactory,
|
||||
count
|
||||
count,
|
||||
filter
|
||||
) {
|
||||
if (passportData.data.any { it is T }) {
|
||||
if (filter == null) {
|
||||
if (mapper == null) {
|
||||
passportData
|
||||
} else {
|
||||
filter(this)
|
||||
mapper(this)
|
||||
}
|
||||
} else {
|
||||
null
|
||||
@@ -51,5 +60,6 @@ suspend fun BehaviourContext.waitAnyPassportMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null },
|
||||
count: Int = 1,
|
||||
filter: PassportMessageMapper? = null
|
||||
) = waitPassportMessagesWith<EncryptedPassportElement>(count, initRequest, errorFactory, filter)
|
||||
filter: SimpleFilter<PassportMessage>? = null,
|
||||
mapper: PassportMessageMapper? = null
|
||||
) = waitPassportMessagesWith<EncryptedPassportElement>(count, initRequest, errorFactory, filter, mapper)
|
||||
|
||||
@@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
||||
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptionsAsync
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.expectFlow
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByUserCallbackQueryMarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.utils.asCallbackQueryUpdate
|
||||
@@ -11,7 +12,7 @@ import dev.inmo.tgbotapi.types.CallbackQuery.*
|
||||
|
||||
internal suspend inline fun <reified T : CallbackQuery> BehaviourContext.onCallbackQuery(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
noinline additionalFilter: (suspend (T) -> Boolean)? = null,
|
||||
noinline additionalFilter: SimpleFilter<T>? = null,
|
||||
markerFactory: MarkerFactory<in T, Any> = ByUserCallbackQueryMarkerFactory,
|
||||
noinline scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, T>
|
||||
) = flowsUpdatesFilter.expectFlow(bot) {
|
||||
@@ -41,56 +42,56 @@ internal suspend inline fun <reified T : CallbackQuery> BehaviourContext.onCallb
|
||||
|
||||
suspend fun BehaviourContext.onDataCallbackQuery(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (DataCallbackQuery) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<DataCallbackQuery>? = null,
|
||||
markerFactory: MarkerFactory<in DataCallbackQuery, Any> = ByUserCallbackQueryMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, DataCallbackQuery>
|
||||
) = onCallbackQuery(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
suspend fun BehaviourContext.onGameShortNameCallbackQuery(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (GameShortNameCallbackQuery) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<GameShortNameCallbackQuery>? = null,
|
||||
markerFactory: MarkerFactory<in GameShortNameCallbackQuery, Any> = ByUserCallbackQueryMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, GameShortNameCallbackQuery>
|
||||
) = onCallbackQuery(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
suspend fun BehaviourContext.onInlineMessageIdCallbackQuery(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (InlineMessageIdCallbackQuery) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<InlineMessageIdCallbackQuery>? = null,
|
||||
markerFactory: MarkerFactory<in InlineMessageIdCallbackQuery, Any> = ByUserCallbackQueryMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, InlineMessageIdCallbackQuery>
|
||||
) = onCallbackQuery(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
suspend fun BehaviourContext.onInlineMessageIdDataCallbackQuery(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (InlineMessageIdDataCallbackQuery) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<InlineMessageIdDataCallbackQuery>? = null,
|
||||
markerFactory: MarkerFactory<in InlineMessageIdDataCallbackQuery, Any> = ByUserCallbackQueryMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, InlineMessageIdDataCallbackQuery>
|
||||
) = onCallbackQuery(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
suspend fun BehaviourContext.onInlineMessageIdGameShortNameCallbackQuery(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (InlineMessageIdGameShortNameCallbackQuery) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<InlineMessageIdGameShortNameCallbackQuery>? = null,
|
||||
markerFactory: MarkerFactory<in InlineMessageIdGameShortNameCallbackQuery, Any> = ByUserCallbackQueryMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, InlineMessageIdGameShortNameCallbackQuery>
|
||||
) = onCallbackQuery(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
suspend fun BehaviourContext.onMessageCallbackQuery(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (MessageCallbackQuery) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<MessageCallbackQuery>? = null,
|
||||
markerFactory: MarkerFactory<in MessageCallbackQuery, Any> = ByUserCallbackQueryMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, MessageCallbackQuery>
|
||||
) = onCallbackQuery(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
suspend fun BehaviourContext.onMessageDataCallbackQuery(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (MessageDataCallbackQuery) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<MessageDataCallbackQuery>? = null,
|
||||
markerFactory: MarkerFactory<in MessageDataCallbackQuery, Any> = ByUserCallbackQueryMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, MessageDataCallbackQuery>
|
||||
) = onCallbackQuery(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
suspend fun BehaviourContext.onMessageGameShortNameCallbackQuery(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (MessageGameShortNameCallbackQuery) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<MessageGameShortNameCallbackQuery>? = null,
|
||||
markerFactory: MarkerFactory<in MessageGameShortNameCallbackQuery, Any> = ByUserCallbackQueryMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, MessageGameShortNameCallbackQuery>
|
||||
) = onCallbackQuery(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
suspend fun BehaviourContext.onUnknownCallbackQueryType(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (UnknownCallbackQueryType) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<UnknownCallbackQueryType>? = null,
|
||||
markerFactory: MarkerFactory<in UnknownCallbackQueryType, Any> = ByUserCallbackQueryMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, UnknownCallbackQueryType>
|
||||
) = onCallbackQuery(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
@@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
||||
import dev.inmo.micro_utils.coroutines.subscribeSafelySkippingExceptionsAsync
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.expectFlow
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatChatMemberUpdatedMarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.utils.extensions.sourceChat
|
||||
@@ -13,7 +14,7 @@ import dev.inmo.tgbotapi.types.update.abstracts.ChatMemberUpdatedUpdate
|
||||
|
||||
internal suspend inline fun <reified U : ChatMemberUpdatedUpdate> BehaviourContext.onChatMemberUpdatedInternal(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
noinline additionalFilter: (suspend (ChatMemberUpdated) -> Boolean)? = null,
|
||||
noinline additionalFilter: SimpleFilter<ChatMemberUpdated>? = null,
|
||||
markerFactory: MarkerFactory<ChatMemberUpdated, Any> = ByChatChatMemberUpdatedMarkerFactory,
|
||||
noinline scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatMemberUpdated>
|
||||
) = flowsUpdatesFilter.expectFlow(bot) {
|
||||
@@ -38,7 +39,7 @@ internal suspend inline fun <reified U : ChatMemberUpdatedUpdate> BehaviourConte
|
||||
|
||||
suspend fun BehaviourContext.onChatMemberUpdated(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (ChatMemberUpdated) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<ChatMemberUpdated>? = null,
|
||||
markerFactory: MarkerFactory<ChatMemberUpdated, Any> = ByChatChatMemberUpdatedMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatMemberUpdated>
|
||||
) = onChatMemberUpdatedInternal<ChatMemberUpdatedUpdate>(
|
||||
@@ -50,7 +51,7 @@ suspend fun BehaviourContext.onChatMemberUpdated(
|
||||
|
||||
suspend fun BehaviourContext.onCommonChatMemberUpdated(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (ChatMemberUpdated) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<ChatMemberUpdated>? = null,
|
||||
markerFactory: MarkerFactory<ChatMemberUpdated, Any> = ByChatChatMemberUpdatedMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatMemberUpdated>
|
||||
) = onChatMemberUpdatedInternal<CommonChatMemberUpdatedUpdate>(
|
||||
@@ -62,7 +63,7 @@ suspend fun BehaviourContext.onCommonChatMemberUpdated(
|
||||
|
||||
suspend fun BehaviourContext.onMyChatMemberUpdated(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (ChatMemberUpdated) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<ChatMemberUpdated>? = null,
|
||||
markerFactory: MarkerFactory<ChatMemberUpdated, Any> = ByChatChatMemberUpdatedMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatMemberUpdated>
|
||||
) = onChatMemberUpdatedInternal<MyChatMemberUpdatedUpdate>(
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTypeReceiver
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatMessageMarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.utils.asBotCommandTextSource
|
||||
import dev.inmo.tgbotapi.extensions.utils.extensions.parseCommandsWithParams
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||
import kotlinx.coroutines.Job
|
||||
@@ -33,6 +33,7 @@ suspend fun BehaviourContext.command(
|
||||
markerFactory,
|
||||
scenarioReceiver
|
||||
)
|
||||
|
||||
suspend fun BehaviourContext.command(
|
||||
command: String,
|
||||
requireOnlyCommandInMessage: Boolean = true,
|
||||
@@ -59,3 +60,53 @@ suspend inline fun BehaviourContext.onCommand(
|
||||
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||
noinline scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, CommonMessage<TextContent>>
|
||||
): Job = onCommand(command.toRegex(), requireOnlyCommandInMessage, includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
suspend fun BehaviourContext.commandWithArgs(
|
||||
commandRegex: Regex,
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: CommonMessageFilter<TextContent>? = null,
|
||||
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTwoTypesReceiver<Unit, CommonMessage<TextContent>, Array<String>>
|
||||
) = command(
|
||||
commandRegex,
|
||||
requireOnlyCommandInMessage = false,
|
||||
includeFilterByChatInBehaviourSubContext = includeFilterByChatInBehaviourSubContext,
|
||||
additionalFilter = additionalFilter,
|
||||
markerFactory = markerFactory
|
||||
) {
|
||||
val args = it.parseCommandsWithParams().let { commandsWithArgs ->
|
||||
val key = commandsWithArgs.keys.firstOrNull { it.matches(commandRegex) } ?: return@let null
|
||||
commandsWithArgs[key]
|
||||
} ?: emptyArray()
|
||||
scenarioReceiver(it, args)
|
||||
}
|
||||
|
||||
suspend fun BehaviourContext.commandWithArgs(
|
||||
command: String,
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: CommonMessageFilter<TextContent>? = null,
|
||||
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTwoTypesReceiver<Unit, CommonMessage<TextContent>, Array<String>>
|
||||
) = commandWithArgs(
|
||||
command.toRegex(),
|
||||
includeFilterByChatInBehaviourSubContext = includeFilterByChatInBehaviourSubContext,
|
||||
additionalFilter = additionalFilter,
|
||||
markerFactory = markerFactory,
|
||||
scenarioReceiver = scenarioReceiver
|
||||
)
|
||||
|
||||
suspend inline fun BehaviourContext.onCommandWithArgs(
|
||||
commandRegex: Regex,
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
noinline additionalFilter: CommonMessageFilter<TextContent>? = null,
|
||||
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||
noinline scenarioReceiver: BehaviourContextAndTwoTypesReceiver<Unit, CommonMessage<TextContent>, Array<String>>
|
||||
): Job = commandWithArgs(commandRegex, includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
suspend inline fun BehaviourContext.onCommandWithArgs(
|
||||
command: String,
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
noinline additionalFilter: CommonMessageFilter<TextContent>? = null,
|
||||
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||
noinline scenarioReceiver: BehaviourContextAndTwoTypesReceiver<Unit, CommonMessage<TextContent>, Array<String>>
|
||||
): Job = onCommandWithArgs(command.toRegex(), includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
@@ -5,6 +5,7 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
||||
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptionsAsync
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.expectFlow
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatMessageMarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.utils.*
|
||||
@@ -17,7 +18,7 @@ import dev.inmo.tgbotapi.types.message.content.media.*
|
||||
import dev.inmo.tgbotapi.types.message.payments.InvoiceContent
|
||||
import dev.inmo.tgbotapi.utils.PreviewFeature
|
||||
|
||||
typealias CommonMessageFilter<T> = (suspend (CommonMessage<T>) -> Boolean)
|
||||
typealias CommonMessageFilter<T> = SimpleFilter<CommonMessage<T>>
|
||||
|
||||
@PreviewFeature
|
||||
internal suspend inline fun <reified T : MessageContent> BehaviourContext.onContent(
|
||||
@@ -123,7 +124,7 @@ suspend fun BehaviourContext.onDocumentMediaGroupContent(
|
||||
suspend fun BehaviourContext.onMediaCollection(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
includeMediaGroups: Boolean = false,
|
||||
additionalFilter: (suspend (CommonMessage<MediaCollectionContent<TelegramMediaFile>>) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<CommonMessage<MediaCollectionContent<TelegramMediaFile>>>? = null,
|
||||
markerFactory: MarkerFactory<in CommonMessage<MediaCollectionContent<TelegramMediaFile>>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, CommonMessage<MediaCollectionContent<TelegramMediaFile>>>
|
||||
) = onContent(includeFilterByChatInBehaviourSubContext, includeMediaGroups, additionalFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
@@ -4,6 +4,7 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
||||
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptionsAsync
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.expectFlow
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatMessageMarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.utils.asBaseSentMessageUpdate
|
||||
@@ -16,7 +17,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage
|
||||
|
||||
internal suspend inline fun <reified T : ChatEvent> BehaviourContext.onEvent(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
noinline additionalFilter: (suspend (ChatEventMessage<T>) -> Boolean)? = null,
|
||||
noinline additionalFilter: SimpleFilter<ChatEventMessage<T>>? = null,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<T>, Any> = ByChatMessageMarkerFactory,
|
||||
noinline scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatEventMessage<T>>
|
||||
) = flowsUpdatesFilter.expectFlow(bot) {
|
||||
@@ -44,122 +45,122 @@ internal suspend inline fun <reified T : ChatEvent> BehaviourContext.onEvent(
|
||||
|
||||
suspend fun BehaviourContext.onChannelEvent(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (ChatEventMessage<ChannelEvent>) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<ChatEventMessage<ChannelEvent>>? = null,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<ChannelEvent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatEventMessage<ChannelEvent>>
|
||||
) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
suspend fun BehaviourContext.onChatEvent(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (ChatEventMessage<ChatEvent>) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<ChatEventMessage<ChatEvent>>? = null,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<ChatEvent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatEventMessage<ChatEvent>>
|
||||
) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
suspend fun BehaviourContext.onVoiceChatEvent(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (ChatEventMessage<VoiceChatEvent>) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<ChatEventMessage<VoiceChatEvent>>? = null,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<VoiceChatEvent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatEventMessage<VoiceChatEvent>>
|
||||
) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
suspend fun BehaviourContext.onVoiceChatStartedEvent(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (ChatEventMessage<VoiceChatStarted>) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<ChatEventMessage<VoiceChatStarted>>? = null,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<VoiceChatStarted>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatEventMessage<VoiceChatStarted>>
|
||||
) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
suspend fun BehaviourContext.onVoiceChatEndedEvent(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (ChatEventMessage<VoiceChatEnded>) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<ChatEventMessage<VoiceChatEnded>>? = null,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<VoiceChatEnded>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatEventMessage<VoiceChatEnded>>
|
||||
) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
suspend fun BehaviourContext.onVoiceChatParticipantsInvitedEvent(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (ChatEventMessage<VoiceChatParticipantsInvited>) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<ChatEventMessage<VoiceChatParticipantsInvited>>? = null,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<VoiceChatParticipantsInvited>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatEventMessage<VoiceChatParticipantsInvited>>
|
||||
) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
suspend fun BehaviourContext.onMessageAutoDeleteTimerChangedEvent(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (ChatEventMessage<MessageAutoDeleteTimerChanged>) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<ChatEventMessage<MessageAutoDeleteTimerChanged>>? = null,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<MessageAutoDeleteTimerChanged>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatEventMessage<MessageAutoDeleteTimerChanged>>
|
||||
) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
suspend fun BehaviourContext.onCommonEvent(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (ChatEventMessage<CommonEvent>) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<ChatEventMessage<CommonEvent>>? = null,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<CommonEvent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatEventMessage<CommonEvent>>
|
||||
) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
suspend fun BehaviourContext.onGroupEvent(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (ChatEventMessage<GroupEvent>) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<ChatEventMessage<GroupEvent>>? = null,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<GroupEvent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatEventMessage<GroupEvent>>
|
||||
) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
suspend fun BehaviourContext.onSupergroupEvent(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (ChatEventMessage<SupergroupEvent>) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<ChatEventMessage<SupergroupEvent>>? = null,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<SupergroupEvent>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatEventMessage<SupergroupEvent>>
|
||||
) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
suspend fun BehaviourContext.onChannelChatCreated(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (ChatEventMessage<ChannelChatCreated>) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<ChatEventMessage<ChannelChatCreated>>? = null,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<ChannelChatCreated>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatEventMessage<ChannelChatCreated>>
|
||||
) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
suspend fun BehaviourContext.onDeleteChatPhoto(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (ChatEventMessage<DeleteChatPhoto>) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<ChatEventMessage<DeleteChatPhoto>>? = null,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<DeleteChatPhoto>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatEventMessage<DeleteChatPhoto>>
|
||||
) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
suspend fun BehaviourContext.onGroupChatCreated(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (ChatEventMessage<GroupChatCreated>) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<ChatEventMessage<GroupChatCreated>>? = null,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<GroupChatCreated>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatEventMessage<GroupChatCreated>>
|
||||
) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
suspend fun BehaviourContext.onLeftChatMember(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (ChatEventMessage<LeftChatMember>) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<ChatEventMessage<LeftChatMember>>? = null,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<LeftChatMember>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatEventMessage<LeftChatMember>>
|
||||
) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
suspend fun BehaviourContext.onNewChatMembers(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (ChatEventMessage<NewChatMembers>) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<ChatEventMessage<NewChatMembers>>? = null,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<NewChatMembers>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatEventMessage<NewChatMembers>>
|
||||
) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
suspend fun BehaviourContext.onNewChatPhoto(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (ChatEventMessage<NewChatPhoto>) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<ChatEventMessage<NewChatPhoto>>? = null,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<NewChatPhoto>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatEventMessage<NewChatPhoto>>
|
||||
) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
suspend fun BehaviourContext.onNewChatTitle(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (ChatEventMessage<NewChatTitle>) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<ChatEventMessage<NewChatTitle>>? = null,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<NewChatTitle>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatEventMessage<NewChatTitle>>
|
||||
) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
suspend fun BehaviourContext.onPinnedMessage(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (ChatEventMessage<PinnedMessage>) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<ChatEventMessage<PinnedMessage>>? = null,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<PinnedMessage>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatEventMessage<PinnedMessage>>
|
||||
) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
suspend fun BehaviourContext.onProximityAlertTriggered(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (ChatEventMessage<ProximityAlertTriggered>) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<ChatEventMessage<ProximityAlertTriggered>>? = null,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<ProximityAlertTriggered>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatEventMessage<ProximityAlertTriggered>>
|
||||
) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
suspend fun BehaviourContext.onSupergroupChatCreated(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (ChatEventMessage<SupergroupChatCreated>) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<ChatEventMessage<SupergroupChatCreated>>? = null,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<SupergroupChatCreated>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatEventMessage<SupergroupChatCreated>>
|
||||
) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
@@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
||||
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptionsAsync
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.expectFlow
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByUserInlineQueryMarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.utils.asInlineQueryUpdate
|
||||
@@ -11,7 +12,7 @@ import dev.inmo.tgbotapi.types.InlineQueries.query.*
|
||||
|
||||
internal suspend inline fun <reified T : InlineQuery> BehaviourContext.onInlineQuery(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
noinline additionalFilter: (suspend (T) -> Boolean)? = null,
|
||||
noinline additionalFilter: SimpleFilter<T>? = null,
|
||||
markerFactory: MarkerFactory<in T, Any> = ByUserInlineQueryMarkerFactory,
|
||||
noinline scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, T>
|
||||
) = flowsUpdatesFilter.expectFlow(bot) {
|
||||
@@ -41,7 +42,7 @@ internal suspend inline fun <reified T : InlineQuery> BehaviourContext.onInlineQ
|
||||
|
||||
suspend fun BehaviourContext.onAnyInlineQuery(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (InlineQuery) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<InlineQuery>? = null,
|
||||
markerFactory: MarkerFactory<in InlineQuery, Any> = ByUserInlineQueryMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, InlineQuery>
|
||||
) = onInlineQuery(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
@@ -49,7 +50,7 @@ suspend fun BehaviourContext.onAnyInlineQuery(
|
||||
|
||||
suspend fun BehaviourContext.onBaseInlineQuery(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (BaseInlineQuery) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<BaseInlineQuery>? = null,
|
||||
markerFactory: MarkerFactory<in BaseInlineQuery, Any> = ByUserInlineQueryMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, BaseInlineQuery>
|
||||
) = onInlineQuery(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
@@ -57,7 +58,7 @@ suspend fun BehaviourContext.onBaseInlineQuery(
|
||||
|
||||
suspend fun BehaviourContext.onLocationInlineQuery(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (LocationInlineQuery) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<LocationInlineQuery>? = null,
|
||||
markerFactory: MarkerFactory<in LocationInlineQuery, Any> = ByUserInlineQueryMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, LocationInlineQuery>
|
||||
) = onInlineQuery(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
@@ -5,6 +5,7 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
||||
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptionsAsync
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.expectFlow
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatMediaGroupMarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.utils.asSentMediaGroupUpdate
|
||||
@@ -19,7 +20,7 @@ import dev.inmo.tgbotapi.utils.PreviewFeature
|
||||
@PreviewFeature
|
||||
internal suspend inline fun <reified T : MediaGroupContent> BehaviourContext.buildMediaGroupTrigger(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
noinline additionalFilter: (suspend (List<MediaGroupMessage<T>>) -> Boolean)? = null,
|
||||
noinline additionalFilter: SimpleFilter<List<MediaGroupMessage<T>>>? = null,
|
||||
markerFactory: MarkerFactory<in List<MediaGroupMessage<T>>, Any> = ByChatMediaGroupMarkerFactory,
|
||||
noinline scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, List<MediaGroupMessage<T>>>
|
||||
) = flowsUpdatesFilter.expectFlow(bot) { update ->
|
||||
@@ -47,43 +48,43 @@ internal suspend inline fun <reified T : MediaGroupContent> BehaviourContext.bui
|
||||
|
||||
suspend fun BehaviourContext.onMediaGroup(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (List<MediaGroupMessage<MediaGroupContent>>) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<List<MediaGroupMessage<MediaGroupContent>>>? = null,
|
||||
markerFactory: MarkerFactory<in List<MediaGroupMessage<MediaGroupContent>>, Any> = ByChatMediaGroupMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, List<MediaGroupMessage<MediaGroupContent>>>
|
||||
) = buildMediaGroupTrigger(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
suspend fun BehaviourContext.onPlaylist(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (List<MediaGroupMessage<AudioMediaGroupContent>>) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<List<MediaGroupMessage<AudioMediaGroupContent>>>? = null,
|
||||
markerFactory: MarkerFactory<in List<MediaGroupMessage<AudioMediaGroupContent>>, Any> = ByChatMediaGroupMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, List<MediaGroupMessage<AudioMediaGroupContent>>>
|
||||
) = buildMediaGroupTrigger(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
suspend fun BehaviourContext.onDocumentsGroup(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (List<MediaGroupMessage<DocumentMediaGroupContent>>) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<List<MediaGroupMessage<DocumentMediaGroupContent>>>? = null,
|
||||
markerFactory: MarkerFactory<in List<MediaGroupMessage<DocumentMediaGroupContent>>, Any> = ByChatMediaGroupMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, List<MediaGroupMessage<DocumentMediaGroupContent>>>
|
||||
) = buildMediaGroupTrigger(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
suspend fun BehaviourContext.onVisualGallery(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (List<MediaGroupMessage<VisualMediaGroupContent>>) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<List<MediaGroupMessage<VisualMediaGroupContent>>>? = null,
|
||||
markerFactory: MarkerFactory<in List<MediaGroupMessage<VisualMediaGroupContent>>, Any> = ByChatMediaGroupMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, List<MediaGroupMessage<VisualMediaGroupContent>>>
|
||||
) = buildMediaGroupTrigger(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
suspend fun BehaviourContext.onVisualMediaGroup(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (List<MediaGroupMessage<VisualMediaGroupContent>>) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<List<MediaGroupMessage<VisualMediaGroupContent>>>? = null,
|
||||
markerFactory: MarkerFactory<in List<MediaGroupMessage<VisualMediaGroupContent>>, Any> = ByChatMediaGroupMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, List<MediaGroupMessage<VisualMediaGroupContent>>>
|
||||
) = onVisualGallery(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
suspend fun BehaviourContext.onPhotoGallery(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (List<MediaGroupMessage<PhotoContent>>) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<List<MediaGroupMessage<PhotoContent>>>? = null,
|
||||
markerFactory: MarkerFactory<in List<MediaGroupMessage<PhotoContent>>, Any> = ByChatMediaGroupMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, List<MediaGroupMessage<PhotoContent>>>
|
||||
) = buildMediaGroupTrigger(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
suspend fun BehaviourContext.onVideoGallery(
|
||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||
additionalFilter: (suspend (List<MediaGroupMessage<VideoContent>>) -> Boolean)? = null,
|
||||
additionalFilter: SimpleFilter<List<MediaGroupMessage<VideoContent>>>? = null,
|
||||
markerFactory: MarkerFactory<in List<MediaGroupMessage<VideoContent>>, Any> = ByChatMediaGroupMarkerFactory,
|
||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, List<MediaGroupMessage<VideoContent>>>
|
||||
) = buildMediaGroupTrigger(includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user