mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-27 20:48:44 +00:00
Merge branch '0.32.0' into klassindex
This commit is contained in:
commit
d3ca4774da
48
CHANGELOG.md
48
CHANGELOG.md
@ -1,5 +1,53 @@
|
||||
# TelegramBotAPI changelog
|
||||
|
||||
## 0.32.0
|
||||
|
||||
**THIS UPDATE CONTAINS BREAKING CHANGES**
|
||||
|
||||
* `Common`:
|
||||
* `Version`:
|
||||
* `MicroUtils`: `0.4.16` -> `0.4.21`
|
||||
* `Core`:
|
||||
* **BREAKING CHANGE** Now `MediaGroupMessage` have a generic type related to `MediaGroupContent`
|
||||
* Methods and types related to `MediaGroupMessage` have been modified according to their meanings
|
||||
* **Important Change** `FlowsUpdatesFilter` now is an interface. Old class has been renamed to
|
||||
`DefaultFlowsUpdatesFilter` and factory method `FlowsUpdatesFilter` has been added
|
||||
* `Behaviour Builder`:
|
||||
* Trigger and expectation extensions for `MessageContent` (`onContentMessage` and `waitContentMessage`)
|
||||
* `onMediaGroup` has been replaced
|
||||
* `waitMediaGroup` has been added
|
||||
* `onVisualMediaGroup` now is just an alternative to `onVisualGallery`
|
||||
* `command` and `onCommand` expectations has been added for commands `String` variant
|
||||
* New extensions `BehaviourContext#oneOf`, `BehaviourContext#parallel` and `Deferred<T>#withAction`
|
||||
|
||||
## 0.31.0
|
||||
|
||||
**THIS UPDATE CONTAINS BREAKING CHANGES**
|
||||
|
||||
* `Common`:
|
||||
* **ALL DEPRECATIONS CREATED SINCE 0.30.0 WERE REMOVED**
|
||||
* `Behaviour Builder`:
|
||||
* Extension `TelegramBot#buildBehaviour` have changed its return value: now it is `Job` instead of
|
||||
`FlowsUpdatesFilter`
|
||||
* `Utils`
|
||||
* New extensions `TelegramBot#longPolling` were added as new recommended way to start getting updates via long
|
||||
polling
|
||||
* Old extensions `RequestsExecutor#startGettingFlowsUpdatesByLongPolling` has been deprecated
|
||||
|
||||
## 0.30.13
|
||||
|
||||
* `Common`:
|
||||
* `Version`:
|
||||
* `MicroUtils`: `0.4.15` -> `0.4.16`
|
||||
* `Core`:
|
||||
* New variable `FlowsUpdatesFilter#allUpdatesWithoutMediaGroupsGroupingFlow` which will contains updates without
|
||||
`SentMediaGroupUpdate`
|
||||
* `Utils`:
|
||||
* Extensions for `ResendableContent` has been added
|
||||
* Extensions for `TextSource` has been added
|
||||
* `Behaviour Builder`:
|
||||
* Project has been created :)
|
||||
|
||||
## 0.30.12
|
||||
|
||||
* `Utils`:
|
||||
|
@ -15,8 +15,9 @@ You can simply use <a href="https://github.com/InsanusMokrassar/TelegramBotAPI-b
|
||||
| -------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| Useful links | [![Chat in Telegram](badges/chat.svg)](https://t.me/InMoTelegramBotAPI) [![Create bot](badges/template.svg)](https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template/generate) [![KDocs](badges/kdocs.svg)](https://tgbotapi.inmo.dev/docs/index.html) [Examples](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/), [Mini tutorial](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) |
|
||||
| TelegramBotAPI Core status | [![Download](https://api.bintray.com/packages/insanusmokrassar/TelegramBotAPI/tgbotapi.core/images/download.svg)](https://bintray.com/insanusmokrassar/TelegramBotAPI/tgbotapi.core/_latestVersion) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.core/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.core) |
|
||||
| TelegramBotAPI Extensions status | [![Download](https://api.bintray.com/packages/insanusmokrassar/TelegramBotAPI/tgbotapi.extensions.api/images/download.svg)](https://bintray.com/insanusmokrassar/TelegramBotAPI/tgbotapi.extensions.api/_latestVersion) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.api/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.api) |
|
||||
| TelegramBotAPI API Extensions status | [![Download](https://api.bintray.com/packages/insanusmokrassar/TelegramBotAPI/tgbotapi.extensions.api/images/download.svg)](https://bintray.com/insanusmokrassar/TelegramBotAPI/tgbotapi.extensions.api/_latestVersion) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.api/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.api) |
|
||||
| TelegramBotAPI Util Extensions status | [![Download](https://api.bintray.com/packages/insanusmokrassar/TelegramBotAPI/tgbotapi.extensions.utils/images/download.svg)](https://bintray.com/insanusmokrassar/TelegramBotAPI/tgbotapi.extensions.utils/_latestVersion) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.utils/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.utils) |
|
||||
| TelegramBotAPI Behaviour Builder Extensions status | [![Download](https://api.bintray.com/packages/insanusmokrassar/TelegramBotAPI/tgbotapi.extensions.behaviour_builder/images/download.svg)](https://bintray.com/insanusmokrassar/TelegramBotAPI/tgbotapi.extensions.behaviour_builder/_latestVersion) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.behaviour_builder/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.behaviour_builder) |
|
||||
| TelegramBotAPI All status | [![Download](https://api.bintray.com/packages/insanusmokrassar/TelegramBotAPI/tgbotapi/images/download.svg)](https://bintray.com/insanusmokrassar/TelegramBotAPI/tgbotapi/_latestVersion) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) |
|
||||
|
||||
**At the time of publication of version `0.28.0` there are errors in serialization plugins like
|
||||
@ -34,6 +35,8 @@ the list of this complex currently next projects:
|
||||
`RequestsExecutor`), which allows to use the core library in more pleasant way
|
||||
* [TelegramBotAPI Util Extensions](tgbotapi.extensions.utils/README.md) - contains extensions for more comfortable
|
||||
work with commands, updates and other different things
|
||||
* [TelegramBotAPI Behaviour Builder Extensions](tgbotapi.extensions.behaviour_builder/README.md) - builder for
|
||||
step-by-step handling of bot behaviour in more comfortable manner
|
||||
* [TelegramBotAPI](tgbotapi/README.md) - concentration of all previously mentioned libraries
|
||||
|
||||
Most part of some specific solves or unuseful
|
||||
@ -88,6 +91,7 @@ kotlin {
|
||||
|
||||
In most cases, the most simple way will be to implement [TelegramBotAPI](tgbotapi/README.md) - it contains
|
||||
all necessary tools for comfort usage of this library. If you want to exclude some libraries, you can implement just
|
||||
[TelegramBotAPI BehaviourBuilder Extensions](tgbotapi.extensions.behaviour_builder/README.md),
|
||||
[TelegramBotAPI API Extensions](tgbotapi.extensions.api/README.md),
|
||||
[TelegramBotAPI Util Extensions](tgbotapi.extensions.utils/README.md) or even
|
||||
[TelegramBotAPI Core](tgbotapi.core/README.md).
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0"?>
|
||||
<minder version="1.11.1">
|
||||
<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"/>
|
||||
@ -14,45 +14,54 @@
|
||||
<style level="9" isset="true" branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="200" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true" connectiondash="dotted" connectionlwidth="2" connectionarrow="fromto" connectionpadding="3" connectionfont="Sans 10" connectiontwidth="100"/>
|
||||
<style level="10" isset="true" branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="200" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true" connectiondash="dotted" connectionlwidth="2" connectionarrow="fromto" connectionpadding="3" connectionfont="Sans 10" connectiontwidth="100"/>
|
||||
</styles>
|
||||
<drawarea x="-320.56697591145837" y="-10.028254191080691" scale="0.75"/>
|
||||
<drawarea x="-950.47548925255796" y="-49.650554065281653" scale="0.5"/>
|
||||
<images/>
|
||||
<nodes>
|
||||
<node id="0" posx="748.88964843749955" posy="119.42341613769531" width="472" height="168" side="top" fold="false" treesize="603" layout="Downwards" group="false">
|
||||
<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="764.88964843749955" posy="135.42341613769531" maxwidth="488.96484375">
|
||||
<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="781.88964843749955" posy="387.42341613769531" width="406" height="145" side="bottom" fold="false" treesize="603" color="#68b723" colorroot="true" layout="Downwards" group="false">
|
||||
<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="797.88964843749955" posy="403.42341613769531" maxwidth="419.451171875">
|
||||
<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="683.38964843749955" posy="632.42341613769531" width="296" height="191" side="bottom" fold="false" treesize="296" color="#68b723" colorroot="true" layout="Downwards" group="false">
|
||||
<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="699.38964843749955" posy="648.42341613769531" maxwidth="295.90315755208337">
|
||||
<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="979.38964843749955" posy="632.42341613769531" width="307" height="168" side="bottom" fold="false" treesize="307" color="#68b723" colorroot="true" layout="Downwards" group="false">
|
||||
<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="995.38964843749955" posy="648.42341613769531" maxwidth="299.252197265625">
|
||||
<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="4" posx="815.52319335937455" posy="948.04447937011719" width="329" height="213" side="top" fold="false" treesize="329" layout="Downwards" group="false">
|
||||
<style branchmargin="100" linktype="curved" linkwidth="5" linkarrow="true" linkdash="solid" nodeborder="bracket" nodewidth="388" nodeborderwidth="3" nodefill="false" nodemargin="11" nodepadding="5" nodefont="Roboto Mono 14" nodemarkup="true"/>
|
||||
<nodename posx="831.52319335937455" posy="964.04447937011719" maxwidth="394.3671875">
|
||||
<text data="tgbotapi Here included all available TelegramBotAPI libraries: * tgbotapi.core * tgbotapi.extensions.api * tgbotapi.extensions.utils">
|
||||
<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)"/>
|
||||
@ -70,6 +79,94 @@
|
||||
<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)"/>
|
||||
@ -102,6 +199,90 @@
|
||||
<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>
|
||||
@ -110,12 +291,17 @@
|
||||
</nodes>
|
||||
<groups/>
|
||||
<connections>
|
||||
<connection from_id="2" to_id="4" drag_x="905.70642089843705" drag_y="891.23394775390625" color="#777777">
|
||||
<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="3" to_id="4" drag_x="1056.456420898437" drag_y="885.48394775390625" color="#777777">
|
||||
<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>
|
||||
|
@ -12,11 +12,11 @@ klock_version=2.0.3
|
||||
uuid_version=0.2.3
|
||||
ktor_version=1.5.0
|
||||
|
||||
micro_utils_version=0.4.15
|
||||
micro_utils_version=0.4.21
|
||||
|
||||
javax_activation_version=1.1.1
|
||||
|
||||
library_group=dev.inmo
|
||||
library_version=0.30.12
|
||||
library_version=0.32.0
|
||||
|
||||
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.7.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-bin.zip
|
||||
|
File diff suppressed because it is too large
Load Diff
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 89 KiB |
@ -8,5 +8,6 @@ pluginManagement {
|
||||
include ":tgbotapi.core"
|
||||
include ":tgbotapi.extensions.api"
|
||||
include ":tgbotapi.extensions.utils"
|
||||
include ":tgbotapi.extensions.behaviour_builder"
|
||||
include ":tgbotapi"
|
||||
include ":docs"
|
||||
|
@ -48,7 +48,10 @@ kotlin {
|
||||
api "com.soywiz.korlibs.klock:klock:$klock_version"
|
||||
api "com.benasher44:uuid:$uuid_version"
|
||||
|
||||
api "dev.inmo:micro_utils.crypto:$micro_utils_version"
|
||||
api "dev.inmo:micro_utils.coroutines:$micro_utils_version"
|
||||
api "dev.inmo:micro_utils.serialization.base64:$micro_utils_version"
|
||||
api "dev.inmo:micro_utils.serialization.encapsulator:$micro_utils_version"
|
||||
|
||||
api "io.ktor:ktor-client-core:$ktor_version"
|
||||
api "com.github.matfax.klassindex:library:4.+"
|
||||
@ -76,7 +79,6 @@ kotlin {
|
||||
implementation kotlin('test-junit')
|
||||
}
|
||||
}
|
||||
|
||||
jsTest {
|
||||
dependencies {
|
||||
implementation kotlin('test-junit')
|
||||
|
@ -1 +1 @@
|
||||
{"bintrayConfig":{"repo":"TelegramBotAPI","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/TelegramBotAPI","autoPublish":true,"overridePublish":true},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API Core","description":"Library for Object-Oriented and type-safe work with Telegram Bot API","url":"https://insanusmokrassar.github.io/TelegramBotAPI","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]}}
|
||||
{"bintrayConfig":{"repo":"TelegramBotAPI","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/TelegramBotAPI","autoPublish":true,"overridePublish":true},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API Core","description":"Library for Object-Oriented and type-safe work with Telegram Bot API","url":"https://insanusmokrassar.github.io/TelegramBotAPI","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","includeGpgSigning":true,"developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]}}
|
@ -1,8 +1,12 @@
|
||||
apply plugin: 'maven-publish'
|
||||
apply plugin: 'signing'
|
||||
|
||||
task javadocsJar(type: Jar) {
|
||||
classifier = 'javadoc'
|
||||
}
|
||||
task sourceJar (type : Jar) {
|
||||
classifier = 'sources'
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
project.publishing.publications.all {
|
||||
@ -10,6 +14,7 @@ afterEvaluate {
|
||||
groupId "${project.group}"
|
||||
if (it.name.contains('kotlinMultiplatform')) {
|
||||
artifactId = "${project.name}"
|
||||
artifact sourceJar
|
||||
} else {
|
||||
artifactId = "${project.name}-$name"
|
||||
}
|
||||
@ -63,3 +68,8 @@ publishing {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
signing {
|
||||
useGpgCmd()
|
||||
publishing.publications.forEach { sign it }
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package dev.inmo.tgbotapi.CommonAbstracts
|
||||
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.utils.internal.fullListOfSubSource
|
||||
|
||||
interface Captioned {
|
||||
val caption: String?
|
||||
@ -13,8 +12,7 @@ interface CaptionedOutput : Captioned {
|
||||
|
||||
interface CaptionedInput : Captioned {
|
||||
/**
|
||||
* Not full list of entities. This list WILL NOT contain [TextPart]s with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource]
|
||||
* @see [CaptionedInput.fullEntitiesList]
|
||||
* Full list of entities. This list WILL contain [TextPart]s with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource]
|
||||
*/
|
||||
val captionEntities: List<TextPart>
|
||||
}
|
||||
@ -25,10 +23,3 @@ interface CaptionedInput : Captioned {
|
||||
*/
|
||||
val CaptionedInput.textSources
|
||||
get() = captionEntities.justTextSources()
|
||||
|
||||
/**
|
||||
* Convert its [CaptionedInput.captionEntities] to list of [dev.inmo.tgbotapi.CommonAbstracts.TextSource]
|
||||
* with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource]
|
||||
*/
|
||||
@Deprecated("Currently list of entities already full. This method is redundant")
|
||||
fun CaptionedInput.fullEntitiesList(): TextSourcesList = caption ?.fullListOfSubSource(captionEntities) ?.map { it.source } ?: emptyList()
|
||||
|
@ -1,7 +1,6 @@
|
||||
package dev.inmo.tgbotapi.CommonAbstracts
|
||||
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.utils.internal.fullListOfSubSource
|
||||
|
||||
interface Explained {
|
||||
val explanation: String?
|
||||
@ -19,8 +18,7 @@ interface ExplainedOutput : ParsableExplainedOutput, EntitiesExplainedOutput
|
||||
|
||||
interface ExplainedInput : Explained {
|
||||
/**
|
||||
* Not full list of entities. This list WILL NOT contain [TextPart]s with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource]
|
||||
* @see [ExplainedInput.fullEntitiesList]
|
||||
* Full list of entities. This list WILL contain [TextPart]s with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource]
|
||||
*/
|
||||
val explanationEntities: List<TextPart>
|
||||
}
|
||||
@ -31,10 +29,3 @@ interface ExplainedInput : Explained {
|
||||
*/
|
||||
val ExplainedInput.textSources
|
||||
get() = explanationEntities.justTextSources()
|
||||
|
||||
/**
|
||||
* Convert its [ExplainedInput.explanationEntities] to list of [dev.inmo.tgbotapi.CommonAbstracts.TextSource]
|
||||
* with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource]
|
||||
*/
|
||||
@Deprecated("Currently list of entities already full. This method is redundant")
|
||||
fun ExplainedInput.fullEntitiesList(): TextSourcesList = explanation ?.fullListOfSubSource(explanationEntities) ?.map { it.source } ?: emptyList()
|
||||
|
@ -8,10 +8,6 @@ import dev.inmo.tgbotapi.types.textLength
|
||||
const val DirectInvocationOfTextSourceConstructor = "It is strongly not recommended to use constructors directly instead of factory methods"
|
||||
|
||||
typealias TextSourcesList = List<TextSource>
|
||||
@Deprecated("All lists of TextSource in public API now are full. So, this typealias is redundant")
|
||||
typealias FullTextSourcesList = List<TextSource>
|
||||
@Deprecated("All lists of TextPart in public API now are full. So, this typealias is redundant")
|
||||
typealias FullTextPartsList = List<TextPart>
|
||||
|
||||
interface TextSource {
|
||||
val markdown: String
|
||||
@ -21,16 +17,6 @@ interface TextSource {
|
||||
|
||||
val asText: String
|
||||
get() = source
|
||||
|
||||
@Deprecated("Rename", ReplaceWith("markdown"))
|
||||
val asMarkdownSource: String
|
||||
get() = markdown
|
||||
@Deprecated("Rename", ReplaceWith("markdownV2"))
|
||||
val asMarkdownV2Source: String
|
||||
get() = markdownV2
|
||||
@Deprecated("Rename", ReplaceWith("html"))
|
||||
val asHtmlSource: String
|
||||
get() = html
|
||||
}
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
@ -43,13 +29,7 @@ inline operator fun TextSource.plus(text: String) = listOf(this, regular(text))
|
||||
inline operator fun List<TextSource>.plus(text: String) = this + regular(text)
|
||||
|
||||
interface MultilevelTextSource : TextSource {
|
||||
@Deprecated("Will be removed in near major release")
|
||||
val textParts: List<TextPart>
|
||||
get() = textParts(0)
|
||||
val subsources: List<TextSource>
|
||||
@Deprecated("Will be removed in near major release", ReplaceWith("subsources"))
|
||||
val textSources: List<TextSource>
|
||||
get() = subsources
|
||||
}
|
||||
|
||||
data class TextPart(
|
||||
|
@ -1,7 +1,6 @@
|
||||
package dev.inmo.tgbotapi.CommonAbstracts
|
||||
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.utils.internal.fullListOfSubSource
|
||||
|
||||
interface Texted {
|
||||
val text: String?
|
||||
@ -19,22 +18,18 @@ interface TextedOutput : ParsableOutput, EntitiesOutput
|
||||
|
||||
interface TextedInput : Texted {
|
||||
/**
|
||||
* Not full list of entities. This list WILL NOT contain [TextPart]s with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource]
|
||||
* @see [CaptionedInput.fullEntitiesList]
|
||||
* Here must be full list of entities. This list must contains [TextPart]s with
|
||||
* [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource] in case if source text contains parts of
|
||||
* regular text
|
||||
*/
|
||||
val textEntities: List<TextPart>
|
||||
}
|
||||
|
||||
/**
|
||||
* Full list of [TextSource] built from source[TextedInput.textEntities]
|
||||
*
|
||||
* @see TextedInput.textEntities
|
||||
* @see justTextSources
|
||||
*/
|
||||
val TextedInput.textSources
|
||||
get() = textEntities.justTextSources()
|
||||
|
||||
/**
|
||||
* Convert its [TextedInput.textEntities] to list of [dev.inmo.tgbotapi.CommonAbstracts.TextSource]
|
||||
* with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource]
|
||||
*/
|
||||
@Deprecated("Currently list of entities already full. This method is redundant")
|
||||
fun TextedInput.fullEntitiesList(): TextSourcesList = text ?.fullListOfSubSource(textEntities) ?.map { it.source } ?: emptyList()
|
||||
|
@ -5,7 +5,8 @@ import dev.inmo.tgbotapi.bot.BaseRequestsExecutor
|
||||
import dev.inmo.tgbotapi.bot.Ktor.base.*
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.bot.exceptions.newRequestException
|
||||
import dev.inmo.tgbotapi.bot.settings.limiters.*
|
||||
import dev.inmo.tgbotapi.bot.settings.limiters.ExceptionsOnlyLimiter
|
||||
import dev.inmo.tgbotapi.bot.settings.limiters.RequestLimiter
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.Response
|
||||
import dev.inmo.tgbotapi.utils.*
|
||||
@ -67,7 +68,7 @@ class KtorRequestsExecutor(
|
||||
return safely(
|
||||
{ e ->
|
||||
throw if (e is ClientRequestException) {
|
||||
val content = e.response ?.readText() ?: throw e
|
||||
val content = e.response.readText()
|
||||
val responseObject = jsonFormatter.decodeFromString(Response.serializer(), content)
|
||||
newRequestException(
|
||||
responseObject,
|
||||
|
@ -6,7 +6,6 @@ import dev.inmo.tgbotapi.bot.exceptions.newRequestException
|
||||
import dev.inmo.tgbotapi.requests.GetUpdates
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.Response
|
||||
import dev.inmo.tgbotapi.types.RetryAfterError
|
||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.call.receive
|
||||
@ -14,7 +13,6 @@ import io.ktor.client.features.timeout
|
||||
import io.ktor.client.request.*
|
||||
import io.ktor.client.statement.HttpResponse
|
||||
import io.ktor.http.ContentType
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlin.collections.set
|
||||
|
||||
|
@ -25,10 +25,9 @@ object MultipartRequestCallFactory : AbstractRequestCallFactory() {
|
||||
Headers.build {
|
||||
append(HttpHeaders.ContentType, value.mimeType)
|
||||
append(HttpHeaders.ContentDisposition, "filename=${value.fileId}")
|
||||
}
|
||||
) {
|
||||
value.file.asInput()
|
||||
}
|
||||
},
|
||||
block = value.file::input
|
||||
)
|
||||
is FileId -> append(key, value.fileId)
|
||||
else -> append(key, value.toString())
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
package dev.inmo.tgbotapi.bot.exceptions
|
||||
|
||||
import com.soywiz.klock.DateTime
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.Response
|
||||
import dev.inmo.tgbotapi.types.RetryAfterError
|
||||
import io.ktor.utils.io.errors.IOException
|
||||
|
||||
fun newRequestException(
|
||||
|
@ -1,15 +1,11 @@
|
||||
package dev.inmo.tgbotapi.bot.settings.limiters
|
||||
|
||||
import com.soywiz.klock.DateTime
|
||||
import dev.inmo.micro_utils.coroutines.*
|
||||
import dev.inmo.tgbotapi.types.MilliSeconds
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.flow.filter
|
||||
import kotlinx.coroutines.sync.Semaphore
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.Transient
|
||||
import kotlin.coroutines.Continuation
|
||||
import kotlin.math.roundToLong
|
||||
|
||||
private fun now(): Long = DateTime.nowUnixLong()
|
||||
|
@ -2,11 +2,13 @@ package dev.inmo.tgbotapi.bot.settings.limiters
|
||||
|
||||
import dev.inmo.micro_utils.coroutines.safely
|
||||
import dev.inmo.tgbotapi.bot.exceptions.TooMuchRequestsException
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.MilliSeconds
|
||||
import dev.inmo.tgbotapi.types.RetryAfterError
|
||||
import io.ktor.client.features.ClientRequestException
|
||||
import io.ktor.http.HttpStatusCode
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.*
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.first
|
||||
|
||||
/**
|
||||
* This limiter will limit requests only after getting a [RetryAfterError] or [ClientRequestException] with
|
||||
@ -60,6 +62,3 @@ class ExceptionsOnlyLimiter(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("Renamed", ReplaceWith("ExceptionsOnlyLimiter", "dev.inmo.tgbotapi.bot.settings.limiters.ExceptionsOnlyLimiter"))
|
||||
typealias EmptyLimiter = ExceptionsOnlyLimiter
|
||||
|
@ -1,9 +1,9 @@
|
||||
package dev.inmo.tgbotapi.bot.settings.limiters
|
||||
|
||||
import dev.inmo.micro_utils.coroutines.*
|
||||
import dev.inmo.micro_utils.coroutines.actor
|
||||
import dev.inmo.micro_utils.coroutines.safely
|
||||
import dev.inmo.tgbotapi.types.MilliSeconds
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.Transient
|
||||
import kotlin.coroutines.*
|
||||
|
@ -0,0 +1,22 @@
|
||||
package dev.inmo.tgbotapi.requests
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.passport.PassportElementError
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Serializable
|
||||
data class SetPassportDataErrors(
|
||||
@SerialName(userIdField)
|
||||
val user: UserId,
|
||||
@SerialName(errorsField)
|
||||
val errors: List<PassportElementError>
|
||||
) : SimpleRequest<Boolean> {
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = Boolean.serializer()
|
||||
override fun method(): String = "setPassportDataErrors"
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
@ -2,10 +2,7 @@ package dev.inmo.tgbotapi.requests.chat.modify
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.types.ChatRequest
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.chatIdField
|
||||
import dev.inmo.tgbotapi.types.messageIdField
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
|
@ -9,8 +9,6 @@ import dev.inmo.tgbotapi.types.MessageEntity.*
|
||||
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 kotlinx.serialization.*
|
||||
|
||||
fun CopyMessage(
|
||||
|
@ -8,6 +8,10 @@ import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.InputMedia.*
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializerClass
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.VisualMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.media.AudioContent
|
||||
import dev.inmo.tgbotapi.types.message.content.media.DocumentContent
|
||||
import dev.inmo.tgbotapi.utils.*
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.builtins.ListSerializer
|
||||
@ -17,13 +21,13 @@ const val rawSendingMediaGroupsWarning = "Media groups contains restrictions rel
|
||||
" types. Currently it is possible to combine photo + video OR audio OR documents"
|
||||
|
||||
@RiskFeature(rawSendingMediaGroupsWarning)
|
||||
fun SendMediaGroup(
|
||||
fun <T : MediaGroupContent> SendMediaGroup(
|
||||
chatId: ChatIdentifier,
|
||||
media: List<MediaGroupMemberInputMedia>,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
): Request<List<MediaGroupMessage>> {
|
||||
): Request<List<MediaGroupMessage<T>>> {
|
||||
if (media.size !in mediaCountInMediaGroup) {
|
||||
throwRangeError("Count of members in media group", mediaCountInMediaGroup, media.size)
|
||||
}
|
||||
@ -47,14 +51,14 @@ fun SendMediaGroup(
|
||||
allowSendingWithoutReply
|
||||
)
|
||||
|
||||
return if (files.isEmpty()) {
|
||||
return (if (files.isEmpty()) {
|
||||
data
|
||||
} else {
|
||||
MultipartRequestImpl(
|
||||
data,
|
||||
SendMediaGroupFiles(files)
|
||||
)
|
||||
}
|
||||
}) as Request<List<MediaGroupMessage<T>>>
|
||||
}
|
||||
|
||||
/**
|
||||
@ -69,7 +73,7 @@ inline fun SendPlaylist(
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) = SendMediaGroup(chatId, media, disableNotification, replyToMessageId, allowSendingWithoutReply)
|
||||
) = SendMediaGroup<AudioContent>(chatId, media, disableNotification, replyToMessageId, allowSendingWithoutReply)
|
||||
|
||||
/**
|
||||
* Use this method to be sure that you are correctly sending documents media group
|
||||
@ -83,7 +87,7 @@ inline fun SendDocumentsGroup(
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) = SendMediaGroup(chatId, media, disableNotification, replyToMessageId, allowSendingWithoutReply)
|
||||
) = SendMediaGroup<DocumentContent>(chatId, media, disableNotification, replyToMessageId, allowSendingWithoutReply)
|
||||
|
||||
/**
|
||||
* Use this method to be sure that you are correctly sending visual media group
|
||||
@ -98,9 +102,9 @@ inline fun SendVisualMediaGroup(
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) = SendMediaGroup(chatId, media, disableNotification, replyToMessageId, allowSendingWithoutReply)
|
||||
) = SendMediaGroup<VisualMediaGroupContent>(chatId, media, disableNotification, replyToMessageId, allowSendingWithoutReply)
|
||||
|
||||
private val messagesListSerializer: KSerializer<List<MediaGroupMessage>>
|
||||
private val messagesListSerializer: KSerializer<List<MediaGroupMessage<MediaGroupContent>>>
|
||||
= ListSerializer(TelegramBotAPIMessageDeserializeOnlySerializerClass())
|
||||
|
||||
@Serializable
|
||||
@ -114,7 +118,7 @@ data class SendMediaGroupData internal constructor(
|
||||
override val replyToMessageId: MessageIdentifier? = null,
|
||||
@SerialName(allowSendingWithoutReplyField)
|
||||
override val allowSendingWithoutReply: Boolean? = null
|
||||
) : DataRequest<List<MediaGroupMessage>>, SendMessageRequest<List<MediaGroupMessage>> {
|
||||
) : DataRequest<List<MediaGroupMessage<MediaGroupContent>>>, SendMessageRequest<List<MediaGroupMessage<MediaGroupContent>>> {
|
||||
@SerialName(mediaField)
|
||||
private val convertedMedia: String
|
||||
get() = buildJsonArray {
|
||||
@ -127,7 +131,7 @@ data class SendMediaGroupData internal constructor(
|
||||
override fun method(): String = "sendMediaGroup"
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
override val resultDeserializer: DeserializationStrategy<List<MediaGroupMessage>>
|
||||
override val resultDeserializer: DeserializationStrategy<List<MediaGroupMessage<MediaGroupContent>>>
|
||||
get() = messagesListSerializer
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ fun Poll.createRequest(
|
||||
correctOptionId,
|
||||
isAnonymous,
|
||||
isClosed,
|
||||
fullEntitiesList(),
|
||||
textSources,
|
||||
scheduledCloseInfo,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
|
@ -1,7 +1,8 @@
|
||||
package dev.inmo.tgbotapi.requests.webhook
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||
import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||
import dev.inmo.tgbotapi.requests.send.media.base.DataRequest
|
||||
import dev.inmo.tgbotapi.requests.send.media.base.MultipartRequestImpl
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
@ -62,12 +62,6 @@ val inlineQueryAnswerResultsLimit = 0 .. 50
|
||||
val customTitleLength = 0 .. 16
|
||||
|
||||
val dartsCubeAndBowlingDiceResultLimit = 1 .. 6
|
||||
@Deprecated("Renamed", ReplaceWith("dartsCubeAndBowlingDiceResultLimit", "dev.inmo.tgbotapi.types.dartsCubeAndBowlingDiceResultLimit"))
|
||||
val dartsAndCubeDiceResultLimit
|
||||
get() = dartsCubeAndBowlingDiceResultLimit
|
||||
@Deprecated("Renamed", ReplaceWith("dartsCubeAndBowlingDiceResultLimit", "dev.inmo.tgbotapi.types.dartsCubeAndBowlingDiceResultLimit"))
|
||||
val diceResultLimit
|
||||
get() = dartsCubeAndBowlingDiceResultLimit
|
||||
val basketballAndFootballDiceResultLimit = 1 .. 5
|
||||
val slotMachineDiceResultLimit = 1 .. 64
|
||||
|
||||
@ -363,3 +357,25 @@ const val forceField = "force"
|
||||
|
||||
const val regularPollType = "regular"
|
||||
const val quizPollType = "quiz"
|
||||
|
||||
const val dataField = "data"
|
||||
const val credentialsField = "credentials"
|
||||
const val hashField = "hash"
|
||||
const val translationField = "translation"
|
||||
const val translationFileField = "translation_file"
|
||||
const val fileField = "file"
|
||||
const val filesField = "files"
|
||||
const val translationFilesField = "translation_files"
|
||||
const val frontSideField = "front_side"
|
||||
const val reverseSideField = "reverse_side"
|
||||
const val selfieField = "selfie"
|
||||
const val secretField = "secret"
|
||||
|
||||
const val errorsField = "errors"
|
||||
const val sourceField = "source"
|
||||
const val fieldNameField = "field_name"
|
||||
const val dataHashField = "data_hash"
|
||||
const val fileHashField = "file_hash"
|
||||
const val fileHashesField = "file_hashes"
|
||||
const val messageField = "message"
|
||||
const val unspecifiedField = "unspecified"
|
||||
|
@ -1,6 +1,5 @@
|
||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.CaptionedOutput
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.WithInputMessageContentInlineQueryResult
|
||||
@ -8,10 +7,5 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.WithInp
|
||||
const val inlineQueryResultAudioType = "audio"
|
||||
|
||||
interface InlineQueryResultAudioCommon : InlineQueryResult,
|
||||
CaptionedOutput,
|
||||
TextedOutput,
|
||||
WithInputMessageContentInlineQueryResult {
|
||||
@Deprecated("Will be removed in next major release")
|
||||
override val caption: String?
|
||||
get() = text
|
||||
}
|
||||
WithInputMessageContentInlineQueryResult
|
||||
|
@ -1,6 +1,5 @@
|
||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.CaptionedOutput
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.*
|
||||
|
||||
@ -9,10 +8,5 @@ const val inlineQueryResultDocumentType = "document"
|
||||
interface InlineQueryResultDocumentCommon : InlineQueryResult,
|
||||
TitledInlineQueryResult,
|
||||
DescribedInlineQueryResult,
|
||||
CaptionedOutput,
|
||||
TextedOutput,
|
||||
WithInputMessageContentInlineQueryResult {
|
||||
@Deprecated("Will be removed in next major release")
|
||||
override val caption: String?
|
||||
get() = text
|
||||
}
|
||||
WithInputMessageContentInlineQueryResult
|
||||
|
@ -1,6 +1,5 @@
|
||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.CaptionedOutput
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.*
|
||||
|
||||
@ -8,10 +7,5 @@ const val inlineQueryResultGifType = "gif"
|
||||
|
||||
interface InlineQueryResultGifCommon : InlineQueryResult,
|
||||
OptionallyTitledInlineQueryResult,
|
||||
CaptionedOutput,
|
||||
TextedOutput,
|
||||
WithInputMessageContentInlineQueryResult {
|
||||
@Deprecated("Will be removed in next major release")
|
||||
override val caption: String?
|
||||
get() = text
|
||||
}
|
||||
WithInputMessageContentInlineQueryResult
|
||||
|
@ -1,6 +1,5 @@
|
||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.CaptionedOutput
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.*
|
||||
|
||||
@ -8,10 +7,5 @@ const val inlineQueryResultMpeg4GifType = "mpeg4_gif"
|
||||
|
||||
interface InlineQueryResultMpeg4GifCommon : InlineQueryResult,
|
||||
OptionallyTitledInlineQueryResult,
|
||||
CaptionedOutput,
|
||||
TextedOutput,
|
||||
WithInputMessageContentInlineQueryResult {
|
||||
@Deprecated("Will be removed in next major release")
|
||||
override val caption: String?
|
||||
get() = text
|
||||
}
|
||||
WithInputMessageContentInlineQueryResult
|
||||
|
@ -1,6 +1,5 @@
|
||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.CaptionedOutput
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.*
|
||||
|
||||
@ -9,10 +8,5 @@ const val inlineQueryResultPhotoType = "photo"
|
||||
interface InlineQueryResultPhotoCommon : InlineQueryResult,
|
||||
OptionallyTitledInlineQueryResult,
|
||||
DescribedInlineQueryResult,
|
||||
CaptionedOutput,
|
||||
TextedOutput,
|
||||
WithInputMessageContentInlineQueryResult {
|
||||
@Deprecated("Will be removed in next major release")
|
||||
override val caption: String?
|
||||
get() = text
|
||||
}
|
||||
WithInputMessageContentInlineQueryResult
|
||||
|
@ -1,6 +1,5 @@
|
||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.CaptionedOutput
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.*
|
||||
|
||||
@ -9,10 +8,5 @@ const val inlineQueryResultVideoType = "video"
|
||||
interface InlineQueryResultVideoCommon : InlineQueryResult,
|
||||
TitledInlineQueryResult,
|
||||
DescribedInlineQueryResult,
|
||||
CaptionedOutput,
|
||||
TextedOutput,
|
||||
WithInputMessageContentInlineQueryResult {
|
||||
@Deprecated("Will be removed in next major release")
|
||||
override val caption: String?
|
||||
get() = text
|
||||
}
|
||||
WithInputMessageContentInlineQueryResult
|
||||
|
@ -1,17 +1,11 @@
|
||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.CaptionedOutput
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.*
|
||||
|
||||
const val inlineQueryResultVoiceType = "voice"
|
||||
|
||||
interface InlineQueryResultVoiceCommon : InlineQueryResult,
|
||||
CaptionedOutput,
|
||||
TextedOutput,
|
||||
WithInputMessageContentInlineQueryResult,
|
||||
TitledInlineQueryResult {
|
||||
@Deprecated("Will be removed in next major release")
|
||||
override val caption: String?
|
||||
get() = text
|
||||
}
|
||||
TitledInlineQueryResult
|
||||
|
@ -37,10 +37,7 @@ data class InputTextMessageContent internal constructor(
|
||||
private val rawEntities: List<RawMessageEntity>? = null,
|
||||
@SerialName(disableWebPagePreviewField)
|
||||
override val disableWebPagePreview: Boolean? = null
|
||||
) : CaptionedOutput, TextedOutput, DisableWebPagePreview, InputMessageContent {
|
||||
@Deprecated("Will be removed in next major release")
|
||||
override val caption: String?
|
||||
get() = text
|
||||
) : TextedOutput, DisableWebPagePreview, InputMessageContent {
|
||||
override val entities: List<TextSource>? by lazy {
|
||||
rawEntities ?.asTextParts(text) ?.justTextSources()
|
||||
}
|
||||
|
@ -3,9 +3,6 @@ package dev.inmo.tgbotapi.types.InputMedia
|
||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Deprecated("Will be removed due to redundancy for end-side users")
|
||||
fun String.toInputMediaFileAttachmentName() = "attach://$this"
|
||||
|
||||
@Serializable(InputMediaSerializer::class)
|
||||
interface InputMedia {
|
||||
val type: String
|
||||
|
@ -42,16 +42,12 @@ data class InputMediaAnimation internal constructor(
|
||||
override val height: Int? = null,
|
||||
override val duration: Long? = null,
|
||||
override val thumb: InputFile? = null
|
||||
) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, TextedOutput, CaptionedOutput {
|
||||
) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, TextedOutput {
|
||||
override val type: String = "animation"
|
||||
override val entities: List<TextSource>? by lazy {
|
||||
rawEntities ?.asTextParts(text ?: return@lazy null) ?.justTextSources()
|
||||
}
|
||||
|
||||
@Deprecated("Will be removed in next major release")
|
||||
override val caption: String?
|
||||
get() = text
|
||||
|
||||
@SerialName(mediaField)
|
||||
override val media: String
|
||||
init { media = file.fileIdToSend } // crutch until js compiling will be fixed
|
||||
|
@ -1,6 +1,5 @@
|
||||
package dev.inmo.tgbotapi.types.InputMedia
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.CaptionedOutput
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.json.Json
|
||||
@ -16,10 +15,7 @@ internal fun <T> T.buildArguments(withSerializer: SerializationStrategy<T>) = ar
|
||||
)
|
||||
|
||||
@Serializable(MediaGroupMemberInputMediaSerializer::class)
|
||||
interface MediaGroupMemberInputMedia : InputMedia, CaptionedOutput, TextedOutput {
|
||||
@Deprecated("Will be removed in next major release")
|
||||
override val caption: String?
|
||||
get() = text
|
||||
interface MediaGroupMemberInputMedia : InputMedia, TextedOutput {
|
||||
fun serialize(format: StringFormat): String
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.InputMedia
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||
|
||||
interface ThumbedInputMedia : InputMedia {
|
||||
val thumb: InputFile?
|
||||
|
@ -1,10 +1,8 @@
|
||||
package dev.inmo.tgbotapi.types.MessageEntity.textsources
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
||||
import dev.inmo.tgbotapi.utils.*
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.internal.*
|
||||
import dev.inmo.tgbotapi.utils.internal.boldMarkdown
|
||||
import dev.inmo.tgbotapi.utils.internal.boldMarkdownV2
|
||||
|
||||
/**
|
||||
* @see bold
|
||||
|
@ -1,10 +1,9 @@
|
||||
package dev.inmo.tgbotapi.types.MessageEntity.textsources
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
||||
import dev.inmo.tgbotapi.utils.*
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.DirectInvocationOfTextSourceConstructor
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.internal.*
|
||||
import dev.inmo.tgbotapi.utils.internal.commandMarkdown
|
||||
import dev.inmo.tgbotapi.utils.internal.commandMarkdownV2
|
||||
|
||||
private val commandRegex = Regex("[/!][^@\\s]*")
|
||||
|
||||
|
@ -1,10 +1,8 @@
|
||||
package dev.inmo.tgbotapi.types.MessageEntity.textsources
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
||||
import dev.inmo.tgbotapi.utils.*
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.internal.*
|
||||
import dev.inmo.tgbotapi.utils.internal.cashTagMarkdown
|
||||
import dev.inmo.tgbotapi.utils.internal.cashTagMarkdownV2
|
||||
|
||||
/**
|
||||
* @see cashTag
|
||||
|
@ -2,10 +2,8 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.DirectInvocationOfTextSourceConstructor
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||
import dev.inmo.tgbotapi.utils.*
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.internal.*
|
||||
import dev.inmo.tgbotapi.utils.internal.codeMarkdown
|
||||
import dev.inmo.tgbotapi.utils.internal.codeMarkdownV2
|
||||
|
||||
/**
|
||||
* @see code
|
||||
|
@ -1,10 +1,8 @@
|
||||
package dev.inmo.tgbotapi.types.MessageEntity.textsources
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
||||
import dev.inmo.tgbotapi.utils.*
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.internal.*
|
||||
import dev.inmo.tgbotapi.utils.internal.emailMarkdown
|
||||
import dev.inmo.tgbotapi.utils.internal.emailMarkdownV2
|
||||
|
||||
/**
|
||||
* @see email
|
||||
|
@ -1,10 +1,8 @@
|
||||
package dev.inmo.tgbotapi.types.MessageEntity.textsources
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
||||
import dev.inmo.tgbotapi.utils.*
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.internal.*
|
||||
import dev.inmo.tgbotapi.utils.internal.hashTagMarkdown
|
||||
import dev.inmo.tgbotapi.utils.internal.hashTagMarkdownV2
|
||||
|
||||
/**
|
||||
* @see hashtag
|
||||
|
@ -1,10 +1,8 @@
|
||||
package dev.inmo.tgbotapi.types.MessageEntity.textsources
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
||||
import dev.inmo.tgbotapi.utils.*
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.internal.*
|
||||
import dev.inmo.tgbotapi.utils.internal.italicMarkdown
|
||||
import dev.inmo.tgbotapi.utils.internal.italicMarkdownV2
|
||||
|
||||
/**
|
||||
* @see italic
|
||||
|
@ -1,10 +1,8 @@
|
||||
package dev.inmo.tgbotapi.types.MessageEntity.textsources
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
||||
import dev.inmo.tgbotapi.utils.*
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.internal.*
|
||||
import dev.inmo.tgbotapi.utils.internal.mentionMarkdown
|
||||
import dev.inmo.tgbotapi.utils.internal.mentionMarkdownV2
|
||||
|
||||
private val String.withoutCommercialAt
|
||||
get() = if (startsWith("@")) {
|
||||
|
@ -1,10 +1,8 @@
|
||||
package dev.inmo.tgbotapi.types.MessageEntity.textsources
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
||||
import dev.inmo.tgbotapi.utils.*
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.internal.*
|
||||
import dev.inmo.tgbotapi.utils.internal.phoneMarkdown
|
||||
import dev.inmo.tgbotapi.utils.internal.phoneMarkdownV2
|
||||
|
||||
/**
|
||||
* @see phone
|
||||
|
@ -1,10 +1,9 @@
|
||||
package dev.inmo.tgbotapi.types.MessageEntity.textsources
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
||||
import dev.inmo.tgbotapi.utils.*
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.DirectInvocationOfTextSourceConstructor
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.internal.*
|
||||
import dev.inmo.tgbotapi.utils.internal.preMarkdown
|
||||
import dev.inmo.tgbotapi.utils.internal.preMarkdownV2
|
||||
|
||||
/**
|
||||
* @see pre
|
||||
|
@ -1,10 +1,9 @@
|
||||
package dev.inmo.tgbotapi.types.MessageEntity.textsources
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
||||
import dev.inmo.tgbotapi.utils.*
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.DirectInvocationOfTextSourceConstructor
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.internal.*
|
||||
import dev.inmo.tgbotapi.utils.internal.regularMarkdown
|
||||
import dev.inmo.tgbotapi.utils.internal.regularMarkdownV2
|
||||
|
||||
/**
|
||||
* @see regular
|
||||
|
@ -1,10 +1,8 @@
|
||||
package dev.inmo.tgbotapi.types.MessageEntity.textsources
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
||||
import dev.inmo.tgbotapi.utils.*
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.internal.*
|
||||
import dev.inmo.tgbotapi.utils.internal.strikethroughMarkdown
|
||||
import dev.inmo.tgbotapi.utils.internal.strikethroughMarkdownV2
|
||||
|
||||
/**
|
||||
* @see strikethrough
|
||||
|
@ -1,10 +1,9 @@
|
||||
package dev.inmo.tgbotapi.types.MessageEntity.textsources
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
||||
import dev.inmo.tgbotapi.utils.*
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.DirectInvocationOfTextSourceConstructor
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.internal.*
|
||||
import dev.inmo.tgbotapi.utils.internal.linkMarkdown
|
||||
import dev.inmo.tgbotapi.utils.internal.linkMarkdownV2
|
||||
|
||||
/**
|
||||
* @see link
|
||||
|
@ -2,10 +2,8 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
||||
import dev.inmo.tgbotapi.types.User
|
||||
import dev.inmo.tgbotapi.utils.*
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.internal.*
|
||||
import dev.inmo.tgbotapi.utils.internal.textMentionMarkdown
|
||||
import dev.inmo.tgbotapi.utils.internal.textMentionMarkdownV2
|
||||
|
||||
/**
|
||||
* @see mention
|
||||
|
@ -1,10 +1,9 @@
|
||||
package dev.inmo.tgbotapi.types.MessageEntity.textsources
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
||||
import dev.inmo.tgbotapi.utils.*
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.DirectInvocationOfTextSourceConstructor
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.TextSource
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.internal.*
|
||||
import dev.inmo.tgbotapi.utils.internal.linkMarkdown
|
||||
import dev.inmo.tgbotapi.utils.internal.linkMarkdownV2
|
||||
|
||||
/**
|
||||
* @see link
|
||||
|
@ -1,10 +1,8 @@
|
||||
package dev.inmo.tgbotapi.types.MessageEntity.textsources
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
||||
import dev.inmo.tgbotapi.utils.*
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.internal.*
|
||||
import dev.inmo.tgbotapi.utils.internal.underlineMarkdown
|
||||
import dev.inmo.tgbotapi.utils.internal.underlineMarkdownV2
|
||||
|
||||
/**
|
||||
* @see underline
|
||||
|
@ -1,6 +1,5 @@
|
||||
package dev.inmo.tgbotapi.types.chat.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.types.ChatId
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.chat.PreviewChatSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
|
@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.types.FileUniqueId
|
||||
|
||||
internal const val fileIdField = "file_id"
|
||||
internal const val fileSizeField = "file_size"
|
||||
internal const val fileDateField = "file_date"
|
||||
internal const val filePathField = "file_path"
|
||||
|
||||
/**
|
||||
|
@ -4,7 +4,6 @@ import com.soywiz.klock.DateTime
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.ChannelChat
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChannelEvent
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.GroupEvent
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage
|
||||
|
||||
data class ChannelEventMessage<T : ChannelEvent>(
|
||||
|
@ -9,14 +9,14 @@ import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent
|
||||
|
||||
data class ChannelMediaGroupMessage(
|
||||
data class ChannelMediaGroupMessage<T : MediaGroupContent>(
|
||||
override val messageId: MessageIdentifier,
|
||||
override val chat: Chat,
|
||||
override val date: DateTime,
|
||||
override val mediaGroupId: MediaGroupIdentifier,
|
||||
override val content: MediaGroupContent,
|
||||
override val content: T,
|
||||
override val editDate: DateTime?,
|
||||
override val forwardInfo: ForwardInfo?,
|
||||
override val replyTo: Message?,
|
||||
override val replyMarkup: InlineKeyboardMarkup?
|
||||
) : MediaGroupMessage
|
||||
) : MediaGroupMessage<T>
|
||||
|
@ -20,6 +20,3 @@ data class ChannelMessageImpl<T: MessageContent>(
|
||||
override val senderBot: CommonBot?,
|
||||
override val authorSignature: AuthorSignature?
|
||||
) : ChannelMessage<T>
|
||||
|
||||
@Deprecated("Renamed", ReplaceWith("ChannelMessageImpl", "dev.inmo.tgbotapi.types.message.ChannelMessageImpl"))
|
||||
typealias ChannelMessage<T> = ChannelMessageImpl<T>
|
||||
|
@ -7,9 +7,6 @@ import dev.inmo.tgbotapi.types.chat.abstracts.GroupChat
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.GroupEvent
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.GroupEventMessage
|
||||
|
||||
@Deprecated("Renamed", ReplaceWith("CommonGroupEventMessage"))
|
||||
typealias GroupEventMessage = CommonGroupEventMessage<*>
|
||||
|
||||
data class CommonGroupEventMessage<T : GroupEvent>(
|
||||
override val messageId: MessageIdentifier,
|
||||
override val user: User,
|
||||
|
@ -7,15 +7,15 @@ import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent
|
||||
|
||||
data class CommonMediaGroupMessage(
|
||||
data class CommonMediaGroupMessage<T : MediaGroupContent>(
|
||||
override val messageId: MessageIdentifier,
|
||||
override val user: User,
|
||||
override val chat: Chat,
|
||||
override val date: DateTime,
|
||||
override val mediaGroupId: MediaGroupIdentifier,
|
||||
override val content: MediaGroupContent,
|
||||
override val content: T,
|
||||
override val editDate: DateTime?,
|
||||
override val forwardInfo: ForwardInfo?,
|
||||
override val replyTo: Message?,
|
||||
override val replyMarkup: InlineKeyboardMarkup?
|
||||
) : MediaGroupMessage, FromUserMessage
|
||||
) : MediaGroupMessage<T>, FromUserMessage
|
||||
|
@ -4,13 +4,9 @@ import com.soywiz.klock.DateTime
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.User
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.SupergroupChat
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.GroupEvent
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.SupergroupEvent
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.SupergroupEventMessage
|
||||
|
||||
@Deprecated("Renamed", ReplaceWith("CommonSupergroupEventMessage"))
|
||||
typealias SupergroupEventMessage = CommonSupergroupEventMessage<*>
|
||||
|
||||
data class CommonSupergroupEventMessage<T : SupergroupEvent>(
|
||||
override val messageId: MessageIdentifier,
|
||||
override val user: User,
|
||||
|
@ -0,0 +1,17 @@
|
||||
package dev.inmo.tgbotapi.types.message
|
||||
|
||||
import com.soywiz.klock.DateTime
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.User
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.FromUserMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
import dev.inmo.tgbotapi.types.passport.PassportData
|
||||
|
||||
data class PassportMessage(
|
||||
override val messageId: MessageIdentifier,
|
||||
override val chat: Chat,
|
||||
override val user: User,
|
||||
override val date: DateTime,
|
||||
val passportData: PassportData
|
||||
) : Message, FromUserMessage
|
@ -22,6 +22,3 @@ data class PrivateMessageImpl<T: MessageContent>(
|
||||
override val senderBot: CommonBot?,
|
||||
val paymentInfo: SuccessfulPaymentInfo?
|
||||
) : PrivateMessage<T>
|
||||
|
||||
@Deprecated("Renamed", ReplaceWith("PrivateMessageImpl", "dev.inmo.tgbotapi.types.message.PrivateMessageImpl"))
|
||||
typealias CommonMessageImpl<T> = PrivateMessageImpl<T>
|
||||
|
@ -18,6 +18,7 @@ import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
|
||||
import dev.inmo.tgbotapi.types.message.content.media.*
|
||||
import dev.inmo.tgbotapi.types.message.payments.InvoiceContent
|
||||
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentInfo
|
||||
import dev.inmo.tgbotapi.types.passport.PassportData
|
||||
import dev.inmo.tgbotapi.types.payments.Invoice
|
||||
import dev.inmo.tgbotapi.types.payments.SuccessfulPayment
|
||||
import dev.inmo.tgbotapi.types.polls.Poll
|
||||
@ -84,7 +85,7 @@ internal data class RawMessage(
|
||||
private val connected_website: String? = null,
|
||||
|
||||
// passport property
|
||||
private val passport_data: Unit? = null,
|
||||
private val passport_data: PassportData? = null,
|
||||
private val proximity_alert_triggered: ProximityAlertTriggered? = null,
|
||||
|
||||
private val reply_markup: InlineKeyboardMarkup? = null
|
||||
@ -324,6 +325,14 @@ internal data class RawMessage(
|
||||
)
|
||||
else -> error("Unknown type of chat: $chat")
|
||||
}
|
||||
} ?: passport_data ?.let{
|
||||
PassportMessage(
|
||||
messageId,
|
||||
chat,
|
||||
from ?: error("For passport must be provided user, but got null"),
|
||||
date.asDate,
|
||||
passport_data
|
||||
)
|
||||
} ?: error("Was not found supported type of data")
|
||||
} catch (e: Exception) {
|
||||
UnknownMessageType(
|
||||
|
@ -3,6 +3,6 @@ package dev.inmo.tgbotapi.types.message.abstracts
|
||||
import dev.inmo.tgbotapi.types.MediaGroupIdentifier
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent
|
||||
|
||||
interface MediaGroupMessage : CommonMessage<MediaGroupContent> {
|
||||
interface MediaGroupMessage<T : MediaGroupContent> : CommonMessage<T> {
|
||||
val mediaGroupId: MediaGroupIdentifier
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package dev.inmo.tgbotapi.types.message.content
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.TextPart
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.TextedInput
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.requests.send.SendTextMessage
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
@ -10,17 +11,11 @@ import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
|
||||
import dev.inmo.tgbotapi.utils.internal.*
|
||||
import dev.inmo.tgbotapi.utils.internal.fullListOfSubSource
|
||||
import dev.inmo.tgbotapi.utils.internal.toMarkdownTexts
|
||||
|
||||
data class TextContent(
|
||||
override val text: String,
|
||||
override val textEntities: List<TextPart> = emptyList()
|
||||
) : MessageContent, TextedInput {
|
||||
@Deprecated("Has been renamed", ReplaceWith("textEntities"))
|
||||
val entities: List<TextPart>
|
||||
get() = textEntities
|
||||
|
||||
override fun createResend(
|
||||
chatId: ChatIdentifier,
|
||||
disableNotification: Boolean,
|
||||
@ -77,10 +72,3 @@ data class TextContent(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert its [TextContent.entities] to list of [dev.inmo.tgbotapi.CommonAbstracts.TextSource]
|
||||
* with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource]
|
||||
*/
|
||||
@Deprecated("Useless due to the fact that currently every message contains full list of sources")
|
||||
fun TextContent.fullEntitiesList(): TextSourcesList = text.fullListOfSubSource(entities).map { it.source }
|
||||
|
@ -1,12 +1,18 @@
|
||||
package dev.inmo.tgbotapi.types.message.content.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.CaptionedInput
|
||||
import dev.inmo.tgbotapi.types.InputMedia.MediaGroupMemberInputMedia
|
||||
import dev.inmo.tgbotapi.types.InputMedia.*
|
||||
|
||||
interface MediaGroupContent : MediaContent, CaptionedInput {
|
||||
fun toMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia
|
||||
}
|
||||
|
||||
interface VisualMediaGroupContent : MediaGroupContent
|
||||
interface AudioMediaGroupContent : MediaGroupContent
|
||||
interface DocumentMediaGroupContent : MediaGroupContent
|
||||
interface VisualMediaGroupContent : MediaGroupContent {
|
||||
override fun toMediaGroupMemberInputMedia(): VisualMediaGroupMemberInputMedia
|
||||
}
|
||||
interface AudioMediaGroupContent : MediaGroupContent {
|
||||
override fun toMediaGroupMemberInputMedia(): AudioMediaGroupMemberInputMedia
|
||||
}
|
||||
interface DocumentMediaGroupContent : MediaGroupContent {
|
||||
override fun toMediaGroupMemberInputMedia(): DocumentMediaGroupMemberInputMedia
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
package dev.inmo.tgbotapi.types.passport
|
||||
|
||||
import dev.inmo.micro_utils.serialization.base64.Base64StringSerializer
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
typealias EncryptedAndBase64EncodedData = String
|
||||
typealias EncryptedByBotPublicKeyData = String
|
||||
typealias EncryptedData = String
|
||||
|
||||
@Serializable
|
||||
data class EncryptedCredentials(
|
||||
@SerialName(dataField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
val data: EncryptedData,
|
||||
@SerialName(hashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
val hash: String,
|
||||
@SerialName(secretField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
val secret: EncryptedByBotPublicKeyData
|
||||
)
|
@ -0,0 +1,15 @@
|
||||
package dev.inmo.tgbotapi.types.passport
|
||||
|
||||
import dev.inmo.tgbotapi.types.credentialsField
|
||||
import dev.inmo.tgbotapi.types.dataField
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.EncryptedPassportElement
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class PassportData(
|
||||
@SerialName(dataField)
|
||||
val data: List<EncryptedPassportElement>,
|
||||
@SerialName(credentialsField)
|
||||
val credentials: EncryptedCredentials
|
||||
)
|
@ -0,0 +1,266 @@
|
||||
@file:Suppress("unused", "EXPERIMENTAL_API_USAGE")
|
||||
|
||||
package dev.inmo.tgbotapi.types.passport
|
||||
|
||||
import dev.inmo.micro_utils.crypto.MD5
|
||||
import dev.inmo.micro_utils.crypto.md5
|
||||
import dev.inmo.micro_utils.serialization.base64.Base64StringSerializer
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.type
|
||||
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
import kotlinx.serialization.json.*
|
||||
|
||||
val ByteArray.passportFileHash: MD5
|
||||
get() = md5()
|
||||
|
||||
@Serializable(PassportElementErrorSerializer::class)
|
||||
sealed class PassportElementError {
|
||||
abstract val source: String
|
||||
abstract val type: String
|
||||
abstract val message: String
|
||||
}
|
||||
|
||||
data class UnknownPassportElementError(
|
||||
val raw: JsonObject
|
||||
) : PassportElementError() {
|
||||
override val source: String = raw[sourceField] ?.jsonPrimitive ?.contentOrNull ?: ""
|
||||
override val type: String = raw[typeField] ?.jsonPrimitive ?.contentOrNull ?: ""
|
||||
override val message: String = raw[messageField] ?.jsonPrimitive ?.contentOrNull ?: ""
|
||||
}
|
||||
|
||||
object PassportElementErrorSerializer : KSerializer<PassportElementError> {
|
||||
private val jsonObjectSerializer = JsonObject.serializer()
|
||||
override val descriptor: SerialDescriptor
|
||||
get() = jsonObjectSerializer.descriptor
|
||||
override fun deserialize(decoder: Decoder): PassportElementError {
|
||||
val json = jsonObjectSerializer.deserialize(decoder)
|
||||
return when (json[sourceField] ?.jsonPrimitive ?.content) {
|
||||
"dataField" -> nonstrictJsonFormat.decodeFromJsonElement(PassportElementErrorDataField.serializer(), json)
|
||||
"frontSideField" -> nonstrictJsonFormat.decodeFromJsonElement(PassportElementErrorFrontSide.serializer(), json)
|
||||
"reverseSideField" -> nonstrictJsonFormat.decodeFromJsonElement(PassportElementErrorReverseSide.serializer(), json)
|
||||
"selfieField" -> nonstrictJsonFormat.decodeFromJsonElement(PassportElementErrorSelfie.serializer(), json)
|
||||
"fileField" -> nonstrictJsonFormat.decodeFromJsonElement(PassportElementFileError.serializer(), json)
|
||||
"filesField" -> nonstrictJsonFormat.decodeFromJsonElement(PassportElementFilesError.serializer(), json)
|
||||
"translationFileField" -> nonstrictJsonFormat.decodeFromJsonElement(PassportElementErrorTranslationFile.serializer(), json)
|
||||
"translationFilesField" -> nonstrictJsonFormat.decodeFromJsonElement(PassportElementErrorTranslationFiles.serializer(), json)
|
||||
"unspecifiedField" -> nonstrictJsonFormat.decodeFromJsonElement(PassportElementErrorUnspecified.serializer(), json)
|
||||
else -> UnknownPassportElementError(json)
|
||||
}
|
||||
}
|
||||
override fun serialize(encoder: Encoder, value: PassportElementError) {
|
||||
val neverMindAboutThisVariable = when (value) {
|
||||
is PassportElementErrorFrontSide -> PassportElementErrorFrontSide.serializer().serialize(encoder, value)
|
||||
is PassportElementErrorReverseSide -> PassportElementErrorReverseSide.serializer().serialize(encoder, value)
|
||||
is PassportElementErrorSelfie -> PassportElementErrorSelfie.serializer().serialize(encoder, value)
|
||||
is PassportElementErrorFile -> PassportElementErrorFile.serializer().serialize(encoder, value)
|
||||
is PassportElementErrorTranslationFile -> PassportElementErrorTranslationFile.serializer().serialize(encoder, value)
|
||||
is PassportElementErrorUnspecified -> PassportElementErrorUnspecified.serializer().serialize(encoder, value)
|
||||
is PassportElementErrorDataField -> PassportElementErrorDataField.serializer().serialize(encoder, value)
|
||||
is PassportElementErrorFiles -> PassportElementErrorFiles.serializer().serialize(encoder, value)
|
||||
is PassportElementErrorTranslationFiles -> PassportElementErrorTranslationFiles.serializer().serialize(encoder, value)
|
||||
is UnknownPassportElementError -> jsonObjectSerializer.serialize(encoder, value.raw)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable
|
||||
sealed class PassportSingleElementError : PassportElementError() {
|
||||
abstract val elementHash: String
|
||||
}
|
||||
|
||||
@Serializable
|
||||
sealed class PassportMultipleElementsError : PassportElementError() {
|
||||
abstract val elementsHashes: List<String>
|
||||
}
|
||||
|
||||
@Serializable
|
||||
sealed class PassportElementFileError : PassportSingleElementError()
|
||||
|
||||
@Serializable
|
||||
sealed class PassportElementFilesError : PassportMultipleElementsError()
|
||||
|
||||
@Serializable
|
||||
data class PassportElementErrorDataField(
|
||||
@SerialName(typeField)
|
||||
override val type: String,
|
||||
@SerialName(fieldNameField)
|
||||
val fieldName: String,
|
||||
@SerialName(dataHashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val elementHash: String,
|
||||
@SerialName(messageField)
|
||||
override val message: String
|
||||
) : PassportSingleElementError() {
|
||||
@SerialName(sourceField)
|
||||
@Required
|
||||
override val source: String = dataField
|
||||
}
|
||||
fun WithData.createDataError(field: String, message: String) = PassportElementErrorDataField(
|
||||
type,
|
||||
field,
|
||||
hash,
|
||||
message
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class PassportElementErrorFrontSide(
|
||||
@SerialName(typeField)
|
||||
override val type: String,
|
||||
@SerialName(fileHashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val elementHash: String,
|
||||
@SerialName(messageField)
|
||||
override val message: String
|
||||
) : PassportElementFileError() {
|
||||
@SerialName(sourceField)
|
||||
@Required
|
||||
override val source: String = frontSideField
|
||||
}
|
||||
fun WithFrontSide.createFrontSideError(message: String, unencryptedFileHash: String) = PassportElementErrorFrontSide(
|
||||
type,
|
||||
unencryptedFileHash,
|
||||
message
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class PassportElementErrorReverseSide(
|
||||
@SerialName(typeField)
|
||||
override val type: String,
|
||||
@SerialName(fileHashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val elementHash: String,
|
||||
@SerialName(messageField)
|
||||
override val message: String
|
||||
) : PassportElementFileError() {
|
||||
@SerialName(sourceField)
|
||||
@Required
|
||||
override val source: String = reverseSideField
|
||||
}
|
||||
fun WithReverseSide.createReverseSideError(message: String, unencryptedFileHash: String) = PassportElementErrorReverseSide(
|
||||
type,
|
||||
unencryptedFileHash,
|
||||
message
|
||||
)
|
||||
@Serializable
|
||||
data class PassportElementErrorSelfie(
|
||||
@SerialName(typeField)
|
||||
override val type: String,
|
||||
@SerialName(fileHashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val elementHash: String,
|
||||
@SerialName(messageField)
|
||||
override val message: String
|
||||
) : PassportElementFileError() {
|
||||
@SerialName(sourceField)
|
||||
@Required
|
||||
override val source: String = selfieField
|
||||
}
|
||||
fun WithSelfie.createSelfieError(message: String, unencryptedFileHash: String) = PassportElementErrorSelfie(
|
||||
type,
|
||||
unencryptedFileHash,
|
||||
message
|
||||
)
|
||||
|
||||
|
||||
@Serializable
|
||||
data class PassportElementErrorFile(
|
||||
@SerialName(typeField)
|
||||
override val type: String,
|
||||
@SerialName(fileHashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val elementHash: String,
|
||||
@SerialName(messageField)
|
||||
override val message: String
|
||||
) : PassportElementFileError() {
|
||||
@SerialName(sourceField)
|
||||
@Required
|
||||
override val source: String = fileField
|
||||
}
|
||||
fun FilesCollection.createFileError(message: String, unencryptedFileHash: String) = PassportElementErrorFile(
|
||||
type,
|
||||
unencryptedFileHash,
|
||||
message
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class PassportElementErrorFiles(
|
||||
@SerialName(typeField)
|
||||
override val type: String,
|
||||
@SerialName(fileHashesField)
|
||||
override val elementsHashes: List<@Serializable(Base64StringSerializer::class) String>,
|
||||
@SerialName(messageField)
|
||||
override val message: String
|
||||
) : PassportElementFilesError() {
|
||||
@SerialName(sourceField)
|
||||
@Required
|
||||
override val source: String = filesField
|
||||
}
|
||||
fun FilesCollection.createFilesError(message: String, unencryptedFileHashes: List<String>) = PassportElementErrorFiles(
|
||||
type,
|
||||
unencryptedFileHashes,
|
||||
message
|
||||
)
|
||||
|
||||
|
||||
@Serializable
|
||||
data class PassportElementErrorTranslationFile(
|
||||
@SerialName(typeField)
|
||||
override val type: String,
|
||||
@SerialName(fileHashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val elementHash: String,
|
||||
@SerialName(messageField)
|
||||
override val message: String
|
||||
) : PassportElementFileError() {
|
||||
@SerialName(sourceField)
|
||||
@Required
|
||||
override val source: String = translationFileField
|
||||
}
|
||||
fun Translatable.createFileError(message: String, unencryptedFileHash: String) = PassportElementErrorTranslationFile(
|
||||
type,
|
||||
unencryptedFileHash,
|
||||
message
|
||||
)
|
||||
@Serializable
|
||||
data class PassportElementErrorTranslationFiles(
|
||||
@SerialName(typeField)
|
||||
override val type: String,
|
||||
@SerialName(fileHashesField)
|
||||
override val elementsHashes: List<@Serializable(Base64StringSerializer::class) String>,
|
||||
@SerialName(messageField)
|
||||
override val message: String
|
||||
) : PassportElementFilesError() {
|
||||
@SerialName(sourceField)
|
||||
@Required
|
||||
override val source: String = translationFilesField
|
||||
}
|
||||
fun Translatable.createFilesError(message: String, unencryptedFileHashes: List<String>) = PassportElementErrorTranslationFiles(
|
||||
type,
|
||||
unencryptedFileHashes,
|
||||
message
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class PassportElementErrorUnspecified(
|
||||
@SerialName(typeField)
|
||||
override val type: String,
|
||||
@SerialName(fileHashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val elementHash: String,
|
||||
@SerialName(messageField)
|
||||
override val message: String
|
||||
) : PassportElementFileError() {
|
||||
@SerialName(sourceField)
|
||||
@Required
|
||||
override val source: String = unspecifiedField
|
||||
}
|
||||
fun EncryptedPassportElement.createUnspecifiedError(message: String, elementHash: String) = PassportElementErrorUnspecified(
|
||||
type,
|
||||
elementHash,
|
||||
message
|
||||
)
|
@ -0,0 +1,18 @@
|
||||
package dev.inmo.tgbotapi.types.passport.encrypted_data
|
||||
|
||||
import dev.inmo.micro_utils.serialization.base64.Base64StringSerializer
|
||||
import dev.inmo.tgbotapi.types.emailField
|
||||
import dev.inmo.tgbotapi.types.hashField
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.WithEmail
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class Email(
|
||||
@SerialName(emailField)
|
||||
override val email: String,
|
||||
@SerialName(hashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val hash: String
|
||||
) : WithEmail {
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package dev.inmo.tgbotapi.types.passport.encrypted_data
|
||||
|
||||
import dev.inmo.micro_utils.serialization.base64.Base64StringSerializer
|
||||
import dev.inmo.tgbotapi.types.dataField
|
||||
import dev.inmo.tgbotapi.types.passport.EncryptedData
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.WithData
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class EncryptedAddress(
|
||||
@SerialName(dataField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val data: EncryptedData,
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val hash: String
|
||||
) : WithData
|
@ -0,0 +1,63 @@
|
||||
package dev.inmo.tgbotapi.types.passport.encrypted_data
|
||||
|
||||
import dev.inmo.micro_utils.serialization.encapsulator.Encapsulator
|
||||
import dev.inmo.tgbotapi.types.hashField
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.EncryptedPassportElement
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.UnknownEncryptedPassportElement
|
||||
import dev.inmo.tgbotapi.types.typeField
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.Serializer
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
import kotlinx.serialization.json.*
|
||||
|
||||
val encryptedElementsClassesByTypes = mapOf(
|
||||
"personal_details" to Encapsulator(EncryptedPersonalDetails::class, EncryptedPersonalDetails.serializer()),
|
||||
"passport" to Encapsulator(CommonPassport::class, CommonPassport.serializer()),
|
||||
"driver_license" to Encapsulator(DriverLicense::class, DriverLicense.serializer()),
|
||||
"identity_card" to Encapsulator(IdentityCard::class, IdentityCard.serializer()),
|
||||
"internal_passport" to Encapsulator(InternalPassport::class, InternalPassport.serializer()),
|
||||
"address" to Encapsulator(EncryptedAddress::class, EncryptedAddress.serializer()),
|
||||
"utility_bill" to Encapsulator(UtilityBill::class, UtilityBill.serializer()),
|
||||
"bank_statement" to Encapsulator(BankStatement::class, BankStatement.serializer()),
|
||||
"rental_agreement" to Encapsulator(RentalAgreement::class, RentalAgreement.serializer()),
|
||||
"passport_registration" to Encapsulator(PassportRegistration::class, PassportRegistration.serializer()),
|
||||
"temporary_registration" to Encapsulator(TemporaryRegistration::class, TemporaryRegistration.serializer()),
|
||||
"phone_number" to Encapsulator(PhoneNumber::class, PhoneNumber.serializer()),
|
||||
"email" to Encapsulator(Email::class, Email.serializer())
|
||||
)
|
||||
|
||||
@RiskFeature("Remember that this method may return \"unknown\" in case if encrypted element was not defined in library")
|
||||
val EncryptedPassportElement.type: String
|
||||
get() = encryptedElementsClassesByTypes.keys.firstOrNull { encryptedElementsClassesByTypes.getValue(it).klass.isInstance(this) } ?: "unknown"
|
||||
|
||||
@Serializer(EncryptedPassportElement::class)
|
||||
object EncryptedElementSerializer : KSerializer<EncryptedPassportElement> {
|
||||
private val jsonSerializer = JsonObject.serializer()
|
||||
override val descriptor: SerialDescriptor = jsonSerializer.descriptor
|
||||
|
||||
override fun deserialize(decoder: Decoder): EncryptedPassportElement {
|
||||
val json = jsonSerializer.deserialize(decoder)
|
||||
return json[typeField] ?.jsonPrimitive ?.content ?.let { type ->
|
||||
encryptedElementsClassesByTypes[type] ?.serializer ?.let { deserializer ->
|
||||
nonstrictJsonFormat.decodeFromJsonElement(deserializer, json)
|
||||
}
|
||||
} ?: UnknownEncryptedPassportElement(json, json[hashField] ?.jsonPrimitive ?.content ?: "")
|
||||
}
|
||||
|
||||
override fun serialize(encoder: Encoder, value: EncryptedPassportElement) {
|
||||
val json = value.let {
|
||||
encryptedElementsClassesByTypes.forEach { (key, encapsulator) ->
|
||||
val json = encapsulator.encapsulate(value) { data ->
|
||||
nonstrictJsonFormat.encodeToJsonElement(this as KSerializer<EncryptedPassportElement>, data).jsonObject
|
||||
} ?: return@forEach
|
||||
return@let JsonObject(json + (typeField to JsonPrimitive(key)))
|
||||
}
|
||||
(value as? UnknownEncryptedPassportElement) ?.rawJson ?: return
|
||||
}
|
||||
jsonSerializer.serialize(encoder, json)
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package dev.inmo.tgbotapi.types.passport.encrypted_data
|
||||
|
||||
import dev.inmo.micro_utils.serialization.base64.Base64StringSerializer
|
||||
import dev.inmo.tgbotapi.types.dataField
|
||||
import dev.inmo.tgbotapi.types.passport.EncryptedData
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.WithData
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class EncryptedPersonalDetails(
|
||||
@SerialName(dataField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val data: EncryptedData,
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val hash: String
|
||||
) : WithData
|
@ -0,0 +1,42 @@
|
||||
package dev.inmo.tgbotapi.types.passport.encrypted_data
|
||||
|
||||
import dev.inmo.micro_utils.serialization.base64.Base64StringSerializer
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.passport.EncryptedData
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.*
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable(EncryptedElementSerializer::class)
|
||||
sealed class Passport : WithData, WithFrontSide, WithSelfie, Translatable
|
||||
|
||||
@Serializable
|
||||
data class CommonPassport(
|
||||
@SerialName(dataField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val data: EncryptedData,
|
||||
@SerialName(frontSideField)
|
||||
override val frontSide: PassportFile? = null,
|
||||
@SerialName(selfieField)
|
||||
override val selfie: PassportFile? = null,
|
||||
@SerialName(translationField)
|
||||
override val translations: List<PassportFile> = emptyList(),
|
||||
@SerialName(hashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val hash: String
|
||||
) : Passport()
|
||||
@Serializable
|
||||
data class InternalPassport(
|
||||
@SerialName(dataField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val data: EncryptedData,
|
||||
@SerialName(frontSideField)
|
||||
override val frontSide: PassportFile? = null,
|
||||
@SerialName(selfieField)
|
||||
override val selfie: PassportFile? = null,
|
||||
@SerialName(translationField)
|
||||
override val translations: List<PassportFile> = emptyList(),
|
||||
@SerialName(hashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val hash: String
|
||||
) : Passport()
|
@ -0,0 +1,23 @@
|
||||
package dev.inmo.tgbotapi.types.passport.encrypted_data
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.files.abstracts.*
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
/**
|
||||
* This object represents a file uploaded to Telegram Passport. Currently all Telegram Passport files are in JPEG format
|
||||
* when decrypted and don't exceed 10MB.
|
||||
*/
|
||||
@Serializable
|
||||
data class PassportFile(
|
||||
@SerialName(fileIdField)
|
||||
override val fileId: FileId,
|
||||
@SerialName(fileUniqueIdField)
|
||||
override val fileUniqueId: FileUniqueId,
|
||||
@SerialName(fileDateField)
|
||||
val uploadingDate: TelegramDate,
|
||||
@SerialName(fileSizeField)
|
||||
override val fileSize: Long? = null
|
||||
) : TelegramMediaFile
|
@ -0,0 +1,18 @@
|
||||
package dev.inmo.tgbotapi.types.passport.encrypted_data
|
||||
|
||||
import dev.inmo.micro_utils.serialization.base64.Base64StringSerializer
|
||||
import dev.inmo.tgbotapi.types.hashField
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.WithPhoneNumber
|
||||
import dev.inmo.tgbotapi.types.phoneNumberField
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class PhoneNumber(
|
||||
@SerialName(phoneNumberField)
|
||||
override val phoneNumber: String,
|
||||
@SerialName(hashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val hash: String
|
||||
) : WithPhoneNumber {
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package dev.inmo.tgbotapi.types.passport.encrypted_data
|
||||
|
||||
import dev.inmo.micro_utils.serialization.base64.Base64StringSerializer
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.FilesCollection
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.Translatable
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable(EncryptedElementSerializer::class)
|
||||
sealed class TranslatableFilesCollection : Translatable, FilesCollection
|
||||
|
||||
@Serializable
|
||||
data class UtilityBill(
|
||||
@SerialName(filesField)
|
||||
override val files: List<PassportFile>,
|
||||
@SerialName(translationField)
|
||||
override val translations: List<PassportFile> = emptyList(),
|
||||
@SerialName(hashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val hash: String
|
||||
) : TranslatableFilesCollection()
|
||||
@Serializable
|
||||
data class BankStatement(
|
||||
@SerialName(filesField)
|
||||
override val files: List<PassportFile>,
|
||||
@SerialName(translationField)
|
||||
override val translations: List<PassportFile> = emptyList(),
|
||||
@SerialName(hashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val hash: String
|
||||
) : TranslatableFilesCollection()
|
||||
@Serializable
|
||||
data class RentalAgreement(
|
||||
@SerialName(filesField)
|
||||
override val files: List<PassportFile>,
|
||||
@SerialName(translationField)
|
||||
override val translations: List<PassportFile> = emptyList(),
|
||||
@SerialName(hashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val hash: String
|
||||
) : TranslatableFilesCollection()
|
||||
@Serializable
|
||||
data class PassportRegistration(
|
||||
@SerialName(filesField)
|
||||
override val files: List<PassportFile>,
|
||||
@SerialName(translationField)
|
||||
override val translations: List<PassportFile> = emptyList(),
|
||||
@SerialName(hashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val hash: String
|
||||
) : TranslatableFilesCollection()
|
||||
@Serializable
|
||||
data class TemporaryRegistration(
|
||||
@SerialName(filesField)
|
||||
override val files: List<PassportFile>,
|
||||
@SerialName(translationField)
|
||||
override val translations: List<PassportFile> = emptyList(),
|
||||
@SerialName(hashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val hash: String
|
||||
) : TranslatableFilesCollection()
|
||||
|
@ -0,0 +1,47 @@
|
||||
package dev.inmo.tgbotapi.types.passport.encrypted_data
|
||||
|
||||
import dev.inmo.micro_utils.serialization.base64.Base64StringSerializer
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.passport.EncryptedData
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.*
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable(EncryptedElementSerializer::class)
|
||||
sealed class TranslatableIDDocument : WithData, WithFrontSide, WithReverseSide, WithSelfie, Translatable
|
||||
|
||||
@Serializable
|
||||
data class DriverLicense(
|
||||
@SerialName(dataField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val data: EncryptedData,
|
||||
@SerialName(frontSideField)
|
||||
override val frontSide: PassportFile? = null,
|
||||
@SerialName(reverseSideField)
|
||||
override val reverseSide: PassportFile? = null,
|
||||
@SerialName(selfieField)
|
||||
override val selfie: PassportFile? = null,
|
||||
@SerialName(translationField)
|
||||
override val translations: List<PassportFile> = emptyList(),
|
||||
@SerialName(hashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val hash: String
|
||||
) : TranslatableIDDocument()
|
||||
|
||||
@Serializable
|
||||
data class IdentityCard(
|
||||
@SerialName(dataField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val data: EncryptedData,
|
||||
@SerialName(frontSideField)
|
||||
override val frontSide: PassportFile? = null,
|
||||
@SerialName(reverseSideField)
|
||||
override val reverseSide: PassportFile? = null,
|
||||
@SerialName(selfieField)
|
||||
override val selfie: PassportFile? = null,
|
||||
@SerialName(translationField)
|
||||
override val translations: List<PassportFile> = emptyList(),
|
||||
@SerialName(hashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val hash: String
|
||||
) : TranslatableIDDocument()
|
@ -0,0 +1,18 @@
|
||||
package dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts
|
||||
|
||||
import dev.inmo.micro_utils.serialization.base64.Base64StringSerializer
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.EncryptedElementSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
|
||||
@Serializable(EncryptedElementSerializer::class)
|
||||
interface EncryptedPassportElement {
|
||||
val hash: String
|
||||
}
|
||||
|
||||
@Serializable(EncryptedElementSerializer::class)
|
||||
data class UnknownEncryptedPassportElement(
|
||||
val rawJson: JsonObject,
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val hash: String
|
||||
) : EncryptedPassportElement
|
@ -0,0 +1,10 @@
|
||||
package dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.EncryptedElementSerializer
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.PassportFile
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable(EncryptedElementSerializer::class)
|
||||
interface FilesCollection : EncryptedPassportElement {
|
||||
val files: List<PassportFile>
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.EncryptedElementSerializer
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.PassportFile
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable(EncryptedElementSerializer::class)
|
||||
interface Translatable : EncryptedPassportElement {
|
||||
val translations: List<PassportFile>
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.types.passport.EncryptedData
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.EncryptedElementSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable(EncryptedElementSerializer::class)
|
||||
interface WithData : EncryptedPassportElement {
|
||||
val data: EncryptedData
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.EncryptedElementSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable(EncryptedElementSerializer::class)
|
||||
interface WithEmail : EncryptedPassportElement {
|
||||
val email: String
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.EncryptedElementSerializer
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.PassportFile
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable(EncryptedElementSerializer::class)
|
||||
interface WithFrontSide : EncryptedPassportElement {
|
||||
val frontSide: PassportFile?
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.EncryptedElementSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable(EncryptedElementSerializer::class)
|
||||
interface WithPhoneNumber : EncryptedPassportElement {
|
||||
val phoneNumber: String
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.EncryptedElementSerializer
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.PassportFile
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable(EncryptedElementSerializer::class)
|
||||
interface WithReverseSide : EncryptedPassportElement {
|
||||
val reverseSide: PassportFile?
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.EncryptedElementSerializer
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.PassportFile
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable(EncryptedElementSerializer::class)
|
||||
interface WithSelfie : EncryptedPassportElement {
|
||||
val selfie: PassportFile?
|
||||
}
|
@ -2,11 +2,12 @@ package dev.inmo.tgbotapi.types.update.MediaGroupUpdates
|
||||
|
||||
import dev.inmo.tgbotapi.types.UpdateIdentifier
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.BaseMessageUpdate
|
||||
|
||||
data class ChannelPostMediaGroupUpdate(
|
||||
override val origins: List<BaseMessageUpdate>
|
||||
) : SentMediaGroupUpdate {
|
||||
override val updateId: UpdateIdentifier = origins.last().updateId
|
||||
override val data: List<MediaGroupMessage> = origins.mapNotNull { it.data as? MediaGroupMessage }
|
||||
override val data: List<MediaGroupMessage<MediaGroupContent>> = origins.mapNotNull { it.data as? MediaGroupMessage<MediaGroupContent> }
|
||||
}
|
||||
|
@ -2,11 +2,12 @@ package dev.inmo.tgbotapi.types.update.MediaGroupUpdates
|
||||
|
||||
import dev.inmo.tgbotapi.types.UpdateIdentifier
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.update.EditChannelPostUpdate
|
||||
|
||||
data class EditChannelPostMediaGroupUpdate(
|
||||
override val origin: EditChannelPostUpdate
|
||||
) : EditMediaGroupUpdate {
|
||||
override val updateId: UpdateIdentifier = origin.updateId
|
||||
override val data: MediaGroupMessage = origin.data as MediaGroupMessage
|
||||
override val data: MediaGroupMessage<MediaGroupContent> = origin.data as MediaGroupMessage<MediaGroupContent>
|
||||
}
|
@ -2,11 +2,12 @@ package dev.inmo.tgbotapi.types.update.MediaGroupUpdates
|
||||
|
||||
import dev.inmo.tgbotapi.types.UpdateIdentifier
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.update.EditMessageUpdate
|
||||
|
||||
data class EditMessageMediaGroupUpdate(
|
||||
override val origin: EditMessageUpdate
|
||||
) : EditMediaGroupUpdate {
|
||||
override val updateId: UpdateIdentifier = origin.updateId
|
||||
override val data: MediaGroupMessage = origin.data as MediaGroupMessage
|
||||
override val data: MediaGroupMessage<MediaGroupContent> = origin.data as MediaGroupMessage<MediaGroupContent>
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package dev.inmo.tgbotapi.types.update.MediaGroupUpdates
|
||||
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.*
|
||||
|
||||
/**
|
||||
@ -13,11 +14,11 @@ import dev.inmo.tgbotapi.types.update.abstracts.*
|
||||
interface MediaGroupUpdate : Update
|
||||
|
||||
interface SentMediaGroupUpdate: MediaGroupUpdate {
|
||||
override val data: List<MediaGroupMessage>
|
||||
override val data: List<MediaGroupMessage<MediaGroupContent>>
|
||||
val origins: List<BaseMessageUpdate>
|
||||
}
|
||||
|
||||
interface EditMediaGroupUpdate : BaseEditMessageUpdate, MediaGroupUpdate {
|
||||
override val data: MediaGroupMessage
|
||||
override val data: MediaGroupMessage<MediaGroupContent>
|
||||
val origin: BaseMessageUpdate
|
||||
}
|
||||
|
@ -2,11 +2,12 @@ package dev.inmo.tgbotapi.types.update.MediaGroupUpdates
|
||||
|
||||
import dev.inmo.tgbotapi.types.UpdateIdentifier
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.BaseMessageUpdate
|
||||
|
||||
data class MessageMediaGroupUpdate(
|
||||
override val origins: List<BaseMessageUpdate>
|
||||
) : SentMediaGroupUpdate {
|
||||
override val updateId: UpdateIdentifier = origins.last().updateId
|
||||
override val data: List<MediaGroupMessage> = origins.mapNotNull { it.data as? MediaGroupMessage }
|
||||
override val data: List<MediaGroupMessage<MediaGroupContent>> = origins.mapNotNull { it.data as? MediaGroupMessage<MediaGroupContent> }
|
||||
}
|
@ -7,34 +7,72 @@ import dev.inmo.tgbotapi.types.update.abstracts.UnknownUpdate
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
import kotlinx.coroutines.flow.*
|
||||
|
||||
@Suppress("EXPERIMENTAL_API_USAGE", "unused")
|
||||
class FlowsUpdatesFilter(
|
||||
broadcastChannelsSize: Int = 100
|
||||
): UpdatesFilter {
|
||||
private val updatesSharedFlow = MutableSharedFlow<Update>(extraBufferCapacity = broadcastChannelsSize)
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
val allUpdatesFlow: Flow<Update> = updatesSharedFlow.asSharedFlow()
|
||||
|
||||
interface FlowsUpdatesFilter : UpdatesFilter {
|
||||
override val allowedUpdates: List<String>
|
||||
get() = ALL_UPDATES_LIST
|
||||
val allUpdatesFlow: Flow<Update>
|
||||
val allUpdatesWithoutMediaGroupsGroupingFlow: Flow<Update>
|
||||
|
||||
val messageFlow: Flow<MessageUpdate>
|
||||
val messageMediaGroupFlow: Flow<MessageMediaGroupUpdate>
|
||||
val editedMessageFlow: Flow<EditMessageUpdate>
|
||||
val editedMessageMediaGroupFlow: Flow<EditMessageMediaGroupUpdate>
|
||||
val channelPostFlow: Flow<ChannelPostUpdate>
|
||||
val channelPostMediaGroupFlow: Flow<ChannelPostMediaGroupUpdate>
|
||||
val editedChannelPostFlow: Flow<EditChannelPostUpdate>
|
||||
val editedChannelPostMediaGroupFlow: Flow<EditChannelPostMediaGroupUpdate>
|
||||
val chosenInlineResultFlow: Flow<ChosenInlineResultUpdate>
|
||||
val inlineQueryFlow: Flow<InlineQueryUpdate>
|
||||
val callbackQueryFlow: Flow<CallbackQueryUpdate>
|
||||
val shippingQueryFlow: Flow<ShippingQueryUpdate>
|
||||
val preCheckoutQueryFlow: Flow<PreCheckoutQueryUpdate>
|
||||
val pollFlow: Flow<PollUpdate>
|
||||
val pollAnswerFlow: Flow<PollAnswerUpdate>
|
||||
val unknownUpdateTypeFlow: Flow<UnknownUpdate>
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates [DefaultFlowsUpdatesFilter]
|
||||
*/
|
||||
@Suppress("FunctionName")
|
||||
fun FlowsUpdatesFilter(
|
||||
broadcastChannelsSize: Int = 100
|
||||
) = DefaultFlowsUpdatesFilter(broadcastChannelsSize)
|
||||
|
||||
@Suppress("EXPERIMENTAL_API_USAGE", "unused")
|
||||
class DefaultFlowsUpdatesFilter(
|
||||
broadcastChannelsSize: Int = 100
|
||||
): FlowsUpdatesFilter {
|
||||
private val updatesSharedFlow = MutableSharedFlow<Update>(extraBufferCapacity = broadcastChannelsSize)
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
override val allUpdatesFlow: Flow<Update> = updatesSharedFlow.asSharedFlow()
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
override val allUpdatesWithoutMediaGroupsGroupingFlow: Flow<Update> = allUpdatesFlow.flatMapConcat {
|
||||
when (it) {
|
||||
is SentMediaGroupUpdate -> it.origins.asFlow()
|
||||
is EditMediaGroupUpdate -> flowOf(it.origin)
|
||||
else -> flowOf(it)
|
||||
}
|
||||
}
|
||||
|
||||
override val asUpdateReceiver: UpdateReceiver<Update> = {
|
||||
updatesSharedFlow.emit(it)
|
||||
}
|
||||
|
||||
val messageFlow: Flow<MessageUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
val messageMediaGroupFlow: Flow<MessageMediaGroupUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
val editedMessageFlow: Flow<EditMessageUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
val editedMessageMediaGroupFlow: Flow<EditMessageMediaGroupUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
val channelPostFlow: Flow<ChannelPostUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
val channelPostMediaGroupFlow: Flow<ChannelPostMediaGroupUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
val editedChannelPostFlow: Flow<EditChannelPostUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
val editedChannelPostMediaGroupFlow: Flow<EditChannelPostMediaGroupUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
val chosenInlineResultFlow: Flow<ChosenInlineResultUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
val inlineQueryFlow: Flow<InlineQueryUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
val callbackQueryFlow: Flow<CallbackQueryUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
val shippingQueryFlow: Flow<ShippingQueryUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
val preCheckoutQueryFlow: Flow<PreCheckoutQueryUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
val pollFlow: Flow<PollUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
val pollAnswerFlow: Flow<PollAnswerUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
val unknownUpdateTypeFlow: Flow<UnknownUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
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 unknownUpdateTypeFlow: Flow<UnknownUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
}
|
@ -18,6 +18,7 @@ package dev.inmo.tgbotapi.utils
|
||||
)
|
||||
annotation class PreviewFeature
|
||||
|
||||
const val lowLevelRiskFeatureMessage = "This method is low-level and not recommended to direct use"
|
||||
@RequiresOptIn(
|
||||
"This feature can work unstable and may have some restrictions in Telegram System",
|
||||
RequiresOptIn.Level.WARNING
|
||||
|
@ -1,21 +0,0 @@
|
||||
package dev.inmo.tgbotapi.utils
|
||||
|
||||
import dev.inmo.micro_utils.coroutines.ExceptionHandler
|
||||
import dev.inmo.micro_utils.coroutines.safely
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.supervisorScope
|
||||
|
||||
|
||||
@Deprecated("In future will be used typealias from micro_utils", ReplaceWith("ExceptionHandler", "dev.inmo.micro_utils.coroutines.ExceptionHandler"))
|
||||
typealias ExceptionHandler<T> = ExceptionHandler<T>
|
||||
/**
|
||||
* It will run [block] inside of [supervisorScope] to avoid problems with catching of exceptions
|
||||
*
|
||||
* @param [onException] Will be called when happen exception inside of [block]. By default will throw exception - this
|
||||
* exception will be available for catching
|
||||
*/
|
||||
@Deprecated("In future will be used typealias from micro_utils", ReplaceWith("safely", "dev.inmo.micro_utils.coroutines.safely"))
|
||||
suspend inline fun <T> handleSafely(
|
||||
noinline onException: ExceptionHandler<T> = { throw it },
|
||||
noinline block: suspend CoroutineScope.() -> T
|
||||
): T = safely(onException, block)
|
@ -5,19 +5,40 @@ import io.ktor.utils.io.core.ByteReadPacket
|
||||
import io.ktor.utils.io.core.Input
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
/**
|
||||
* Information about file for [StorageFile]
|
||||
*
|
||||
* @param contentType Raw type like "application/json"
|
||||
* @param fileName This filename will be used in telegram system as name of file
|
||||
*/
|
||||
@Serializable
|
||||
data class StorageFileInfo(
|
||||
val contentType: String,
|
||||
val fileName: String
|
||||
) {
|
||||
/**
|
||||
* This methods is required for random generation of name for keeping warranties about unique file name
|
||||
*/
|
||||
fun generateCustomName() = "${uuid4()}.${fileName.fileExtension}"
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains info about file, which potentially can be sent to telegram system.
|
||||
*
|
||||
* @param storageFileInfo Information about this file
|
||||
* @param inputSource Lambda which able to allocate [Input] for uploading/manipulating data
|
||||
*
|
||||
* @see StorageFileInfo
|
||||
* @see asStorageFile
|
||||
*/
|
||||
data class StorageFile(
|
||||
val storageFileInfo: StorageFileInfo,
|
||||
private val inputSource: () -> Input
|
||||
) {
|
||||
fun asInput() = inputSource()
|
||||
val input: Input
|
||||
get() = inputSource()
|
||||
@Deprecated("This method will be fully replaced with input property", ReplaceWith("input"))
|
||||
fun asInput() = input
|
||||
}
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
@ -31,5 +52,8 @@ inline fun StorageFile(
|
||||
ByteReadPacket(bytes)
|
||||
}
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE", "unused")
|
||||
inline fun ByteArray.asStorageFile(fileName: String, mimeType: MimeType) = StorageFile(fileName, this, mimeType)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user