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

Compare commits

..

181 Commits

Author SHA1 Message Date
edad64c6e3 actualize changelog 2020-02-15 16:56:15 +06:00
8c06322586 now LiveLocation is deprecated in TelegramBotAPI and placed into TelegramBotAPI-extensions-api 2020-02-15 16:19:12 +06:00
9684e55c12 update group badge
update group badge

update group badge
2020-02-15 16:11:42 +06:00
d7d92cd83f fixes in readme 2020-02-15 15:49:29 +06:00
7229d96ce7 remove redundant .gitignore 2020-02-15 15:38:24 +06:00
c32ab031dd fill changelog 2020-02-15 15:37:15 +06:00
a8d7104145 extract RequestsExecutor extensions 2020-02-15 15:33:04 +06:00
ff550fafde add subproject TelegramBotAPI-extensions-api 2020-02-15 01:23:52 +06:00
1dbb0e669d started 0.23.3 2020-02-15 00:55:37 +06:00
723818f04f improve badge 2020-02-15 00:54:44 +06:00
0c107bc512 replace TelegramBotAPI to the separated subproject 2020-02-15 00:50:35 +06:00
945df1bc5f Add chat badge in README 2020-02-14 19:18:15 +06:00
239d740587 Make text in chat badge less 2020-02-14 19:15:36 +06:00
5fdcf252b2 Create chat.svg 2020-02-14 19:14:30 +06:00
a17ae07e50 InputMedia#media fix (version 0.23.2) 2020-02-14 12:06:54 +06:00
8bbfa2ee24 Create FUNDING.yml 2020-02-10 23:13:07 +06:00
4b908f9975 Now it is possible to send broadcast channels size for FlowsUpdatesFilter 2020-02-09 15:15:36 +06:00
542fcef6da optimize imports 2020-02-08 00:00:52 +06:00
0959c0b0d7 Merge pull request #64 from InsanusMokrassar/0.23.1
0.23.1
2020-02-07 23:12:13 +06:00
34f606545e additional fixes in live location 2020-02-07 22:45:57 +06:00
0e33b123e9 additional fixes in live location 2020-02-07 22:43:48 +06:00
d6bbb0cadc update LiveLocation logic 2020-02-07 22:36:15 +06:00
8fd6a09763 toInputFile specifying return types 2020-02-07 22:12:18 +06:00
aa333d7c58 fill CHANGELOG and update README 2020-02-07 11:00:21 +06:00
fe8c3392fa Actialize bot action tests 2020-02-07 10:49:16 +06:00
c2c7ac0d1e InvoiceOfPayment is renamed to InvoiceContent 2020-02-07 10:47:35 +06:00
04e4407b96 fill changelog about new actions 2020-02-07 10:36:31 +06:00
60a30f972f add additional methods for quiz poll 2020-02-07 10:33:36 +06:00
9ed1500bee add additional methods for regular poll 2020-02-07 10:31:22 +06:00
7d0009039f logical fixes 2020-02-07 10:12:21 +06:00
e43ad41d2f complete filling of requests extensions 2020-02-07 00:56:32 +06:00
c7d5fdd2e0 fill edit and stop live location methods 2020-02-07 00:40:47 +06:00
e7bdc85279 precomplete of games extensions 2020-02-07 00:29:50 +06:00
dcfa198c8c send game and other extensions 2020-02-07 00:25:24 +06:00
a846d0031c updates in sendInvoice and its extensions 2020-02-07 00:15:28 +06:00
0dd632eb46 add send invoice extensions 2020-02-07 00:01:21 +06:00
dfe5595fd3 add delete sticker from set 2020-02-06 23:55:17 +06:00
945dd05cfd add add sticker to set and set sticker position in set extensions 2020-02-06 23:54:14 +06:00
09c623c1d7 add create new sticker set extensions 2020-02-06 23:46:16 +06:00
269a4dd707 add upload sticker file extensions 2020-02-06 23:39:57 +06:00
2399dc0d0a add get sticker set extensions 2020-02-06 23:38:37 +06:00
3a0be49cc5 additions in sendSticker 2020-02-06 23:35:51 +06:00
28898ea2d4 add sendSticker extensions 2020-02-06 23:33:58 +06:00
679f282bd2 refactor delete extensions 2020-02-06 23:28:46 +06:00
02fa83c92a small refactor in PinChatMessage 2020-02-06 23:17:55 +06:00
69f81785bf rename RequestsExecutor#setChatPermissions -> RequestsExecutor#setDefaultChatMembersPermissions 2020-02-06 23:15:13 +06:00
86f1e3ea36 add get file info extensions 2020-02-06 23:12:49 +06:00
be4043f3c2 fix in RequestsExecutor#getUserProfilePhotos extension 2020-02-06 23:09:01 +06:00
b4d0ca507b add get user profile photos extensions 2020-02-06 23:08:13 +06:00
cc433d4091 add send bot action extensions 2020-02-06 23:06:29 +06:00
f8ffd5fec3 add send polls extensions 2020-02-06 22:52:10 +06:00
799eadd7a7 add send contact extensions 2020-02-06 22:44:26 +06:00
bc7cfc0d32 add send venue extensions 2020-02-06 22:40:19 +06:00
4ca8125637 add send location extensions and LiveLocation 2020-02-06 22:32:20 +06:00
5475f27a24 add send video note extensions 2020-02-06 21:41:46 +06:00
6d425cc0f6 add send video extensions 2020-02-06 21:36:18 +06:00
ff3ef6e957 add send voice extensions 2020-02-06 21:27:42 +06:00
28eecfa3ef add send animation extensions 2020-02-06 21:23:59 +06:00
56663d8e73 add send document extensions 2020-02-06 21:15:17 +06:00
2fd842746b add send audio extensions 2020-02-06 21:05:16 +06:00
5e5dc105a5 refactor type inside edit messages extensions 2020-02-06 20:36:29 +06:00
6cf836708d complete filling of until SendPhoto for usefull extensions 2020-02-06 14:25:17 +06:00
5e6ff01940 complete update methods 2020-02-06 14:05:36 +06:00
2cfabb1c2a update Chat dependency in methods 2020-02-06 13:38:52 +06:00
de1d6aa70c LeaveChat and ExportChatInviteLink now have one more extension 2020-02-06 13:31:53 +06:00
90d5833021 CommonMultipartFileRequest now is internal 2020-02-06 13:29:14 +06:00
527b718f55 chat methods now have additional usefull extensions 2020-02-06 13:27:58 +06:00
2eb2d25662 complete answers extensions 2020-02-06 12:54:55 +06:00
9c25254937 AnswerInlineQuery simple sending extensions 2020-02-06 12:38:56 +06:00
601958a513 AnswerCallbackQuery simple sending extensions 2020-02-06 12:12:20 +06:00
ab6688bbaa additional KtorUpdatesPoller method 2020-02-06 12:08:31 +06:00
4f2a8e49bc Add maven version badge 2020-02-04 13:46:07 +06:00
0ce9080efc Add awesome badge due to merged PR in kotlin awesome
https://github.com/KotlinBy/awesome-kotlin/pull/526
2020-02-04 13:42:06 +06:00
f2701b920f start 0.23.1 2020-02-01 14:14:45 +06:00
a3b29f7db5 update link to unsupported passport API changelog 2020-01-29 12:04:40 +06:00
43a36072f1 Merge pull request #63 from InsanusMokrassar/0.23.0
0.23.0
2020-01-23 22:37:34 +06:00
0c11be7fe4 rewrite work with Bot class 2020-01-23 22:32:45 +06:00
7a880ba2bd UnknownPollType now can be created only inside of library 2020-01-23 22:15:08 +06:00
1a258ae912 RequestPollKeyboardButton#requestPoll is required parameter for now 2020-01-23 22:09:06 +06:00
9dc3e1ecc6 fixes in KeyboardButtonPollType serialization 2020-01-23 21:52:28 +06:00
b9e674821b fix in createRequest for Poll 2020-01-23 20:45:02 +06:00
f4a731940e QuizPoll#correctOptionId now is nullable 2020-01-23 20:40:56 +06:00
43ef7656d0 startGettingUpdates now have parameter for pollAnswer 2020-01-23 20:13:32 +06:00
b9ab7f2955 AnonymousPollOption renamed to SimplePollOption 2020-01-23 20:11:24 +06:00
00886dcfb7 now user have correct serializer 2020-01-23 19:31:09 +06:00
46573512a2 fix in javaLocale extension 2020-01-23 19:14:33 +06:00
a8ae0a296a separated User object and additional fields for Bot representation 2020-01-23 19:08:02 +06:00
8687a2ba6b "KeyboardButton" now is sealed class 2020-01-23 18:06:22 +06:00
dbd9c72249 UpdatesFilter now support PollAnswerUpdate 2020-01-23 17:32:04 +06:00
7aef76f432 PollAnswerUpdate 2020-01-23 17:29:09 +06:00
aece0784ab fixes in PollContent#createResend, added Poll#createRequest 2020-01-23 17:25:57 +06:00
4e1dbb8741 PollAnswer 2020-01-23 17:17:24 +06:00
41db785696 "language" field im RawMessageEntity 2020-01-23 17:07:28 +06:00
4e39f77b53 SendRegularPoll, SendQuizPoll 2020-01-23 17:01:13 +06:00
258ab44bac added votes count field to poll 2020-01-23 16:40:57 +06:00
423efafa04 extend polls 2020-01-23 16:36:25 +06:00
229334e781 start 0.23.0 2020-01-23 16:00:46 +06:00
c4f22c2c43 Merge pull request #62 from InsanusMokrassar/0.22.2
0.22.2
2020-01-23 04:23:23 +06:00
2980b345a9 optimize imports 2020-01-23 04:23:06 +06:00
ca24416934 UpdatesFilter#unknownUpdateTypeCallback 2020-01-23 04:21:45 +06:00
c006b47429 fix in cashTag internal fun 2020-01-23 04:08:56 +06:00
8487ee1f31 fixes in calling of "asUpdate" 2020-01-23 04:01:24 +06:00
f4fe680cac UnknownCallbackQueryType 2020-01-23 03:59:59 +06:00
cf814fcecb update gradle.properties 2020-01-23 03:51:08 +06:00
a967b06d2e remove redundant line from changelog 2020-01-23 03:48:33 +06:00
83e5d40443 UnknownUpdate -> UnknownUpdateType, unknown types for messages and chats 2020-01-23 03:47:43 +06:00
a8ca45a4bd replace UnknownUpdate 2020-01-23 03:35:56 +06:00
961fa65415 UnknownUpdate 2020-01-23 03:31:56 +06:00
4182d66f6e cashtag entity type was added 2020-01-23 03:05:28 +06:00
971589fe99 start 0.22.2 2020-01-23 03:03:38 +06:00
257574324a Update README.md 2020-01-21 16:03:02 +06:00
cf3e372ca3 Added a cut for README 2020-01-21 16:01:53 +06:00
502a53fd62 fixes in new "asInputMedia" functions 2020-01-21 14:30:33 +06:00
353891eb37 Merge pull request #60 from InsanusMokrassar/0.22.1
0.22.1
2020-01-20 22:39:23 +06:00
5f593439a3 remove file link maker 2020-01-20 22:38:45 +06:00
f99873dd70 hotfix 2020-01-20 22:10:46 +06:00
d330cd2bfc hotfix 2020-01-20 20:14:52 +06:00
92224b95df PreviewFeature, message links 2020-01-20 16:35:36 +06:00
63e0f5c054 0.22.1 2020-01-20 14:42:38 +06:00
dd76e704a8 Update README.md 2020-01-17 08:29:22 +06:00
4845a61539 Update README.md 2020-01-17 08:24:38 +06:00
9dfb16f534 update publish scripts 2020-01-15 21:41:52 +06:00
50ae9ef955 Merge pull request #59 from InsanusMokrassar/0.22.0
0.22.0
2020-01-15 13:35:08 +06:00
f80bb18ca5 ResendableContent change fill in changelog 2020-01-15 13:30:28 +06:00
40eaffb8e3 EditChatMessage change fill in changelog 2020-01-15 13:27:29 +06:00
0c9f9f59c1 update changelog 0.22.0 type of title 2020-01-15 13:12:35 +06:00
12496f8261 make all serializers are internal 2020-01-15 13:03:42 +06:00
3fe7bd1382 AbleToBe -> Possibly and ForwardedMessage -> ForwardInfo 2020-01-15 12:52:52 +06:00
e3117f3679 migrate 0.21.1 -> 0.22.0 2020-01-15 12:31:17 +06:00
562459f0b7 update ktor 2020-01-15 12:28:06 +06:00
e98e61747c update README 2020-01-15 11:49:55 +06:00
e1082c3741 update README 2020-01-15 11:48:44 +06:00
3fa2071847 now most part of request have changed return types 2020-01-15 11:17:53 +06:00
4c60b8fd82 Merge branch 'master' into 0.21.1 2020-01-15 09:50:57 +06:00
cb30beaa31 one more fix for publishing 2020-01-13 23:21:57 +06:00
10df8cbc55 one more fix for publishing 2020-01-13 23:21:07 +06:00
4b66617db6 one more fix for publishing 2020-01-13 21:47:41 +06:00
9ddab0bf29 updates in publish script 2020-01-13 11:26:52 +06:00
e43d7350ed started 0.21.1 2020-01-08 12:11:57 +06:00
82129205fa add availability info about maven 2020-01-06 22:47:43 +06:00
034b30d65f update publishing scheme to be able to publish with signed artifacts 2020-01-06 22:44:31 +06:00
0d72c51448 Set theme jekyll-theme-cayman 2020-01-06 22:44:23 +06:00
fe11b088fc Update README.md 2020-01-05 21:39:04 +06:00
336f280b8a Update README.md 2020-01-05 21:30:17 +06:00
0f9e048274 Update README.md 2020-01-05 21:26:43 +06:00
f8b6073cd4 update compatibility info in README 2020-01-05 20:58:07 +06:00
0899a69762 update versions 2020-01-05 20:45:50 +06:00
031c61a872 Merge pull request #54 from InsanusMokrassar/0.21.0
0.21.0 TelegramBotAPI 4.5
2020-01-05 20:31:37 +06:00
33d8dcf977 update CHANGELOG 2020-01-05 20:30:42 +06:00
2f09504f08 fix in formatting of hashtag text 2020-01-05 20:28:44 +06:00
f4c11cacc6 fix in formatting of hashtag text 2020-01-05 20:18:05 +06:00
4ac01d5331 all fields in text sources are lazy 2020-01-05 20:07:51 +06:00
bb3ebb455e update CHANGELOG 2020-01-05 19:58:29 +06:00
7694b25d33 optimize imports 2020-01-05 19:51:32 +06:00
b095f07b9c add subcondition for adding subparts in raw message entities 2020-01-05 19:50:04 +06:00
72127ce133 rework in part of text message entities 2020-01-05 19:24:17 +06:00
398adf06ff Actualized work with pre type of text - now it is possible to use language for formatting of text 2020-01-03 00:27:24 +06:00
dbef69ffac fixed problem that usually string formatting did not trigger escaping of control characters 2020-01-03 00:04:49 +06:00
f68edebd24 RawMessageEntity will not throw exception 2020-01-02 23:58:16 +06:00
482d924070 refactor and preparing to multilevel message entities 2020-01-02 23:55:26 +06:00
e7495468a2 added support of strikethrough and underline 2020-01-02 23:10:39 +06:00
bba37d8889 all TelegramMediaFile instances now have field fileUniqueId, which represents file_unique_id field from API 2020-01-01 22:26:19 +06:00
198e15a937 now ChatPhoto have two additional fields: smallFileUniqueId and bigFileUniqueId 2020-01-01 22:20:08 +06:00
5ee472305c add restrictions check in SetChatAdministratorCustomTitle 2020-01-01 21:56:53 +06:00
47428dd6f9 now any administrator object instance have nullable field 2020-01-01 21:51:11 +06:00
b4e4bed622 added the new request SetChatAdministratorCustomTitle to manage the custom titles of administrators promoted by the bot. 2020-01-01 21:45:39 +06:00
4dd2a8437c added the field slowModeDelay to the ExtendedSupergroupChat objects 2020-01-01 21:38:05 +06:00
8b93922f82 starts 0.21.0 2020-01-01 21:28:00 +06:00
43b08e9319 Now setWebhook supports custom listen address even if certificate was not provided 2020-01-01 14:43:32 +06:00
62d474b7cc Merge pull request #52 from InsanusMokrassar/0.20.4
0.20.4
2020-01-01 14:34:07 +06:00
0066e814b3 a little reorder of arguments in setWebhook 2020-01-01 14:12:37 +06:00
ef7e94ba68 now setWebhook supports setting up of path for listening 2020-01-01 14:07:17 +06:00
27aba72a5a started 0.20.4 2020-01-01 14:06:03 +06:00
680e960037 [0.20.3] hotfix in LeftChatMember parents 2019-12-16 23:24:40 +06:00
ff47168fdc update build status place 2019-12-14 00:13:10 +06:00
a68c31f9d1 0.20.2 - MessageToEditNotFoundException 2019-12-13 23:55:06 +06:00
ac915b79f7 fix of exceptions catching 2019-12-13 23:54:02 +06:00
1659f6f909 a little fix 2019-12-13 23:36:31 +06:00
5249fb517f 0.20.2 - MessageIsNotModifierException 2019-12-13 23:34:58 +06:00
fdf45d7566 a little fix in changelog 2019-12-11 17:05:48 +06:00
dc93997b8c Merge pull request #48 from InsanusMokrassar/0.20.1
0.20.1
2019-12-11 17:05:12 +06:00
621 changed files with 11530 additions and 2891 deletions

5
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1,5 @@
# These are supported funding model platforms
patreon: InsanusMokrassar
custom: ['https://paypal.me/InsanusMokrassar?locale.x=ru_RU']

View File

@@ -1,5 +1,190 @@
# TelegramBotAPI changelog
## 0.23.0 TelegramBotAPI 4.6
* `Poll` now is sealed class
* `RegularPoll` type was added to represent polls with type `regular`
* `QuizPoll` type was added to represent polls with type `quiz`
* `UnknownPollType` type was added to represent polls which are unknown in current version
* `AnonymousPollOption` was renamed to `SimplePollOption`
* `SendPoll` was rewritten as sealed class
* `SendRegularPoll` was created and represent `sendPoll` method with type `regular`
* `SendQuizPoll` was created and represent `sendPoll` method with type `quiz`
* `Poll#createRequest` extension was added
* `PollAnswerUpdate` type of update was added
* `PollAnswer` type was added
* `UpdatesFilter` now support work with `PollAnswerUpdate`
* `language` field in PreTextSource now correctly passed from telegram MessageEntities
* `KeyboardButton` now is sealed class
* Fixed problem of incorrect representation of this class (any type of request can be created separately)
* Added new types of `KeyboardButton`:
* `UnknownKeyboardButton`
* `SimpleKeyboardButton`
* `RequestContactKeyboardButton`
* `RequestLocationKeyboardButton`
* `RequestPollKeyboardButton`
* Added new type `KeyboardButtonPollType`:
* `UnknownKeyboardButtonPollType`
* `RegularKeyboardButtonPollType`
* `QuizKeyboardButtonPollType`
* `User` now is sealed class
* `CommonUser` was added as representation of default `User`
* `Bot` was added as representation of bot user (it is sealed class)
* `ExtendedBot` with additional info
* `CommonBot` with simple info
* `GetMe` now return `ExtendedBot` object
* Now extension `javaLocale` is extension for `CommonUser`
### 0.23.1
* Versions updates:
* Klock `1.8.6` -> `1.8.7`
* Ktor `1.3.0` -> `1.3.1`
* Now it is possible to get updates by polling with custom executor engine
* `CommonMultipartFileRequest` now is internal
* Added `LiveLocation` class for more useful tracking live locations
* `InvoiceOfPayment` is renamed to `InvoiceContent` and now is `MessageContent` instead of `PaymentInfo`
* `SendInvoice` now return `ContentMessage<InvoiceContent>`
* `paymentInfo` inside of `CommonMessageImpl` now can be set only to `SuccessfulPaymentInfo`
* Added `RecordVideoNoteAction` and `UploadVideoNoteAction` for `record_video_note` and `upload_video_note` actions
* For most part of messages was added `RequestsExecutor` extensions for more useful way of usage
* `toInputFile` extensions now will return more exact types
* Now it is possible to send broadcast channels size for `FlowsUpdatesFilter`
### 0.23.2
* Fixes in `InputMedia` - `media` field was not included to serialization
### 0.23.3 Project separating prepare version
__API Extensions__
* Project created
* For `SendPhoto` was added new functions for uploading of `MultipartFile`
* `deleteWebhook` extension for `RequestsExecutor` was added
__Telegram Bot API__
* All `RequestsExecutor` extensions related to Telegram Bots API was replaced into `API Extensions` project
## 0.22.0
* **`KtorCallFactory` must return `HttpStatement` instead of `HttpClientCall`**
* `SendMessage` was renamed to `SendTextMessage` and previous `SendMessage` is deprecated
* All `AbleToBe*` interfaces was renamed to `Possibly*`
* `AbleToBeEditedMessage` -> `PossiblyEditedMessage`
* `AbleToBeForwardedMessage` -> `PossiblyForwardedMessage`
* `AbleToBeMarkedUp` -> `PossiblyMarkedUp`
* `AbleToBeEditedMessage` -> `PossiblyEditedMessage`
* `ForwardedMessage` type was renamed to `ForwardInfo`
* `AnonymousForwardedMessage` -> `AnonymousForwardInfo`
* `UserForwardedMessage` -> `UserForwardInfo`
* `ForwardedFromChannelMessage` -> `ForwardFromChannelInfo`
* `PossiblyForwardedMessage#forwarded` field now renamed to `forwardInfo`
* All serializers in library now are `internal`. **If you have used some of them or I have marked as internal by a
mistake - don't hesitate to say this.**
* `EditChatMessage` now have generic type and extends `SimpleRequest<ContentMessage<GenericType>>`
* `ResendableContent` now extends `Request<out Message>` instead of `Request<Message>`
* Most part of requests have changed return type. They are listed below:
<details>
* `ForwardMessage`
* `GetChatAdministrators`
* `EditChatMessageLiveLocation`
* `StopChatMessageLiveLocation`
* `EditChatMessageText`
* `EditChatMessageCaption`
* `EditChatMessageMedia`
* `EditChatMessageReplyMarkup`
* `SendAnimation`
* `SendAudio`
* `SendContact`
* `SendLocation`
* `SendTextMessage`
* `SendPoll`
* `SendVenue`
* `SendGame`
* `SendDocument`
* `SendMediaGroup`
* `SendPhoto`
* `SendVideo`
* `SendVideoNote`
* `SendVoice`
* `SendSticker`
</details>
* Changed type of `createResend`
<details>
* `GameContent`
* `LocationContent`
* `PollContent`
* `TextContent`
* `VenueContent`
* `AnimationContent`
* `AudioContent`
* `DocumentContent`
* `ContactContent`
* `PhotoContent`
* `VideoContent`
* `VideoNoteContent`
* `VoiceContent`
* `StickerContent`
</details>
* Version updates:
* Ktor `1.2.6` -> `1.3.0`
### 0.22.1 MediaContent#asInputMedia
* All `MediaContent` instances now can create their `InputMedia` analog
* New annotation `PreviewFeature` was added to mark new thing as preview for the time
while they can work incorrectly
* Added links utils:
* `makeLinkToMessage` have two signatures - for direct creating using username and for abstract creating using
chat id
### 0.22.2 CashTag and independent updates handling
* `cashtag` entity type was added
* Several `Unknown*` realizations was added:
* `UnknownUpdateType`
* `UnknownMessageType`
* `UnknownChatType`
* `UnknownCallbackQueryType`
* `UpdatesFilter` now have one additional income callback: `unknownUpdateTypeCallback`
* `createSimpleUpdateFilter` can receive one more callback: `unknownCallback` (for `unknownUpdateTypeCallback`)
## 0.21.0 TelegramBotAPI 4.5
* _**All `MessageEntity`'es now are replaced with `TextPart`**_
* Added support of strikethrough and underline
* Added `UnderlineTextSource`
* Added `StrikethroughTextSource`
* Added support in `RawMessageEntity`
* Added support of `MarkdownV2`
* Now will not be thrown exception when there is income unknown type of `RawMessageEntity`. Instead of this will be
created `RegularTextSource` with the same text
* Fixed problem that usually string formatting did not trigger escaping of control characters
* Actualized work with `pre` type of text - now it is possible to use `language` for formatting of text
* Removed constructor of `TextMentionTextSource`, which was deprecated previously
* All `TelegramMediaFile` instances now have field `fileUniqueId`, which represents `file_unique_id` field from API
* Now `ChatPhoto` have two additional fields: `smallFileUniqueId` and `bigFileUniqueId`
* Now any administrator object instance have `customTitle` nullable field
* Added the new request `SetChatAdministratorCustomTitle` to manage the custom titles of administrators promoted by the
bot.
* Added the field `slowModeDelay` to the `ExtendedSupergroupChat` objects.
* `CaptionedInput` now have extension `fullEntitiesList` which will return list of `TextPart` with `RegularSource`'s
* `TextPart` added - it will be used as part of some text and can be not related to telegram bot
* `MultilevelTextSource` was added - it is type of `TextSource`, which can have subsources as parts of this text
* In all `TextSource`s all fields now are lazy for avoiding of potential risk for performance issues
* Updates in versions:
* Coroutines `1.3.2` -> `1.3.3`
* Klock `1.8.0` -> `1.8.6`
* UUID `0.0.6` -> `0.0.7`
## 0.20.0 MPP Migration
* Time library change: `joda-time` -> `com.soywiz.korlibs.klock:klock`
@@ -13,7 +198,7 @@
* `User` now implement `PrivateChat`
* `TextMentionMessageEntity` now accept `PrivateChat` instead of `User` in main constructor
* `TextMentionMessageEntity` now contains not user, but contains `PrivateChat`
* Fixeed: `TextMentionMessageEntity#asHtmlSource` previously worked incorrect
* Fixed: `TextMentionMessageEntity#asHtmlSource` previously worked incorrect
* Abstraction `TextSource`
* `MessageEntity` now extends `TextSource`
* `createFormattedText` method now accept `List<TextSource>`
@@ -22,6 +207,21 @@
* A lot of `TextSource` implementors was added. More info [here](src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/)
* All `MessageEntity` implementations now are using new `TextSource` analogues as delegates
### 0.20.2
* New exception type `MessageIsNotModifierException` was added
* New exception type `MessageToEditNotFoundException` was added
* Now exceptions in requests will be caught correctly
### 0.20.3
* Now `LeftChatMamber` is a `CommonEvent`
### 0.20.4
* Now `setWebhook` supports setting up of path for listening
* Now `setWebhook` supports custom listen address even if certificate was not provided
## 0.19.0 ImplicitReflection removing
* Total rework of serialization for requests. Now all `SimpleRequest` children have:

126
README.md
View File

@@ -1,7 +1,12 @@
# TelegramBotAPI
[![Awesome Kotlin Badge](https://kotlin.link/awesome-kotlin.svg)](https://github.com/KotlinBy/awesome-kotlin)
[![Download](https://api.bintray.com/packages/insanusmokrassar/StandardRepository/TelegramBotAPI/images/download.svg) ](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI/_latestVersion)
[![Build Status](https://jenkins.insanusmokrassar.space/buildStatus/icon?job=TelegramBotAPI_master__publishing)](https://jenkins.insanusmokrassar.space/job/TelegramBotAPI_master__publishing/)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI)
[![Build Status](https://jenkins.insanusmokrassar.com/buildStatus/icon?job=TelegramBotAPI_master__publishing)](https://jenkins.insanusmokrassar.com/job/TelegramBotAPI_master__publishing/)
[![Chat in Telegram](badges/chat.svg)](https://t.me/InMoTelegramBotAPI)
## What is it?
@@ -10,9 +15,9 @@ moments are describing by official [Telegram Bot API](https://core.telegram.org/
## Compatibility
This version compatible with [29th of July 2019 update of TelegramBotAPI](https://core.telegram.org/bots/api#july-29-2019).
This version compatible with [23th of January 2020 update of TelegramBotAPI (version 4.6)](https://core.telegram.org/bots/api#january-23-2020).
There is Telegram Passport API exception of implemented functionality, which was presented in
[August 2018 update of TelegramBotAPI](https://core.telegram.org/bots/api#august-27-2018) update. It will be implemented
[August 2018 update of TelegramBotAPI](https://core.telegram.org/bots/api-changelog#august-27-2018) update. It will be implemented
as soon as possible. All APIs that are not included are presented
[wiki](https://github.com/InsanusMokrassar/TelegramBotAPI/wiki/Not-included-API).
@@ -25,27 +30,18 @@ like inserting of additional libraries (like `kotlin stdlib`). In the examples w
[![Download](https://api.bintray.com/packages/insanusmokrassar/StandardRepository/TelegramBotAPI/images/download.svg) ](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI/_latestVersion)
Currently, last versions of library are not included into the Maven repository (for the reason difficult in publishing
Currently, last versions of library can be available from the Maven repository with errors (for the reason difficult in publishing
of signed artifacts in Bintray). You can:
* Use earlier version (available version you can find
[here](https://mvnrepository.com/artifact/com.github.insanusmokrassar/TelegramBotAPI))
* Add `jCenter` repository in build config
### Maven
### TelegramBotAPI
To use last versions you will need to add several lines in repositories block of your pom.xml:
Contains core and most required things, like types, requests and `KtorRequestsExecutor`.
```xml
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray</name>
<url>http://jcenter.bintray.com</url>
</repository>
```
#### Maven
Dependency config presented here:
@@ -57,13 +53,11 @@ Dependency config presented here:
</dependency>
```
### Gradle
#### Gradle
To use last versions you will need to add one line in repositories block of your build.gradle:
To use last versions you will need to add one line in repositories block of your `build.gradle`:
```groovy
jcenter()
```
`jcenter()` or `mavenCentral()`
And add next line to your dependencies block:
@@ -77,24 +71,59 @@ or for old gradle:
compile "com.github.insanusmokrassar:TelegramBotAPI:$telegrambotapi_version"
```
### API extensions
Contains extensions for `RequestsExecutor` which usually more obvious than original ones in `TelegramBotAPI` and more
useful.
#### Maven
Dependency config presented here:
```xml
<dependency>
<groupId>com.github.insanusmokrassar</groupId>
<artifactId>TelegramBotAPI-extensions-api</artifactId>
<version>${telegrambotapi.version}</version>
</dependency>
```
#### Gradle
To use last versions you will need to add one line in repositories block of your `build.gradle`:
`jcenter()` or `mavenCentral()`
And add next line to your dependencies block:
```groovy
implementation "com.github.insanusmokrassar:TelegramBotAPI-extensions-api:$telegrambotapi_version"
```
or for old gradle:
```groovy
compile "com.github.insanusmokrassar:TelegramBotAPI-extensions-api:$telegrambotapi_version"
```
## How to work with library?
For now, this library have no some API god-object. Instead of this, this library has several
important objects:
* [RequestsExecutor](src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/RequestsExecutor.kt)
* [Requests](src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests)
* [Types](src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types)
* [RequestsExecutor](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/RequestsExecutor.kt)
* [Requests](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests)
* [Types](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types)
### Types
Types declare different objects representation. For example, `Chat` for now represented as
interface and has several realisations:
* PrivateChat
* GroupChat
* SupergroupChat
* ChannelChat
* `PrivateChat`
* `GroupChat`
* `SupergroupChat`
* `ChannelChat`
Instead of common garbage with all information as in original [Chat](https://core.telegram.org/bots/api#chat),
here it was separated for more obvious difference between chats types and their possible content.
@@ -111,10 +140,16 @@ val requestsExecutor: RequestsExecutor = ...
requestsExecutor.execute(GetMe())
```
The result type of [GetMe](src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetMe) request is
[User](src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/User). In fact, in this result must contain
`isBot` equal to `true` always.
Or you can use new syntax (available by implementing of project [API extensions](#API-extensions):
```kotlin
val bot: RequestsExecutor = ...
bot.getMe()
```
The result type of [GetMe (and getMe extension)](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetMe.kt)
request is
[ExtendedBot](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/User.kt).
### RequestsExecutor
@@ -123,31 +158,38 @@ realisation of `RequestsExecutor`, but it is possible, that in future it will be
project. How to create `RequestsExecutor`:
```kotlin
val requestsExecutor = KtorRequestsExecutor(TOKEN)
val requestsExecutor = KtorRequestsExecutor(
TelegramAPIUrlsKeeper(TOKEN)
)
```
Here `KtorRequestsExecutor` - default realisation with Ktor. `TOKEN` is just a token of bot which was retrieved
according to [instruction](https://core.telegram.org/bots#3-how-do-i-create-a-bot).
Here:
Besides, for correct usage of this, you must implement in your project both one of engines for client and server
Ktor libraries:
* `KtorRequestsExecutor` - default realisation with [ktor](https://ktor.io)
* `TelegramAPIUrlsKeeper` - special keeper, which you can save and use for getting files full urls (`resolveFileURL`
extension inside of `PathedFile.kt`)
* `TOKEN` is just a token of bot which was retrieved according to
[instruction](https://core.telegram.org/bots#3-how-do-i-create-a-bot).
By default, for JVM there is implemented `CIO` client engine, but there is not server engine. Both can be changed like
here:
```groovy
dependencies {
// ...
implementation "io.ktor:ktor-server-cio:$ktor_version"
implementation "io.ktor:ktor-client-okhttp:$ktor_version"
implementation "io.ktor:ktor-server-cio:$ktor_version" // for implementing of server engine
implementation "io.ktor:ktor-client-okhttp:$ktor_version" // for implementing of additional client engine
// ...
}
```
It is able to avoid using of `server` dependency in case if will not be used `Webhook`s. In this case,
You can avoid using of `server` dependency in case if you will not use `Webhook`s. In this case,
dependencies list will be simplify:
```groovy
dependencies {
// ...
implementation "io.ktor:ktor-client-okhttp:$ktor_version"
implementation "io.ktor:ktor-client-okhttp:$ktor_version" // for implementing of additional client engine
// ...
}
```
@@ -170,7 +212,7 @@ Currently webhook method contains `UpdatesFilter` as necessary argument for gett
separate getting updates for media groups - they are accumulating with debounce in one second
(for being sure that all objects of media group was received).
Updates polling also support `UpdatesFilter` but you must not use it and can get updates directly
Updates polling also support `UpdatesFilter` but it is not required to use it and you can get updates directly
in `UpdateReceiver`, which you will provide to `startGettingOfUpdates` method
### Webhook set up
@@ -203,6 +245,6 @@ Here:
* `WEBHOOK_URL` - the url which will be used by Telegram system to send updates
* `INTERNAL_PORT` - the port which will be used in bot for listening of updates
* `filter` - instance of [UpdatesFilter](src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/extensions/UpdatesFilter.kt),
* `filter` - instance of [UpdatesFilter](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/UpdatesFilter.kt),
which will be used to filter incoming updates
* `ENGINE_FACTORY` - used factory name, for example, `CIO` in case of usage `io.ktor:ktor-server-cio` as server engine

View File

@@ -0,0 +1,48 @@
buildscript {
repositories {
mavenLocal()
jcenter()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version"
}
}
plugins {
id "org.jetbrains.kotlin.multiplatform" version "$kotlin_version"
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version"
}
project.version = "$library_version"
project.group = "com.github.insanusmokrassar"
apply from: "publish.gradle"
repositories {
mavenLocal()
jcenter()
mavenCentral()
maven { url "https://kotlin.bintray.com/kotlinx" }
}
kotlin {
jvm()
js()
sourceSets {
commonMain {
dependencies {
implementation kotlin('stdlib')
if (project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") {
api "${project.group}:TelegramBotAPI:$library_version"
} else {
implementation project(":TelegramBotAPI")
}
}
}
}
}

View File

@@ -0,0 +1,57 @@
apply plugin: 'maven-publish'
task javadocsJar(type: Jar) {
classifier = 'javadoc'
}
afterEvaluate {
project.publishing.publications.all {
// rename artifacts
groupId "${project.group}"
if (it.name.contains('kotlinMultiplatform')) {
artifactId = "${project.name}"
} else {
artifactId = "${project.name}-$name"
}
}
}
publishing {
publications.all {
artifact javadocsJar
pom.withXml {
asNode().children().last() + {
resolveStrategy = Closure.DELEGATE_FIRST
description "API extensions which provide work with RequestsExecutor of TelegramBotAPI almost like it is described in original Telegram Bot API reference"
name "Telegram Bot API Extensions for API"
url "https://insanusmokrassar.github.io/TelegramBotAPI"
scm {
developerConnection "scm:git:[fetch=]https://github.com/insanusmokrassar/TelegramBotAPI.git[push=]https://github.com/insanusmokrassar/TelegramBotAPI.git"
url "https://github.com/insanusmokrassar/TelegramBotAPI.git"
}
developers {
developer {
id "InsanusMokrassar"
name "Ovsiannikov Aleksei"
email "ovsyannikov.alexey95@gmail.com"
}
}
licenses {
license {
name "Apache Software License 2.0"
url "https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"
}
}
}
}
}
}

View File

@@ -0,0 +1 @@
{"bintrayConfig":{"repo":"StandardRepository","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/TelegramBotAPI"},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API Extensions for API","description":"API extensions which provide work with RequestsExecutor of TelegramBotAPI almost like it is described in original Telegram Bot API reference","url":"https://insanusmokrassar.github.io/TelegramBotAPI","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]},"type":"Multiplatform"}

View File

@@ -0,0 +1,55 @@
apply plugin: 'com.jfrog.bintray'
apply from: "maven.publish.gradle"
bintray {
user = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER')
key = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY')
filesSpec {
from "${buildDir}/publications/"
eachFile {
String directorySubname = it.getFile().parentFile.name
if (it.getName() == "module.json") {
if (directorySubname == "kotlinMultiplatform") {
it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.module")
} else {
it.setPath("${project.name}-${directorySubname}/${project.version}/${project.name}-${directorySubname}-${project.version}.module")
}
} else {
if (directorySubname == "kotlinMultiplatform" && it.getName() == "pom-default.xml") {
it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.pom")
} else {
it.exclude()
}
}
}
into "${project.group}".replace(".", "/")
}
pkg {
repo = "StandardRepository"
name = "${project.name}"
vcsUrl = "https://github.com/InsanusMokrassar/TelegramBotAPI"
licenses = ["Apache-2.0"]
version {
name = "${project.version}"
released = new Date()
vcsTag = "${project.version}"
gpg {
sign = true
passphrase = project.hasProperty('signing.gnupg.passphrase') ? project.property('signing.gnupg.passphrase') : System.getenv('signing.gnupg.passphrase')
}
}
}
}
bintrayUpload.doFirst {
publications = publishing.publications.collect {
if (it.name.contains('kotlinMultiplatform')) {
null
} else {
it.name
}
} - null
}
bintrayUpload.dependsOn publishToMavenLocal

View File

@@ -0,0 +1,28 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.DeleteMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
suspend fun RequestsExecutor.deleteMessage(
chatId: ChatIdentifier,
messageId: MessageIdentifier
) = execute(
DeleteMessage(chatId, messageId)
)
suspend fun RequestsExecutor.deleteMessage(
chat: Chat,
messageId: MessageIdentifier
) = deleteMessage(chat.id, messageId)
suspend fun RequestsExecutor.deleteMessage(
message: Message
) = deleteMessage(message.chat, message.messageId)
suspend fun Message.delete(
requestsExecutor: RequestsExecutor
) = requestsExecutor.deleteMessage(this)

View File

@@ -0,0 +1,50 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.ForwardMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
suspend fun RequestsExecutor.forwardMessage(
fromChatId: ChatIdentifier,
toChatId: ChatIdentifier,
messageId: MessageIdentifier,
disableNotification: Boolean = false
) = execute(
ForwardMessage(fromChatId, toChatId, messageId, disableNotification)
)
suspend fun RequestsExecutor.forwardMessage(
fromChat: Chat,
toChatId: ChatIdentifier,
messageId: MessageIdentifier,
disableNotification: Boolean = false
) = forwardMessage(fromChat.id, toChatId, messageId, disableNotification)
suspend fun RequestsExecutor.forwardMessage(
fromChatId: ChatIdentifier,
toChat: Chat,
messageId: MessageIdentifier,
disableNotification: Boolean = false
) = forwardMessage(fromChatId, toChat.id, messageId, disableNotification)
suspend fun RequestsExecutor.forwardMessage(
fromChat: Chat,
toChat: Chat,
messageId: MessageIdentifier,
disableNotification: Boolean = false
) = forwardMessage(fromChat.id, toChat.id, messageId, disableNotification)
suspend fun RequestsExecutor.forwardMessage(
toChatId: ChatIdentifier,
message: Message,
disableNotification: Boolean = false
) = forwardMessage(message.chat, toChatId, message.messageId, disableNotification)
suspend fun RequestsExecutor.forwardMessage(
toChat: Chat,
message: Message,
disableNotification: Boolean = false
) = forwardMessage(message.chat, toChat, message.messageId, disableNotification)

View File

@@ -0,0 +1,6 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.GetMe
suspend fun RequestsExecutor.getMe() = execute(GetMe())

View File

@@ -0,0 +1,27 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.GetUpdates
import com.github.insanusmokrassar.TelegramBotAPI.types.ALL_UPDATES_LIST
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
suspend fun RequestsExecutor.getUpdates(
offset: UpdateIdentifier? = null,
limit: Int? = null,
timeout: Int? = null,
allowed_updates: List<String>? = ALL_UPDATES_LIST
) = execute(
GetUpdates(
offset, limit, timeout, allowed_updates
)
)
suspend fun RequestsExecutor.getUpdates(
lastUpdate: Update,
limit: Int? = null,
timeout: Int? = null,
allowed_updates: List<String>? = ALL_UPDATES_LIST
) = getUpdates(
lastUpdate.updateId + 1, limit, timeout, allowed_updates
)

View File

@@ -0,0 +1,135 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.LiveLocation.editLiveLocation
import com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.LiveLocation.stopLiveLocation
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendLocation
import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.LocationContent
import com.soywiz.klock.DateTime
import com.soywiz.klock.TimeSpan
import io.ktor.utils.io.core.Closeable
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import kotlin.math.ceil
private val livePeriodDelayMillis = (livePeriodLimit.last - 60L) * 1000L
class LiveLocation internal constructor(
private val requestsExecutor: RequestsExecutor,
scope: CoroutineScope,
autoCloseTimeDelay: Double,
initMessage: ContentMessage<LocationContent>
) : Closeable {
private val doWhenClose = {
scope.launch {
requestsExecutor.stopLiveLocation(message)
}
}
private val autoCloseTime = DateTime.now() + TimeSpan(autoCloseTimeDelay)
val leftUntilCloseMillis: TimeSpan
get() = autoCloseTime - DateTime.now()
var isClosed: Boolean = false
private set
get() = field || leftUntilCloseMillis.millisecondsLong < 0L
private var message: ContentMessage<LocationContent> = initMessage
val lastLocation: Location
get() = message.content.location
suspend fun updateLocation(
location: Location,
replyMarkup: InlineKeyboardMarkup? = null
): Location {
if (!isClosed) {
message = requestsExecutor.editLiveLocation(
message,
location,
replyMarkup
)
return lastLocation
} else {
error("LiveLocation is closed")
}
}
override fun close() {
if (isClosed) {
return
}
isClosed = true
doWhenClose()
}
}
suspend fun RequestsExecutor.startLiveLocation(
scope: CoroutineScope,
chatId: ChatIdentifier,
latitude: Double,
longitude: Double,
liveTimeMillis: Long = livePeriodDelayMillis,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
): LiveLocation {
val liveTimeAsDouble = liveTimeMillis.toDouble()
val locationMessage = execute(
SendLocation(
chatId,
latitude,
longitude,
ceil(liveTimeAsDouble / 1000).toLong(),
disableNotification,
replyToMessageId,
replyMarkup
)
)
return LiveLocation(
this,
scope,
liveTimeAsDouble,
locationMessage
)
}
suspend fun RequestsExecutor.startLiveLocation(
scope: CoroutineScope,
chat: Chat,
latitude: Double,
longitude: Double,
liveTimeMillis: Long = livePeriodDelayMillis,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
): LiveLocation = startLiveLocation(
scope, chat.id, latitude, longitude, liveTimeMillis, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.startLiveLocation(
scope: CoroutineScope,
chatId: ChatId,
location: Location,
liveTimeMillis: Long = livePeriodDelayMillis,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
): LiveLocation = startLiveLocation(
scope, chatId, location.latitude, location.longitude, liveTimeMillis, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.startLiveLocation(
scope: CoroutineScope,
chat: Chat,
location: Location,
liveTimeMillis: Long = livePeriodDelayMillis,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
): LiveLocation = startLiveLocation(
scope, chat.id, location.latitude, location.longitude, liveTimeMillis, disableNotification, replyToMessageId, replyMarkup
)

View File

@@ -0,0 +1,34 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.StopPoll
import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
suspend fun RequestsExecutor.stopPoll(
chatId: ChatIdentifier,
messageId: MessageIdentifier,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(
StopPoll(chatId, messageId, replyMarkup)
)
suspend fun RequestsExecutor.stopPoll(
chat: Chat,
messageId: MessageIdentifier,
replyMarkup: InlineKeyboardMarkup? = null
) = stopPoll(chat.id, messageId, replyMarkup)
suspend fun RequestsExecutor.stopPoll(
chatId: ChatId,
message: Message,
replyMarkup: InlineKeyboardMarkup? = null
) = stopPoll(chatId, message.messageId, replyMarkup)
suspend fun RequestsExecutor.stopPoll(
chat: Chat,
message: Message,
replyMarkup: InlineKeyboardMarkup? = null
) = stopPoll(chat.id, message.messageId, replyMarkup)

View File

@@ -0,0 +1,22 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.answers
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.AnswerCallbackQuery
import com.github.insanusmokrassar.TelegramBotAPI.types.CallbackQuery.CallbackQuery
import com.github.insanusmokrassar.TelegramBotAPI.types.CallbackQueryIdentifier
suspend fun RequestsExecutor.answerCallbackQuery(
callbackQueryId: CallbackQueryIdentifier,
text: String? = null,
showAlert: Boolean? = null,
url: String? = null,
cachedTimeSeconds: Int? = null
) = execute(AnswerCallbackQuery(callbackQueryId, text, showAlert, url, cachedTimeSeconds))
suspend fun RequestsExecutor.answerCallbackQuery(
callbackQuery: CallbackQuery,
text: String? = null,
showAlert: Boolean? = null,
url: String? = null,
cachedTimeSeconds: Int? = null
) = answerCallbackQuery(callbackQuery.id, text, showAlert, url, cachedTimeSeconds)

View File

@@ -0,0 +1,29 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.answers
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.AnswerInlineQuery
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.abstracts.InlineQuery
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueryIdentifier
suspend fun RequestsExecutor.answerInlineQuery(
inlineQueryID: InlineQueryIdentifier,
results: List<InlineQueryResult> = emptyList(),
cachedTime: Int? = null,
isPersonal: Boolean? = null,
nextOffset: String? = null,
switchPmText: String? = null,
switchPmParameter: String? = null
) = execute(
AnswerInlineQuery(inlineQueryID, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)
)
suspend fun RequestsExecutor.answerInlineQuery(
inlineQuery: InlineQuery,
results: List<InlineQueryResult> = emptyList(),
cachedTime: Int? = null,
isPersonal: Boolean? = null,
nextOffset: String? = null,
switchPmText: String? = null,
switchPmParameter: String? = null
) = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)

View File

@@ -0,0 +1,23 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.answers.payments
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.AnswerPreCheckoutQueryError
import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.AnswerPreCheckoutQueryOk
import com.github.insanusmokrassar.TelegramBotAPI.types.PreCheckoutQueryId
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.PreCheckoutQuery
suspend fun RequestsExecutor.answerPreCheckoutQueryOk(
id: PreCheckoutQueryId
) = execute(AnswerPreCheckoutQueryOk(id))
suspend fun RequestsExecutor.answerPreCheckoutQueryOk(
preCheckoutQuery: PreCheckoutQuery
) = answerPreCheckoutQueryOk(preCheckoutQuery.id)
suspend fun RequestsExecutor.answerPreCheckoutQueryError(
id: PreCheckoutQueryId,
error: String
) = execute(AnswerPreCheckoutQueryError(id, error))
suspend fun RequestsExecutor.answerPreCheckoutQueryError(
preCheckoutQuery: PreCheckoutQuery,
error: String
) = answerPreCheckoutQueryError(preCheckoutQuery.id, error)

View File

@@ -0,0 +1,28 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.answers.payments
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.AnswerShippingQueryError
import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.AnswerShippingQueryOk
import com.github.insanusmokrassar.TelegramBotAPI.types.ShippingQueryIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.ShippingOption
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.ShippingQuery
suspend fun RequestsExecutor.answerShippingQueryOk(
id: ShippingQueryIdentifier,
shippingOptions: List<ShippingOption>
) = execute(AnswerShippingQueryOk(id, shippingOptions))
suspend fun RequestsExecutor.answerShippingQueryOk(
shippingQuery: ShippingQuery,
shippingOptions: List<ShippingOption>
) = answerShippingQueryOk(shippingQuery.id, shippingOptions)
suspend fun RequestsExecutor.answerShippingQueryError(
id: ShippingQueryIdentifier,
error: String
) = execute(AnswerShippingQueryError(id, error))
suspend fun RequestsExecutor.answerShippingQueryError(
shippingQuery: ShippingQuery,
error: String
) = answerShippingQueryError(shippingQuery.id, error)

View File

@@ -0,0 +1,14 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.ExportChatInviteLink
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
suspend fun RequestsExecutor.exportChatInviteLink(
chatId: ChatIdentifier
) = execute(ExportChatInviteLink(chatId))
suspend fun RequestsExecutor.exportChatInviteLink(
chat: PublicChat
) = exportChatInviteLink(chat.id)

View File

@@ -0,0 +1,14 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.LeaveChat
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
suspend fun RequestsExecutor.leaveChat(
chatId: ChatIdentifier
) = execute(LeaveChat(chatId))
suspend fun RequestsExecutor.leaveChat(
chat: PublicChat
) = leaveChat(chat.id)

View File

@@ -0,0 +1,14 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.get
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.get.GetChat
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
suspend fun RequestsExecutor.getChat(
chatId: ChatIdentifier
) = execute(GetChat(chatId))
suspend fun RequestsExecutor.getChat(
chat: Chat
) = getChat(chat.id)

View File

@@ -0,0 +1,14 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.get
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.get.GetChatAdministrators
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
suspend fun RequestsExecutor.getChatAdministrators(
chatId: ChatIdentifier
) = execute(GetChatAdministrators(chatId))
suspend fun RequestsExecutor.getChatAdministrators(
chat: PublicChat
) = getChatAdministrators(chat.id)

View File

@@ -0,0 +1,14 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.get
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.get.GetChatMembersCount
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
suspend fun RequestsExecutor.getChatMembersCount(
chatId: ChatIdentifier
) = execute(GetChatMembersCount(chatId))
suspend fun RequestsExecutor.getChatMembersCount(
chat: PublicChat
) = getChatMembersCount(chat.id)

View File

@@ -0,0 +1,26 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.members
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members.GetChatMember
import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
suspend fun RequestsExecutor.getChatMember(
chatId: ChatIdentifier,
userId: UserId
) = execute(GetChatMember(chatId, userId))
suspend fun RequestsExecutor.getChatMember(
chat: PublicChat,
userId: UserId
) = getChatMember(chat.id, userId)
suspend fun RequestsExecutor.getChatMember(
chatId: ChatId,
user: User
) = getChatMember(chatId, user.id)
suspend fun RequestsExecutor.getChatMember(
chat: PublicChat,
user: User
) = getChatMember(chat.id, user.id)

View File

@@ -0,0 +1,30 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.members
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members.KickChatMember
import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
suspend fun RequestsExecutor.kickChatMember(
chatId: ChatIdentifier,
userId: UserId,
untilDate: TelegramDate? = null
) = execute(KickChatMember(chatId, userId, untilDate))
suspend fun RequestsExecutor.kickChatMember(
chat: PublicChat,
userId: UserId,
untilDate: TelegramDate? = null
) = kickChatMember(chat.id, userId, untilDate)
suspend fun RequestsExecutor.kickChatMember(
chatId: ChatId,
user: User,
untilDate: TelegramDate? = null
) = kickChatMember(chatId, user.id, untilDate)
suspend fun RequestsExecutor.kickChatMember(
chat: PublicChat,
user: User,
untilDate: TelegramDate? = null
) = kickChatMember(chat.id, user.id, untilDate)

View File

@@ -0,0 +1,112 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.members
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members.PromoteChatMember
import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
suspend fun RequestsExecutor.promoteChatMember(
chatId: ChatIdentifier,
userId: UserId,
untilDate: TelegramDate? = null,
canChangeInfo: Boolean? = null,
canPostMessages: Boolean? = null,
canEditMessages: Boolean? = null,
canDeleteMessages: Boolean? = null,
canInviteUsers: Boolean? = null,
canRestrictMembers: Boolean? = null,
canPinMessages: Boolean? = null,
canPromoteMembers: Boolean? = null
) = execute(
PromoteChatMember(
chatId,
userId,
untilDate,
canChangeInfo,
canPostMessages,
canEditMessages,
canDeleteMessages,
canInviteUsers,
canRestrictMembers,
canPinMessages,
canPromoteMembers
)
)
suspend fun RequestsExecutor.promoteChatMember(
chat: PublicChat,
userId: UserId,
untilDate: TelegramDate? = null,
canChangeInfo: Boolean? = null,
canPostMessages: Boolean? = null,
canEditMessages: Boolean? = null,
canDeleteMessages: Boolean? = null,
canInviteUsers: Boolean? = null,
canRestrictMembers: Boolean? = null,
canPinMessages: Boolean? = null,
canPromoteMembers: Boolean? = null
) = promoteChatMember(
chat.id,
userId,
untilDate,
canChangeInfo,
canPostMessages,
canEditMessages,
canDeleteMessages,
canInviteUsers,
canRestrictMembers,
canPinMessages,
canPromoteMembers
)
suspend fun RequestsExecutor.promoteChatMember(
chatId: ChatId,
user: User,
untilDate: TelegramDate? = null,
canChangeInfo: Boolean? = null,
canPostMessages: Boolean? = null,
canEditMessages: Boolean? = null,
canDeleteMessages: Boolean? = null,
canInviteUsers: Boolean? = null,
canRestrictMembers: Boolean? = null,
canPinMessages: Boolean? = null,
canPromoteMembers: Boolean? = null
) = promoteChatMember(
chatId,
user.id,
untilDate,
canChangeInfo,
canPostMessages,
canEditMessages,
canDeleteMessages,
canInviteUsers,
canRestrictMembers,
canPinMessages,
canPromoteMembers
)
suspend fun RequestsExecutor.promoteChatMember(
chat: PublicChat,
user: User,
untilDate: TelegramDate? = null,
canChangeInfo: Boolean? = null,
canPostMessages: Boolean? = null,
canEditMessages: Boolean? = null,
canDeleteMessages: Boolean? = null,
canInviteUsers: Boolean? = null,
canRestrictMembers: Boolean? = null,
canPinMessages: Boolean? = null,
canPromoteMembers: Boolean? = null
) = promoteChatMember(
chat.id,
user.id,
untilDate,
canChangeInfo,
canPostMessages,
canEditMessages,
canDeleteMessages,
canInviteUsers,
canRestrictMembers,
canPinMessages,
canPromoteMembers
)

View File

@@ -0,0 +1,36 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.members
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members.RestrictChatMember
import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
suspend fun RequestsExecutor.restrictChatMember(
chatId: ChatIdentifier,
userId: UserId,
untilDate: TelegramDate? = null,
permissions: ChatPermissions = ChatPermissions()
) = execute(RestrictChatMember(chatId, userId, untilDate, permissions))
suspend fun RequestsExecutor.restrictChatMember(
chat: PublicChat,
userId: UserId,
untilDate: TelegramDate? = null,
permissions: ChatPermissions = ChatPermissions()
) = restrictChatMember(chat.id, userId, untilDate, permissions)
suspend fun RequestsExecutor.restrictChatMember(
chatId: ChatId,
user: User,
untilDate: TelegramDate? = null,
permissions: ChatPermissions = ChatPermissions()
) = restrictChatMember(chatId, user.id, untilDate, permissions)
suspend fun RequestsExecutor.restrictChatMember(
chat: PublicChat,
user: User,
untilDate: TelegramDate? = null,
permissions: ChatPermissions = ChatPermissions()
) = restrictChatMember(chat.id, user.id, untilDate, permissions)

View File

@@ -0,0 +1,30 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.members
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members.SetChatAdministratorCustomTitle
import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
suspend fun RequestsExecutor.setChatAdministratorCustomTitle(
chatId: ChatId,
userId: UserId,
customTitle: String
) = execute(SetChatAdministratorCustomTitle(chatId, userId, customTitle))
suspend fun RequestsExecutor.setChatAdministratorCustomTitle(
chat: PublicChat,
userId: UserId,
customTitle: String
) = setChatAdministratorCustomTitle(chat.id, userId, customTitle)
suspend fun RequestsExecutor.setChatAdministratorCustomTitle(
chatId: ChatId,
user: User,
customTitle: String
) = setChatAdministratorCustomTitle(chatId, user.id, customTitle)
suspend fun RequestsExecutor.setChatAdministratorCustomTitle(
chat: PublicChat,
user: User,
customTitle: String
) = setChatAdministratorCustomTitle(chat.id, user.id, customTitle)

View File

@@ -0,0 +1,27 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.members
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members.UnbanChatMember
import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
suspend fun RequestsExecutor.unbanChatMember(
chatId: ChatIdentifier,
userId: UserId
) = execute(UnbanChatMember(chatId, userId))
suspend fun RequestsExecutor.unbanChatMember(
chat: PublicChat,
userId: UserId
) = unbanChatMember(chat.id, userId)
suspend fun RequestsExecutor.unbanChatMember(
chatId: ChatId,
user: User
) = unbanChatMember(chatId, user.id)
suspend fun RequestsExecutor.unbanChatMember(
chat: PublicChat,
user: User
) = unbanChatMember(chat.id, user.id)

View File

@@ -0,0 +1,14 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.modify
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify.DeleteChatPhoto
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
suspend fun RequestsExecutor.deleteChatPhoto(
chatId: ChatIdentifier
) = execute(DeleteChatPhoto(chatId))
suspend fun RequestsExecutor.deleteChatPhoto(
chat: PublicChat
) = deleteChatPhoto(chat.id)

View File

@@ -0,0 +1,29 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.modify
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify.PinChatMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
suspend fun RequestsExecutor.pinChatMessage(
chatId: ChatIdentifier,
messageId: MessageIdentifier,
disableNotification: Boolean = false
) = execute(PinChatMessage(chatId, messageId, disableNotification))
suspend fun RequestsExecutor.pinChatMessage(
chat: PublicChat,
messageId: MessageIdentifier,
disableNotification: Boolean = false
) = pinChatMessage(chat.id, messageId, disableNotification)
suspend fun RequestsExecutor.pinChatMessage(
message: Message,
disableNotification: Boolean = false
) = if (message.chat is PublicChat) {
pinChatMessage(message.chat.id, message.messageId, disableNotification)
} else {
error("It is possible to pin messages only in non one-to-one chats")
}

View File

@@ -0,0 +1,16 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.modify
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify.SetChatDescription
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
suspend fun RequestsExecutor.setChatDescription(
chatId: ChatIdentifier,
description: String
) = execute(SetChatDescription(chatId, description))
suspend fun RequestsExecutor.setChatDescription(
chat: PublicChat,
description: String
) = setChatDescription(chat.id, description)

View File

@@ -0,0 +1,17 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.modify
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify.SetChatPermissions
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
suspend fun RequestsExecutor.setDefaultChatMembersPermissions(
chatId: ChatIdentifier,
permissions: ChatPermissions
) = execute(SetChatPermissions(chatId, permissions))
suspend fun RequestsExecutor.setDefaultChatMembersPermissions(
chat: PublicChat,
permissions: ChatPermissions
) = setDefaultChatMembersPermissions(chat.id, permissions)

View File

@@ -0,0 +1,17 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.modify
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify.SetChatPhoto
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
suspend fun RequestsExecutor.setChatPhoto(
chatId: ChatIdentifier,
photo: MultipartFile
) = execute(SetChatPhoto(chatId, photo))
suspend fun RequestsExecutor.setChatPhoto(
chat: PublicChat,
photo: MultipartFile
) = setChatPhoto(chat.id, photo)

View File

@@ -0,0 +1,16 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.modify
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify.SetChatTitle
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
suspend fun RequestsExecutor.setChatTitle(
chatId: ChatIdentifier,
title: String
) = execute(SetChatTitle(chatId, title))
suspend fun RequestsExecutor.setChatTitle(
chat: PublicChat,
title: String
) = setChatTitle(chat.id, title)

View File

@@ -0,0 +1,14 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.modify
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify.UnpinChatMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
suspend fun RequestsExecutor.unpinChatMessage(
chatId: ChatIdentifier
) = execute(UnpinChatMessage(chatId))
suspend fun RequestsExecutor.unpinChatMessage(
chat: PublicChat
) = unpinChatMessage(chat.id)

View File

@@ -0,0 +1,14 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.stickers
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.stickers.DeleteChatStickerSet
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.SupergroupChat
suspend fun RequestsExecutor.deleteChatStickerSet(
chatId: ChatIdentifier
) = execute(DeleteChatStickerSet(chatId))
suspend fun RequestsExecutor.deleteChatStickerSet(
chat: SupergroupChat
) = deleteChatStickerSet(chat.id)

View File

@@ -0,0 +1,17 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.stickers
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.stickers.SetChatStickerSet
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.StickerSetName
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.SupergroupChat
suspend fun RequestsExecutor.setChatStickerSet(
chatId: ChatIdentifier,
stickerSetName: StickerSetName
) = execute(SetChatStickerSet(chatId, stickerSetName))
suspend fun RequestsExecutor.setChatStickerSet(
chat: SupergroupChat,
stickerSetName: StickerSetName
) = setChatStickerSet(chat.id, stickerSetName)

View File

@@ -0,0 +1,60 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.LiveLocation
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation.EditChatMessageLiveLocation
import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.LocationContent
suspend fun RequestsExecutor.editLiveLocation(
chatId: ChatIdentifier,
messageId: MessageIdentifier,
latitude: Double,
longitude: Double,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(
EditChatMessageLiveLocation(
chatId, messageId, latitude, longitude, replyMarkup
)
)
suspend fun RequestsExecutor.editLiveLocation(
chat: Chat,
messageId: MessageIdentifier,
latitude: Double,
longitude: Double,
replyMarkup: InlineKeyboardMarkup? = null
) = editLiveLocation(chat.id, messageId, latitude, longitude, replyMarkup)
suspend fun RequestsExecutor.editLiveLocation(
message: ContentMessage<LocationContent>,
latitude: Double,
longitude: Double,
replyMarkup: InlineKeyboardMarkup? = null
) = editLiveLocation(message.chat, message.messageId, latitude, longitude, replyMarkup)
suspend fun RequestsExecutor.editLiveLocation(
chatId: ChatIdentifier,
messageId: MessageIdentifier,
location: Location,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(
EditChatMessageLiveLocation(
chatId, messageId, location.latitude, location.longitude, replyMarkup
)
)
suspend fun RequestsExecutor.editLiveLocation(
chat: Chat,
messageId: MessageIdentifier,
location: Location,
replyMarkup: InlineKeyboardMarkup? = null
) = editLiveLocation(chat.id, messageId, location.latitude, location.longitude, replyMarkup)
suspend fun RequestsExecutor.editLiveLocation(
message: ContentMessage<LocationContent>,
location: Location,
replyMarkup: InlineKeyboardMarkup? = null
) = editLiveLocation(message.chat, message.messageId, location.latitude, location.longitude, replyMarkup)

View File

@@ -0,0 +1,23 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.LiveLocation
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation.EditInlineMessageLiveLocation
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineMessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.Location
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
suspend fun RequestsExecutor.editLiveLocation(
inlineMessageId: InlineMessageIdentifier,
latitude: Double,
longitude: Double,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(
EditInlineMessageLiveLocation(
inlineMessageId, latitude, longitude, replyMarkup
)
)
suspend fun RequestsExecutor.editLiveLocation(
inlineMessageId: InlineMessageIdentifier,
location: Location,
replyMarkup: InlineKeyboardMarkup? = null
) = editLiveLocation(inlineMessageId, location.latitude, location.longitude, replyMarkup)

View File

@@ -0,0 +1,31 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.LiveLocation
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation.StopChatMessageLiveLocation
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.LocationContent
suspend fun RequestsExecutor.stopLiveLocation(
chatId: ChatIdentifier,
messageId: MessageIdentifier,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(
StopChatMessageLiveLocation(
chatId, messageId, replyMarkup
)
)
suspend fun RequestsExecutor.stopLiveLocation(
chat: Chat,
messageId: MessageIdentifier,
replyMarkup: InlineKeyboardMarkup? = null
) = stopLiveLocation(chat.id, messageId, replyMarkup)
suspend fun RequestsExecutor.stopLiveLocation(
message: ContentMessage<LocationContent>,
replyMarkup: InlineKeyboardMarkup? = null
) = stopLiveLocation(message.chat, message.messageId, replyMarkup)

View File

@@ -0,0 +1,15 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.LiveLocation
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation.StopInlineMessageLiveLocation
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineMessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
suspend fun RequestsExecutor.stopLiveLocation(
inlineMessageId: InlineMessageIdentifier,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(
StopInlineMessageLiveLocation(
inlineMessageId, replyMarkup
)
)

View File

@@ -0,0 +1,29 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.ReplyMarkup
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.ReplyMarkup.EditChatMessageReplyMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
suspend fun RequestsExecutor.editMessageReplyMarkup(
chatId: ChatIdentifier,
messageId: MessageIdentifier,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(
EditChatMessageReplyMarkup(chatId, messageId, replyMarkup)
)
suspend fun RequestsExecutor.editMessageReplyMarkup(
chat: Chat,
messageId: MessageIdentifier,
replyMarkup: InlineKeyboardMarkup? = null
) = editMessageReplyMarkup(chat.id, messageId, replyMarkup)
suspend fun RequestsExecutor.editMessageReplyMarkup(
message: Message,
replyMarkup: InlineKeyboardMarkup? = null
) = editMessageReplyMarkup(message.chat.id, message.messageId, replyMarkup)

View File

@@ -0,0 +1,11 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.ReplyMarkup
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.ReplyMarkup.EditInlineMessageReplyMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineMessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
suspend fun RequestsExecutor.editMessageReplyMarkup(
inlineMessageId: InlineMessageIdentifier,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(EditInlineMessageReplyMarkup(inlineMessageId, replyMarkup))

View File

@@ -0,0 +1,39 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.caption
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.caption.EditChatMessageCaption
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
suspend fun RequestsExecutor.editMessageCaption(
chatId: ChatIdentifier,
messageId: MessageIdentifier,
text: String,
parseMode: ParseMode? = null,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(
EditChatMessageCaption(chatId, messageId, text, parseMode, replyMarkup)
)
suspend fun RequestsExecutor.editMessageCaption(
chat: Chat,
messageId: MessageIdentifier,
text: String,
parseMode: ParseMode? = null,
replyMarkup: InlineKeyboardMarkup? = null
) = editMessageCaption(chat.id, messageId, text, parseMode, replyMarkup)
suspend fun <T> RequestsExecutor.editMessageCaption(
message: ContentMessage<T>,
text: String,
parseMode: ParseMode? = null,
replyMarkup: InlineKeyboardMarkup? = null
): ContentMessage<MediaContent> where T : CaptionedInput, T : MediaContent {
return editMessageCaption(message.chat.id, message.messageId, text, parseMode, replyMarkup)
}

View File

@@ -0,0 +1,14 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.caption
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.caption.EditInlineMessageCaption
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineMessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
suspend fun RequestsExecutor.editMessageCaption(
inlineMessageId: InlineMessageIdentifier,
text: String,
parseMode: ParseMode? = null,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(EditInlineMessageCaption(inlineMessageId, text, parseMode, replyMarkup))

View File

@@ -0,0 +1,33 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.media
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media.EditChatMessageMedia
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.InputMedia
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
suspend fun RequestsExecutor.editMessageMedia(
chatId: ChatIdentifier,
messageId: MessageIdentifier,
media: InputMedia,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(
EditChatMessageMedia(chatId, messageId, media, replyMarkup)
)
suspend fun RequestsExecutor.editMessageMedia(
chat: Chat,
messageId: MessageIdentifier,
media: InputMedia,
replyMarkup: InlineKeyboardMarkup? = null
) = editMessageMedia(chat.id, messageId, media, replyMarkup)
suspend fun RequestsExecutor.editMessageMedia(
message: ContentMessage<out MediaContent>,
media: InputMedia,
replyMarkup: InlineKeyboardMarkup? = null
) = editMessageMedia(message.chat.id, message.messageId, media, replyMarkup)

View File

@@ -0,0 +1,13 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.media
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media.EditInlineMessageMedia
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineMessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.InputMedia
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
suspend fun RequestsExecutor.editMessageCaption(
inlineMessageId: InlineMessageIdentifier,
media: InputMedia,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(EditInlineMessageMedia(inlineMessageId, media, replyMarkup))

View File

@@ -0,0 +1,39 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.text
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.text.EditChatMessageText
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
suspend fun RequestsExecutor.editMessageText(
chatId: ChatIdentifier,
messageId: MessageIdentifier,
text: String,
parseMode: ParseMode? = null,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(
EditChatMessageText(chatId, messageId, text, parseMode, disableWebPagePreview, replyMarkup)
)
suspend fun RequestsExecutor.editMessageText(
chat: Chat,
messageId: MessageIdentifier,
text: String,
parseMode: ParseMode? = null,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null
) = editMessageText(chat.id, messageId, text, parseMode, disableWebPagePreview, replyMarkup)
suspend fun RequestsExecutor.editMessageText(
message: ContentMessage<TextContent>,
text: String,
parseMode: ParseMode? = null,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null
) = editMessageText(message.chat.id, message.messageId, text, parseMode, disableWebPagePreview, replyMarkup)

View File

@@ -0,0 +1,15 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.text
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.text.EditInlineMessageText
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineMessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
suspend fun RequestsExecutor.editMessageText(
inlineMessageId: InlineMessageIdentifier,
text: String,
parseMode: ParseMode? = null,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(EditInlineMessageText(inlineMessageId, text, parseMode, disableWebPagePreview, replyMarkup))

View File

@@ -0,0 +1,54 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.games
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.GetGameHighScoresByChat
import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.GameContent
suspend fun RequestsExecutor.getGameScore(
userId: UserId,
chatId: ChatId,
messageId: MessageIdentifier
) = execute(
GetGameHighScoresByChat(userId, chatId, messageId)
)
suspend fun RequestsExecutor.getGameScore(
user: CommonUser,
chatId: ChatId,
messageId: MessageIdentifier
) = getGameScore(
user.id, chatId, messageId
)
suspend fun RequestsExecutor.getGameScore(
userId: UserId,
chat: Chat,
messageId: MessageIdentifier
) = getGameScore(
userId, chat.id, messageId
)
suspend fun RequestsExecutor.getGameScore(
user: CommonUser,
chat: Chat,
messageId: MessageIdentifier
) = getGameScore(
user.id, chat.id, messageId
)
suspend fun RequestsExecutor.getGameScore(
userId: UserId,
message: ContentMessage<GameContent>
) = getGameScore(
userId, message.chat.id, message.messageId
)
suspend fun RequestsExecutor.getGameScore(
user: CommonUser,
message: ContentMessage<GameContent>
) = getGameScore(
user.id, message.chat.id, message.messageId
)

View File

@@ -0,0 +1,19 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.games
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.GetGameHighScoresByInlineMessageId
import com.github.insanusmokrassar.TelegramBotAPI.types.*
suspend fun RequestsExecutor.getGameScore(
userId: UserId,
inlineMessageId: InlineMessageIdentifier
) = execute(
GetGameHighScoresByInlineMessageId(
userId, inlineMessageId
)
)
suspend fun RequestsExecutor.getGameScore(
user: CommonUser,
inlineMessageId: InlineMessageIdentifier
) = getGameScore(user.id, inlineMessageId)

View File

@@ -0,0 +1,72 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.games
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.SetGameScoreByChatId
import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.GameContent
suspend fun RequestsExecutor.setGameScore(
userId: UserId,
score: Long,
chatId: ChatId,
messageId: MessageIdentifier,
force: Boolean = false,
disableEditMessage: Boolean = false
) = execute(
SetGameScoreByChatId(userId, score, chatId, messageId, force, disableEditMessage)
)
suspend fun RequestsExecutor.setGameScore(
user: CommonUser,
score: Long,
chatId: ChatId,
messageId: MessageIdentifier,
force: Boolean = false,
disableEditMessage: Boolean = false
) = setGameScore(
user.id, score, chatId, messageId, force, disableEditMessage
)
suspend fun RequestsExecutor.setGameScore(
userId: UserId,
score: Long,
chat: Chat,
messageId: MessageIdentifier,
force: Boolean = false,
disableEditMessage: Boolean = false
) = setGameScore(
userId, score, chat.id, messageId, force, disableEditMessage
)
suspend fun RequestsExecutor.setGameScore(
user: CommonUser,
score: Long,
chat: Chat,
messageId: MessageIdentifier,
force: Boolean = false,
disableEditMessage: Boolean = false
) = setGameScore(
user.id, score, chat.id, messageId, force, disableEditMessage
)
suspend fun RequestsExecutor.setGameScore(
userId: UserId,
score: Long,
message: ContentMessage<GameContent>,
force: Boolean = false,
disableEditMessage: Boolean = false
) = setGameScore(
userId, score, message.chat.id, message.messageId, force, disableEditMessage
)
suspend fun RequestsExecutor.setGameScore(
user: CommonUser,
score: Long,
message: ContentMessage<GameContent>,
force: Boolean = false,
disableEditMessage: Boolean = false
) = setGameScore(
user.id, score, message.chat.id, message.messageId, force, disableEditMessage
)

View File

@@ -0,0 +1,25 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.games
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.SetGameScoreByInlineMessageId
import com.github.insanusmokrassar.TelegramBotAPI.types.*
suspend fun RequestsExecutor.setGameScore(
userId: UserId,
score: Long,
inlineMessageId: InlineMessageIdentifier,
force: Boolean = false,
disableEditMessage: Boolean = false
) = execute(
SetGameScoreByInlineMessageId(
userId, score, inlineMessageId, force, disableEditMessage
)
)
suspend fun RequestsExecutor.setGameScore(
user: CommonUser,
score: Long,
inlineMessageId: InlineMessageIdentifier,
force: Boolean = false,
disableEditMessage: Boolean = false
) = setGameScore(user.id, score, inlineMessageId, force, disableEditMessage)

View File

@@ -0,0 +1,16 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.get
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
import com.github.insanusmokrassar.TelegramBotAPI.requests.get.GetFile
import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.TelegramMediaFile
suspend fun RequestsExecutor.getFileAdditionalInfo(
fileId: FileId
) = execute(
GetFile(fileId)
)
suspend fun RequestsExecutor.getFileAdditionalInfo(
file: TelegramMediaFile
) = getFileAdditionalInfo(file.fileId)

View File

@@ -0,0 +1,17 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.get
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.get.GetStickerSet
import com.github.insanusmokrassar.TelegramBotAPI.types.files.Sticker
suspend fun RequestsExecutor.getStickerSet(
name: String
) = execute(
GetStickerSet(name)
)
suspend fun RequestsExecutor.getStickerSet(
sticker: Sticker
) = getStickerSet(
sticker.stickerSetName ?: error("Sticker must contains stickerSetName to be correctly used in getStickerSet method")
)

View File

@@ -0,0 +1,22 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.get
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.get.GetUserProfilePhotos
import com.github.insanusmokrassar.TelegramBotAPI.types.CommonUser
import com.github.insanusmokrassar.TelegramBotAPI.types.UserId
suspend fun RequestsExecutor.getUserProfilePhotos(
userId: UserId,
offset: Int? = null,
limit: Int? = null
) = execute(
GetUserProfilePhotos(
userId, offset, limit
)
)
suspend fun RequestsExecutor.getUserProfilePhotos(
user: CommonUser,
offset: Int? = null,
limit: Int? = null
) = getUserProfilePhotos(user.id, offset, limit)

View File

@@ -0,0 +1,102 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendAction
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.actions.*
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
suspend fun RequestsExecutor.sendBotAction(
chatId: ChatIdentifier,
action: BotAction
) = execute(
SendAction(chatId, action)
)
suspend fun RequestsExecutor.sendBotAction(
chat: Chat,
action: BotAction
) = sendBotAction(chat.id, action)
suspend fun RequestsExecutor.sendActionTyping(
chatId: ChatIdentifier
) = sendBotAction(chatId, TypingAction)
suspend fun RequestsExecutor.sendActionUploadPhoto(
chatId: ChatIdentifier
) = sendBotAction(chatId, UploadPhotoAction)
suspend fun RequestsExecutor.sendActionRecordVideo(
chatId: ChatIdentifier
) = sendBotAction(chatId, RecordVideoAction)
suspend fun RequestsExecutor.sendActionUploadVideo(
chatId: ChatIdentifier
) = sendBotAction(chatId, UploadVideoAction)
suspend fun RequestsExecutor.sendActionRecordAudio(
chatId: ChatIdentifier
) = sendBotAction(chatId, RecordAudioAction)
suspend fun RequestsExecutor.sendActionUploadAudio(
chatId: ChatIdentifier
) = sendBotAction(chatId, UploadAudioAction)
suspend fun RequestsExecutor.sendActionUploadDocument(
chatId: ChatIdentifier
) = sendBotAction(chatId, UploadDocumentAction)
suspend fun RequestsExecutor.sendActionFindLocation(
chatId: ChatIdentifier
) = sendBotAction(chatId, FindLocationAction)
suspend fun RequestsExecutor.sendActionRecordVideoNote(
chatId: ChatIdentifier
) = sendBotAction(chatId, RecordVideoNoteAction)
suspend fun RequestsExecutor.sendActionUploadVideoNote(
chatId: ChatIdentifier
) = sendBotAction(chatId, UploadVideoNoteAction)
suspend fun RequestsExecutor.sendActionTyping(
chat: Chat
) = sendBotAction(chat, TypingAction)
suspend fun RequestsExecutor.sendActionUploadPhoto(
chat: Chat
) = sendBotAction(chat, UploadPhotoAction)
suspend fun RequestsExecutor.sendActionRecordVideo(
chat: Chat
) = sendBotAction(chat, RecordVideoAction)
suspend fun RequestsExecutor.sendActionUploadVideo(
chat: Chat
) = sendBotAction(chat, UploadVideoAction)
suspend fun RequestsExecutor.sendActionRecordAudio(
chat: Chat
) = sendBotAction(chat, RecordAudioAction)
suspend fun RequestsExecutor.sendActionUploadAudio(
chat: Chat
) = sendBotAction(chat, UploadAudioAction)
suspend fun RequestsExecutor.sendActionUploadDocument(
chat: Chat
) = sendBotAction(chat, UploadDocumentAction)
suspend fun RequestsExecutor.sendActionFindLocation(
chat: Chat
) = sendBotAction(chat, FindLocationAction)
suspend fun RequestsExecutor.sendActionRecordVideoNote(
chat: Chat
) = sendBotAction(chat, RecordVideoNoteAction)
suspend fun RequestsExecutor.sendActionUploadVideoNote(
chat: Chat
) = sendBotAction(chat, UploadVideoNoteAction)

View File

@@ -0,0 +1,55 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendContact
import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
suspend fun RequestsExecutor.sendContact(
chatId: ChatIdentifier,
phoneNumber: String,
firstName: String,
lastName: String? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendContact(
chatId, phoneNumber, firstName, lastName, disableNotification, replyToMessageId, replyMarkup
)
)
suspend fun RequestsExecutor.sendContact(
chatId: ChatIdentifier,
contact: Contact,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendContact(
chatId, contact, disableNotification, replyToMessageId, replyMarkup
)
)
suspend fun RequestsExecutor.sendContact(
chat: Chat,
phoneNumber: String,
firstName: String,
lastName: String? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendContact(
chat.id, phoneNumber, firstName, lastName, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendContact(
chat: Chat,
contact: Contact,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendContact(
chat.id, contact, disableNotification, replyToMessageId, replyMarkup
)

View File

@@ -0,0 +1,71 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendLocation
import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
suspend fun RequestsExecutor.sendLocation(
chatId: ChatIdentifier,
latitude: Double,
longitude: Double,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendLocation(
chatId,
latitude,
longitude,
disableNotification = disableNotification,
replyToMessageId = replyToMessageId,
replyMarkup = replyMarkup
)
)
suspend fun RequestsExecutor.sendLocation(
chatId: ChatIdentifier,
location: Location,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendLocation(
chatId,
location.latitude,
location.longitude,
disableNotification,
replyToMessageId,
replyMarkup
)
suspend fun RequestsExecutor.sendLocation(
chat: Chat,
latitude: Double,
longitude: Double,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendLocation(
chat.id,
latitude,
longitude,
disableNotification,
replyToMessageId,
replyMarkup
)
suspend fun RequestsExecutor.sendLocation(
chat: Chat,
location: Location,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendLocation(
chat.id,
location.latitude,
location.longitude,
disableNotification,
replyToMessageId,
replyMarkup
)

View File

@@ -0,0 +1,54 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendTextMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
suspend fun RequestsExecutor.sendMessage(
chatId: ChatIdentifier,
text: String,
parseMode: ParseMode? = null,
disableWebPagePreview: Boolean? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendTextMessage(chatId, text, parseMode, disableWebPagePreview, disableNotification, replyToMessageId, replyMarkup)
)
suspend fun RequestsExecutor.sendTextMessage(
chatId: ChatIdentifier,
text: String,
parseMode: ParseMode? = null,
disableWebPagePreview: Boolean? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendMessage(
chatId, text, parseMode, disableWebPagePreview, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendMessage(
chat: Chat,
text: String,
parseMode: ParseMode? = null,
disableWebPagePreview: Boolean? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendMessage(chat.id, text, parseMode, disableWebPagePreview, disableNotification, replyToMessageId, replyMarkup)
suspend fun RequestsExecutor.sendTextMessage(
chat: Chat,
text: String,
parseMode: ParseMode? = null,
disableWebPagePreview: Boolean? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendTextMessage(chat.id, text, parseMode, disableWebPagePreview, disableNotification, replyToMessageId, replyMarkup)

View File

@@ -0,0 +1,59 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendVenue
import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
suspend fun RequestsExecutor.sendVenue(
chatId: ChatIdentifier,
latitude: Double,
longitude: Double,
title: String,
address: String,
foursquareId: String? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendVenue(
chatId, latitude, longitude, title, address, foursquareId, disableNotification, replyToMessageId, replyMarkup
)
)
suspend fun RequestsExecutor.sendVenue(
chat: Chat,
latitude: Double,
longitude: Double,
title: String,
address: String,
foursquareId: String? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVenue(
chat.id, latitude, longitude, title, address, foursquareId, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendVenue(
chatId: ChatIdentifier,
venue: Venue,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendVenue(
chatId, venue, disableNotification, replyToMessageId, replyMarkup
)
)
suspend fun RequestsExecutor.sendVenue(
chat: Chat,
venue: Venue,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVenue(
chat.id, venue, disableNotification, replyToMessageId, replyMarkup
)

View File

@@ -0,0 +1,51 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.games
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.games.SendGame
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
import com.github.insanusmokrassar.TelegramBotAPI.types.games.Game
suspend fun RequestsExecutor.sendGame(
chatId: ChatIdentifier,
gameShortName: String,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendGame(
chatId, gameShortName, disableNotification, replyToMessageId, replyMarkup
)
)
suspend fun RequestsExecutor.sendGame(
chat: Chat,
gameShortName: String,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendGame(
chat.id, gameShortName, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendGame(
chatId: ChatIdentifier,
game: Game,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendGame(
chatId, game.title, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendGame(
chat: Chat,
game: Game,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendGame(
chat.id, game.title, disableNotification, replyToMessageId, replyMarkup
)

View File

@@ -0,0 +1,167 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendAnimation
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.files.AnimationFile
import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize
suspend fun RequestsExecutor.sendAnimation(
chatId: ChatIdentifier,
animation: FileId,
thumb: FileId? = null,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendAnimation(
chatId,
animation,
thumb,
text,
parseMode,
duration,
width,
height,
disableNotification,
replyToMessageId,
replyMarkup
)
)
suspend fun RequestsExecutor.sendAnimation(
chatId: ChatIdentifier,
animation: AnimationFile,
thumb: PhotoSize? = animation.thumb,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAnimation(
chatId, animation.fileId, thumb ?.fileId, text, parseMode, animation.duration, animation.width, animation.height, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendAnimation(
chatId: ChatIdentifier,
animation: MultipartFile,
thumb: FileId? = null,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendAnimation(
chatId,
animation,
thumb,
text,
parseMode,
duration,
width,
height,
disableNotification,
replyToMessageId,
replyMarkup
)
)
suspend fun RequestsExecutor.sendAnimation(
chatId: ChatIdentifier,
animation: MultipartFile,
thumb: MultipartFile? = null,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendAnimation(
chatId,
animation,
thumb,
text,
parseMode,
duration,
width,
height,
disableNotification,
replyToMessageId,
replyMarkup
)
)
suspend fun RequestsExecutor.sendAnimation(
chatId: ChatIdentifier,
animation: FileId,
thumb: MultipartFile,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendAnimation(
chatId,
animation,
thumb,
text,
parseMode,
duration,
width,
height,
disableNotification,
replyToMessageId,
replyMarkup
)
)
suspend fun RequestsExecutor.sendAnimation(
chatId: ChatIdentifier,
animation: MultipartFile,
thumb: PhotoSize? = null,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAnimation(
chatId, animation, thumb ?.fileId , text, parseMode, duration, width, height, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendAnimation(
chatId: ChatIdentifier,
animation: AnimationFile,
thumb: MultipartFile,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAnimation(
chatId, animation.fileId, thumb, text, parseMode, animation.duration, animation.width, animation.height, disableNotification, replyToMessageId, replyMarkup
)

View File

@@ -0,0 +1,168 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendAudio
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.files.AudioFile
import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize
suspend fun RequestsExecutor.sendAudio(
chatId: ChatIdentifier,
audio: FileId,
thumb: FileId? = null,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
performer: String? = null,
title: String? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendAudio(
chatId,
audio,
thumb,
text,
parseMode,
duration,
performer,
title,
disableNotification,
replyToMessageId,
replyMarkup
)
)
suspend fun RequestsExecutor.sendAudio(
chatId: ChatIdentifier,
audio: AudioFile,
thumb: PhotoSize? = audio.thumb,
text: String? = null,
parseMode: ParseMode? = null,
title: String? = audio.title,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAudio(
chatId, audio.fileId, thumb ?.fileId, text, parseMode, audio.duration, audio.performer, title, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendAudio(
chatId: ChatIdentifier,
audio: MultipartFile,
thumb: FileId? = null,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
performer: String? = null,
title: String? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendAudio(
chatId,
audio,
thumb,
text,
parseMode,
duration,
performer,
title,
disableNotification,
replyToMessageId,
replyMarkup
)
)
suspend fun RequestsExecutor.sendAudio(
chatId: ChatIdentifier,
audio: MultipartFile,
thumb: MultipartFile? = null,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
performer: String? = null,
title: String? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendAudio(
chatId,
audio,
thumb,
text,
parseMode,
duration,
performer,
title,
disableNotification,
replyToMessageId,
replyMarkup
)
)
suspend fun RequestsExecutor.sendAudio(
chatId: ChatIdentifier,
audio: FileId,
thumb: MultipartFile,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
performer: String? = null,
title: String? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendAudio(
chatId,
audio,
thumb,
text,
parseMode,
duration,
performer,
title,
disableNotification,
replyToMessageId,
replyMarkup
)
)
suspend fun RequestsExecutor.sendAudio(
chatId: ChatIdentifier,
audio: MultipartFile,
thumb: PhotoSize? = null,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
performer: String? = null,
title: String? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAudio(
chatId, audio, thumb ?.fileId , text, parseMode, duration, performer, title, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendAudio(
chatId: ChatIdentifier,
audio: AudioFile,
thumb: MultipartFile,
text: String? = null,
parseMode: ParseMode? = null,
title: String? = audio.title,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAudio(
chatId, audio.fileId, thumb, text, parseMode, audio.duration, audio.performer, title, disableNotification, replyToMessageId, replyMarkup
)

View File

@@ -0,0 +1,139 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendDocument
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.files.DocumentFile
import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize
suspend fun RequestsExecutor.sendDocument(
chatId: ChatIdentifier,
document: FileId,
thumb: FileId? = null,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendDocument(
chatId,
document,
thumb,
text,
parseMode,
disableNotification,
replyToMessageId,
replyMarkup
)
)
suspend fun RequestsExecutor.sendDocument(
chatId: ChatIdentifier,
document: DocumentFile,
thumb: PhotoSize? = document.thumb,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendDocument(
chatId, document.fileId, thumb ?.fileId, text, parseMode, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendDocument(
chatId: ChatIdentifier,
document: MultipartFile,
thumb: FileId? = null,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendDocument(
chatId,
document,
thumb,
text,
parseMode,
disableNotification,
replyToMessageId,
replyMarkup
)
)
suspend fun RequestsExecutor.sendDocument(
chatId: ChatIdentifier,
document: MultipartFile,
thumb: MultipartFile? = null,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendDocument(
chatId,
document,
thumb,
text,
parseMode,
disableNotification,
replyToMessageId,
replyMarkup
)
)
suspend fun RequestsExecutor.sendDocument(
chatId: ChatIdentifier,
document: FileId,
thumb: MultipartFile,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendDocument(
chatId,
document,
thumb,
text,
parseMode,
disableNotification,
replyToMessageId,
replyMarkup
)
)
suspend fun RequestsExecutor.sendDocument(
chatId: ChatIdentifier,
document: MultipartFile,
thumb: PhotoSize? = null,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendDocument(
chatId, document, thumb ?.fileId , text, parseMode, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendDocument(
chatId: ChatIdentifier,
document: DocumentFile,
thumb: MultipartFile,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendDocument(
chatId, document.fileId, thumb, text, parseMode, disableNotification, replyToMessageId, replyMarkup
)

View File

@@ -0,0 +1,28 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendMediaGroup
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.MediaGroupMemberInputMedia
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
suspend fun RequestsExecutor.sendMediaGroup(
chatId: ChatIdentifier,
media: List<MediaGroupMemberInputMedia>,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null
) = execute(
SendMediaGroup(
chatId, media, disableNotification, replyToMessageId
)
)
suspend fun RequestsExecutor.sendMediaGroup(
chat: Chat,
media: List<MediaGroupMemberInputMedia>,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null
) = sendMediaGroup(
chat.id, media, disableNotification, replyToMessageId
)

View File

@@ -0,0 +1,136 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendPhoto
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
import com.github.insanusmokrassar.TelegramBotAPI.types.files.*
suspend fun RequestsExecutor.sendPhoto(
chatId: ChatIdentifier,
fileId: FileId,
caption: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendPhoto(
chatId,
fileId,
caption,
parseMode,
disableNotification,
replyToMessageId,
replyMarkup
)
)
suspend fun RequestsExecutor.sendPhoto(
chatId: ChatIdentifier,
photo: MultipartFile,
caption: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendPhoto(
chatId,
photo,
caption,
parseMode,
disableNotification,
replyToMessageId,
replyMarkup
)
)
suspend fun RequestsExecutor.sendPhoto(
chatId: ChatIdentifier,
file: PhotoSize,
caption: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(
chatId, file.fileId, caption, parseMode, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendPhoto(
chatId: ChatIdentifier,
photo: Photo,
caption: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(
chatId, photo.biggest() ?: throw IllegalArgumentException("Photo $photo is empty"), caption, parseMode, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendPhoto(
chat: Chat,
fileId: FileId,
caption: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(
chat.id,
fileId,
caption,
parseMode,
disableNotification,
replyToMessageId,
replyMarkup
)
suspend fun RequestsExecutor.sendPhoto(
chat: Chat,
file: PhotoSize,
caption: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(
chat.id, file.fileId, caption, parseMode, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendPhoto(
chat: Chat,
photo: Photo,
caption: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(
chat.id, photo.biggest() ?: throw IllegalArgumentException("Photo $photo is empty"), caption, parseMode, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendPhoto(
chat: Chat,
fileId: MultipartFile,
caption: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(
chat.id,
fileId,
caption,
parseMode,
disableNotification,
replyToMessageId,
replyMarkup
)

View File

@@ -0,0 +1,66 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendSticker
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
import com.github.insanusmokrassar.TelegramBotAPI.types.files.Sticker
suspend fun RequestsExecutor.sendSticker(
chatId: ChatIdentifier,
sticker: FileId,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendSticker(chatId, sticker, disableNotification, replyToMessageId, replyMarkup)
)
suspend fun RequestsExecutor.sendSticker(
chatId: ChatIdentifier,
sticker: MultipartFile,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendSticker(chatId, sticker, disableNotification, replyToMessageId, replyMarkup)
)
suspend fun RequestsExecutor.sendSticker(
chat: Chat,
sticker: FileId,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendSticker(chat.id, sticker, disableNotification, replyToMessageId, replyMarkup)
suspend fun RequestsExecutor.sendSticker(
chat: Chat,
sticker: MultipartFile,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendSticker(chat.id, sticker, disableNotification, replyToMessageId, replyMarkup)
suspend fun RequestsExecutor.sendSticker(
chatId: ChatIdentifier,
sticker: Sticker,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendSticker(
chatId, sticker.fileId, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendSticker(
chat: Chat,
sticker: Sticker,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendSticker(chat.id, sticker.fileId, disableNotification, replyToMessageId, replyMarkup)

View File

@@ -0,0 +1,135 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendVideo
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize
import com.github.insanusmokrassar.TelegramBotAPI.types.files.VideoFile
suspend fun RequestsExecutor.sendVideo(
chatId: ChatIdentifier,
video: FileId,
thumb: FileId? = null,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendVideo(
chatId,
video,
thumb,
text,
parseMode,
duration,
width,
height,
null,
disableNotification,
replyToMessageId,
replyMarkup
)
)
suspend fun RequestsExecutor.sendVideo(
chatId: ChatIdentifier,
video: VideoFile,
thumb: PhotoSize? = video.thumb,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(
chatId, video.fileId, thumb ?.fileId, text, parseMode, video.duration, video.width, video.height, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendVideo(
chatId: ChatIdentifier,
video: MultipartFile,
thumb: FileId? = null,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
supportStreaming: Boolean? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendVideo(chatId, video, thumb, text, parseMode, duration, width, height, supportStreaming, disableNotification, replyToMessageId, replyMarkup)
)
suspend fun RequestsExecutor.sendVideo(
chatId: ChatIdentifier,
video: MultipartFile,
thumb: MultipartFile? = null,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
supportStreaming: Boolean? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendVideo(chatId, video, thumb, text, parseMode, duration, width, height, supportStreaming, disableNotification, replyToMessageId, replyMarkup)
)
suspend fun RequestsExecutor.sendVideo(
chatId: ChatIdentifier,
video: FileId,
thumb: MultipartFile,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendVideo(chatId, video, thumb, text, parseMode, duration, width, height, null, disableNotification, replyToMessageId, replyMarkup)
)
suspend fun RequestsExecutor.sendVideo(
chatId: ChatIdentifier,
video: MultipartFile,
thumb: PhotoSize? = null,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
supportStreaming: Boolean? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(
chatId, video, thumb ?.fileId , text, parseMode, duration, width, height, supportStreaming, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendVideo(
chatId: ChatIdentifier,
video: VideoFile,
thumb: MultipartFile,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(
chatId, video.fileId, thumb, text, parseMode, video.duration, video.width, video.height, disableNotification, replyToMessageId, replyMarkup
)

View File

@@ -0,0 +1,157 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendVideoNote
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize
import com.github.insanusmokrassar.TelegramBotAPI.types.files.VideoFile
suspend fun RequestsExecutor.sendVideoNote(
chatId: ChatIdentifier,
videoNote: FileId,
thumb: FileId? = null,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
size: Int? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendVideoNote(
chatId,
videoNote,
thumb,
text,
parseMode,
duration,
size,
disableNotification,
replyToMessageId,
replyMarkup
)
)
suspend fun RequestsExecutor.sendVideoNote(
chatId: ChatIdentifier,
videoNote: VideoFile,
thumb: PhotoSize? = videoNote.thumb,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideoNote(
chatId, videoNote.fileId, thumb ?.fileId, text, parseMode, videoNote.duration, videoNote.width, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendVideoNote(
chatId: ChatIdentifier,
videoNote: MultipartFile,
thumb: FileId? = null,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
size: Int? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendVideoNote(
chatId,
videoNote,
thumb,
text,
parseMode,
duration,
size,
disableNotification,
replyToMessageId,
replyMarkup
)
)
suspend fun RequestsExecutor.sendVideoNote(
chatId: ChatIdentifier,
videoNote: MultipartFile,
thumb: MultipartFile? = null,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
size: Int? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendVideoNote(
chatId,
videoNote,
thumb,
text,
parseMode,
duration,
size,
disableNotification,
replyToMessageId,
replyMarkup
)
)
suspend fun RequestsExecutor.sendVideoNote(
chatId: ChatIdentifier,
videoNote: FileId,
thumb: MultipartFile,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
size: Int? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendVideoNote(
chatId,
videoNote,
thumb,
text,
parseMode,
duration,
size,
disableNotification,
replyToMessageId,
replyMarkup
)
)
suspend fun RequestsExecutor.sendVideoNote(
chatId: ChatIdentifier,
videoNote: MultipartFile,
thumb: PhotoSize? = null,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
size: Int? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideoNote(
chatId, videoNote, thumb ?.fileId , text, parseMode, duration, size, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendVideoNote(
chatId: ChatIdentifier,
videoNote: VideoFile,
thumb: MultipartFile,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideoNote(
chatId, videoNote.fileId, thumb, text, parseMode, videoNote.duration, videoNote.width, disableNotification, replyToMessageId, replyMarkup
)

View File

@@ -0,0 +1,149 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendVoice
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.files.AudioFile
import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize
suspend fun RequestsExecutor.sendVoice(
chatId: ChatIdentifier,
voice: FileId,
thumb: FileId? = null,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendVoice(
chatId,
voice,
thumb,
text,
parseMode,
duration,
disableNotification,
replyToMessageId,
replyMarkup
)
)
suspend fun RequestsExecutor.sendVoice(
chatId: ChatIdentifier,
voice: AudioFile,
thumb: PhotoSize? = voice.thumb,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVoice(
chatId, voice.fileId, thumb ?.fileId, text, parseMode, voice.duration, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendVoice(
chatId: ChatIdentifier,
voice: MultipartFile,
thumb: FileId? = null,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendVoice(
chatId,
voice,
thumb,
text,
parseMode,
duration,
disableNotification,
replyToMessageId,
replyMarkup
)
)
suspend fun RequestsExecutor.sendVoice(
chatId: ChatIdentifier,
voice: MultipartFile,
thumb: MultipartFile? = null,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendVoice(
chatId,
voice,
thumb,
text,
parseMode,
duration,
disableNotification,
replyToMessageId,
replyMarkup
)
)
suspend fun RequestsExecutor.sendVoice(
chatId: ChatIdentifier,
voice: FileId,
thumb: MultipartFile,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendVoice(
chatId,
voice,
thumb,
text,
parseMode,
duration,
disableNotification,
replyToMessageId,
replyMarkup
)
)
suspend fun RequestsExecutor.sendVoice(
chatId: ChatIdentifier,
voice: MultipartFile,
thumb: PhotoSize? = null,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVoice(
chatId, voice, thumb ?.fileId , text, parseMode, duration, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendVoice(
chatId: ChatIdentifier,
voice: AudioFile,
thumb: MultipartFile,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVoice(
chatId, voice.fileId, thumb, text, parseMode, voice.duration, disableNotification, replyToMessageId, replyMarkup
)

View File

@@ -0,0 +1,54 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.payments
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.payments.SendInvoice
import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.LabeledPrice
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.abstracts.Currency
suspend fun RequestsExecutor.sendInvoice(
chatId: ChatId,
title: String,
description: String,
payload: String,
providerToken: String,
startParameter: StartParameter,
currency: Currency,
prices: List<LabeledPrice>,
providerData: String? = null,
requireName: Boolean = false,
requirePhoneNumber: Boolean = false,
requireEmail: Boolean = false,
requireShippingAddress: Boolean = false,
shouldSendPhoneNumberToProvider: Boolean = false,
shouldSendEmailToProvider: Boolean = false,
priceDependOnShipAddress: Boolean = false,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(
SendInvoice(chatId, title, description, payload, providerToken, startParameter, currency, prices, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, replyToMessageId, replyMarkup)
)
suspend fun RequestsExecutor.sendInvoice(
user: CommonUser,
title: String,
description: String,
payload: String,
providerToken: String,
startParameter: StartParameter,
currency: Currency,
prices: List<LabeledPrice>,
providerData: String? = null,
requireName: Boolean = false,
requirePhoneNumber: Boolean = false,
requireEmail: Boolean = false,
requireShippingAddress: Boolean = false,
shouldSendPhoneNumberToProvider: Boolean = false,
shouldSendEmailToProvider: Boolean = false,
priceDependOnShipAddress: Boolean = false,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: InlineKeyboardMarkup? = null
) = sendInvoice(user.id, title, description, payload, providerToken, startParameter, currency, prices, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, replyToMessageId, replyMarkup)

View File

@@ -0,0 +1,135 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.polls
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.polls.SendQuizPoll
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.polls.SendRegularPoll
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.QuizPoll
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.RegularPoll
suspend fun RequestsExecutor.sendRegularPoll(
chatId: ChatIdentifier,
question: String,
options: List<String>,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
allowMultipleAnswers: Boolean = false,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendRegularPoll(
chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, disableNotification, replyToMessageId, replyMarkup
)
)
suspend fun RequestsExecutor.sendRegularPoll(
chatId: ChatIdentifier,
poll: RegularPoll,
isClosed: Boolean = false,
question: String = poll.question,
options: List<String> = poll.options.map { it.text },
isAnonymous: Boolean = poll.isAnonymous,
allowMultipleAnswers: Boolean = poll.allowMultipleAnswers,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendRegularPoll(
chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, disableNotification, replyToMessageId, replyMarkup
)
)
suspend fun RequestsExecutor.sendRegularPoll(
chat: Chat,
question: String,
options: List<String>,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
allowMultipleAnswers: Boolean = false,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendRegularPoll(
chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendRegularPoll(
chat: Chat,
poll: RegularPoll,
isClosed: Boolean = false,
question: String = poll.question,
options: List<String> = poll.options.map { it.text },
isAnonymous: Boolean = poll.isAnonymous,
allowMultipleAnswers: Boolean = poll.allowMultipleAnswers,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendRegularPoll(
chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendQuizPoll(
chatId: ChatIdentifier,
question: String,
options: List<String>,
correctOptionId: Int,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendQuizPoll(
chatId, question, options, correctOptionId, isAnonymous, isClosed, disableNotification, replyToMessageId, replyMarkup
)
)
suspend fun RequestsExecutor.sendQuizPoll(
chat: Chat,
question: String,
options: List<String>,
correctOptionId: Int,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(
chat.id, question, options, correctOptionId, isAnonymous, isClosed, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendQuizPoll(
chatId: ChatIdentifier,
isClosed: Boolean = false,
quizPoll: QuizPoll,
question: String = quizPoll.question,
options: List<String> = quizPoll.options.map { it.text },
correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"),
isAnonymous: Boolean = quizPoll.isAnonymous,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendQuizPoll(
chatId, question, options, correctOptionId, isAnonymous, isClosed, disableNotification, replyToMessageId, replyMarkup
)
)
suspend fun RequestsExecutor.sendQuizPoll(
chat: Chat,
isClosed: Boolean = false,
quizPoll: QuizPoll,
question: String = quizPoll.question,
options: List<String> = quizPoll.options.map { it.text },
correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"),
isAnonymous: Boolean = quizPoll.isAnonymous,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(
chat.id, question, options, correctOptionId, isAnonymous, isClosed, disableNotification, replyToMessageId, replyMarkup
)

View File

@@ -0,0 +1,90 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.stickers
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.AddStickerToSet
import com.github.insanusmokrassar.TelegramBotAPI.types.CommonUser
import com.github.insanusmokrassar.TelegramBotAPI.types.UserId
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.StickerSet
suspend fun RequestsExecutor.addStickerToSet(
userId: UserId,
stickerSetName: String,
sticker: FileId,
emojis: String,
maskPosition: MaskPosition? = null
) = execute(
AddStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
)
suspend fun RequestsExecutor.addStickerToSet(
userId: UserId,
stickerSetName: String,
sticker: MultipartFile,
emojis: String,
maskPosition: MaskPosition? = null
) = execute(
AddStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
)
suspend fun RequestsExecutor.addStickerToSet(
user: CommonUser,
stickerSetName: String,
sticker: FileId,
emojis: String,
maskPosition: MaskPosition? = null
) = addStickerToSet(
user.id, stickerSetName, sticker, emojis, maskPosition
)
suspend fun RequestsExecutor.addStickerToSet(
user: CommonUser,
stickerSetName: String,
sticker: MultipartFile,
emojis: String,
maskPosition: MaskPosition? = null
) = addStickerToSet(
user.id, stickerSetName, sticker, emojis, maskPosition
)
suspend fun RequestsExecutor.addStickerToSet(
userId: UserId,
stickerSet: StickerSet,
sticker: FileId,
emojis: String,
maskPosition: MaskPosition? = null
) = addStickerToSet(
userId, stickerSet.name, sticker, emojis, maskPosition
)
suspend fun RequestsExecutor.addStickerToSet(
userId: UserId,
stickerSet: StickerSet,
sticker: MultipartFile,
emojis: String,
maskPosition: MaskPosition? = null
) = addStickerToSet(
userId, stickerSet.name, sticker, emojis, maskPosition
)
suspend fun RequestsExecutor.addStickerToSet(
user: CommonUser,
stickerSet: StickerSet,
sticker: FileId,
emojis: String,
maskPosition: MaskPosition? = null
) = addStickerToSet(
user.id, stickerSet.name, sticker, emojis, maskPosition
)
suspend fun RequestsExecutor.addStickerToSet(
user: CommonUser,
stickerSet: StickerSet,
sticker: MultipartFile,
emojis: String,
maskPosition: MaskPosition? = null
) = addStickerToSet(
user.id, stickerSet.name, sticker, emojis, maskPosition
)

View File

@@ -0,0 +1,54 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.stickers
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.CreateNewStickerSet
import com.github.insanusmokrassar.TelegramBotAPI.types.CommonUser
import com.github.insanusmokrassar.TelegramBotAPI.types.UserId
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
suspend fun RequestsExecutor.createNewStickerSet(
userId: UserId,
name: String,
sticker: FileId,
emojis: String,
containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null
) = execute(
CreateNewStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition)
)
suspend fun RequestsExecutor.createNewStickerSet(
userId: UserId,
name: String,
sticker: MultipartFile,
emojis: String,
containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null
) = execute(
CreateNewStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition)
)
suspend fun RequestsExecutor.createNewStickerSet(
user: CommonUser,
name: String,
sticker: FileId,
emojis: String,
containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null
) = createNewStickerSet(
user.id, name, sticker, emojis, containsMasks, maskPosition
)
suspend fun RequestsExecutor.createNewStickerSet(
user: CommonUser,
name: String,
sticker: MultipartFile,
emojis: String,
containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null
) = createNewStickerSet(
user.id, name, sticker, emojis, containsMasks, maskPosition
)

View File

@@ -0,0 +1,20 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.stickers
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.DeleteStickerFromSet
import com.github.insanusmokrassar.TelegramBotAPI.types.files.Sticker
suspend fun RequestsExecutor.deleteStickerFromSet(
sticker: FileId
) = execute(
DeleteStickerFromSet(
sticker
)
)
suspend fun RequestsExecutor.deleteStickerFromSet(
sticker: Sticker
) = deleteStickerFromSet(
sticker.fileId
)

View File

@@ -0,0 +1,24 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.stickers
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.SetStickerPositionInSet
import com.github.insanusmokrassar.TelegramBotAPI.types.files.Sticker
suspend fun RequestsExecutor.setStickerPositionInSet(
sticker: FileId,
position: Int
) = execute(
SetStickerPositionInSet(
sticker,
position
)
)
suspend fun RequestsExecutor.setStickerPositionInSet(
sticker: Sticker,
position: Int
) = setStickerPositionInSet(
sticker.fileId,
position
)

View File

@@ -0,0 +1,21 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.stickers
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.UploadStickerFile
import com.github.insanusmokrassar.TelegramBotAPI.types.CommonUser
import com.github.insanusmokrassar.TelegramBotAPI.types.UserId
suspend fun RequestsExecutor.uploadStickerFile(
userId: UserId,
sticker: MultipartFile
) = execute(
UploadStickerFile(userId, sticker)
)
suspend fun RequestsExecutor.uploadStickerFile(
user: CommonUser,
sticker: MultipartFile
) = execute(
UploadStickerFile(user.id, sticker)
)

View File

@@ -0,0 +1,6 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.webhook
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.webhook.DeleteWebhook
suspend fun RequestsExecutor.deleteWebhook() = execute(DeleteWebhook())

View File

@@ -0,0 +1,6 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.webhook
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.webhook.GetWebhookInfo
suspend fun RequestsExecutor.getWebhookInfo() = execute(GetWebhookInfo())

View File

@@ -0,0 +1,28 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.webhook
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
import com.github.insanusmokrassar.TelegramBotAPI.requests.webhook.SetWebhook
suspend fun RequestsExecutor.setWebhookInfo(
url: String,
certificate: FileId,
maxAllowedConnections: Int? = null,
allowedUpdates: List<String>? = null
) = execute(
SetWebhook(
url, certificate, maxAllowedConnections, allowedUpdates
)
)
suspend fun RequestsExecutor.setWebhookInfo(
url: String,
certificate: MultipartFile,
maxAllowedConnections: Int? = null,
allowedUpdates: List<String>? = null
) = execute(
SetWebhook(
url, certificate, maxAllowedConnections, allowedUpdates
)
)

208
TelegramBotAPI/README.md Normal file
View File

@@ -0,0 +1,208 @@
# TelegramBotAPI
[![Awesome Kotlin Badge](https://kotlin.link/awesome-kotlin.svg)](https://github.com/KotlinBy/awesome-kotlin)
[![Download](https://api.bintray.com/packages/insanusmokrassar/StandardRepository/TelegramBotAPI/images/download.svg) ](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI/_latestVersion)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI)
[![Build Status](https://jenkins.insanusmokrassar.com/buildStatus/icon?job=TelegramBotAPI_master__publishing)](https://jenkins.insanusmokrassar.com/job/TelegramBotAPI_master__publishing/)
## What is it?
Library for Object-Oriented and type-safe work with Telegram Bot API. Most part of some specific solves or unuseful
moments are describing by official [Telegram Bot API](https://core.telegram.org/bots/api).
## Compatibility
This version compatible with [23th of January 2020 update of TelegramBotAPI (version 4.6)](https://core.telegram.org/bots/api#january-23-2020).
There is Telegram Passport API exception of implemented functionality, which was presented in
[August 2018 update of TelegramBotAPI](https://core.telegram.org/bots/api-changelog#august-27-2018) update. It will be implemented
as soon as possible. All APIs that are not included are presented
[wiki](https://github.com/InsanusMokrassar/TelegramBotAPI/wiki/Not-included-API).
## How to implement library?
Common ways to implement this library are presented here. In some cases it will require additional steps
like inserting of additional libraries (like `kotlin stdlib`). In the examples will be used variable
`telegrambotapi.version`, which must be set up by developer. Available versions are presented on
[bintray](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI), next version is last published:
[![Download](https://api.bintray.com/packages/insanusmokrassar/StandardRepository/TelegramBotAPI/images/download.svg) ](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI/_latestVersion)
Currently, last versions of library can be available from the Maven repository with errors (for the reason difficult in publishing
of signed artifacts in Bintray). You can:
* Use earlier version (available version you can find
[here](https://mvnrepository.com/artifact/com.github.insanusmokrassar/TelegramBotAPI))
* Add `jCenter` repository in build config
### Maven
Dependency config presented here:
```xml
<dependency>
<groupId>com.github.insanusmokrassar</groupId>
<artifactId>TelegramBotAPI</artifactId>
<version>${telegrambotapi.version}</version>
</dependency>
```
### Gradle
To use last versions you will need to add one line in repositories block of your `build.gradle`:
`jcenter()` or `mavenCentral()`
And add next line to your dependencies block:
```groovy
implementation "com.github.insanusmokrassar:TelegramBotAPI:$telegrambotapi_version"
```
or for old gradle:
```groovy
compile "com.github.insanusmokrassar:TelegramBotAPI:$telegrambotapi_version"
```
## How to work with library?
For now, this library have no some API god-object. Instead of this, this library has several
important objects:
* [RequestsExecutor](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/RequestsExecutor.kt)
* [Requests](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests)
* [Types](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types)
### Types
Types declare different objects representation. For example, `Chat` for now represented as
interface and has several realisations:
* `PrivateChat`
* `GroupChat`
* `SupergroupChat`
* `ChannelChat`
Instead of common garbage with all information as in original [Chat](https://core.telegram.org/bots/api#chat),
here it was separated for more obvious difference between chats types and their possible content.
The same principle work with a lot of others things in this Telegram bot API.
### Requests
Requests usually are very simple objects, but some of them are using their own
build factories. For example, the next code show, how to get information about bot:
```kotlin
val requestsExecutor: RequestsExecutor = ...
requestsExecutor.execute(GetMe())
```
Or you can use new syntax:
```kotlin
val bot: RequestsExecutor = ...
bot.getMe()
```
The result type of [GetMe (and getMe extension)](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetMe.kt)
request is
[ExtendedBot](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/User.kt).
### RequestsExecutor
It is base object which can be used to execute requests in API. For now by default included Ktor
realisation of `RequestsExecutor`, but it is possible, that in future it will be extracted in separated
project. How to create `RequestsExecutor`:
```kotlin
val requestsExecutor = KtorRequestsExecutor(
TelegramAPIUrlsKeeper(TOKEN)
)
```
Here:
* `KtorRequestsExecutor` - default realisation with [ktor](https://ktor.io)
* `TelegramAPIUrlsKeeper` - special keeper, which you can save and use for getting files full urls (`resolveFileURL`
extension inside of `PathedFile.kt`)
* `TOKEN` is just a token of bot which was retrieved according to
[instruction](https://core.telegram.org/bots#3-how-do-i-create-a-bot).
By default, for JVM there is implemented `CIO` client engine, but there is not server engine. Both can be changed like
here:
```groovy
dependencies {
// ...
implementation "io.ktor:ktor-server-cio:$ktor_version" // for implementing of server engine
implementation "io.ktor:ktor-client-okhttp:$ktor_version" // for implementing of additional client engine
// ...
}
```
You can avoid using of `server` dependency in case if you will not use `Webhook`s. In this case,
dependencies list will be simplify:
```groovy
dependencies {
// ...
implementation "io.ktor:ktor-client-okhttp:$ktor_version" // for implementing of additional client engine
// ...
}
```
Here was used `okhttp` realisation of client, but there are several others engines for Ktor. More information
available on ktor.io site for [client](https://ktor.io/clients/http-client/engines.html) and [server](https://ktor.io/quickstart/artifacts.html)
engines.
## Getting updates
In this library currently realised two ways to get updates from telegram:
* Polling - in this case bot will request updates from time to time (you can set up delay between requests)
* Webhook via reverse proxy or something like this
### Updates filters
Currently webhook method contains `UpdatesFilter` as necessary argument for getting updates.
`UpdatesFilter` will sort updates and throw their into different callbacks. Currently supporting
separate getting updates for media groups - they are accumulating with debounce in one second
(for being sure that all objects of media group was received).
Updates polling also support `UpdatesFilter` but it is not required to use it and you can get updates directly
in `UpdateReceiver`, which you will provide to `startGettingOfUpdates` method
### Webhook set up
If you wish to use webhook method, you will need:
* White IP - your IP address or host, which available for calling. [TelegramBotAPI](https://core.telegram.org/bots/api#setwebhook)
recommend to use some unique address for each bot which you are using
* SSL certificate. Usually you can obtain the certificate using your domain provider, [Let'sEncrypt](https://letsencrypt.org/) or [create it](https://core.telegram.org/bots/self-signed)
* Nginx or something like this
Template for Nginx server config you can find in [this gist](https://gist.github.com/InsanusMokrassar/fcc6e09cebd07e46e8f0fdec234750c4#file-nginxssl-conf).
For webhook you can provide `File` with public part of certificate, `URL` where bot will be available and inner `PORT` which
will be used to start receiving of updates. Actually, you can skip passing of `File` when you have something like
nginx for proxy forwarding.
In case of using `nginx` with reverse-proxy config, setting up of Webhook will look like:
```kotlin
requestsExecutor.setWebhook(
WEBHOOK_URL,
INTERNAL_PORT,
filter,
ENGINE_FACTORY
)
```
Here:
* `WEBHOOK_URL` - the url which will be used by Telegram system to send updates
* `INTERNAL_PORT` - the port which will be used in bot for listening of updates
* `filter` - instance of [UpdatesFilter](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/UpdatesFilter.kt),
which will be used to filter incoming updates
* `ENGINE_FACTORY` - used factory name, for example, `CIO` in case of usage `io.ktor:ktor-server-cio` as server engine

View File

@@ -17,7 +17,7 @@ plugins {
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version"
}
project.version = "0.20.1"
project.version = "$library_version"
project.group = "com.github.insanusmokrassar"
apply from: "publish.gradle"

View File

@@ -1,5 +1,4 @@
apply plugin: 'maven-publish'
apply plugin: 'signing'
task javadocsJar(type: Jar) {
classifier = 'javadoc'
@@ -35,25 +34,24 @@ publishing {
}
developers {
developer {
id "InsanusMokrassar"
name "Ovsiannikov Aleksei"
email "ovsyannikov.alexey95@gmail.com"
}
}
licenses {
license {
name "Apache Software License 2.0"
url "https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"
}
}
}
}
}
}
signing {
useGpgCmd()
sign(publishing.publications)
}
}

View File

@@ -0,0 +1,55 @@
apply plugin: 'com.jfrog.bintray'
apply from: "maven.publish.gradle"
bintray {
user = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER')
key = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY')
filesSpec {
from "${buildDir}/publications/"
eachFile {
String directorySubname = it.getFile().parentFile.name
if (it.getName() == "module.json") {
if (directorySubname == "kotlinMultiplatform") {
it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.module")
} else {
it.setPath("${project.name}-${directorySubname}/${project.version}/${project.name}-${directorySubname}-${project.version}.module")
}
} else {
if (directorySubname == "kotlinMultiplatform" && it.getName() == "pom-default.xml") {
it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.pom")
} else {
it.exclude()
}
}
}
into "${project.group}".replace(".", "/")
}
pkg {
repo = "StandardRepository"
name = "${project.name}"
vcsUrl = "https://github.com/InsanusMokrassar/TelegramBotAPI"
licenses = ["Apache-2.0"]
version {
name = "${project.version}"
released = new Date()
vcsTag = "${project.version}"
gpg {
sign = true
passphrase = project.hasProperty('signing.gnupg.passphrase') ? project.property('signing.gnupg.passphrase') : System.getenv('signing.gnupg.passphrase')
}
}
}
}
bintrayUpload.doFirst {
publications = publishing.publications.collect {
if (it.name.contains('kotlinMultiplatform')) {
null
} else {
it.name
}
} - null
}
bintrayUpload.dependsOn publishToMavenLocal

View File

@@ -1,7 +1,7 @@
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.utils.fullListOfSubSource
interface Captioned {
val caption: String?
@@ -12,5 +12,7 @@ interface CaptionedOutput : Captioned {
}
interface CaptionedInput : Captioned {
val captionEntities: List<MessageEntity>
val captionEntities: List<TextPart>
}
fun CaptionedInput.fullEntitiesList() = caption ?.fullListOfSubSource(captionEntities) ?.map { it.source } ?: emptyList()

View File

@@ -0,0 +1,17 @@
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts
interface TextSource {
val asMarkdownSource: String
val asMarkdownV2Source: String
val asHtmlSource: String
}
interface MultilevelTextSource : TextSource {
val textParts: List<TextPart>
}
data class TextPart(
val range: IntRange,
val source: TextSource
)

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