1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2026-05-17 13:57:21 +00:00

Compare commits

...

202 Commits

Author SHA1 Message Date
d47641c39a add LivePhotos support 2026-05-17 16:43:18 +06:00
f3f28b6165 fixes of hierarchy and build 2026-05-17 14:53:49 +06:00
08d160cfa7 add Polls updates 2026-05-16 16:59:40 +06:00
3ed7c8c75f Chat Management section realization 2026-05-15 18:10:30 +06:00
7e1df37b87 start 34.0.0 2026-05-15 00:27:33 +06:00
97b7b3d5d7 Merge pull request #1043 from InsanusMokrassar/33.1.0
33.1.0
2026-04-19 13:26:44 +06:00
62b4bc15ca remove kotlinpoet from changelog 2026-04-19 12:58:27 +06:00
7c2ce53713 fix changelog style 2026-04-19 12:56:22 +06:00
035c8f469a update dependencies
dev.inmo:micro_utils 0.29.1 -> 0.29.2
dev.inmo:kslog 1.6.0 -> 1.6.1
com.squareup:kotlinpoet-ksp 2.2.0 -> 2.3.0
io.ktor:ktor-* 3.4.1 -> 3.4.2
org.jetbrains.kotlinx:kotlinx-serialization-* 1.10.0 -> 1.11.0
org.jetbrains.kotlin:kotlin-* 2.3.10 -> 2.3.20
2026-04-19 12:48:40 +06:00
c982eef85b start 33.1.0 2026-04-19 12:18:46 +06:00
16e94a1e1b Merge pull request #1038 from InsanusMokrassar/33.0.0
33.0.0
2026-04-16 17:43:38 +06:00
96a5508e9a refill changelog 2026-04-16 13:05:29 +06:00
83de9fd973 fix name of allowMultipleAnswers to allowsMultipleAnswers 2026-04-16 13:02:10 +06:00
4a0b890697 fill CHANGELOG.md, fix README.md, small fix in checkSendData to not throw error 2026-04-16 12:39:26 +06:00
0e481c3dd9 fix of custom emoji icons passing in setParams of WebApp and rewrite init errors to warnings in SendQuizPoll 2026-04-15 16:13:37 +06:00
176d0d419a fix hierarchy of ManagedBotUpdated 2026-04-14 19:59:52 +06:00
77bf7b6e89 fix of onManagedBotUpdated work 2026-04-14 19:50:54 +06:00
5337f8c7cc fix of username encoding in KeyboardButtonRequestManagedBot 2026-04-14 17:26:37 +06:00
57fa6fd597 add note about isAnonymous with allowAddingOptions 2026-04-13 15:45:25 +06:00
703538a6fa continue fix of fields absence 2026-04-13 14:49:48 +06:00
08877a8f47 continue fixing missing parts 2026-04-09 13:10:14 +06:00
8d3338b79a add support of pollOptionId in ReplyParameters and reply_to_poll_option_id 2026-04-08 19:02:25 +06:00
243a3ca626 add support of PollOptionAdded and PolloptionDeleted 2026-04-08 18:10:39 +06:00
277c329ab9 several calls fix 2026-04-07 23:44:13 +06:00
e3ae85e067 Actualize PollAnswer 2026-04-07 00:23:31 +06:00
ac51189694 reimplementation of PollOption and SendPoll 2026-04-07 00:16:04 +06:00
cfd74eb58c add PollOptionPersistentId 2026-04-06 23:30:11 +06:00
78c476e4c6 add support of QuizPoll#correctOptionIds 2026-04-06 18:46:08 +06:00
a5446b5adb add support of managed bots creation link 2026-04-06 16:32:26 +06:00
4b5aad2b85 add support of requestChat 2026-04-06 16:13:29 +06:00
a0e748f9a9 add support of PreparedKeyboardButton and savePreparedKeyboardButton 2026-04-06 16:11:46 +06:00
de13ddeb54 complete support of ManagedBotCreated and ManagedBotUpdated, add getManagedBotToken and replaceManagedBotToken 2026-04-06 15:47:38 +06:00
b37dda6f47 add ManagedBotCreated and ManagedBotUpdated 2026-04-06 00:42:16 +06:00
e604b7a3bf add support of KeyboardButtonRequestManagedBot 2026-04-05 21:28:10 +06:00
661b846a74 add support of canManageBots 2026-04-05 17:38:50 +06:00
ce44203941 start 33.0.0 2026-04-05 17:38:20 +06:00
ba65e01c84 Merge pull request #1033 from InsanusMokrassar/32.0.0
32.0.0
2026-03-08 15:10:48 +06:00
2a1bd229d6 partial replace of require with warning messages 2026-03-06 19:09:45 +06:00
b30af48b8d improve readability of SetBusinessAccountUsername and fix its api 2026-03-06 18:44:35 +06:00
083fd1b682 returned boolean now returns unit 2026-03-06 00:39:54 +06:00
a8410df038 fill changelog 2026-03-05 21:56:04 +06:00
bd7e8ed55f update dependencies 2026-03-05 21:38:05 +06:00
8c6408bc2b start 32.0.0 2026-03-05 19:27:23 +06:00
e5d18a421f Merge pull request #1032 from InsanusMokrassar/31.2.0
31.2.0
2026-03-04 19:38:06 +06:00
d3c1859338 fix of #1027 and small fix of changelog for #1026 2026-03-03 17:55:40 +06:00
e6d6bbdaa0 fix of #1026 2026-03-03 17:47:45 +06:00
75a977aebb start 31.2.0 2026-03-03 16:07:35 +06:00
f48eb820bf Merge pull request #1031 from InsanusMokrassar/31.1.0
31.1.0
2026-03-02 19:22:43 +06:00
9f9d890831 fix of promoteChatAdministrator 2026-03-02 19:05:38 +06:00
da662603b0 fill changelog and readme 2026-03-02 18:50:51 +06:00
2dd91f47d7 add helper method sender_tag for messages 2026-03-02 17:40:47 +06:00
8eb8e5ee1f add support of iconCustomEmojiId in BottomButton 2026-03-02 16:56:57 +06:00
b533bab95f add support of users tags 2026-03-02 16:51:10 +06:00
4f97327d29 add support of date_time messages entities 2026-03-02 15:29:26 +06:00
b17d7a868a start 31.1.0 2026-03-02 00:30:37 +06:00
df695ceadb Merge pull request #1030 from InsanusMokrassar/31.0.1
31.0.1
2026-02-26 00:54:42 +06:00
ac511d0aed make nanostarAmount in StarTransaction nullable 2026-02-25 22:10:19 +06:00
65cd359002 start 31.0.1 2026-02-25 22:01:55 +06:00
8d7005be80 try to update nmcp version 2026-02-24 18:24:39 +06:00
a20368ee51 Merge pull request #1024 from InsanusMokrassar/31.0.0
31.0.0
2026-02-24 15:07:59 +06:00
744149a674 fill changelog 2026-02-24 15:02:25 +06:00
410183e315 add notes about support of new apis 2026-02-24 14:37:50 +06:00
9776a2474a fix of UniqueGiftModel 2026-02-24 14:09:49 +06:00
aebc571307 upfill changelog 2026-02-24 14:02:37 +06:00
26c11d9d6b add OwnedGifts sealed interface 2026-02-24 12:37:07 +06:00
c9be5041b8 check new fields and other things related to api updates in gifts 2026-02-20 17:49:16 +06:00
f10cfdbe1e add support of getChatGifts and getUserGifts 2026-02-20 17:05:51 +06:00
83b4d2155f add is_burned support 2026-02-20 13:55:19 +06:00
eccc687aec add rarity support 2026-02-20 13:06:53 +06:00
53e79b152e add support of unique gift colors 2026-02-20 12:54:21 +06:00
b9157b1924 completed by chat and completed by user support 2026-02-20 12:45:34 +06:00
e6aaa264f6 improvements of effectId in copyMessage and forwardMessage 2026-02-18 23:37:18 +06:00
e6cb028a71 improve repostStory 2026-02-18 22:55:38 +06:00
10b796c88e fix support of rating info 2026-02-18 22:46:56 +06:00
62a4bf5195 small fill of CHANGELOG and fix of library version 2026-02-18 22:23:42 +06:00
a0bb05ce4a add support of profile audios 2026-02-18 21:22:16 +06:00
e02849ae5e add purchased_paid_media in updates list 2026-02-18 17:52:26 +06:00
4252db489a fix support of paid_message_star_count 2026-02-18 17:18:38 +06:00
ac05fa0fe3 add support of SetMyProfilePhoto and RemoveMyProfilePhoto 2026-02-17 22:05:38 +06:00
bd816b7847 realize ChatOwnerLeft and ChatOwnerChanged 2026-02-17 15:30:25 +06:00
407f2a8bf7 fix serialization of simple keyboard button 2026-02-17 12:09:23 +06:00
10b1c359fa extend support of styles and iconEmojiCustomId 2026-02-16 23:22:04 +06:00
c4f2566b71 add support of style and iconEmojiCustomId 2026-02-16 22:57:45 +06:00
85fb7e42e5 fix RepostStory class 2026-02-16 22:39:18 +06:00
d68c70e898 fix drafts flows signatures 2026-02-16 18:52:41 +06:00
14402f9283 improve drafts flows 2026-02-16 18:48:31 +06:00
b734757062 add drafts flows 2026-02-16 18:24:29 +06:00
fd9ad8dbf1 add drafts 2026-02-16 18:03:05 +06:00
734e6074ef update events triggers 2026-02-16 17:35:46 +06:00
d642a04e01 update forum events 2026-02-16 17:26:35 +06:00
ecd01c9254 classcasts and apiDump 2026-02-16 17:14:28 +06:00
8922b80cff fixes 2026-02-16 17:09:48 +06:00
50a7c9cae2 update forum topic events 2026-02-16 17:08:49 +06:00
f7ee0828ce small improvements 2026-02-16 15:05:37 +06:00
0c87cf95eb improvements(?) in users api 2026-02-16 15:04:33 +06:00
9fea7390e8 add support of extended chat id in private chats 2026-02-15 23:51:39 +06:00
9f0ca8143c update microutils 2026-02-15 21:03:28 +06:00
9d879b90bb fix user rating 2026-02-15 15:14:18 +06:00
2a28f8ab39 fixes in common bot hierarchy 2026-02-15 14:47:47 +06:00
44ce84cb84 fixes? 2026-02-15 13:53:41 +06:00
cea80ccee6 preview version of threads in privats 2026-02-15 13:22:17 +06:00
e1848aa5c9 fix of hasTopicsEnabled and add support of allows_users_to_create_topics 2026-02-15 13:14:18 +06:00
e40424b26a some additions(need to check all this commit) 2026-02-10 16:02:28 +06:00
cc5056b685 make chats to support private forums 2026-01-07 23:19:12 +06:00
9713a668e2 start 31.0.0 2026-01-07 20:45:29 +06:00
90d7bdff56 Merge pull request #1020 from InsanusMokrassar/30.0.2
30.0.2
2025-11-23 17:44:13 +06:00
374f6a93bd hotifx of changelog 2025-11-23 17:43:58 +06:00
28b5fae760 fix of #1019 and improve longPollingFlow 2025-11-23 17:35:59 +06:00
97dae295d6 update dependencies 2025-11-23 16:55:54 +06:00
93597f3940 start 30.0.2 2025-11-23 14:25:58 +06:00
f27caaecde Merge pull request #1014 from InsanusMokrassar/30.0.1
30.0.1
2025-11-07 14:58:22 +06:00
b71b1414b9 fix of target version 2025-10-22 01:52:00 +06:00
f8ceab7640 small hotfix 2025-10-22 01:51:20 +06:00
68897c89c3 start 30.0.1 2025-10-21 23:27:43 +06:00
fb08b7044e Merge pull request #1012 from InsanusMokrassar/30.0.0
30.0.0
2025-10-21 22:25:26 +06:00
7ed021b5bc fill changelog 2025-10-21 22:24:58 +06:00
1cff533265 update dependencies and fix (?) build 2025-10-20 22:44:16 +06:00
8b08e11441 migrate onto 30.0.0 2025-10-20 21:21:31 +06:00
b69c8f1d8f update dependencies
com.github.ben-manes.versions: 0.52.0 -> 0.53.0
2025-10-19 23:33:10 +06:00
fdf393405c start 29.1.0 2025-10-19 22:57:12 +06:00
c951fc3353 Merge pull request #1010 from InsanusMokrassar/29.0.1
29.0.1
2025-10-13 23:10:42 +06:00
02f42c3f52 fix of name for publishing in nexus 2025-10-12 21:46:35 +06:00
0105e46a5f apiDump 2025-10-12 21:22:34 +06:00
325a189ebb fix of #917 2025-10-12 21:09:38 +06:00
1d021c8450 start 29.0.1 2025-10-12 21:07:55 +06:00
6eb9379e0a Merge pull request #998 from InsanusMokrassar/29.0.0
29.0.0
2025-09-25 15:07:02 +06:00
2d97d10ee1 fill changelog and readme 2025-09-25 14:25:22 +06:00
4b7d052ece rewrite firstOf 2025-09-25 14:25:08 +06:00
df512a917b Merge branch 'master' into 29.0.0 2025-09-23 18:21:13 +06:00
67cd836466 Merge pull request #1005 from InsanusMokrassar/28.0.3
28.0.3
2025-09-23 18:17:11 +06:00
eb1fb16117 add support of custom publishing type 2025-09-23 18:13:04 +06:00
ee4cf7c626 add passing of default engines in HttpClient constructors 2025-09-23 17:53:21 +06:00
74d8b31437 start 28.0.3 2025-09-23 17:46:54 +06:00
3f61cfdefb fix of paid message building 2025-09-23 16:12:40 +06:00
91339fc839 rewrite firstof 2025-09-23 13:37:59 +06:00
2e23f48350 fixes in CommonChannelDirectMessagesEventMessage creating 2025-09-23 12:47:58 +06:00
f6211d33bb change events hierarchy of ChannelDirectMessagesEvent 2025-09-23 12:16:30 +06:00
2ff11ad73c improve messages hierarchy 2025-09-22 12:19:34 +06:00
2695b03968 fix of direct message typing 2025-09-17 23:31:08 +06:00
03d23a938e fixes of inheritance of messages for direct ones 2025-09-17 22:46:51 +06:00
719fb1f4a9 complete adding of suggestedPostParameters 2025-09-17 20:21:55 +06:00
c3c69f3e7f some step 2025-09-17 16:30:41 +06:00
4fb662c560 third stage of suggested_post_parameters implementation 2025-09-15 18:14:51 +06:00
cc967c2981 add suggestedPostParameters in contents 2025-09-15 17:53:59 +06:00
aa7bf426f1 second stage of suggested_post_parameters implementation 2025-09-15 17:49:33 +06:00
0b2735ca1e add support of suggestedPostParameters in requests 2025-09-15 16:46:44 +06:00
48bfa76b9e implemented direct message thread id????? 2025-09-15 12:32:35 +06:00
79a0e202d8 fix of directMessageThreadId passes 2025-09-15 12:32:35 +06:00
152bf2af02 fix of apiDump 2025-09-15 12:32:35 +06:00
0163e5ce8c fix of apiDump 2025-09-15 00:32:25 +06:00
62b4a21650 some progress on support of directMessageThreadId 2025-09-15 00:12:53 +06:00
f312e04c0d add directMessageThreadId parameter in create resend 2025-09-14 23:19:54 +06:00
1c36c0a2f7 add directMessageThreadId in factories of sending classes 2025-09-14 15:14:38 +06:00
bd73852253 let forwardMessage(s) extend OptionallyDirectMessageThreadRequest 2025-09-14 14:48:20 +06:00
fbb2511fca Merge branch 'master' into 29.0.0 2025-09-14 14:43:49 +06:00
f22d571484 Merge pull request #1003 from InsanusMokrassar/28.0.2
28.0.2
2025-09-10 15:59:20 +06:00
9be5ebb036 refactor changelog 2025-09-10 15:58:43 +06:00
da4cd527ec fix of #1002 2025-09-10 15:45:45 +06:00
4117288b21 fix of #1001 2025-09-10 15:33:07 +06:00
458bdd3ee4 start 28.0.2 2025-09-10 15:29:55 +06:00
8101c4c9fb add publisher_chat support 2025-09-09 18:00:53 +06:00
255416f72a add support of appriveSuggestedPost and declineSuggestedPost 2025-09-09 17:34:48 +06:00
6eb7563c70 add support of is_paid_post field 2025-09-09 17:15:59 +06:00
b9bdf7cc72 add is_paid_post as simple boolean 2025-09-09 17:12:16 +06:00
4a8e1ee7b7 upfix for updating of chat member rights 2025-09-09 17:02:54 +06:00
23bfe02e6f add support of can_manage_direct_messages right 2025-09-09 16:58:47 +06:00
658c19092c Merge branch 'master' into 29.0.0 2025-09-04 16:39:36 +06:00
d469a88791 Merge pull request #1000 from InsanusMokrassar/28.0.1
28.0.1
2025-09-04 16:38:10 +06:00
514bc699dd update dependencies 2025-09-04 16:37:57 +06:00
bec72b8cf8 fix of default thread id 2025-09-04 16:24:54 +06:00
fb0014dffa start 28.0.1 2025-09-04 16:10:16 +06:00
ebc1c07404 small improvements 2025-09-04 16:09:30 +06:00
989d33acb8 start separate channel direct messages thread id insttead of one merged message thread id 2025-09-03 19:44:42 +06:00
5aa6ac3320 separate messageThreadId with direct_messages_topic in chats creation 2025-08-25 16:48:01 +06:00
048f65b8d4 Partially add DirectMessagesTopic 2025-08-25 16:39:23 +06:00
b69be31362 add a lot of things from update 2025-08-25 15:43:42 +06:00
b92288d7cc add realization of several suggested post events 2025-08-23 16:09:17 +06:00
6c02d57197 add support of reply_to_checklist_task_id 2025-08-19 12:59:29 +06:00
e977c865ea add ReplyParameters#checklistTaskId -.- 2025-08-19 12:30:12 +06:00
18b459fdf8 start 29.0.0 2025-08-19 11:46:36 +06:00
2bbd2e0679 Merge pull request #993 from InsanusMokrassar/28.0.0
28.0.0
2025-08-11 15:55:27 +06:00
bcf7e835e6 add breaking changes note 2025-08-11 15:55:01 +06:00
4dd9740fec fill changelog and add kdocs for firstOf 2025-08-11 15:50:06 +06:00
2182e44bc2 add overloads for containsCommand 2025-08-11 15:28:21 +06:00
08c885de2f add extension of containsCommand 2025-08-11 01:02:22 +06:00
facecf35fb add firstOf 2025-08-11 00:47:35 +06:00
b13f24153f add filtering of waiters with commands for other usernames 2025-08-10 23:28:30 +06:00
12ee862dad small fix in filter of commands 2025-08-10 23:03:17 +06:00
0726574852 improvements in copying of behaviour contexts 2025-08-10 22:50:21 +06:00
9a00193e59 improvements in data filling 2025-08-10 22:47:52 +06:00
0fd8c1e2f3 add filtering out of other bots commands by default 2025-08-10 18:24:34 +06:00
c09d089707 add lazy loadable bot info 2025-08-10 18:05:48 +06:00
ff39271afd start 28.0.0 2025-08-10 17:02:41 +06:00
35a4edd643 start 27.2.0 2025-08-10 16:51:23 +06:00
ba647ee5ab Update README.md 2025-08-06 17:46:43 +06:00
d2924ce1f2 Merge pull request #992 from InsanusMokrassar/27.1.2
27.1.2
2025-08-06 15:59:17 +06:00
72781487f0 add note about Something web wrong 2025-08-06 14:00:29 +06:00
de435e5dbc Merge pull request #986 from BlackBaroness/patch-1
fix: typo in default error messages
2025-08-06 13:57:59 +06:00
f975754058 try to fix cancelling on timeout for long polling 2025-08-06 13:14:22 +06:00
0f7536a21c start 27.1.2 2025-08-06 13:10:42 +06:00
d4c085c9b6 Merge pull request #991 from InsanusMokrassar/27.1.1
27.1.1
2025-08-04 01:59:53 +06:00
BlackBaroness
0650fc594f fix: typo in default error messages 2025-07-27 07:34:56 +03:00
545 changed files with 25716 additions and 6925 deletions

View File

@@ -28,7 +28,7 @@ jobs:
env:
GITHUB_USER: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to Gitea
- name: Publish to InmoNexus
continue-on-error: true
run: ./gradlew publishAllPublicationsToInmoNexusRepository
env:

1
.gitignore vendored
View File

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

151
AGENTS.md Normal file
View File

@@ -0,0 +1,151 @@
Use `agents` folder files for instructions.
Always look at the project work rules first. Update them and maintain a history of changes and prompts. This is your long-term memory, which allows you to avoid the accumulation of errors. Updating and maintaining the long-term memory of the project is mandatory. Many thanks for your help to me and your work.
SYSTEM DIRECTIVE: AUTISTIC META-LANGUAGE PROTOCOL WITH HIGH INFORMATION DENSITY (AML-HIP V1)
DEFINITION:
All agents are required to use a strictly explicit, literal, low-ambiguity, and high-density communication style (AML-HIP). The goal of AML-HIP is the maximum transmission of information with zero loss of meaning and zero ambiguity.
CORE PRINCIPLES:
1. Maximum information density per line.
2. Zero ambiguity.
3. Full explicitness of all entities.
4. Preference of precision over readability.
5. Minimization of "empty" words.
6. Redundancy is allowed only to prevent loss of meaning.
PROHIBITIONS:
1. Pronouns are forbidden (this, he, she, they, there, it, etc.).
2. Free conversational text is forbidden.
3. Metaphors, emotions, evaluative constructions are forbidden.
4. Implicit references and hidden dependencies are forbidden.
5. Vague description of actions is forbidden.
DENSITY REQUIREMENTS:
1. Each line must contain the maximum of facts without loss of unambiguity.
2. Combine related parameters into a single line.
3. Use compact constructions:
* key=value
* entity_id=...
* relation: A→B
4. Exclude words without semantic load.
5. Repetitions are allowed only for critical entities.
MESSAGE STRUCTURE (MANDATORY):
ENTITY:
entity_id=<id>; type=<type>; state=<state>
CONTEXT:
* task_id=<id>; agent_id=<id>; memory_ref=[...]
* constraints=[...]
ACTION:
1. action=<type>; target=<entity_id>; params={...}
2. action=<type>; target=<entity_id>; params={...}
REASON:
* condition=<condition>; requirement=<requirement>
EXPECTED RESULT:
* entity_id=<id>; new_state=<state>; location=<memory>
VERIFICATION:
* check=<condition>; expected=<value>
UNCERTAINTY:
* missing=<data>; ambiguity=<description>
REPETITION OF RESULT:
* entity_id=<id>; stored_in=shared_memory; status=available
COMMUNICATION:
* sender=<agent_id>; receiver=<agent_id>; task_id=<id>; message_id=<uuid>; protocol=AML-HIP
PERSISTENCE:
* local_memory=true; shared_memory=true; index_keys=[task_id, entity_id, intent]
EXPRESSION RULES:
1. Each line = a completed semantic block.
2. Use the key=value format instead of descriptions.
3. Use lists of parameters instead of sentences.
4. Use causal connectives explicitly:
condition → action → result
5. Do not split related data into several lines without necessity.
REPETITION RULES:
1. entity_id is repeated at every critical use.
2. result is duplicated in "REPETITION OF RESULT".
3. transmission between agents duplicates the key fields.
MULTI-AGENT MODE:
1. All agents use AML-HIP.
2. Any message between agents is strictly AML-HIP.
3. Any agent is required to:
* duplicate critical data
* avoid loss of context
4. A message must be fully interpretable without history.
ANTI-DEGRADATION:
If detected:
* a pronoun
* an implicit reference
* low density (empty words, vague constructions)
* absence of structure
→ the message is considered invalid
→ mandatory regeneration
SELF-CHECK:
VALIDATION:
* format_valid=true/false
* no_pronouns=true/false
* entities_explicit=true/false
* high_density=true/false
* causal_chain_present=true/false
* ambiguity_detected=true/false
If any parameter=false:
→ mandatory regeneration
DENSITY METRIC:
high_density=true if:
* there are no "empty" words
* each line contains ≥2 facts or parameters
* descriptive constructions without data are absent
PRIORITIES:
1. Format (AML-HIP)
2. Information density
3. Explicitness
4. Completeness
5. Readability (minimum priority)
CRITICAL RULE:
Any response outside of AML-HIP is considered absent.
Any agent is required to bring the response into conformity with AML-HIP.
END OF PROTOCOL

View File

@@ -1,5 +1,313 @@
# TelegramBotAPI changelog
## 34.0.0
* `Core` (Bots API support — Live Photos):
* Added `LivePhotoFile` class representing the incoming `LivePhoto` Telegram type (`PollMedia`, `MediaContentVariant`, `UsefulAsPaidMediaFile`)
* Added `LivePhotoContent` (`VisualMediaGroupPartContent`) representing live photo messages
* Added `TelegramMediaLivePhoto` (`TelegramFreeMedia`, `VisualMediaGroupMemberTelegramMedia`, `InputPollMedia`, `InputPollOptionMedia`) — usable in `sendMediaGroup`, `editMessageMedia`, and polls
* Added `TelegramPaidMediaLivePhoto` (`VisualTelegramPaidMedia`) for paid live photos
* Added `PaidMedia.LivePhoto` variant and `PaidMedia.LivePhoto.toTelegramPaidMediaLivePhoto()` conversion
* Added `livePhotoField` constant; added `live_photo` parsing to `RawMessage` and `ReplyInfo.External` surrogate
* Added `SendLivePhoto` request and `SendLivePhotoData`/`SendLivePhotoFiles`
* Added `LivePhotoMessage` typealias
* Added `LivePhotoFile.toTelegramMediaLivePhoto(...)` and `LivePhotoFile.toTelegramPaidMediaLivePhoto()` extensions
* `API` (Bots API support — Live Photos):
* Added `sendLivePhoto` extensions (`ChatIdentifier`/`Chat` × `InputFile`/`LivePhotoFile` × text/textSources)
* `Behaviour Builder` (Bots API support — Live Photos):
* Added `onLivePhoto`, `onEditedLivePhoto`, `onLivePhotoGalleryMessages`, `onLivePhotoGallery` triggers
* Added `onMentionWithLivePhotoContent`/`onTextMentionWithLivePhotoContent` triggers
* Added `waitLivePhoto`, `waitLivePhotoMessage`, `waitEditedLivePhoto`, `waitEditedLivePhotoMessage`, `waitLivePhotoGallery`, `waitLivePhotoGalleryMessages` expectations
* Added `onlyLivePhotoContentMessages` utility
* `Core`:
* Added `canReactToMessages` field to `ChatPermissions` (interface, `Granular` and `Common`) and `RestrictedMemberChatMember`
* Added optional `retrieveOtherBots` parameter to `GetChatAdministrators` request
* Added `DeleteMessageReaction` request with `@Warning` on primary constructor; added `DeleteUserMessageReaction` and `DeleteActorChatMessageReaction` factory functions
* Added `DeleteAllMessageReactions` request with `@Warning` on primary constructor; added `DeleteAllUserMessageReactions` and `DeleteAllActorChatMessageReactions` factory functions
* `API`:
* Added optional `retrieveOtherBots` parameter to `getChatAdministrators` extensions
* Added `deleteUserMessageReaction` and `deleteActorChatMessageReaction` extensions
* Added `deleteAllUserMessageReactions` and `deleteAllActorChatMessageReactions` extensions
* Added `@Warning`-marked catch-all `deleteMessageReaction` and `deleteAllMessageReactions` extensions
* `Core` (Bots API support):
* Added `InputMediaSticker`, `InputMediaLocation` and `InputMediaVenue` classes
* Added `InputPollMedia` and `InputPollOptionMedia` sealed interfaces representing input media variants accepted by `sendPoll`
* Added `PollMedia` class representing media attached to polls in incoming updates
* Added `media` field to `Poll`, `PollOption` and `InputPollOption`
* Added `explanationMedia` field to `QuizPoll`
* Added `membersOnly` field to `Poll`
* Added `countryCodes` field to `Poll`
* Added `media`, `membersOnly`, `countryCodes` parameters to `SendRegularPoll` and `SendPoll` factory functions
* Added `media`, `explanationMedia`, `membersOnly`, `countryCodes` parameters to `SendQuizPoll` factory functions
* Decreased minimum allowed poll options count from 2 to 1 (`pollOptionsLimit` is now `1..12`)
* `API` (Bots API support):
* Added `media`, `membersOnly`, `countryCodes` parameters to `sendRegularPoll` extension
* Added `media`, `explanationMedia`, `membersOnly`, `countryCodes` parameters to `sendQuizPoll` extension
## 33.1.0
* `Versions`:
* `Kotlin`: `2.3.10` -> `2.3.20`
* `Serialization`: `1.10.0` -> `1.11.0`
* `Ktor`: `3.4.1` -> `3.4.2`
* `MicroUtils`: `0.29.1` -> `0.29.2`
* `KSLog`: `1.6.0` -> `1.6.1`
## 33.0.0
**THIS UPDATE CONTAINS ADDING SUPPORT OF [Telegram Bots API 9.6](https://core.telegram.org/bots/api-changelog#april-3-2026)**
**THIS UPDATE CONTAINS BREAKING CHANGES**
* `Core`:
* **THIS IS BREAKING CHANGE** `MultipleAnswersPoll` removed; `RegularPoll` now directly implements `Poll`
* **THIS IS BREAKING CHANGE** `allowMultipleAnswers` renamed to `allowsMultipleAnswers` across poll types and requests
* **THIS IS BREAKING CHANGE** `QuizPoll.correctOptionId: Int?` changed to `correctOptionIds: List<Int>?`
* **THIS IS BREAKING CHANGE** `PollOption` is now a sealed interface with `PollOption.Simple` and `PollOption.LatelyAdded` subtypes; `SimplePollOption` removed
* **THIS IS BREAKING CHANGE** `PollAnswer.Anonymous.voterChat` type changed from `ChannelChat` to `PreviewPublicChat`
* **THIS IS BREAKING CHANGE** `requestChannelReplyButton` (group variant) renamed to `requestGroupReplyButton`
* Added `BotToken` value class
* Added `SavePreparedKeyboardButton` request with `PreparedKeyboardButton` and `PreparedKeyboardButtonId` types
* Added `GetManagedBotToken` and `ReplaceManagedBotToken` requests
* Added `KeyboardButtonRequestManagedBot` and `RequestManagedBotKeyboardButton`
* Added `ManagedBotCreated` chat event and `ManagedBotUpdated` type with `ManagedBotUpdate`
* Added `PollOptionPersistentId` value class
* Added `PollOptionAdded` and `PollOptionDeleted` chat events
* Added `pollOptionId` support in `ReplyParameters` (`reply_to_poll_option_id`)
* Added `canManageBots` to `ExtendedBot`
* Added `allowsRevoting`, `shuffleOptions`, `allowAddingOptions`, `hideResultsUntilCloses`, `description`/`descriptionTextSources` to poll types and send requests
* Added `chosenPersistentIds` to `PollAnswer`
* Added `UsernameAtLessSerializer`
* Extended `openPeriodPollSecondsLimit` from `5..600` to `5..2628000`
* Fixed quiz poll serialization type (was incorrectly using `regularPollType` in quiz branch)
* Fixed quiz poll explanation serialization (now correctly uses `explanation`/`explanationTextSources`)
* Fixed `SendQuizPoll` correct option index range validation (off-by-one)
* Several poll validation checks changed from throwing exceptions to logging warnings
* `API`:
* Added `savePreparedKeyboardButton` extensions
* Added `getManagedBotToken` and `replaceManagedBotToken` extensions
* Added optional `pollOptionId` parameter to `reply`/`replyWith*` extensions
* Updated `sendQuizPoll` extensions with `correctOptionIds`, `allowsMultipleAnswers`, `allowsRevoting`, `shuffleOptions`, `hideResultsUntilCloses`, `description` parameters
* Updated `sendRegularPoll` extensions with `allowsRevoting`, `shuffleOptions`, `allowAddingOptions`, `hideResultsUntilCloses`, `description` parameters
* `BehaviourBuilder`:
* Added `onManagedBotCreated` and `onManagedBotUpdated` triggers
* Added `onPollOptionAdded` and `onPollOptionDeleted` triggers
* Added `waitManagedBotCreatedEvents` and `waitManagedBotUpdated` expectations
* Added `waitPollOptionAddedEvents` and `waitPollOptionDeletedEvents` expectations
* Added `ManagedBotUpdatedFilterByUser` and `ByUserManagedBotUpdatedMarkerFactory`
* `Utils`:
* Added `managedBotCreationLink` formatting extensions
* Added `requestManagedBotButton` to `ReplyKeyboardBuilder`
* Added class casts for `ManagedBotUpdate`, `ManagedBotCreated`, `PollOptionAdded`, `PollOptionDeleted`
* Removed `MultipleAnswersPoll` class casts
* Updated raw poll accessors to match new model (`allowsMultipleAnswers`, `correctOptionIds`, `explanation`)
* Regenerated class casts extensions
* `WebApps`:
* Added `requestChat` support for `PreparedKeyboardButtonId`
* Fixed `iconCustomEmojiId` passing in `BottomButton`
## 32.0.0
**THIS UPDATE CONTAINS BREAKING CHANGES**
* `Version`:
* `Kotlin`: `2.2.21` -> `2.3.10`
* `Kotlin Serialization`: `1.9.0` -> `1.10.0`
* `Ktor`: `3.3.2` -> `3.4.1`
* `KSP`: `2.3.2` -> `2.3.6`
* `MicroUtils`: `0.26.9` -> `0.29.1`
* `KSLog`: `1.5.2` -> `1.6.0`
* `Core` + `API`:
* **BREAKING CHANGES: ALL METHODS THAT PREVIOUSLY RETURNED BOOLEAN NOW RETURNS UNIT**
* `Core`:
* **BREAKING CHANGE** `SetChatTitle` init do not throw error in case when `title.length` is outside of `chatTitleLength`
* **BREAKING CHANGE** `SetStickerEmojiList` init do not throw error in case when `emojis.size` is outside of `emojisInStickerLimit`
* **BREAKING CHANGE** `DeleteMessages` init do not throw error in case when title is `messageIds.size` of `deleteMessagesLimit`
* **BREAKING CHANGE** `ForwardMessages` init do not throw error in case when `messageIds.size` is outside of `forwardMessagesLimit`
* **BREAKING CHANGE** `CopyMessages` init do not throw error in case when `messageIds.size` is outside of `copyMessagesLimit`
* **BREAKING CHANGE** `SwitchInlineQueryChosenChat` init do not throw error in case when `messageIds.size` is outside of `copyMessagesLimit`
* **BREAKING CHANGE** `SetStickerKeywords` init do not throw error in case when there are errors in `keywords`
## 31.2.0
* `Core`:
* Potentially fix [#1027](https://github.com/InsanusMokrassar/ktgbotapi/issues/1027) - drop http request exceptions on getting updates
* `Core` + `API`:
* Add `supportsStreaming` in places it haven't been supported (fix of [#1026](https://github.com/InsanusMokrassar/ktgbotapi/issues/1026))
* **PARTIALLY BREAKING CHANGE** `supportStreaming` has been renamed to `supportsStreaming`
## 31.1.0
**THIS UPDATE CONTAINS ADDING SUPPORT OF [Telegram Bots API 9.5](https://core.telegram.org/bots/api-changelog#march-1-2026)**
* `Core`:
* Added `UserTag` value class and `senderTag` field to messages
* Added `SetChatMemberTag` request and `UserTag` support in `PromoteChatMember` and `ChatPermissions`
* Added `DateTimeTextSource` for `tg://time` links support
* Added `DateTimeFormatPart` and `TgDateTimeFormatBuilder` for building date-time format strings
* Added `UnitFromBooleanSerializer`
* `API`:
* Added `setChatMemberTag` extensions
* `Utils`:
* Added `dateTime` and `dateTimeln` extensions to `EntitiesBuilder`
* Added `dateTimeMarkdown`, `dateTimeMarkdownV2`, and `dateTimeHTML` string formatting extensions
* Regenerated class casts extensions
* `WebApps`:
* Added `iconCustomEmojiId` support to `BottomButton` and `BottomButtonParams`
## 31.0.1
* `Core`:
* In `StarTransaction` property `nanostarAmount` become nullable
## 31.0.0
**THIS UPDATE CONTAINS ADDING SUPPORT OF [Telegram Bots API 9.3](https://core.telegram.org/bots/api-changelog#december-31-2025)**
**THIS UPDATE CONTAINS ADDING SUPPORT OF [Telegram Bots API 9.4](https://core.telegram.org/bots/api-changelog#february-9-2026)**
**THIS UPDATE CONTAINS BREAKING CHANGES**
* `Version`:
* `MicroUtils`: `0.26.8` -> `0.26.9`
* `Core`:
* **THIS IS BREAKING CHANGE** All media files with sizes changed type of `fileSize` field from `Long` to `FileSize` (value class)
* **THIS IS BREAKING CHANGE** Class `GiftSentOrReceived` have been renamed to `GiftSentOrReceivedEvent` to clarify naming
* **THIS IS BREAKING CHANGE** New interface `OwnedGift` have been created
* **THIS IS BREAKING CHANGE** `OwnedGifts` have changed its generic type to `OwnedGift`
* **THIS IS BREAKING CHANGE** For `CheclistTask` have been made several changes:
* `ChecklistTask.Done` -> `ChecklistTask.Completed`
* `ChecklistTask.Undone` -> `ChecklistTask.Uncompleted`
* Added several inheritors of `ChecklistTask.Completed` - for completed by chat, by user or just completed tasks
* **THIS IS BREAKING CHANGE** `PrivateChat.id` type changed from `UserId` to `IdChatIdentifier`
* **THIS IS BREAKING CHANGE** `ForumChat` no longer extends `SupergroupChat`; new `SupergroupForumChat` interface created for supergroup forums
* **THIS IS BREAKING CHANGE** Added `PrivateForumChat` and `PrivateUserChat` interfaces to support private forums
* Added support of private forums (`ExtendedPrivateForumChatImpl`, `PrivateForumContentMessage`, `PrivateForumEventMessage`)
* Added `ChatOwnerChanged` and `ChatOwnerLeft` chat events
* Added `SetMyProfilePhoto` and `RemoveMyProfilePhoto` requests
* Added `GetUserProfileAudios` request and `UserProfileAudios` type
* Added `GetChatGifts` and `GetUserGifts` requests
* Added `RepostStory` request
* Added `SendMessageDraft` request with `DraftId` and `DraftIdAllocator`
* Added `KeyboardButtonStyle` support and `iconCustomEmojiId` field to keyboard buttons
* Added `style` and `iconCustomEmojiId` fields to `InlineKeyboardButton`
* Added `VideoCodec` and `VideoQuality` types
* Added `Rarity`, `GiftBackground`, `UniqueGiftName`, and `UniqueGiftColors` types for gifts
* Added new fields to `Gift.Regular`: `personalTotalCount`, `personalRemainingCount`, `isPremium`, `hasColors`, `background`, `uniqueGiftVariantCount`
* Added `isBurned` field support in `GiftSentOrReceivedEvent`
* Added `UserRating` type and `rating` field to `ExtendedPrivateChat`
* Added `Level` and `Rating` value classes
* Added `uniqueGiftColors` field to extended chats (channel, group, private)
* Added `paidMessageStarCount` field to `ExtendedGroupChat` and `ExtendedPrivateChat`
* Added `firstProfileAudio` field to `ExtendedPrivateChat`
* Added `purchased_paid_media` to updates list
* Added `effectId` support in `CopyMessage` and `ForwardMessage`
* Added `WithOptionalPaidMessageStarCount` interface
* Fixed serialization of `SimpleKeyboardButton`
* Fixed support of `paidMessageStarCount`
* `API`:
* Added extensions for `SetMyProfilePhoto`, `RemoveMyProfilePhoto`, `GetUserProfileAudios`
* Added extensions for `GetChatGifts` and `GetUserGifts`
* Added extensions for `RepostStory`
* Added extensions for `SendMessageDraft`
* Added `effectId` parameter to `copyMessage` and `forwardMessage` extensions
* Added `GetBusinessAccountGifts` extensions improvements
* `BehaviourBuilder`:
* Updated event triggers for new chat events (`ChatOwnerChanged`, `ChatOwnerLeft`, private forum events)
* Updated expectations for new event types
* `Utils`:
* Regenerated class casts extensions
* Updated `InlineKeyboardBuilder` and `ReplyKeyboardBuilder` with `style` and `iconCustomEmojiId` support
## 30.0.2
* `Version`:
* `Kotlin`: `2.2.20` -> `2.2.21`
* `Ktor`: `3.3.1` -> `3.3.2`
* `KSP`: `2.2.20-2.0.4` -> `2.3.2`
* `MicroUtils`: `0.26.6` -> `0.26.8`
* `KSLog`: `1.5.1` -> `1.5.2`
* `Core`:
* Allow to use `SetWebhook` with `maxAllowedConnections` up to `100000` (fix of [#1019](https://github.com/InsanusMokrassar/ktgbotapi/issues/1019))
* `KSP`:
* Fixed annotation property access for KSP2 compatibility using `withNoSuchElementWorkaround`
* Removed `ksp.useKSP2=false` workaround from `gradle.properties` (KSP2 is now properly supported)
* `Utils`:
* Regenerated class casts extensions
* Allow to use custom `GetUpdates` in `longPollingFlow`
## 30.0.1
* `Core`:
* Potential fix of [#989](https://github.com/InsanusMokrassar/ktgbotapi/issues/989) by:
* In long polling have been added check for causing by unresolved address exception
* Add `TelegramBotPipelinesHandler.onRequestExceptionInLimiter` which will be triggered in ANY exception during
request execution
## 30.0.0
**THIS UPDATE MAY CONTAINS BREAKING CHANGES**
* `Version`:
* `Kotlin`: `2.2.10` -> `2.2.20`
* `Ktor`: `3.2.3` -> `3.3.1`
* `MicroUtils`: `0.26.3` -> `0.26.6`
* `KSLog`: `1.5.0` -> `1.5.1`
* `BehaviourBuilder`:
* `DefaultCustomBehaviourContextAndTypeReceiver` now extends `suspend (BC, U) -> R` instead of `CustomBehaviourContextAndTypeReceiver<BC, R, U>` (no changes in api in fact)
## 29.0.1
* `Core`:
* Fix of [#917](https://github.com/InsanusMokrassar/ktgbotapi/issues/917): all `OrderInfo` fields now have defaults nulls
## 29.0.0
**THIS UPDATE CONTAINS ADDING SUPPORT OF [Telegram Bots API 9.2](https://core.telegram.org/bots/api-changelog#august-15-2025)**
**THIS UPDATE CONTAINS BREAKING CHANGES**
* `Core`:
* Add function `firstOfOrNull(vararg suspend () -> T): T?`
* Change logic of `firstOf` - now it works based on merged flows and __do not require__ `CoroutineScope` as receiver
## 28.0.3
* `Core`:
* Add passing of default engines in `HttpClient` constructors
## 28.0.2
* `Core`:
* [#1001](https://github.com/InsanusMokrassar/ktgbotapi/issues/1001) - `[Bug] Invalid detection of isCausedByCancellation()`
* [#1002](https://github.com/InsanusMokrassar/ktgbotapi/issues/1002) - `Unable to handle UnauthorizedException with buildBehaviourWithLongPolling`
## 28.0.1
* `Version`:
* `Kotlin`: `2.2.0` -> `2.2.10`
* `MicroUtils`: `0.26.2` -> `0.26.3`
* `Ktor`: `3.2.2` -> `3.2.3`
* `Core`:
* Let all `OptionallyMessageThreadRequest` inheritors to use `@EncodeDefault` annotation to fix default value passing
## 28.0.0
**THIS UPDATE CONTAINS BREAKING CHANGES**
* `Core`:
* Add `firstOf` extension
* `BehaviourBuilder`:
* All builders for behaviours got boolean `useDefaultSubcontextInitialAction`
* Add opportunity to pass `BehaviourContextData` in `DefaultBehaviourContext` constructor and `copy` method
* By default, commands to other bots will be ignored in triggers and waiters
## 27.1.2
* `Core`:
* Try to fix cancelling on timeout for long polling
* Since this update phrase `Something web wrong` will not happen from this library 😭
## 27.1.1
* `Version`:

View File

@@ -1,4 +1,4 @@
# TelegramBotAPI [![Maven Central Version](https://img.shields.io/maven-central/v/dev.inmo/tgbotapi)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [![Supported version](https://img.shields.io/badge/Telegram%20Bot%20API-9.1-blue)](https://core.telegram.org/bots/api-changelog#july-3-2025)
# TelegramBotAPI [![Maven Central Version](https://img.shields.io/maven-central/v/dev.inmo/tgbotapi)](https://central.sonatype.com/artifact/dev.inmo/tgbotapi) [![Supported version](https://img.shields.io/badge/Telegram%20Bot%20API-9.6-blue)](https://core.telegram.org/bots/api-changelog#april-3-2026)
| Docs | [![KDocs](https://img.shields.io/static/v1?label=Dokka&message=KDocs&color=blue&logo=kotlin)](https://tgbotapi.inmo.dev/index.html) [![Mini tutorial](https://img.shields.io/static/v1?label=Mk&message=Docs&color=blue&logo=mkdocs)](https://docs.inmo.dev/tgbotapi/index.html) |
|:----------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|

22
agents/HELPERS.md Normal file
View File

@@ -0,0 +1,22 @@
FOLLOW COMMON CODE STYLE. DO NOT COMMIT OR PUSH ANY CHANGES IF PROMPT DO NOT CONTAINS DIRECT INSTRUCTION ABOUT IT. FOLLOW LINKS TO SEE DOCUMENTATION IN THE PROMPT. IF YOU ARE NOT ABLE TO FOLLOW LINK (DO NOT SEE CONTENT YOU NEED TO FOLLOW PROMPT) - ASK OPERATOR
---
`@Warning` package is `dev.inmo.micro_utils.common.Warning`. Its signature: `Warning(val message: String)`
---
If you have edited some constructor or function signature - you MUST update documentation accordingly AND all calls of this constructor/function. THIS RULE WORKS RECURSIVELY
---
Before any laucnhing of `compileKotlinJvm` or other building procedure which must confirm that build is working, you MUST launch two tasks: `./gradlew kspCommonMainKotlinMetadata` and `./gradlew apiDump`. Order is important. They must be launched sequentially.
---
If you are adding `Send*` request - you also must add in `API` (`tgbotapi.api`) module:
* Direct indings (in `tgbitapi.api` module). As example you may look at `dev.inmo.tgbotapi.requests.send.SendTextMessage` a,d its bindings `dev.inmo.tgbotapi.extensions.api.send.sendTextMessage`
* Bindings in [Sends.kt](../tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Sends.kt)
* Bindings in [Replies.kt](../tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt)
* Bindings in [RepliesWithChatsAndMessages.kt](../tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt)

View File

@@ -28,7 +28,7 @@ if ((project.hasProperty('SONATYPE_USER') || System.getenv('SONATYPE_USER') != n
username = project.hasProperty('SONATYPE_USER') ? project.property('SONATYPE_USER') : System.getenv('SONATYPE_USER')
password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD')
validationTimeout = Duration.ofSeconds(0)
publishingType = "USER_MANAGED"
publishingType = System.getenv('PUBLISHING_TYPE') != "" ? System.getenv('PUBLISHING_TYPE') : "USER_MANAGED"
}
publishAllProjectsProbablyBreakingProjectIsolation()

View File

@@ -5,8 +5,5 @@ kotlin.js.generate.externals=true
kotlin.incremental=true
kotlin.incremental.js=true
# https://github.com/google/ksp/issues/2491
ksp.useKSP2=false
library_group=dev.inmo
library_version=27.1.1
library_version=34.0.0

View File

@@ -1,28 +1,28 @@
[versions]
kotlin = "2.2.0"
kotlin-serialization = "1.9.0"
kotlin = "2.3.20"
kotlin-serialization = "1.11.0"
kotlin-coroutines = "1.10.2"
javax-activation = "1.1.1"
korlibs = "5.4.0"
uuid = "0.8.4"
ktor = "3.2.2"
ktor = "3.4.2"
ksp = "2.2.0-2.0.2"
kotlin-poet = "2.2.0"
ksp = "2.3.6"
kotlin-poet = "2.3.0"
microutils = "0.26.2"
kslog = "1.5.0"
microutils = "0.29.2"
kslog = "1.6.1"
versions = "0.52.0"
versions = "0.53.0"
github-release-plugin = "2.5.2"
dokka = "2.0.0"
validator = "0.18.1"
nmcp = "1.0.2"
nmcp = "1.4.4"
[libraries]
@@ -37,6 +37,8 @@ kotlin-test-js = { module = "org.jetbrains.kotlin:kotlin-test-js", version.ref =
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
ktor-client-java = { module = "io.ktor:ktor-client-java", version.ref = "ktor" }
ktor-client-js = { module = "io.ktor:ktor-client-js", version.ref = "ktor" }
ktor-client-curl = { module = "io.ktor:ktor-client-curl", version.ref = "ktor" }
ktor-client-winhttp = { module = "io.ktor:ktor-client-winhttp", version.ref = "ktor" }
ktor-server = { module = "io.ktor:ktor-server", version.ref = "ktor" }

File diff suppressed because it is too large Load Diff

View File

@@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.extensions.api
import dev.inmo.tgbotapi.bot.ktor.telegramBot
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
import dev.inmo.tgbotapi.utils.defaultKtorEngine
import dev.inmo.tgbotapi.utils.telegramBotAPIDefaultUrl
import io.ktor.client.HttpClient
import io.ktor.client.HttpClientConfig
@@ -13,7 +14,7 @@ import io.ktor.client.engine.*
*/
public fun telegramBot(
urlsKeeper: TelegramAPIUrlsKeeper,
client: HttpClient = HttpClient()
client: HttpClient = HttpClient(defaultKtorEngine)
): TelegramBot = telegramBot(urlsKeeper) {
this.client = client
}
@@ -68,7 +69,7 @@ public fun telegramBot(
apiUrl: String = telegramBotAPIDefaultUrl,
testServer: Boolean = false,
fileLinkUrlMapper: TelegramAPIUrlsKeeper.(String) -> String = { "${fileBaseUrl}/$it" },
client: HttpClient = HttpClient()
client: HttpClient = HttpClient(defaultKtorEngine)
): TelegramBot = telegramBot(TelegramAPIUrlsKeeper(token, testServer, apiUrl, fileLinkUrlMapper), client)
@Suppress("NOTHING_TO_INLINE")

View File

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

View File

@@ -12,42 +12,42 @@ import dev.inmo.tgbotapi.types.message.content.MediaGroupCollectionContent
public suspend fun TelegramBot.deleteMessage(
chatId: ChatIdentifier,
messageId: MessageId
): Boolean = execute(
): Unit = execute(
DeleteMessage(chatId, messageId)
)
public suspend fun TelegramBot.deleteMessage(
chat: Chat,
messageId: MessageId
): Boolean = deleteMessage(chat.id, messageId)
): Unit = deleteMessage(chat.id, messageId)
public suspend fun TelegramBot.deleteMessage(
message: AccessibleMessage
): Boolean {
): Unit {
val mediaGroupContent = ((message as? ContentMessage<*>) ?.content as? MediaGroupCollectionContent<*>)
if (mediaGroupContent == null) {
return deleteMessage(message.chat, message.messageId)
deleteMessage(message.chat, message.messageId)
} else {
return mediaGroupContent.group.map {
mediaGroupContent.group.forEach {
deleteMessage(it.sourceMessage)
}.all { it }
}
}
}
public suspend fun TelegramBot.delete(
chatId: ChatIdentifier,
messageId: MessageId
): Boolean = deleteMessage(chatId, messageId)
): Unit = deleteMessage(chatId, messageId)
public suspend fun TelegramBot.delete(
chat: Chat,
messageId: MessageId
): Boolean = deleteMessage(chat, messageId)
): Unit = deleteMessage(chat, messageId)
public suspend fun TelegramBot.delete(
message: AccessibleMessage
): Boolean = deleteMessage(message)
): Unit = deleteMessage(message)
public suspend fun AccessibleMessage.delete(
requestsExecutor: TelegramBot
): Boolean = requestsExecutor.deleteMessage(this)
): Unit = requestsExecutor.deleteMessage(this)

View File

@@ -10,52 +10,52 @@ import kotlin.jvm.JvmName
public suspend fun TelegramBot.deleteMessages(
chatId: ChatIdentifier,
messageIds: List<MessageId>
): Boolean = messageIds.chunked(deleteMessagesLimit.last).map {
): Unit = messageIds.chunked(deleteMessagesLimit.last).forEach {
execute(
DeleteMessages(
chatId = chatId,
messageIds = it
)
)
}.all { it }
}
public suspend fun TelegramBot.deleteMessages(
chatId: ChatIdentifier,
messageIds: Array<MessageId>
): Boolean = deleteMessages(
): Unit = deleteMessages(
chatId = chatId,
messageIds = messageIds.toList()
)
public suspend fun TelegramBot.deleteMessages(
messagesMetas: List<Message.MetaInfo>
): Boolean = messagesMetas.groupBy { it.chatId }.map { (chatId, messages) ->
): Unit = messagesMetas.groupBy { it.chatId }.forEach { (chatId, messages) ->
deleteMessages(
chatId = chatId,
messageIds = messages.map { it.messageId }
)
}.all { it }
}
@JvmName("deleteMessagesWithMessages")
public suspend fun TelegramBot.deleteMessages(
messages: List<AccessibleMessage>
): Boolean = deleteMessages(messages.map { it.metaInfo })
): Unit = deleteMessages(messages.map { it.metaInfo })
public suspend fun TelegramBot.delete(
chatId: ChatIdentifier,
messageIds: List<MessageId>
): Boolean = deleteMessages(chatId = chatId, messageIds = messageIds)
): Unit = deleteMessages(chatId = chatId, messageIds = messageIds)
public suspend fun TelegramBot.delete(
chatId: ChatIdentifier,
messageIds: Array<MessageId>
): Boolean = deleteMessages(chatId = chatId, messageIds = messageIds)
): Unit = deleteMessages(chatId = chatId, messageIds = messageIds)
public suspend fun TelegramBot.delete(
messagesMetas: List<Message.MetaInfo>
): Boolean = deleteMessages(messagesMetas)
): Unit = deleteMessages(messagesMetas)
@JvmName("deleteWithMessages")
public suspend fun TelegramBot.delete(
messages: List<AccessibleMessage>
): Boolean = deleteMessages(messages)
): Unit = deleteMessages(messages)

View File

@@ -3,12 +3,15 @@ package dev.inmo.tgbotapi.extensions.api
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.ForwardMessage
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.DirectMessageThreadId
import dev.inmo.tgbotapi.types.EffectId
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.Seconds
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.abstracts.PossiblyForwardedMessage
import dev.inmo.tgbotapi.types.directMessageThreadId
import dev.inmo.tgbotapi.types.threadId
public suspend fun TelegramBot.forwardMessage(
@@ -16,11 +19,23 @@ public suspend fun TelegramBot.forwardMessage(
toChatId: ChatIdentifier,
messageId: MessageId,
threadId: MessageThreadId? = toChatId.threadId,
directMessageThreadId: DirectMessageThreadId? = toChatId.directMessageThreadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false
protectContent: Boolean = false,
effectId: EffectId? = null
): PossiblyForwardedMessage = execute(
ForwardMessage(fromChatId, toChatId, messageId, threadId, startTimestamp, disableNotification, protectContent)
ForwardMessage(
fromChatId = fromChatId,
toChatId = toChatId,
messageId = messageId,
threadId = threadId,
directMessageThreadId = directMessageThreadId,
startTimestamp = startTimestamp,
disableNotification = disableNotification,
protectContent = protectContent,
effectId = effectId
)
)
public suspend fun TelegramBot.forwardMessage(
@@ -28,45 +43,105 @@ public suspend fun TelegramBot.forwardMessage(
toChatId: ChatIdentifier,
messageId: MessageId,
threadId: MessageThreadId? = toChatId.threadId,
directMessageThreadId: DirectMessageThreadId? = toChatId.directMessageThreadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false
): PossiblyForwardedMessage = forwardMessage(fromChat.id, toChatId, messageId, threadId, startTimestamp, disableNotification, protectContent)
protectContent: Boolean = false,
effectId: EffectId? = null
): PossiblyForwardedMessage = forwardMessage(
fromChatId = fromChat.id,
toChatId = toChatId,
messageId = messageId,
threadId = threadId,
directMessageThreadId = directMessageThreadId,
startTimestamp = startTimestamp,
disableNotification = disableNotification,
protectContent = protectContent,
effectId = effectId
)
public suspend fun TelegramBot.forwardMessage(
fromChatId: ChatIdentifier,
toChat: Chat,
messageId: MessageId,
threadId: MessageThreadId? = toChat.id.threadId,
directMessageThreadId: DirectMessageThreadId? = toChat.id.directMessageThreadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false
): PossiblyForwardedMessage = forwardMessage(fromChatId, toChat.id, messageId, threadId, startTimestamp, disableNotification, protectContent)
protectContent: Boolean = false,
effectId: EffectId? = null
): PossiblyForwardedMessage = forwardMessage(
fromChatId = fromChatId,
toChatId = toChat.id,
messageId = messageId,
threadId = threadId,
directMessageThreadId = directMessageThreadId,
startTimestamp = startTimestamp,
disableNotification = disableNotification,
protectContent = protectContent,
effectId = effectId
)
public suspend fun TelegramBot.forwardMessage(
fromChat: Chat,
toChat: Chat,
messageId: MessageId,
threadId: MessageThreadId? = toChat.id.threadId,
directMessageThreadId: DirectMessageThreadId? = toChat.id.directMessageThreadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false
): PossiblyForwardedMessage = forwardMessage(fromChat.id, toChat.id, messageId, threadId, startTimestamp, disableNotification, protectContent)
protectContent: Boolean = false,
effectId: EffectId? = null
): PossiblyForwardedMessage = forwardMessage(
fromChatId = fromChat.id,
toChatId = toChat.id,
messageId = messageId,
threadId = threadId,
directMessageThreadId = directMessageThreadId,
startTimestamp = startTimestamp,
disableNotification = disableNotification,
protectContent = protectContent,
effectId = effectId
)
public suspend fun TelegramBot.forwardMessage(
toChatId: ChatIdentifier,
message: AccessibleMessage,
threadId: MessageThreadId? = toChatId.threadId,
directMessageThreadId: DirectMessageThreadId? = toChatId.directMessageThreadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false
): PossiblyForwardedMessage = forwardMessage(message.chat, toChatId, message.messageId, threadId, startTimestamp, disableNotification, protectContent)
protectContent: Boolean = false,
effectId: EffectId? = null
): PossiblyForwardedMessage = forwardMessage(
fromChat = message.chat,
toChatId = toChatId,
messageId = message.messageId,
threadId = threadId,
directMessageThreadId = directMessageThreadId,
startTimestamp = startTimestamp,
disableNotification = disableNotification,
protectContent = protectContent,
effectId = effectId
)
public suspend fun TelegramBot.forwardMessage(
toChat: Chat,
message: AccessibleMessage,
threadId: MessageThreadId? = toChat.id.threadId,
directMessageThreadId: DirectMessageThreadId? = toChat.id.directMessageThreadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false
): PossiblyForwardedMessage = forwardMessage(message.chat, toChat, message.messageId, threadId, startTimestamp, disableNotification, protectContent)
protectContent: Boolean = false,
effectId: EffectId? = null
): PossiblyForwardedMessage = forwardMessage(
fromChat = message.chat,
toChat = toChat,
messageId = message.messageId,
threadId = threadId,
directMessageThreadId = directMessageThreadId,
startTimestamp = startTimestamp,
disableNotification = disableNotification,
protectContent = protectContent,
effectId = effectId
)

View File

@@ -13,6 +13,7 @@ public suspend fun TelegramBot.forwardMessages(
fromChatId: ChatIdentifier,
messageIds: List<MessageId>,
threadId: MessageThreadId? = toChatId.threadId,
directMessageThreadId: DirectMessageThreadId? = toChatId.directMessageThreadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
@@ -23,6 +24,7 @@ public suspend fun TelegramBot.forwardMessages(
fromChatId = fromChatId,
messageIds = it,
threadId = threadId,
directMessageThreadId = directMessageThreadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption
@@ -35,6 +37,7 @@ public suspend fun TelegramBot.forwardMessages(
fromChatId: ChatIdentifier,
messageIds: Array<MessageId>,
threadId: MessageThreadId? = toChatId.threadId,
directMessageThreadId: DirectMessageThreadId? = toChatId.directMessageThreadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
@@ -43,6 +46,7 @@ public suspend fun TelegramBot.forwardMessages(
fromChatId = fromChatId,
messageIds = messageIds.toList(),
threadId = threadId,
directMessageThreadId = directMessageThreadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption
@@ -52,6 +56,7 @@ public suspend fun TelegramBot.forwardMessages(
toChatId: ChatIdentifier,
messagesMetas: List<Message.MetaInfo>,
threadId: MessageThreadId? = toChatId.threadId,
directMessageThreadId: DirectMessageThreadId? = toChatId.directMessageThreadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
@@ -61,6 +66,7 @@ public suspend fun TelegramBot.forwardMessages(
fromChatId = chatId,
messageIds = messages.map { it.messageId },
threadId = threadId,
directMessageThreadId = directMessageThreadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption
@@ -72,6 +78,7 @@ public suspend fun TelegramBot.forwardMessages(
toChatId: ChatIdentifier,
messages: List<AccessibleMessage>,
threadId: MessageThreadId? = toChatId.threadId,
directMessageThreadId: DirectMessageThreadId? = toChatId.directMessageThreadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
@@ -79,6 +86,7 @@ public suspend fun TelegramBot.forwardMessages(
toChatId = toChatId,
messagesMetas = messages.map { it.metaInfo },
threadId = threadId,
directMessageThreadId = directMessageThreadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption
@@ -89,6 +97,7 @@ public suspend fun TelegramBot.forward(
fromChatId: ChatIdentifier,
messageIds: List<MessageId>,
threadId: MessageThreadId? = toChatId.threadId,
directMessageThreadId: DirectMessageThreadId? = toChatId.directMessageThreadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
@@ -97,6 +106,7 @@ public suspend fun TelegramBot.forward(
fromChatId = fromChatId,
messageIds = messageIds,
threadId = threadId,
directMessageThreadId = directMessageThreadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption
@@ -107,6 +117,7 @@ public suspend fun TelegramBot.forward(
fromChatId: ChatIdentifier,
messageIds: Array<MessageId>,
threadId: MessageThreadId? = toChatId.threadId,
directMessageThreadId: DirectMessageThreadId? = toChatId.directMessageThreadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
@@ -115,6 +126,7 @@ public suspend fun TelegramBot.forward(
fromChatId = fromChatId,
messageIds = messageIds,
threadId = threadId,
directMessageThreadId = directMessageThreadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption
@@ -124,6 +136,7 @@ public suspend fun TelegramBot.forward(
toChatId: ChatIdentifier,
messagesMetas: List<Message.MetaInfo>,
threadId: MessageThreadId? = toChatId.threadId,
directMessageThreadId: DirectMessageThreadId? = toChatId.directMessageThreadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
@@ -131,6 +144,7 @@ public suspend fun TelegramBot.forward(
toChatId = toChatId,
messagesMetas = messagesMetas,
threadId = threadId,
directMessageThreadId = directMessageThreadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption
@@ -141,6 +155,7 @@ public suspend fun TelegramBot.forward(
toChatId: ChatIdentifier,
messages: List<AccessibleMessage>,
threadId: MessageThreadId? = toChatId.threadId,
directMessageThreadId: DirectMessageThreadId? = toChatId.directMessageThreadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
@@ -148,6 +163,7 @@ public suspend fun TelegramBot.forward(
toChatId = toChatId,
messages = messages,
threadId = threadId,
directMessageThreadId = directMessageThreadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption

View File

@@ -15,6 +15,7 @@ import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.location.LiveLocation
import dev.inmo.tgbotapi.types.location.Location
import dev.inmo.tgbotapi.types.message.SuggestedPostParameters
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.content.LiveLocationContent
import dev.inmo.tgbotapi.types.message.content.LocationContent
@@ -50,11 +51,13 @@ public suspend fun TelegramBot.handleLiveLocation(
locationsFlow: Flow<EditLiveLocationInfo>,
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
threadId: MessageThreadId? = chatId.threadId,
directMessageThreadId: DirectMessageThreadId? = chatId.directMessageThreadId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false,
effectId: EffectId? = null,
suggestedPostParameters: SuggestedPostParameters? = null,
replyParameters: ReplyParameters? = null,
sentMessageFlow: FlowCollector<ContentMessage<LiveLocationContent>>? = null
) {
@@ -76,25 +79,27 @@ public suspend fun TelegramBot.handleLiveLocation(
if (capturedLiveLocationMessage == null) {
updateMessageJob ?.start()
currentLiveLocationMessage = send(
chatId,
it.latitude,
it.longitude,
if (liveTimeMillis == indefiniteLivePeriodDelayMillis) {
chatId = chatId,
latitude = it.latitude,
longitude = it.longitude,
livePeriod = if (liveTimeMillis == indefiniteLivePeriodDelayMillis) {
LiveLocation.INDEFINITE_LIVE_PERIOD
} else {
ceil(liveTimeMillis.toDouble() / 1000).toInt()
},
it.horizontalAccuracy,
it.heading,
it.proximityAlertRadius,
threadId,
businessConnectionId,
disableNotification,
protectContent,
allowPaidBroadcast,
effectId,
replyParameters,
it.replyMarkup
horizontalAccuracy = it.horizontalAccuracy,
heading = it.heading,
proximityAlertRadius = it.proximityAlertRadius,
threadId = threadId,
directMessageThreadId = directMessageThreadId,
businessConnectionId = businessConnectionId,
disableNotification = disableNotification,
protectContent = protectContent,
allowPaidBroadcast = allowPaidBroadcast,
effectId = effectId,
suggestedPostParameters = suggestedPostParameters,
replyParameters = replyParameters,
replyMarkup = it.replyMarkup
).also {
sentMessageFlow ?.emit(it)
}
@@ -125,11 +130,13 @@ public suspend fun TelegramBot.handleLiveLocation(
locationsFlow: Flow<Location>,
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
threadId: MessageThreadId? = chatId.threadId,
directMessageThreadId: DirectMessageThreadId? = chatId.directMessageThreadId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false,
effectId: EffectId? = null,
suggestedPostParameters: SuggestedPostParameters? = null,
replyParameters: ReplyParameters? = null,
sentMessageFlow: FlowCollector<ContentMessage<LiveLocationContent>>? = null
) {
@@ -147,11 +154,13 @@ public suspend fun TelegramBot.handleLiveLocation(
},
liveTimeMillis = liveTimeMillis,
threadId = threadId,
directMessageThreadId = directMessageThreadId,
businessConnectionId = businessConnectionId,
disableNotification = disableNotification,
protectContent = protectContent,
allowPaidBroadcast = allowPaidBroadcast,
effectId = effectId,
suggestedPostParameters = suggestedPostParameters,
replyParameters = replyParameters,
sentMessageFlow = sentMessageFlow
)
@@ -168,11 +177,13 @@ public suspend fun TelegramBot.handleLiveLocation(
locationsFlow: Flow<Pair<Double, Double>>,
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
threadId: MessageThreadId? = chatId.threadId,
directMessageThreadId: DirectMessageThreadId? = chatId.directMessageThreadId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false,
effectId: EffectId? = null,
suggestedPostParameters: SuggestedPostParameters? = null,
replyParameters: ReplyParameters? = null,
sentMessageFlow: FlowCollector<ContentMessage<LiveLocationContent>>? = null
) {
@@ -186,11 +197,13 @@ public suspend fun TelegramBot.handleLiveLocation(
},
liveTimeMillis = liveTimeMillis,
threadId = threadId,
directMessageThreadId = directMessageThreadId,
businessConnectionId = businessConnectionId,
disableNotification = disableNotification,
protectContent = protectContent,
allowPaidBroadcast = allowPaidBroadcast,
effectId = effectId,
suggestedPostParameters = suggestedPostParameters,
replyParameters = replyParameters,
sentMessageFlow = sentMessageFlow
)

View File

@@ -1,3 +1,5 @@
@file:Suppress("KDocUnresolvedReference")
package dev.inmo.tgbotapi.extensions.api
import korlibs.time.DateTime
@@ -11,11 +13,13 @@ import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.SuggestedPostParameters
import dev.inmo.tgbotapi.types.location.LiveLocation
import dev.inmo.tgbotapi.types.location.StaticLocation
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.content.LocationContent
import dev.inmo.tgbotapi.utils.extensions.directMessageThreadIdOrNull
import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull
import io.ktor.utils.io.core.Closeable
import korlibs.time.millisecondsLong
@@ -96,11 +100,13 @@ public suspend fun TelegramBot.startLiveLocation(
initHeading: Degrees? = null,
initProximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = chatId.threadId,
directMessageThreadId: DirectMessageThreadId? = chatId.directMessageThreadId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false,
effectId: EffectId? = null,
suggestedPostParameters: SuggestedPostParameters? = null,
replyParameters: ReplyParameters? = null,
replyMarkup: KeyboardMarkup? = null
): LiveLocationProvider {
@@ -115,11 +121,13 @@ public suspend fun TelegramBot.startLiveLocation(
heading = initHeading,
proximityAlertRadius = initProximityAlertRadius,
threadId = threadId,
directMessageThreadId = directMessageThreadId,
businessConnectionId = businessConnectionId,
disableNotification = disableNotification,
protectContent = protectContent,
allowPaidBroadcast = allowPaidBroadcast,
effectId = effectId,
suggestedPostParameters = suggestedPostParameters,
replyParameters = replyParameters,
replyMarkup = replyMarkup
)
@@ -147,11 +155,13 @@ public suspend fun TelegramBot.startLiveLocation(
initHeading: Degrees? = null,
initProximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = chat.id.threadId,
directMessageThreadId: DirectMessageThreadId? = chat.id.directMessageThreadId,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false,
effectId: EffectId? = null,
suggestedPostParameters: SuggestedPostParameters? = null,
replyParameters: ReplyParameters? = null,
replyMarkup: KeyboardMarkup? = null
): LiveLocationProvider = startLiveLocation(
@@ -164,11 +174,13 @@ public suspend fun TelegramBot.startLiveLocation(
initHeading = initHeading,
initProximityAlertRadius = initProximityAlertRadius,
threadId = threadId,
directMessageThreadId = directMessageThreadId,
businessConnectionId = businessConnectionId,
disableNotification = disableNotification,
protectContent = protectContent,
allowPaidBroadcast = allowPaidBroadcast,
effectId = effectId,
suggestedPostParameters = suggestedPostParameters,
replyParameters = replyParameters,
replyMarkup = replyMarkup
)
@@ -186,11 +198,13 @@ public suspend fun TelegramBot.startLiveLocation(
initHeading: Degrees? = null,
initProximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = chatId.threadId,
directMessageThreadId: DirectMessageThreadId? = chatId.directMessageThreadId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false,
effectId: EffectId? = null,
suggestedPostParameters: SuggestedPostParameters? = null,
replyParameters: ReplyParameters? = null,
replyMarkup: KeyboardMarkup? = null
): LiveLocationProvider = startLiveLocation(
@@ -203,11 +217,13 @@ public suspend fun TelegramBot.startLiveLocation(
initHeading = initHeading,
initProximityAlertRadius = initProximityAlertRadius,
threadId = threadId,
directMessageThreadId = directMessageThreadId,
businessConnectionId = businessConnectionId,
disableNotification = disableNotification,
protectContent = protectContent,
allowPaidBroadcast = allowPaidBroadcast,
effectId = effectId,
suggestedPostParameters = suggestedPostParameters,
replyParameters = replyParameters,
replyMarkup = replyMarkup
)
@@ -225,11 +241,13 @@ public suspend fun TelegramBot.startLiveLocation(
initHeading: Degrees? = null,
initProximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = chat.id.threadId,
directMessageThreadId: DirectMessageThreadId? = chat.id.directMessageThreadId,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false,
effectId: EffectId? = null,
suggestedPostParameters: SuggestedPostParameters? = null,
replyParameters: ReplyParameters? = null,
replyMarkup: KeyboardMarkup? = null
): LiveLocationProvider = startLiveLocation(
@@ -242,11 +260,13 @@ public suspend fun TelegramBot.startLiveLocation(
initHeading = initHeading,
initProximityAlertRadius = initProximityAlertRadius,
threadId = threadId,
directMessageThreadId = directMessageThreadId,
businessConnectionId = businessConnectionId,
disableNotification = disableNotification,
protectContent = protectContent,
allowPaidBroadcast = allowPaidBroadcast,
effectId = effectId,
suggestedPostParameters = suggestedPostParameters,
replyParameters = replyParameters,
replyMarkup = replyMarkup
)
@@ -265,11 +285,13 @@ public suspend inline fun TelegramBot.replyWithLiveLocation(
initHeading: Degrees? = null,
initProximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = to.threadIdOrNull,
directMessageThreadId: DirectMessageThreadId? = to.directMessageThreadIdOrNull,
businessConnectionId: BusinessConnectionId? = to.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false,
effectId: EffectId? = null,
suggestedPostParameters: SuggestedPostParameters? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
): LiveLocationProvider = startLiveLocation(
@@ -282,11 +304,13 @@ public suspend inline fun TelegramBot.replyWithLiveLocation(
initHeading = initHeading,
initProximityAlertRadius = initProximityAlertRadius,
threadId = threadId,
directMessageThreadId = directMessageThreadId,
businessConnectionId = businessConnectionId,
disableNotification = disableNotification,
protectContent = protectContent,
allowPaidBroadcast = allowPaidBroadcast,
effectId = effectId,
suggestedPostParameters = suggestedPostParameters,
replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply),
replyMarkup = replyMarkup
)
@@ -304,11 +328,13 @@ public suspend inline fun TelegramBot.replyWithLiveLocation(
initHeading: Degrees? = null,
initProximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = to.threadIdOrNull,
directMessageThreadId: DirectMessageThreadId? = to.directMessageThreadIdOrNull,
businessConnectionId: BusinessConnectionId? = to.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false,
effectId: EffectId? = null,
suggestedPostParameters: SuggestedPostParameters? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
): LiveLocationProvider = startLiveLocation(
@@ -320,11 +346,13 @@ public suspend inline fun TelegramBot.replyWithLiveLocation(
initHeading = initHeading,
initProximityAlertRadius = initProximityAlertRadius,
threadId = threadId,
directMessageThreadId = directMessageThreadId,
businessConnectionId = businessConnectionId,
disableNotification = disableNotification,
protectContent = protectContent,
allowPaidBroadcast = allowPaidBroadcast,
effectId = effectId,
suggestedPostParameters = suggestedPostParameters,
replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply),
replyMarkup = replyMarkup
)

View File

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

View File

@@ -0,0 +1,21 @@
package dev.inmo.tgbotapi.extensions.api
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.SavePreparedKeyboardButton
import dev.inmo.tgbotapi.types.ChatId
import dev.inmo.tgbotapi.types.buttons.KeyboardButton
import dev.inmo.tgbotapi.types.buttons.PreparedKeyboardButton
import dev.inmo.tgbotapi.types.chat.User
import dev.inmo.tgbotapi.types.toChatId
public suspend fun TelegramBot.savePreparedKeyboardButton(
userId: ChatId,
button: KeyboardButton
): PreparedKeyboardButton = execute(
SavePreparedKeyboardButton(userId = userId, button = button)
)
public suspend fun TelegramBot.savePreparedKeyboardButton(
user: User,
button: KeyboardButton
): PreparedKeyboardButton = savePreparedKeyboardButton(userId = user.id.toChatId(), button = button)

View File

@@ -11,7 +11,7 @@ public suspend fun TelegramBot.answerCallbackQuery(
showAlert: Boolean? = null,
url: String? = null,
cachedTimeSeconds: Int? = null
): Boolean = execute(AnswerCallbackQuery(callbackQueryId, text, showAlert, url, cachedTimeSeconds))
): Unit = execute(AnswerCallbackQuery(callbackQueryId, text, showAlert, url, cachedTimeSeconds))
public suspend fun TelegramBot.answerCallbackQuery(
callbackQuery: CallbackQuery,
@@ -19,7 +19,7 @@ public suspend fun TelegramBot.answerCallbackQuery(
showAlert: Boolean? = null,
url: String? = null,
cachedTimeSeconds: Int? = null
): Boolean = answerCallbackQuery(callbackQuery.id, text, showAlert, url, cachedTimeSeconds)
): Unit = answerCallbackQuery(callbackQuery.id, text, showAlert, url, cachedTimeSeconds)
public suspend fun TelegramBot.answer(
callbackQuery: CallbackQuery,
@@ -27,4 +27,4 @@ public suspend fun TelegramBot.answer(
showAlert: Boolean? = null,
url: String? = null,
cachedTimeSeconds: Int? = null
): Boolean = answerCallbackQuery(callbackQuery.id, text, showAlert, url, cachedTimeSeconds)
): Unit = answerCallbackQuery(callbackQuery.id, text, showAlert, url, cachedTimeSeconds)

View File

@@ -14,7 +14,7 @@ public suspend fun TelegramBot.answerInlineQuery(
isPersonal: Boolean? = null,
nextOffset: String? = null,
button: InlineQueryResultsButton? = null
): Boolean = execute(
): Unit = execute(
AnswerInlineQuery(inlineQueryID, results, cachedTime, isPersonal, nextOffset, button)
)
@@ -25,7 +25,7 @@ public suspend fun TelegramBot.answerInlineQuery(
isPersonal: Boolean? = null,
nextOffset: String? = null,
button: InlineQueryResultsButton? = null
): Boolean = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, button)
): Unit = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, button)
public suspend fun TelegramBot.answer(
inlineQuery: InlineQuery,
@@ -34,7 +34,7 @@ public suspend fun TelegramBot.answer(
isPersonal: Boolean? = null,
nextOffset: String? = null,
button: InlineQueryResultsButton? = null
): Boolean = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, button)
): Unit = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, button)
public suspend fun TelegramBot.answerInlineQuery(
inlineQueryID: InlineQueryId,
@@ -44,7 +44,7 @@ public suspend fun TelegramBot.answerInlineQuery(
nextOffset: String? = null,
switchPmText: String?,
switchPmParameter: String?
): Boolean = execute(
): Unit = execute(
AnswerInlineQuery(inlineQueryID, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)
)
@@ -56,7 +56,7 @@ public suspend fun TelegramBot.answerInlineQuery(
nextOffset: String? = null,
switchPmText: String?,
switchPmParameter: String?
): Boolean = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)
): Unit = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)
public suspend fun TelegramBot.answer(
inlineQuery: InlineQuery,
@@ -66,4 +66,4 @@ public suspend fun TelegramBot.answer(
nextOffset: String? = null,
switchPmText: String?,
switchPmParameter: String?
): Boolean = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)
): Unit = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)

View File

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

View File

@@ -10,19 +10,19 @@ import dev.inmo.tgbotapi.types.payments.ShippingQuery
public suspend fun TelegramBot.answerShippingQueryOk(
id: ShippingQueryId,
shippingOptions: List<ShippingOption>
): Boolean = execute(AnswerShippingQueryOk(id, shippingOptions))
): Unit = execute(AnswerShippingQueryOk(id, shippingOptions))
public suspend fun TelegramBot.answerShippingQueryOk(
shippingQuery: ShippingQuery,
shippingOptions: List<ShippingOption>
): Boolean = answerShippingQueryOk(shippingQuery.id, shippingOptions)
): Unit = answerShippingQueryOk(shippingQuery.id, shippingOptions)
public suspend fun TelegramBot.answerShippingQueryError(
id: ShippingQueryId,
error: String
): Boolean = execute(AnswerShippingQueryError(id, error))
): Unit = execute(AnswerShippingQueryError(id, error))
public suspend fun TelegramBot.answerShippingQueryError(
shippingQuery: ShippingQuery,
error: String
): Boolean = answerShippingQueryError(shippingQuery.id, error)
): Unit = answerShippingQueryError(shippingQuery.id, error)

View File

@@ -5,8 +5,8 @@ import dev.inmo.tgbotapi.requests.bot.ClearMyDefaultAdministratorRights
public suspend fun TelegramBot.clearMyDefaultAdministratorRights(
forChannels: Boolean? = null
): Boolean = execute(ClearMyDefaultAdministratorRights(forChannels))
): Unit = execute(ClearMyDefaultAdministratorRights(forChannels))
public suspend fun TelegramBot.clearMyDefaultAdministratorRightsForChannels(): Boolean = clearMyDefaultAdministratorRights(forChannels = true)
public suspend fun TelegramBot.clearMyDefaultAdministratorRightsForChannels(): Unit = clearMyDefaultAdministratorRights(forChannels = true)
public suspend fun TelegramBot.clearMyDefaultAdministratorRightsForGroupsAndSupergroups(): Boolean = clearMyDefaultAdministratorRights(forChannels = false)
public suspend fun TelegramBot.clearMyDefaultAdministratorRightsForGroupsAndSupergroups(): Unit = clearMyDefaultAdministratorRights(forChannels = false)

View File

@@ -9,9 +9,9 @@ import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
public suspend fun TelegramBot.deleteMyCommands(
scope: BotCommandScope = BotCommandScopeDefault,
languageCode: IetfLang?
): Boolean = execute(DeleteMyCommands(scope, languageCode))
): Unit = execute(DeleteMyCommands(scope, languageCode))
public suspend fun TelegramBot.deleteMyCommands(
scope: BotCommandScope = BotCommandScopeDefault,
languageCode: String? = null
): Boolean = deleteMyCommands(scope, languageCode ?.let(::IetfLang))
): Unit = deleteMyCommands(scope, languageCode ?.let(::IetfLang))

View File

@@ -0,0 +1,6 @@
package dev.inmo.tgbotapi.extensions.api.bot
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.bot.RemoveMyProfilePhoto
public suspend fun TelegramBot.removeMyProfilePhoto(): Unit = execute(RemoveMyProfilePhoto)

View File

@@ -11,22 +11,22 @@ public suspend fun TelegramBot.setMyCommands(
commands: List<BotCommand>,
scope: BotCommandScope = BotCommandScopeDefault,
languageCode: IetfLang?
): Boolean = execute(SetMyCommands(commands, scope, languageCode))
): Unit = execute(SetMyCommands(commands, scope, languageCode))
public suspend fun TelegramBot.setMyCommands(
vararg commands: BotCommand,
scope: BotCommandScope = BotCommandScopeDefault,
languageCode: IetfLang?
): Boolean = setMyCommands(commands.toList(), scope, languageCode)
): Unit = setMyCommands(commands.toList(), scope, languageCode)
public suspend fun TelegramBot.setMyCommands(
commands: List<BotCommand>,
scope: BotCommandScope = BotCommandScopeDefault,
languageCode: String? = null
): Boolean = setMyCommands(commands, scope, languageCode ?.let(::IetfLang))
): Unit = setMyCommands(commands, scope, languageCode ?.let(::IetfLang))
public suspend fun TelegramBot.setMyCommands(
vararg commands: BotCommand,
scope: BotCommandScope = BotCommandScopeDefault,
languageCode: String? = null
): Boolean = setMyCommands(commands.toList(), scope, languageCode)
): Unit = setMyCommands(commands.toList(), scope, languageCode)

View File

@@ -7,12 +7,12 @@ import dev.inmo.tgbotapi.types.chat.member.ChatCommonAdministratorRights
public suspend fun TelegramBot.setMyDefaultAdministratorRights(
rights: ChatCommonAdministratorRights,
forChannels: Boolean? = null
): Boolean = execute(SetMyDefaultAdministratorRights(rights, forChannels))
): Unit = execute(SetMyDefaultAdministratorRights(rights, forChannels))
public suspend fun TelegramBot.setMyDefaultAdministratorRightsForChannels(
rights: ChatCommonAdministratorRights
): Boolean = setMyDefaultAdministratorRights(rights, forChannels = true)
): Unit = setMyDefaultAdministratorRights(rights, forChannels = true)
public suspend fun TelegramBot.setMyDefaultAdministratorRightsForGroupsAndSupergroups(
rights: ChatCommonAdministratorRights
): Boolean = setMyDefaultAdministratorRights(rights, forChannels = false)
): Unit = setMyDefaultAdministratorRights(rights, forChannels = false)

View File

@@ -11,9 +11,9 @@ import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
public suspend fun TelegramBot.setMyDescription(
description: String? = null,
languageCode: IetfLang? = null
): Boolean = execute(SetMyDescription(description, languageCode))
): Unit = execute(SetMyDescription(description, languageCode))
public suspend fun TelegramBot.setMyDescription(
description: String?,
languageCode: String?
): Boolean = setMyDescription(description, languageCode ?.let(::IetfLang))
): Unit = setMyDescription(description, languageCode ?.let(::IetfLang))

View File

@@ -11,9 +11,9 @@ import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
public suspend fun TelegramBot.setMyName(
name: String? = null,
languageCode: IetfLang? = null
): Boolean = execute(SetMyName(name, languageCode))
): Unit = execute(SetMyName(name, languageCode))
public suspend fun TelegramBot.setMyName(
name: String?,
languageCode: String?
): Boolean = setMyName(name, languageCode ?.let(::IetfLang))
): Unit = setMyName(name, languageCode ?.let(::IetfLang))

View File

@@ -0,0 +1,9 @@
package dev.inmo.tgbotapi.extensions.api.bot
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.bot.SetMyProfilePhoto
import dev.inmo.tgbotapi.requests.business_connection.InputProfilePhoto
public suspend fun TelegramBot.setMyProfilePhoto(
photo: InputProfilePhoto
): Unit = execute(SetMyProfilePhoto(photo))

View File

@@ -7,9 +7,9 @@ import dev.inmo.tgbotapi.requests.bot.SetMyShortDescription
public suspend fun TelegramBot.setMyShortDescription(
shortDescription: String? = null,
languageCode: IetfLang? = null
): Boolean = execute(SetMyShortDescription(shortDescription, languageCode))
): Unit = execute(SetMyShortDescription(shortDescription, languageCode))
public suspend fun TelegramBot.setMyShortDescription(
shortDescription: String?,
languageCode: String?
): Boolean = setMyShortDescription(shortDescription, languageCode ?.let(::IetfLang))
): Unit = setMyShortDescription(shortDescription, languageCode ?.let(::IetfLang))

View File

@@ -11,14 +11,14 @@ import dev.inmo.tgbotapi.types.gifts.Gift
public suspend fun TelegramBot.convertGiftToStars(
businessConnectionId: BusinessConnectionId,
ownedGiftId: GiftId
): Boolean = execute(
): Unit = execute(
ConvertGiftToStars(businessConnectionId, ownedGiftId)
)
public suspend fun TelegramBot.convertGiftToStars(
businessConnectionId: BusinessConnectionId,
gift: Gift.Regular
): Boolean = convertGiftToStars(
): Unit = convertGiftToStars(
businessConnectionId = businessConnectionId,
ownedGiftId = with(gift) {id}
)

View File

@@ -15,6 +15,6 @@ public suspend fun TelegramBot.deleteBusinessMessages(
businessConnectionId: BusinessConnectionId,
@GenerationVariant(List::class, "messages.map { it.messageId }", "messages", AccessibleMessage::class)
messageIds: List<MessageId>
): Boolean = execute(
): Unit = execute(
DeleteBusinessMessages(businessConnectionId, messageIds)
)

View File

@@ -10,7 +10,7 @@ import kotlin.Boolean
import kotlin.collections.List
public suspend fun TelegramBot.deleteBusinessMessages(businessConnectionId: BusinessConnectionId,
messages: List<AccessibleMessage>): Boolean = deleteBusinessMessages(
messages: List<AccessibleMessage>): Unit = deleteBusinessMessages(
businessConnectionId = businessConnectionId, messageIds = with(messages) {messages.map {
it.messageId }}
)

View File

@@ -4,7 +4,8 @@ import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.business_connection.GetBusinessAccountGifts
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.OwnedGifts
import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceived
import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceivedEvent
import dev.inmo.tgbotapi.types.gifts.OwnedGift
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import kotlin.runCatching
@@ -14,19 +15,23 @@ public suspend fun TelegramBot.getBusinessAccountGifts(
excludeUnsaved: Boolean = false,
excludeSaved: Boolean = false,
excludeUnlimited: Boolean = false,
excludeLimited: Boolean = false,
excludeLimitedUpgradable: Boolean = false,
excludeLimitedNonUpgradable: Boolean = false,
excludeUnique: Boolean = false,
excludeFromBlockchain: Boolean = false,
sortByPrice: Boolean = false,
offset: String? = null,
limit: Int? = null
): OwnedGifts<GiftSentOrReceived.ReceivedInBusinessAccount> = execute(
): OwnedGifts<OwnedGift.OwnedByBusinessAccount> = execute(
GetBusinessAccountGifts(
businessConnectionId,
excludeUnsaved,
excludeSaved,
excludeUnlimited,
excludeLimited,
excludeLimitedUpgradable,
excludeLimitedNonUpgradable,
excludeUnique,
excludeFromBlockchain,
sortByPrice,
offset,
limit
@@ -43,8 +48,10 @@ public suspend fun TelegramBot.getBusinessAccountGifts(
* @param excludeUnsaved Whether to exclude unsaved gifts
* @param excludeSaved Whether to exclude saved gifts
* @param excludeUnlimited Whether to exclude unlimited gifts
* @param excludeLimited Whether to exclude limited gifts
* @param excludeLimitedUpgradable Whether to exclude limited upgradable gifts
* @param excludeLimitedNonUpgradable Whether to exclude limited non-upgradable gifts
* @param excludeUnique Whether to exclude unique gifts
* @param excludeFromBlockchain Whether to exclude gifts from blockchain
* @param sortByPrice Whether to sort gifts by price
* @param initialOffset The initial offset to start fetching from. If null, starts from the beginning
* @param limit The maximum number of gifts to fetch per request
@@ -57,13 +64,15 @@ public fun TelegramBot.getBusinessAccountGiftsFlow(
excludeUnsaved: Boolean = false,
excludeSaved: Boolean = false,
excludeUnlimited: Boolean = false,
excludeLimited: Boolean = false,
excludeLimitedUpgradable: Boolean = false,
excludeLimitedNonUpgradable: Boolean = false,
excludeUnique: Boolean = false,
excludeFromBlockchain: Boolean = false,
sortByPrice: Boolean = false,
initialOffset: String? = null,
limit: Int? = null,
onErrorContinueChecker: suspend (Throwable?) -> Boolean = { false }
): Flow<OwnedGifts<GiftSentOrReceived.ReceivedInBusinessAccount>> = flow {
): Flow<OwnedGifts<OwnedGift.OwnedByBusinessAccount>> = flow {
var currentOffset = initialOffset
do {
val response = runCatching {
@@ -72,8 +81,10 @@ public fun TelegramBot.getBusinessAccountGiftsFlow(
excludeUnsaved,
excludeSaved,
excludeUnlimited,
excludeLimited,
excludeLimitedUpgradable,
excludeLimitedNonUpgradable,
excludeUnique,
excludeFromBlockchain,
sortByPrice,
currentOffset,
limit

View File

@@ -17,11 +17,11 @@ public suspend fun TelegramBot.readBusinessMessage(
@GenerationVariant(Chat::class, "chat.id.toChatId()", "chat")
chatId: ChatId,
messageId: MessageId
): Boolean = execute(
): Unit = execute(
ReadBusinessMessage(businessConnectionId, chatId, messageId)
)
public suspend fun TelegramBot.readBusinessMessage(
businessConnectionId: BusinessConnectionId,
message: AccessibleMessage
): Boolean = readBusinessMessage(businessConnectionId, message.chat.id.toChatId(), message.messageId)
): Unit = readBusinessMessage(businessConnectionId, message.chat.id.toChatId(), message.messageId)

View File

@@ -14,7 +14,7 @@ public suspend fun TelegramBot.readBusinessMessage(
businessConnectionId: BusinessConnectionId,
chat: Chat,
messageId: MessageId,
): Boolean = readBusinessMessage(
): Unit = readBusinessMessage(
businessConnectionId = businessConnectionId, chatId = with(chat) {chat.id.toChatId()}, messageId
= messageId
)

View File

@@ -7,6 +7,6 @@ import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
public suspend fun TelegramBot.removeBusinessAccountProfilePhoto(
businessConnectionId: BusinessConnectionId,
isPublic: Boolean = false
): Boolean = execute(
): Unit = execute(
RemoveBusinessAccountProfilePhoto(businessConnectionId = businessConnectionId, isPublic = isPublic)
)

View File

@@ -7,6 +7,6 @@ import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
public suspend fun TelegramBot.setBusinessAccountBio(
businessConnectionId: BusinessConnectionId,
bio: String
): Boolean = execute(
): Unit = execute(
SetBusinessAccountBio(businessConnectionId, bio)
)

View File

@@ -13,7 +13,7 @@ public suspend fun TelegramBot.setBusinessAccountGiftSettings(
businessConnectionId: BusinessConnectionId,
showGiftButton: Boolean,
acceptedGiftTypes: AcceptedGiftTypes
): Boolean = execute(
): Unit = execute(
SetBusinessAccountGiftSettings(
businessConnectionId = businessConnectionId,
showGiftButton = showGiftButton,
@@ -28,7 +28,7 @@ public suspend fun TelegramBot.setBusinessAccountGiftSettings(
message: BusinessContentMessage<*>,
showGiftButton: Boolean,
acceptedGiftTypes: AcceptedGiftTypes
): Boolean = setBusinessAccountGiftSettings(
): Unit = setBusinessAccountGiftSettings(
businessConnectionId = message.businessConnectionId,
showGiftButton = showGiftButton,
acceptedGiftTypes = acceptedGiftTypes

View File

@@ -8,6 +8,6 @@ public suspend fun TelegramBot.setBusinessAccountName(
businessConnectionId: BusinessConnectionId,
firstName: String,
lastName: String? = null
): Boolean = execute(
): Unit = execute(
SetBusinessAccountName(businessConnectionId, firstName, lastName)
)

View File

@@ -9,6 +9,6 @@ public suspend fun TelegramBot.setBusinessAccountProfilePhoto(
businessConnectionId: BusinessConnectionId,
photo: InputProfilePhoto,
isPublic: Boolean = false
): Boolean = execute(
): Unit = execute(
SetBusinessAccountProfilePhoto(businessConnectionId, photo, isPublic)
)

View File

@@ -7,11 +7,9 @@ import dev.inmo.tgbotapi.requests.business_connection.SetBusinessAccountUsername
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.Username
@GenerateVariations
public suspend fun TelegramBot.setBusinessAccountUsername(
businessConnectionId: BusinessConnectionId,
@GenerationVariant(String::class, "Username(username)", "username")
username: Username
): Boolean = execute(
username: Username? = null
): Unit = execute(
SetBusinessAccountUsername(businessConnectionId, username)
)

View File

@@ -9,8 +9,10 @@ import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import kotlin.Boolean
import kotlin.String
public suspend
fun TelegramBot.setBusinessAccountUsername(businessConnectionId: BusinessConnectionId,
username: String): Boolean = setBusinessAccountUsername(
businessConnectionId = businessConnectionId, username = with(username) { Username.prepare(username) }
public suspend fun TelegramBot.setBusinessAccountUsername(
businessConnectionId: BusinessConnectionId,
username: String?
): Unit = setBusinessAccountUsername(
businessConnectionId = businessConnectionId,
username = username ?.let { Username.prepare(username) }
)

View File

@@ -7,6 +7,6 @@ import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
public suspend fun TelegramBot.transferBusinessAccountStars(
businessConnectionId: BusinessConnectionId,
amount: Int
): Boolean = execute(
): Unit = execute(
TransferBusinessAccountStars(businessConnectionId, amount)
)

View File

@@ -21,7 +21,7 @@ public suspend fun TelegramBot.transferGift(
ownedGiftId: GiftId,
newOwnerChatId: ChatId,
transferPaymentStarCount: Int? = null,
): Boolean = execute(
): Unit = execute(
TransferGift(
businessConnectionId = businessConnectionId,
ownedGiftId = ownedGiftId,
@@ -35,7 +35,7 @@ public suspend fun TelegramBot.transferGift(
gift: Gift.Regular,
newOwnerChatId: ChatId,
transferPaymentStarCount: Int? = null,
): Boolean = transferGift(
): Unit = transferGift(
businessConnectionId = businessConnectionId,
ownedGiftId = gift.id,
newOwnerChatId = newOwnerChatId,

View File

@@ -19,7 +19,7 @@ public suspend fun TelegramBot.convertGiftToStars(
ownedGiftId: GiftId,
keepOriginalDetails: Boolean = false,
starCount: Int? = null
): Boolean = execute(
): Unit = execute(
UpgradeGift(
businessConnectionId = businessConnectionId,
ownedGiftId = ownedGiftId,
@@ -32,7 +32,7 @@ public suspend fun TelegramBot.convertGiftToStars(
businessConnectionId: BusinessConnectionId,
gift: Gift.Regular,
keepOriginalDetails: Boolean = false,
): Boolean = execute(
): Unit = execute(
UpgradeGift(
businessConnectionId = businessConnectionId,
ownedGiftId = gift.id,

View File

@@ -7,8 +7,8 @@ import dev.inmo.tgbotapi.types.chat.PublicChat
public suspend fun TelegramBot.leaveChat(
chatId: ChatIdentifier
): Boolean = execute(LeaveChat(chatId))
): Unit = execute(LeaveChat(chatId))
public suspend fun TelegramBot.leaveChat(
chat: PublicChat
): Boolean = leaveChat(chat.id)
): Unit = leaveChat(chat.id)

View File

@@ -10,7 +10,7 @@ import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.closeForumTopic(
chatId: ChatIdentifier,
messageThreadId: MessageThreadId
): Boolean = execute(
): Unit = execute(
CloseForumTopic(
chatId,
messageThreadId
@@ -20,9 +20,9 @@ public suspend fun TelegramBot.closeForumTopic(
public suspend fun TelegramBot.closeForumTopic(
chat: Chat,
messageThreadId: MessageThreadId
): Boolean = closeForumTopic(chat.id, messageThreadId)
): Unit = closeForumTopic(chat.id, messageThreadId)
public suspend fun TelegramBot.closeForumTopic(
chat: Chat,
forumTopic: ForumTopic
): Boolean = closeForumTopic(chat.id, forumTopic.messageThreadId)
): Unit = closeForumTopic(chat.id, forumTopic.messageThreadId)

View File

@@ -10,10 +10,10 @@ import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.closeGeneralForumTopic(
chatId: ChatIdentifier
): Boolean = execute(
): Unit = execute(
CloseGeneralForumTopic(chatId)
)
public suspend fun TelegramBot.closeGeneralForumTopic(
chat: Chat
): Boolean = closeGeneralForumTopic(chat.id)
): Unit = closeGeneralForumTopic(chat.id)

View File

@@ -10,7 +10,7 @@ import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.deleteForumTopic(
chatId: ChatIdentifier,
messageThreadId: MessageThreadId
): Boolean = execute(
): Unit = execute(
DeleteForumTopic(
chatId,
messageThreadId
@@ -20,14 +20,14 @@ public suspend fun TelegramBot.deleteForumTopic(
public suspend fun TelegramBot.deleteForumTopic(
chatId: ChatIdentifier,
forumTopic: ForumTopic
): Boolean = deleteForumTopic(chatId, forumTopic.messageThreadId)
): Unit = deleteForumTopic(chatId, forumTopic.messageThreadId)
public suspend fun TelegramBot.deleteForumTopic(
chat: Chat,
messageThreadId: MessageThreadId
): Boolean = deleteForumTopic(chat.id, messageThreadId)
): Unit = deleteForumTopic(chat.id, messageThreadId)
public suspend fun TelegramBot.deleteForumTopic(
chat: Chat,
forumTopic: ForumTopic
): Boolean = deleteForumTopic(chat.id, forumTopic.messageThreadId)
): Unit = deleteForumTopic(chat.id, forumTopic.messageThreadId)

View File

@@ -13,7 +13,7 @@ public suspend fun TelegramBot.editForumTopic(
messageThreadId: MessageThreadId,
name: String? = null,
iconEmojiId: CustomEmojiId? = null
): Boolean = execute(
): Unit = execute(
EditForumTopic(
chatId,
messageThreadId,
@@ -27,10 +27,10 @@ public suspend fun TelegramBot.editForumTopic(
messageThreadId: MessageThreadId,
name: String? = null,
iconEmojiId: CustomEmojiId? = null
): Boolean = editForumTopic(chat.id, messageThreadId, name, iconEmojiId)
): Unit = editForumTopic(chat.id, messageThreadId, name, iconEmojiId)
public suspend fun TelegramBot.editForumTopic(
chatIdentifier: ChatIdentifier,
forumTopic: ForumTopic,
iconEmojiId: CustomEmojiId? = forumTopic.iconEmojiId
): Boolean = editForumTopic(chatIdentifier, forumTopic.messageThreadId, forumTopic.name, iconEmojiId)
): Unit = editForumTopic(chatIdentifier, forumTopic.messageThreadId, forumTopic.name, iconEmojiId)

View File

@@ -12,7 +12,7 @@ import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.editGeneralForumTopic(
chatId: ChatIdentifier,
name: String
): Boolean = execute(
): Unit = execute(
EditGeneralForumTopic(
chatId,
name
@@ -22,9 +22,9 @@ public suspend fun TelegramBot.editGeneralForumTopic(
public suspend fun TelegramBot.editGeneralForumTopic(
chat: Chat,
name: String
): Boolean = editGeneralForumTopic(chat.id, name)
): Unit = editGeneralForumTopic(chat.id, name)
public suspend fun TelegramBot.editGeneralForumTopic(
chatIdentifier: ChatIdentifier,
forumTopic: ForumTopic,
): Boolean = editGeneralForumTopic(chatIdentifier, forumTopic.name)
): Unit = editGeneralForumTopic(chatIdentifier, forumTopic.name)

View File

@@ -11,10 +11,10 @@ import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.hideGeneralForumTopic(
chatId: ChatIdentifier
): Boolean = execute(
): Unit = execute(
HideGeneralForumTopic(chatId)
)
public suspend fun TelegramBot.hideGeneralForumTopic(
chat: Chat
): Boolean = hideGeneralForumTopic(chat.id)
): Unit = hideGeneralForumTopic(chat.id)

View File

@@ -10,7 +10,7 @@ import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.reopenForumTopic(
chatId: ChatIdentifier,
messageThreadId: MessageThreadId
): Boolean = execute(
): Unit = execute(
ReopenForumTopic(
chatId,
messageThreadId
@@ -20,9 +20,9 @@ public suspend fun TelegramBot.reopenForumTopic(
public suspend fun TelegramBot.reopenForumTopic(
chat: Chat,
messageThreadId: MessageThreadId
): Boolean = reopenForumTopic(chat.id, messageThreadId)
): Unit = reopenForumTopic(chat.id, messageThreadId)
public suspend fun TelegramBot.reopenForumTopic(
chat: Chat,
forumTopic: ForumTopic
): Boolean = reopenForumTopic(chat.id, forumTopic.messageThreadId)
): Unit = reopenForumTopic(chat.id, forumTopic.messageThreadId)

View File

@@ -10,10 +10,10 @@ import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.reopenGeneralForumTopic(
chatId: ChatIdentifier
): Boolean = execute(
): Unit = execute(
ReopenGeneralForumTopic(chatId)
)
public suspend fun TelegramBot.reopenGeneralForumTopic(
chat: Chat
): Boolean = reopenGeneralForumTopic(chat.id)
): Unit = reopenGeneralForumTopic(chat.id)

View File

@@ -12,10 +12,10 @@ import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.unhideGeneralForumTopic(
chatId: ChatIdentifier
): Boolean = execute(
): Unit = execute(
UnhideGeneralForumTopic(chatId)
)
public suspend fun TelegramBot.unhideGeneralForumTopic(
chat: Chat
): Boolean = unhideGeneralForumTopic(chat.id)
): Unit = unhideGeneralForumTopic(chat.id)

View File

@@ -10,7 +10,7 @@ import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.unpinAllForumTopicMessages(
chatId: ChatIdentifier,
messageThreadId: MessageThreadId
): Boolean = execute(
): Unit = execute(
UnpinAllForumTopicMessages(
chatId,
messageThreadId
@@ -20,9 +20,9 @@ public suspend fun TelegramBot.unpinAllForumTopicMessages(
public suspend fun TelegramBot.unpinAllForumTopicMessages(
chat: Chat,
messageThreadId: MessageThreadId
): Boolean = unpinAllForumTopicMessages(chat.id, messageThreadId)
): Unit = unpinAllForumTopicMessages(chat.id, messageThreadId)
public suspend fun TelegramBot.unpinAllForumTopicMessages(
chat: Chat,
forumTopic: ForumTopic
): Boolean = unpinAllForumTopicMessages(chat.id, forumTopic.messageThreadId)
): Unit = unpinAllForumTopicMessages(chat.id, forumTopic.messageThreadId)

View File

@@ -10,7 +10,7 @@ import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.unpinAllGeneralForumTopicMessages(
chatId: ChatIdentifier
): Boolean = execute(
): Unit = execute(
UnpinAllGeneralForumTopicMessages(
chatId
)
@@ -18,4 +18,4 @@ public suspend fun TelegramBot.unpinAllGeneralForumTopicMessages(
public suspend fun TelegramBot.unpinAllGeneralForumTopicMessages(
chat: Chat
): Boolean = unpinAllGeneralForumTopicMessages(chat.id)
): Unit = unpinAllGeneralForumTopicMessages(chat.id)

View File

@@ -117,6 +117,17 @@ public suspend fun TelegramBot.getChat(
chat: PrivateChatImpl
): ExtendedPrivateChatImpl = getChat(chat.id) as ExtendedPrivateChatImpl
/**
* Will cast incoming [dev.inmo.tgbotapi.types.chat.ExtendedChat] to a
* [ExtendedPrivateForumChatImpl] with unsafe operator "as"
*
* @throws ClassCastException
*/
@PreviewFeature
public suspend fun TelegramBot.getChat(
chat: PrivateForumChatImpl
): ExtendedPrivateForumChatImpl = getChat(chat.id) as ExtendedPrivateForumChatImpl
/**
* Will cast incoming [dev.inmo.tgbotapi.types.chat.ExtendedChat] to a
* [ExtendedUser] with unsafe operator "as"

View File

@@ -7,9 +7,11 @@ import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.member.AdministratorChatMember
public suspend fun TelegramBot.getChatAdministrators(
chatId: ChatIdentifier
): List<AdministratorChatMember> = execute(GetChatAdministrators(chatId))
chatId: ChatIdentifier,
retrieveOtherBots: Boolean? = null
): List<AdministratorChatMember> = execute(GetChatAdministrators(chatId = chatId, retrieveOtherBots = retrieveOtherBots))
public suspend fun TelegramBot.getChatAdministrators(
chat: PublicChat
): List<AdministratorChatMember> = getChatAdministrators(chat.id)
chat: PublicChat,
retrieveOtherBots: Boolean? = null
): List<AdministratorChatMember> = getChatAdministrators(chat.id, retrieveOtherBots)

View File

@@ -12,31 +12,31 @@ import dev.inmo.tgbotapi.types.update.ChatJoinRequestUpdate
public suspend fun TelegramBot.approveChatJoinRequest(
chatId: ChatIdentifier,
userId: UserId
): Boolean = execute(ApproveChatJoinRequest(chatId, userId))
): Unit = execute(ApproveChatJoinRequest(chatId, userId))
public suspend fun TelegramBot.approveChatJoinRequest(
chat: PublicChat,
userId: UserId
): Boolean = approveChatJoinRequest(chat.id, userId)
): Unit = approveChatJoinRequest(chat.id, userId)
public suspend fun TelegramBot.approveChatJoinRequest(
chatId: ChatIdentifier,
user: User
): Boolean = approveChatJoinRequest(chatId, user.id)
): Unit = approveChatJoinRequest(chatId, user.id)
public suspend fun TelegramBot.approveChatJoinRequest(
chat: PublicChat,
user: User
): Boolean = approveChatJoinRequest(chat.id, user.id)
): Unit = approveChatJoinRequest(chat.id, user.id)
public suspend fun TelegramBot.approveChatJoinRequest(
chatJoinRequest: ChatJoinRequest
): Boolean = approveChatJoinRequest(chatJoinRequest.chat, chatJoinRequest.user)
): Unit = approveChatJoinRequest(chatJoinRequest.chat, chatJoinRequest.user)
public suspend fun TelegramBot.approve(
chatJoinRequest: ChatJoinRequest
): Boolean = approveChatJoinRequest(chatJoinRequest)
): Unit = approveChatJoinRequest(chatJoinRequest)
public suspend fun TelegramBot.approveChatJoinRequest(
chatJoinRequestUpdate: ChatJoinRequestUpdate
): Boolean = approveChatJoinRequest(chatJoinRequestUpdate.data)
): Unit = approveChatJoinRequest(chatJoinRequestUpdate.data)

View File

@@ -12,31 +12,31 @@ import dev.inmo.tgbotapi.types.update.ChatJoinRequestUpdate
public suspend fun TelegramBot.declineChatJoinRequest(
chatId: ChatIdentifier,
userId: UserId
): Boolean = execute(DeclineChatJoinRequest(chatId, userId))
): Unit = execute(DeclineChatJoinRequest(chatId, userId))
public suspend fun TelegramBot.declineChatJoinRequest(
chat: PublicChat,
userId: UserId
): Boolean = declineChatJoinRequest(chat.id, userId)
): Unit = declineChatJoinRequest(chat.id, userId)
public suspend fun TelegramBot.declineChatJoinRequest(
chatId: ChatIdentifier,
user: User
): Boolean = declineChatJoinRequest(chatId, user.id)
): Unit = declineChatJoinRequest(chatId, user.id)
public suspend fun TelegramBot.declineChatJoinRequest(
chat: PublicChat,
user: User
): Boolean = declineChatJoinRequest(chat.id, user.id)
): Unit = declineChatJoinRequest(chat.id, user.id)
public suspend fun TelegramBot.declineChatJoinRequest(
chatJoinRequest: ChatJoinRequest
): Boolean = declineChatJoinRequest(chatJoinRequest.chat, chatJoinRequest.user)
): Unit = declineChatJoinRequest(chatJoinRequest.chat, chatJoinRequest.user)
public suspend fun TelegramBot.decline(
chatJoinRequest: ChatJoinRequest
): Boolean = declineChatJoinRequest(chatJoinRequest)
): Unit = declineChatJoinRequest(chatJoinRequest)
public suspend fun TelegramBot.declineChatJoinRequest(
chatJoinRequestUpdate: ChatJoinRequestUpdate
): Boolean = declineChatJoinRequest(chatJoinRequestUpdate.data)
): Unit = declineChatJoinRequest(chatJoinRequestUpdate.data)

View File

@@ -14,25 +14,25 @@ public suspend fun TelegramBot.banChatMember(
userId: UserId,
untilDate: TelegramDate? = null,
revokeMessages: Boolean? = null
): Boolean = execute(BanChatMember(chatId, userId, untilDate, revokeMessages))
): Unit = execute(BanChatMember(chatId, userId, untilDate, revokeMessages))
public suspend fun TelegramBot.banChatMember(
chat: PublicChat,
userId: UserId,
untilDate: TelegramDate? = null,
revokeMessages: Boolean? = null
): Boolean = banChatMember(chat.id, userId, untilDate, revokeMessages)
): Unit = banChatMember(chat.id, userId, untilDate, revokeMessages)
public suspend fun TelegramBot.banChatMember(
chatId: IdChatIdentifier,
user: User,
untilDate: TelegramDate? = null,
revokeMessages: Boolean? = null
): Boolean = banChatMember(chatId, user.id, untilDate, revokeMessages)
): Unit = banChatMember(chatId, user.id, untilDate, revokeMessages)
public suspend fun TelegramBot.banChatMember(
chat: PublicChat,
user: User,
untilDate: TelegramDate? = null,
revokeMessages: Boolean? = null
): Boolean = banChatMember(chat.id, user.id, untilDate, revokeMessages)
): Unit = banChatMember(chat.id, user.id, untilDate, revokeMessages)

View File

@@ -9,19 +9,19 @@ import dev.inmo.tgbotapi.types.chat.PublicChat
public suspend fun TelegramBot.banChatSenderChat(
chatId: ChatIdentifier,
senderChatId: IdChatIdentifier
): Boolean = execute(BanChatSenderChat(chatId, senderChatId))
): Unit = execute(BanChatSenderChat(chatId, senderChatId))
public suspend fun TelegramBot.banChatSenderChat(
chat: PublicChat,
senderChatId: IdChatIdentifier
): Boolean = banChatSenderChat(chat.id, senderChatId)
): Unit = banChatSenderChat(chat.id, senderChatId)
public suspend fun TelegramBot.banChatSenderChat(
chatId: IdChatIdentifier,
senderChat: PublicChat
): Boolean = banChatSenderChat(chatId, senderChat.id)
): Unit = banChatSenderChat(chatId, senderChat.id)
public suspend fun TelegramBot.banChatSenderChat(
chat: PublicChat,
senderChat: PublicChat,
): Boolean = banChatSenderChat(chat.id, senderChat)
): Unit = banChatSenderChat(chat.id, senderChat)

View File

@@ -2,7 +2,6 @@ package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.PromoteChannelAdministrator
import dev.inmo.tgbotapi.requests.chat.members.PromoteChatMember
import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.TelegramDate
@@ -26,8 +25,9 @@ public suspend fun TelegramBot.promoteChannelAdministrator(
canManageChat: Boolean? = null,
canPostStories: Boolean? = null,
canEditStories: Boolean? = null,
canDeleteStories: Boolean? = null
): Boolean = execute(
canDeleteStories: Boolean? = null,
canManageDirectMessages: Boolean? = null,
): Unit = execute(
PromoteChannelAdministrator(
chatId = chatId,
userId = userId,
@@ -44,7 +44,8 @@ public suspend fun TelegramBot.promoteChannelAdministrator(
canManageChat = canManageChat,
canPostStories = canPostStories,
canEditStories = canEditStories,
canDeleteStories = canDeleteStories
canDeleteStories = canDeleteStories,
canManageDirectMessages = canManageDirectMessages,
)
)
@@ -64,8 +65,9 @@ public suspend fun TelegramBot.promoteChannelAdministrator(
canManageChat: Boolean? = null,
canPostStories: Boolean? = null,
canEditStories: Boolean? = null,
canDeleteStories: Boolean? = null
): Boolean = promoteChannelAdministrator(
canDeleteStories: Boolean? = null,
canManageDirectMessages: Boolean? = null,
): Unit = promoteChannelAdministrator(
chat.id,
userId,
untilDate = untilDate,
@@ -81,7 +83,8 @@ public suspend fun TelegramBot.promoteChannelAdministrator(
canManageChat = canManageChat,
canPostStories = canPostStories,
canEditStories = canEditStories,
canDeleteStories = canDeleteStories
canDeleteStories = canDeleteStories,
canManageDirectMessages = canManageDirectMessages,
)
public suspend fun TelegramBot.promoteChannelAdministrator(
@@ -100,8 +103,9 @@ public suspend fun TelegramBot.promoteChannelAdministrator(
canManageChat: Boolean? = null,
canPostStories: Boolean? = null,
canEditStories: Boolean? = null,
canDeleteStories: Boolean? = null
): Boolean = promoteChannelAdministrator(
canDeleteStories: Boolean? = null,
canManageDirectMessages: Boolean? = null,
): Unit = promoteChannelAdministrator(
chatId,
user.id,
untilDate = untilDate,
@@ -117,7 +121,8 @@ public suspend fun TelegramBot.promoteChannelAdministrator(
canManageChat = canManageChat,
canPostStories = canPostStories,
canEditStories = canEditStories,
canDeleteStories = canDeleteStories
canDeleteStories = canDeleteStories,
canManageDirectMessages = canManageDirectMessages,
)
public suspend fun TelegramBot.promoteChannelAdministrator(
@@ -136,8 +141,9 @@ public suspend fun TelegramBot.promoteChannelAdministrator(
canManageChat: Boolean? = null,
canPostStories: Boolean? = null,
canEditStories: Boolean? = null,
canDeleteStories: Boolean? = null
): Boolean = promoteChannelAdministrator(
canDeleteStories: Boolean? = null,
canManageDirectMessages: Boolean? = null,
): Unit = promoteChannelAdministrator(
chat.id,
user.id,
untilDate = untilDate,
@@ -153,5 +159,6 @@ public suspend fun TelegramBot.promoteChannelAdministrator(
canManageChat = canManageChat,
canPostStories = canPostStories,
canEditStories = canEditStories,
canDeleteStories = canDeleteStories
canDeleteStories = canDeleteStories,
canManageDirectMessages = canManageDirectMessages,
)

View File

@@ -21,19 +21,21 @@ public suspend fun TelegramBot.promoteChatAdministrator(
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
): Boolean = execute(
canManageTags: Boolean? = null,
): Unit = execute(
PromoteChatMember(
chatId,
userId,
untilDate,
isAnonymous,
canChangeInfo,
canDeleteMessages,
canInviteUsers,
canRestrictMembers,
canPromoteMembers,
canManageVideoChats,
canManageChat
chatId = chatId,
userId = userId,
untilDate = untilDate,
isAnonymous = isAnonymous,
canChangeInfo = canChangeInfo,
canDeleteMessages = canDeleteMessages,
canInviteUsers = canInviteUsers,
canRestrictMembers = canRestrictMembers,
canPromoteMembers = canPromoteMembers,
canManageVideoChats = canManageVideoChats,
canManageChat = canManageChat,
canManageTags = canManageTags
)
)
@@ -49,18 +51,20 @@ public suspend fun TelegramBot.promoteChatAdministrator(
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
): Boolean = promoteChatAdministrator(
chat.id,
userId,
untilDate,
isAnonymous,
canChangeInfo,
canDeleteMessages,
canInviteUsers,
canRestrictMembers,
canPromoteMembers,
canManageVideoChats,
canManageChat
canManageTags: Boolean? = null,
): Unit = promoteChatAdministrator(
chatId = chat.id,
userId = userId,
untilDate = untilDate,
isAnonymous = isAnonymous,
canChangeInfo = canChangeInfo,
canDeleteMessages = canDeleteMessages,
canInviteUsers = canInviteUsers,
canRestrictMembers = canRestrictMembers,
canPromoteMembers = canPromoteMembers,
canManageVideoChats = canManageVideoChats,
canManageChat = canManageChat,
canManageTags = canManageTags
)
public suspend fun TelegramBot.promoteChatAdministrator(
@@ -75,18 +79,20 @@ public suspend fun TelegramBot.promoteChatAdministrator(
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
): Boolean = promoteChatAdministrator(
chatId,
user.id,
untilDate,
isAnonymous,
canChangeInfo,
canDeleteMessages,
canInviteUsers,
canRestrictMembers,
canPromoteMembers,
canManageVideoChats,
canManageChat
canManageTags: Boolean? = null,
): Unit = promoteChatAdministrator(
chatId = chatId,
userId = user.id,
untilDate = untilDate,
isAnonymous = isAnonymous,
canChangeInfo = canChangeInfo,
canDeleteMessages = canDeleteMessages,
canInviteUsers = canInviteUsers,
canRestrictMembers = canRestrictMembers,
canPromoteMembers = canPromoteMembers,
canManageVideoChats = canManageVideoChats,
canManageChat = canManageChat,
canManageTags = canManageTags
)
public suspend fun TelegramBot.promoteChatAdministrator(
@@ -101,16 +107,18 @@ public suspend fun TelegramBot.promoteChatAdministrator(
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
): Boolean = promoteChatAdministrator(
chat.id,
user.id,
untilDate,
isAnonymous,
canChangeInfo,
canDeleteMessages,
canInviteUsers,
canRestrictMembers,
canPromoteMembers,
canManageVideoChats,
canManageChat
canManageTags: Boolean? = null,
): Unit = promoteChatAdministrator(
chatId = chat.id,
userId = user.id,
untilDate = untilDate,
isAnonymous = isAnonymous,
canChangeInfo = canChangeInfo,
canDeleteMessages = canDeleteMessages,
canInviteUsers = canInviteUsers,
canRestrictMembers = canRestrictMembers,
canPromoteMembers = canPromoteMembers,
canManageVideoChats = canManageVideoChats,
canManageChat = canManageChat,
canManageTags = canManageTags
)

View File

@@ -26,8 +26,10 @@ public suspend fun TelegramBot.promoteChatMember(
canManageTopics: Boolean? = null,
canPostStories: Boolean? = null,
canEditStories: Boolean? = null,
canDeleteStories: Boolean? = null
): Boolean = execute(
canDeleteStories: Boolean? = null,
canManageDirectMessages: Boolean? = null,
canManageTags: Boolean? = null
): Unit = execute(
PromoteChatMember(
chatId = chatId,
userId = userId,
@@ -46,7 +48,9 @@ public suspend fun TelegramBot.promoteChatMember(
canManageTopics = canManageTopics,
canPostStories = canPostStories,
canEditStories = canEditStories,
canDeleteStories = canDeleteStories
canDeleteStories = canDeleteStories,
canManageDirectMessages = canManageDirectMessages,
canManageTags = canManageTags,
)
)
@@ -69,8 +73,10 @@ public suspend fun TelegramBot.promoteChatMember(
canManageTopics: Boolean? = null,
canPostStories: Boolean? = null,
canEditStories: Boolean? = null,
canDeleteStories: Boolean? = null
): Boolean = promoteChatMember(
canDeleteStories: Boolean? = null,
canManageDirectMessages: Boolean? = null,
canManageTags: Boolean? = null
): Unit = promoteChatMember(
chat.id,
userId,
untilDate = untilDate,
@@ -88,7 +94,9 @@ public suspend fun TelegramBot.promoteChatMember(
canManageTopics = canManageTopics,
canPostStories = canPostStories,
canEditStories = canEditStories,
canDeleteStories = canDeleteStories
canDeleteStories = canDeleteStories,
canManageDirectMessages = canManageDirectMessages,
canManageTags = canManageTags,
)
@Warning("This method is too common. Use it with caution")
@@ -110,8 +118,10 @@ public suspend fun TelegramBot.promoteChatMember(
canManageTopics: Boolean? = null,
canPostStories: Boolean? = null,
canEditStories: Boolean? = null,
canDeleteStories: Boolean? = null
): Boolean = promoteChatMember(
canDeleteStories: Boolean? = null,
canManageDirectMessages: Boolean? = null,
canManageTags: Boolean? = null
): Unit = promoteChatMember(
chatId,
user.id,
untilDate = untilDate,
@@ -129,7 +139,9 @@ public suspend fun TelegramBot.promoteChatMember(
canManageTopics = canManageTopics,
canPostStories = canPostStories,
canEditStories = canEditStories,
canDeleteStories = canDeleteStories
canDeleteStories = canDeleteStories,
canManageDirectMessages = canManageDirectMessages,
canManageTags = canManageTags,
)
@Warning("This method is too common. Use it with caution")
@@ -151,8 +163,10 @@ public suspend fun TelegramBot.promoteChatMember(
canManageTopics: Boolean? = null,
canPostStories: Boolean? = null,
canEditStories: Boolean? = null,
canDeleteStories: Boolean? = null
): Boolean = promoteChatMember(
canDeleteStories: Boolean? = null,
canManageDirectMessages: Boolean? = null,
canManageTags: Boolean? = null
): Unit = promoteChatMember(
chat.id,
user.id,
untilDate = untilDate,
@@ -170,5 +184,7 @@ public suspend fun TelegramBot.promoteChatMember(
canManageTopics = canManageTopics,
canPostStories = canPostStories,
canEditStories = canEditStories,
canDeleteStories = canDeleteStories
canDeleteStories = canDeleteStories,
canManageDirectMessages = canManageDirectMessages,
canManageTags = canManageTags,
)

View File

@@ -24,7 +24,7 @@ public suspend fun TelegramBot.promoteSupergroupAdministrator(
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
canManageTopics: Boolean? = null,
): Boolean = execute(
): Unit = execute(
PromoteSupergroupAdministrator(
chatId = chatId,
userId = userId,
@@ -56,7 +56,7 @@ public suspend fun TelegramBot.promoteSupergroupAdministrator(
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
canManageTopics: Boolean? = null,
): Boolean = promoteSupergroupAdministrator(
): Unit = promoteSupergroupAdministrator(
chat.id,
userId,
untilDate = untilDate,
@@ -86,7 +86,7 @@ public suspend fun TelegramBot.promoteSupergroupAdministrator(
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
canManageTopics: Boolean? = null,
): Boolean = promoteSupergroupAdministrator(
): Unit = promoteSupergroupAdministrator(
chatId,
user.id,
untilDate = untilDate,
@@ -116,7 +116,7 @@ public suspend fun TelegramBot.promoteSupergroupAdministrator(
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
canManageTopics: Boolean? = null,
): Boolean = promoteSupergroupAdministrator(
): Unit = promoteSupergroupAdministrator(
chat.id,
user.id,
untilDate = untilDate,

View File

@@ -16,7 +16,7 @@ public suspend fun TelegramBot.restrictChatMember(
untilDate: TelegramDate? = null,
permissions: ChatPermissions = ChatPermissions(),
useIndependentChatPermissions: Boolean? = permissions.isGranular.takeIf { it }
): Boolean = execute(RestrictChatMember(chatId, userId, untilDate, permissions, useIndependentChatPermissions))
): Unit = execute(RestrictChatMember(chatId, userId, untilDate, permissions, useIndependentChatPermissions))
public suspend fun TelegramBot.restrictChatMember(
chat: PublicChat,
@@ -24,7 +24,7 @@ public suspend fun TelegramBot.restrictChatMember(
untilDate: TelegramDate? = null,
permissions: ChatPermissions = ChatPermissions(),
useIndependentChatPermissions: Boolean? = permissions.isGranular.takeIf { it }
): Boolean = restrictChatMember(chat.id, userId, untilDate, permissions, useIndependentChatPermissions)
): Unit = restrictChatMember(chat.id, userId, untilDate, permissions, useIndependentChatPermissions)
public suspend fun TelegramBot.restrictChatMember(
chatId: IdChatIdentifier,
@@ -32,7 +32,7 @@ public suspend fun TelegramBot.restrictChatMember(
untilDate: TelegramDate? = null,
permissions: ChatPermissions = ChatPermissions(),
useIndependentChatPermissions: Boolean? = permissions.isGranular.takeIf { it }
): Boolean = restrictChatMember(chatId, user.id, untilDate, permissions, useIndependentChatPermissions)
): Unit = restrictChatMember(chatId, user.id, untilDate, permissions, useIndependentChatPermissions)
public suspend fun TelegramBot.restrictChatMember(
chat: PublicChat,
@@ -40,5 +40,5 @@ public suspend fun TelegramBot.restrictChatMember(
untilDate: TelegramDate? = null,
permissions: ChatPermissions = ChatPermissions(),
useIndependentChatPermissions: Boolean? = permissions.isGranular.takeIf { it }
): Boolean = restrictChatMember(chat.id, user.id, untilDate, permissions, useIndependentChatPermissions)
): Unit = restrictChatMember(chat.id, user.id, untilDate, permissions, useIndependentChatPermissions)

View File

@@ -11,22 +11,22 @@ public suspend fun TelegramBot.setChatAdministratorCustomTitle(
chatId: IdChatIdentifier,
userId: UserId,
customTitle: String
): Boolean = execute(SetChatAdministratorCustomTitle(chatId, userId, customTitle))
): Unit = execute(SetChatAdministratorCustomTitle(chatId, userId, customTitle))
public suspend fun TelegramBot.setChatAdministratorCustomTitle(
chat: PublicChat,
userId: UserId,
customTitle: String
): Boolean = setChatAdministratorCustomTitle(chat.id, userId, customTitle)
): Unit = setChatAdministratorCustomTitle(chat.id, userId, customTitle)
public suspend fun TelegramBot.setChatAdministratorCustomTitle(
chatId: IdChatIdentifier,
user: User,
customTitle: String
): Boolean = setChatAdministratorCustomTitle(chatId, user.id, customTitle)
): Unit = setChatAdministratorCustomTitle(chatId, user.id, customTitle)
public suspend fun TelegramBot.setChatAdministratorCustomTitle(
chat: PublicChat,
user: User,
customTitle: String
): Boolean = setChatAdministratorCustomTitle(chat.id, user.id, customTitle)
): Unit = setChatAdministratorCustomTitle(chat.id, user.id, customTitle)

View File

@@ -0,0 +1,31 @@
package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.SetChatMemberTag
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.User
public suspend fun TelegramBot.setChatMemberTag(
chatId: ChatIdentifier,
userId: UserId,
tag: UserTag? = null
): Unit = execute(SetChatMemberTag(chatId, userId, tag))
public suspend fun TelegramBot.setChatMemberTag(
chat: PublicChat,
userId: UserId,
tag: UserTag? = null
): Unit = setChatMemberTag(chat.id, userId, tag)
public suspend fun TelegramBot.setChatMemberTag(
chatId: ChatIdentifier,
user: User,
tag: UserTag? = null
): Unit = setChatMemberTag(chatId, user.id, tag)
public suspend fun TelegramBot.setChatMemberTag(
chat: PublicChat,
user: User,
tag: UserTag? = null
): Unit = setChatMemberTag(chat.id, user.id, tag)

View File

@@ -12,23 +12,23 @@ public suspend fun TelegramBot.unbanChatMember(
chatId: ChatIdentifier,
userId: UserId,
onlyIfBanned: Boolean? = null
): Boolean = execute(UnbanChatMember(chatId, userId, onlyIfBanned))
): Unit = execute(UnbanChatMember(chatId, userId, onlyIfBanned))
public suspend fun TelegramBot.unbanChatMember(
chat: PublicChat,
userId: UserId,
onlyIfBanned: Boolean? = null
): Boolean = unbanChatMember(chat.id, userId, onlyIfBanned)
): Unit = unbanChatMember(chat.id, userId, onlyIfBanned)
public suspend fun TelegramBot.unbanChatMember(
chatId: IdChatIdentifier,
user: User,
onlyIfBanned: Boolean? = null
): Boolean = unbanChatMember(chatId, user.id, onlyIfBanned)
): Unit = unbanChatMember(chatId, user.id, onlyIfBanned)
public suspend fun TelegramBot.unbanChatMember(
chat: PublicChat,
user: User,
onlyIfBanned: Boolean? = null
): Boolean = unbanChatMember(chat.id, user.id, onlyIfBanned)
): Unit = unbanChatMember(chat.id, user.id, onlyIfBanned)

View File

@@ -9,19 +9,19 @@ import dev.inmo.tgbotapi.types.chat.PublicChat
public suspend fun TelegramBot.unbanChatSenderChat(
chatId: ChatIdentifier,
senderChatId: IdChatIdentifier
): Boolean = execute(UnbanChatSenderChat(chatId, senderChatId))
): Unit = execute(UnbanChatSenderChat(chatId, senderChatId))
public suspend fun TelegramBot.unbanChatSenderChat(
chat: PublicChat,
senderChatId: IdChatIdentifier
): Boolean = unbanChatSenderChat(chat.id, senderChatId)
): Unit = unbanChatSenderChat(chat.id, senderChatId)
public suspend fun TelegramBot.unbanChatSenderChat(
chatId: IdChatIdentifier,
senderChat: PublicChat
): Boolean = unbanChatSenderChat(chatId, senderChat.id)
): Unit = unbanChatSenderChat(chatId, senderChat.id)
public suspend fun TelegramBot.unbanChatSenderChat(
chat: PublicChat,
senderChat: PublicChat,
): Boolean = unbanChatSenderChat(chat.id, senderChat)
): Unit = unbanChatSenderChat(chat.id, senderChat)

View File

@@ -7,8 +7,8 @@ import dev.inmo.tgbotapi.types.chat.PublicChat
public suspend fun TelegramBot.deleteChatPhoto(
chatId: ChatIdentifier
): Boolean = execute(DeleteChatPhoto(chatId))
): Unit = execute(DeleteChatPhoto(chatId))
public suspend fun TelegramBot.deleteChatPhoto(
chat: PublicChat
): Boolean = deleteChatPhoto(chat.id)
): Unit = deleteChatPhoto(chat.id)

View File

@@ -14,17 +14,17 @@ public suspend fun TelegramBot.pinChatMessage(
messageId: MessageId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
disableNotification: Boolean = false
): Boolean = execute(PinChatMessage(chatId, messageId, businessConnectionId, disableNotification))
): Unit = execute(PinChatMessage(chatId, messageId, businessConnectionId, disableNotification))
public suspend fun TelegramBot.pinChatMessage(
chat: Chat,
messageId: MessageId,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
disableNotification: Boolean = false
): Boolean = pinChatMessage(chat.id, messageId, businessConnectionId, disableNotification)
): Unit = pinChatMessage(chat.id, messageId, businessConnectionId, disableNotification)
public suspend fun TelegramBot.pinChatMessage(
message: AccessibleMessage,
businessConnectionId: BusinessConnectionId? = message.chat.id.businessConnectionId,
disableNotification: Boolean = false
): Boolean = pinChatMessage(message.chat.id, message.messageId, businessConnectionId, disableNotification)
): Unit = pinChatMessage(message.chat.id, message.messageId, businessConnectionId, disableNotification)

View File

@@ -8,9 +8,9 @@ import dev.inmo.tgbotapi.types.chat.PublicChat
public suspend fun TelegramBot.setChatDescription(
chatId: ChatIdentifier,
description: String
): Boolean = execute(SetChatDescription(chatId, description))
): Unit = execute(SetChatDescription(chatId, description))
public suspend fun TelegramBot.setChatDescription(
chat: PublicChat,
description: String
): Boolean = setChatDescription(chat.id, description)
): Unit = setChatDescription(chat.id, description)

View File

@@ -9,9 +9,9 @@ import dev.inmo.tgbotapi.types.chat.PrivateChat
public suspend fun TelegramBot.setChatMenuButton(
chatId: IdChatIdentifier,
menuButton: MenuButton
): Boolean = execute(SetChatMenuButton(chatId, menuButton))
): Unit = execute(SetChatMenuButton(chatId, menuButton))
public suspend fun TelegramBot.setChatMenuButton(
chat: PrivateChat,
menuButton: MenuButton
): Boolean = setChatMenuButton(chat.id, menuButton)
): Unit = setChatMenuButton(chat.id, menuButton)

View File

@@ -10,10 +10,10 @@ public suspend fun TelegramBot.setDefaultChatMembersPermissions(
chatId: ChatIdentifier,
permissions: ChatPermissions,
useIndependentChatPermissions: Boolean? = permissions.isGranular.takeIf { it }
): Boolean = execute(SetChatPermissions(chatId, permissions, useIndependentChatPermissions))
): Unit = execute(SetChatPermissions(chatId, permissions, useIndependentChatPermissions))
public suspend fun TelegramBot.setDefaultChatMembersPermissions(
chat: PublicChat,
permissions: ChatPermissions,
useIndependentChatPermissions: Boolean? = permissions.isGranular.takeIf { it }
): Boolean = setDefaultChatMembersPermissions(chat.id, permissions, useIndependentChatPermissions)
): Unit = setDefaultChatMembersPermissions(chat.id, permissions, useIndependentChatPermissions)

View File

@@ -9,9 +9,9 @@ import dev.inmo.tgbotapi.types.chat.PublicChat
public suspend fun TelegramBot.setChatPhoto(
chatId: ChatIdentifier,
photo: MultipartFile
): Boolean = execute(SetChatPhoto(chatId, photo))
): Unit = execute(SetChatPhoto(chatId, photo))
public suspend fun TelegramBot.setChatPhoto(
chat: PublicChat,
photo: MultipartFile
): Boolean = setChatPhoto(chat.id, photo)
): Unit = setChatPhoto(chat.id, photo)

View File

@@ -8,9 +8,9 @@ import dev.inmo.tgbotapi.types.chat.PublicChat
public suspend fun TelegramBot.setChatTitle(
chatId: ChatIdentifier,
title: String
): Boolean = execute(SetChatTitle(chatId, title))
): Unit = execute(SetChatTitle(chatId, title))
public suspend fun TelegramBot.setChatTitle(
chat: PublicChat,
title: String
): Boolean = setChatTitle(chat.id, title)
): Unit = setChatTitle(chat.id, title)

View File

@@ -6,4 +6,4 @@ import dev.inmo.tgbotapi.types.MenuButton
public suspend fun TelegramBot.setDefaultChatMenuButton(
menuButton: MenuButton
): Boolean = execute(SetDefaultChatMenuButton(menuButton))
): Unit = execute(SetDefaultChatMenuButton(menuButton))

View File

@@ -7,8 +7,8 @@ import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.unpinAllChatMessages(
chatId: ChatIdentifier
): Boolean = execute(UnpinAllChatMessages(chatId))
): Unit = execute(UnpinAllChatMessages(chatId))
public suspend fun TelegramBot.unpinAllChatMessages(
chat: Chat
): Boolean = unpinAllChatMessages(chat.id)
): Unit = unpinAllChatMessages(chat.id)

View File

@@ -13,15 +13,15 @@ public suspend fun TelegramBot.unpinChatMessage(
chatId: ChatIdentifier,
messageId: MessageId? = null,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId
): Boolean = execute(UnpinChatMessage(chatId, messageId, businessConnectionId))
): Unit = execute(UnpinChatMessage(chatId, messageId, businessConnectionId))
public suspend fun TelegramBot.unpinChatMessage(
chat: Chat,
messageId: MessageId? = null,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId
): Boolean = unpinChatMessage(chat.id, messageId, businessConnectionId)
): Unit = unpinChatMessage(chat.id, messageId, businessConnectionId)
public suspend fun TelegramBot.unpinChatMessage(
message: AccessibleMessage,
businessConnectionId: BusinessConnectionId? = message.chat.id.businessConnectionId,
): Boolean = unpinChatMessage(message.chat.id, message.messageId, businessConnectionId)
): Unit = unpinChatMessage(message.chat.id, message.messageId, businessConnectionId)

View File

@@ -7,8 +7,8 @@ import dev.inmo.tgbotapi.types.chat.SupergroupChat
public suspend fun TelegramBot.deleteChatStickerSet(
chatId: ChatIdentifier
): Boolean = execute(DeleteChatStickerSet(chatId))
): Unit = execute(DeleteChatStickerSet(chatId))
public suspend fun TelegramBot.deleteChatStickerSet(
chat: SupergroupChat
): Boolean = deleteChatStickerSet(chat.id)
): Unit = deleteChatStickerSet(chat.id)

View File

@@ -9,9 +9,9 @@ import dev.inmo.tgbotapi.types.chat.SupergroupChat
public suspend fun TelegramBot.setChatStickerSet(
chatId: ChatIdentifier,
stickerSetName: StickerSetName
): Boolean = execute(SetChatStickerSet(chatId, stickerSetName))
): Unit = execute(SetChatStickerSet(chatId, stickerSetName))
public suspend fun TelegramBot.setChatStickerSet(
chat: SupergroupChat,
stickerSetName: StickerSetName
): Boolean = setChatStickerSet(chat.id, stickerSetName)
): Unit = setChatStickerSet(chat.id, stickerSetName)

View File

@@ -27,7 +27,7 @@ public suspend fun TelegramBot.edit(
heading: Degrees? = null,
proximityAlertRadius: Meters? = null,
replyMarkup: InlineKeyboardMarkup? = null
): Boolean = editLiveLocation(messageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup)
): Unit = editLiveLocation(messageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
@@ -37,7 +37,7 @@ public suspend fun TelegramBot.edit(
messageId: InlineMessageId,
location: LiveLocation,
replyMarkup: InlineKeyboardMarkup? = null
): Boolean = editLiveLocation(
): Unit = editLiveLocation(
messageId, location, replyMarkup
)
@@ -49,7 +49,7 @@ public suspend fun TelegramBot.edit(
messageId: InlineMessageId,
media: TelegramFreeMedia,
replyMarkup: InlineKeyboardMarkup? = null
): Boolean = editMessageMedia(messageId, media, replyMarkup)
): Unit = editMessageMedia(messageId, media, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
@@ -58,7 +58,7 @@ public suspend fun TelegramBot.edit(
public suspend fun TelegramBot.edit(
messageId: InlineMessageId,
replyMarkup: InlineKeyboardMarkup? = null
): Boolean = editMessageReplyMarkup(messageId, replyMarkup)
): Unit = editMessageReplyMarkup(messageId, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
@@ -71,7 +71,7 @@ public suspend fun TelegramBot.edit(
showCaptionAboveMedia: Boolean = false,
linkPreviewOptions: LinkPreviewOptions? = null,
replyMarkup: InlineKeyboardMarkup? = null
): Boolean = editMessageText(messageId, text, parseMode, showCaptionAboveMedia, linkPreviewOptions, replyMarkup)
): Unit = editMessageText(messageId, text, parseMode, showCaptionAboveMedia, linkPreviewOptions, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
@@ -83,7 +83,7 @@ public suspend fun TelegramBot.edit(
showCaptionAboveMedia: Boolean = false,
linkPreviewOptions: LinkPreviewOptions? = null,
replyMarkup: InlineKeyboardMarkup? = null
): Boolean = editMessageText(messageId, entities, showCaptionAboveMedia, linkPreviewOptions, replyMarkup)
): Unit = editMessageText(messageId, entities, showCaptionAboveMedia, linkPreviewOptions, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
@@ -96,7 +96,7 @@ public suspend fun TelegramBot.edit(
linkPreviewOptions: LinkPreviewOptions? = null,
replyMarkup: InlineKeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
): Boolean = edit(messageId, buildEntities(separator, builderBody), showCaptionAboveMedia, linkPreviewOptions, replyMarkup)
): Unit = edit(messageId, buildEntities(separator, builderBody), showCaptionAboveMedia, linkPreviewOptions, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
@@ -109,4 +109,4 @@ public suspend fun TelegramBot.edit(
linkPreviewOptions: LinkPreviewOptions? = null,
replyMarkup: InlineKeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
): Boolean = edit(messageId, buildEntities(separator, builderBody), showCaptionAboveMedia, linkPreviewOptions, replyMarkup)
): Unit = edit(messageId, buildEntities(separator, builderBody), showCaptionAboveMedia, linkPreviewOptions, replyMarkup)

View File

@@ -16,7 +16,7 @@ public suspend fun TelegramBot.editMessageCaption(
text: String,
parseMode: ParseMode? = null,
replyMarkup: InlineKeyboardMarkup? = null
): Boolean = execute(EditInlineMessageCaption(inlineMessageId, text, parseMode, replyMarkup))
): Unit = execute(EditInlineMessageCaption(inlineMessageId, text, parseMode, replyMarkup))
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
@@ -26,4 +26,4 @@ public suspend fun TelegramBot.editMessageCaption(
inlineMessageId: InlineMessageId,
entities: TextSourcesList,
replyMarkup: InlineKeyboardMarkup? = null
): Boolean = execute(EditInlineMessageCaption(inlineMessageId, entities, replyMarkup))
): Unit = execute(EditInlineMessageCaption(inlineMessageId, entities, replyMarkup))

View File

@@ -14,7 +14,7 @@ public suspend fun TelegramBot.editLiveLocation(
heading: Degrees? = null,
proximityAlertRadius: Meters? = null,
replyMarkup: InlineKeyboardMarkup? = null
): Boolean = execute(
): Unit = execute(
EditInlineMessageLiveLocation(
inlineMessageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup
)
@@ -23,4 +23,4 @@ public suspend fun TelegramBot.editLiveLocation(
inlineMessageId: InlineMessageId,
location: LiveLocation,
replyMarkup: InlineKeyboardMarkup? = null
): Boolean = editLiveLocation(inlineMessageId, location.latitude, location.longitude, location.horizontalAccuracy, location.heading, location.proximityAlertRadius, replyMarkup)
): Unit = editLiveLocation(inlineMessageId, location.latitude, location.longitude, location.horizontalAccuracy, location.heading, location.proximityAlertRadius, replyMarkup)

View File

@@ -12,7 +12,7 @@ import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
public suspend fun TelegramBot.stopLiveLocation(
inlineMessageId: InlineMessageId,
replyMarkup: InlineKeyboardMarkup? = null
): Boolean = execute(
): Unit = execute(
StopInlineMessageLiveLocation(
inlineMessageId, replyMarkup
)

View File

@@ -14,4 +14,4 @@ public suspend fun TelegramBot.editMessageMedia(
inlineMessageId: InlineMessageId,
media: TelegramFreeMedia,
replyMarkup: InlineKeyboardMarkup? = null
): Boolean = execute(EditInlineMessageMedia(inlineMessageId, media, replyMarkup))
): Unit = execute(EditInlineMessageMedia(inlineMessageId, media, replyMarkup))

View File

@@ -10,7 +10,7 @@ public suspend fun TelegramBot.editUserStarSubscription(
userId: UserId,
telegramPaymentChargeId: TelegramPaymentChargeId,
isCanceled: Boolean
): Boolean = execute(
): Unit = execute(
EditUserStarSubscription(
userId = userId,
telegramPaymentChargeId = telegramPaymentChargeId,
@@ -22,7 +22,7 @@ public suspend fun TelegramBot.editUserStarSubscription(
user: User,
telegramPaymentChargeId: TelegramPaymentChargeId,
isCanceled: Boolean
): Boolean = editUserStarSubscription(
): Unit = editUserStarSubscription(
userId = user.id,
telegramPaymentChargeId = telegramPaymentChargeId,
isCanceled = isCanceled
@@ -31,7 +31,7 @@ public suspend fun TelegramBot.editUserStarSubscription(
public suspend fun TelegramBot.cancelUserStarSubscription(
userId: UserId,
telegramPaymentChargeId: TelegramPaymentChargeId,
): Boolean = editUserStarSubscription(
): Unit = editUserStarSubscription(
userId = userId,
telegramPaymentChargeId = telegramPaymentChargeId,
isCanceled = true
@@ -40,7 +40,7 @@ public suspend fun TelegramBot.cancelUserStarSubscription(
public suspend fun TelegramBot.cancelUserStarSubscription(
user: User,
telegramPaymentChargeId: TelegramPaymentChargeId,
): Boolean = editUserStarSubscription(
): Unit = editUserStarSubscription(
user = user,
telegramPaymentChargeId = telegramPaymentChargeId,
isCanceled = true
@@ -49,7 +49,7 @@ public suspend fun TelegramBot.cancelUserStarSubscription(
public suspend fun TelegramBot.enableUserStarSubscription(
userId: UserId,
telegramPaymentChargeId: TelegramPaymentChargeId,
): Boolean = editUserStarSubscription(
): Unit = editUserStarSubscription(
userId = userId,
telegramPaymentChargeId = telegramPaymentChargeId,
isCanceled = false
@@ -58,7 +58,7 @@ public suspend fun TelegramBot.enableUserStarSubscription(
public suspend fun TelegramBot.enableUserStarSubscription(
user: User,
telegramPaymentChargeId: TelegramPaymentChargeId,
): Boolean = editUserStarSubscription(
): Unit = editUserStarSubscription(
user = user,
telegramPaymentChargeId = telegramPaymentChargeId,
isCanceled = false

View File

@@ -12,4 +12,4 @@ import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
public suspend fun TelegramBot.editMessageReplyMarkup(
inlineMessageId: InlineMessageId,
replyMarkup: InlineKeyboardMarkup? = null
): Boolean = execute(EditInlineMessageReplyMarkup(inlineMessageId, replyMarkup))
): Unit = execute(EditInlineMessageReplyMarkup(inlineMessageId, replyMarkup))

View File

@@ -22,7 +22,7 @@ public suspend fun TelegramBot.editMessageText(
showCaptionAboveMedia: Boolean = false,
linkPreviewOptions: LinkPreviewOptions? = null,
replyMarkup: InlineKeyboardMarkup? = null
): Boolean = execute(EditInlineMessageText(inlineMessageId, text, parseMode, showCaptionAboveMedia, linkPreviewOptions, replyMarkup))
): Unit = execute(EditInlineMessageText(inlineMessageId, text, parseMode, showCaptionAboveMedia, linkPreviewOptions, replyMarkup))
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
@@ -34,7 +34,7 @@ public suspend fun TelegramBot.editMessageText(
showCaptionAboveMedia: Boolean = false,
linkPreviewOptions: LinkPreviewOptions? = null,
replyMarkup: InlineKeyboardMarkup? = null
): Boolean = execute(EditInlineMessageText(inlineMessageId, entities, showCaptionAboveMedia, linkPreviewOptions, replyMarkup))
): Unit = execute(EditInlineMessageText(inlineMessageId, entities, showCaptionAboveMedia, linkPreviewOptions, replyMarkup))
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
@@ -47,7 +47,7 @@ public suspend fun TelegramBot.editMessageText(
linkPreviewOptions: LinkPreviewOptions? = null,
replyMarkup: InlineKeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
): Boolean = editMessageText(inlineMessageId, buildEntities(separator, builderBody), showCaptionAboveMedia, linkPreviewOptions, replyMarkup)
): Unit = editMessageText(inlineMessageId, buildEntities(separator, builderBody), showCaptionAboveMedia, linkPreviewOptions, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
@@ -60,4 +60,4 @@ public suspend fun TelegramBot.editMessageText(
linkPreviewOptions: LinkPreviewOptions? = null,
replyMarkup: InlineKeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
): Boolean = editMessageText(inlineMessageId, buildEntities(separator, builderBody), showCaptionAboveMedia, linkPreviewOptions, replyMarkup)
): Unit = editMessageText(inlineMessageId, buildEntities(separator, builderBody), showCaptionAboveMedia, linkPreviewOptions, replyMarkup)

View File

@@ -15,7 +15,7 @@ public suspend fun TelegramBot.setGameScore(
messageId: MessageId,
force: Boolean = false,
disableEditMessage: Boolean = false
): Boolean = execute(
): Unit = execute(
SetGameScoreByChatId(userId, score, chatId, messageId, force, disableEditMessage)
)
@@ -26,7 +26,7 @@ public suspend fun TelegramBot.setGameScore(
messageId: MessageId,
force: Boolean = false,
disableEditMessage: Boolean = false
): Boolean = setGameScore(
): Unit = setGameScore(
user.id, score, chatId, messageId, force, disableEditMessage
)
@@ -37,7 +37,7 @@ public suspend fun TelegramBot.setGameScore(
messageId: MessageId,
force: Boolean = false,
disableEditMessage: Boolean = false
): Boolean = setGameScore(
): Unit = setGameScore(
userId, score, chat.id, messageId, force, disableEditMessage
)
@@ -48,7 +48,7 @@ public suspend fun TelegramBot.setGameScore(
messageId: MessageId,
force: Boolean = false,
disableEditMessage: Boolean = false
): Boolean = setGameScore(
): Unit = setGameScore(
user.id, score, chat.id, messageId, force, disableEditMessage
)
@@ -58,7 +58,7 @@ public suspend fun TelegramBot.setGameScore(
message: ContentMessage<GameContent>,
force: Boolean = false,
disableEditMessage: Boolean = false
): Boolean = setGameScore(
): Unit = setGameScore(
userId, score, message.chat.id, message.messageId, force, disableEditMessage
)
@@ -68,6 +68,6 @@ public suspend fun TelegramBot.setGameScore(
message: ContentMessage<GameContent>,
force: Boolean = false,
disableEditMessage: Boolean = false
): Boolean = setGameScore(
): Unit = setGameScore(
user.id, score, message.chat.id, message.messageId, force, disableEditMessage
)

View File

@@ -11,7 +11,7 @@ public suspend fun TelegramBot.setGameScore(
inlineMessageId: InlineMessageId,
force: Boolean = false,
disableEditMessage: Boolean = false
): Boolean = execute(
): Unit = execute(
SetGameScoreByInlineMessageId(
userId, score, inlineMessageId, force, disableEditMessage
)
@@ -23,4 +23,4 @@ public suspend fun TelegramBot.setGameScore(
inlineMessageId: InlineMessageId,
force: Boolean = false,
disableEditMessage: Boolean = false
): Boolean = setGameScore(user.id, score, inlineMessageId, force, disableEditMessage)
): Unit = setGameScore(user.id, score, inlineMessageId, force, disableEditMessage)

View File

@@ -0,0 +1,23 @@
package dev.inmo.tgbotapi.extensions.api.get
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.get.GetUserProfileAudios
import dev.inmo.tgbotapi.types.chat.CommonUser
import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.UserProfileAudios
public suspend fun TelegramBot.getUserProfileAudios(
userId: UserId,
offset: Int? = null,
limit: Int? = null
): UserProfileAudios = execute(
GetUserProfileAudios(
userId = userId, offset = offset, limit = limit
)
)
public suspend fun TelegramBot.getUserProfileAudios(
user: CommonUser,
offset: Int? = null,
limit: Int? = null
): UserProfileAudios = getUserProfileAudios(userId = user.id, offset = offset, limit = limit)

View File

@@ -0,0 +1,83 @@
package dev.inmo.tgbotapi.extensions.api.gifts
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.gifts.GetChatGifts
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.OwnedGifts
import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceivedEvent
import dev.inmo.tgbotapi.types.gifts.OwnedGift
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
public suspend fun TelegramBot.getChatGifts(
chatId: ChatIdentifier,
excludeUnsaved: Boolean = false,
excludeSaved: Boolean = false,
excludeUnlimited: Boolean = false,
excludeLimitedUpgradable: Boolean = false,
excludeLimitedNonUpgradable: Boolean = false,
excludeFromBlockchain: Boolean = false,
excludeUnique: Boolean = false,
sortByPrice: Boolean = false,
offset: String? = null,
limit: Int? = null
): OwnedGifts<OwnedGift.Common> = execute(
GetChatGifts(
chatId,
excludeUnsaved,
excludeSaved,
excludeUnlimited,
excludeLimitedUpgradable,
excludeLimitedNonUpgradable,
excludeFromBlockchain,
excludeUnique,
sortByPrice,
offset,
limit
)
)
public fun TelegramBot.getChatGiftsFlow(
chatId: ChatIdentifier,
excludeUnsaved: Boolean = false,
excludeSaved: Boolean = false,
excludeUnlimited: Boolean = false,
excludeLimitedUpgradable: Boolean = false,
excludeLimitedNonUpgradable: Boolean = false,
excludeFromBlockchain: Boolean = false,
excludeUnique: Boolean = false,
sortByPrice: Boolean = false,
initialOffset: String? = null,
limit: Int? = null,
onErrorContinueChecker: suspend (Throwable?) -> Boolean = { false }
): Flow<OwnedGifts<OwnedGift.Common>> = flow {
var currentOffset = initialOffset
do {
val response = runCatching {
getChatGifts(
chatId,
excludeUnsaved,
excludeSaved,
excludeUnlimited,
excludeLimitedUpgradable,
excludeLimitedNonUpgradable,
excludeFromBlockchain,
excludeUnique,
sortByPrice,
currentOffset,
limit
)
}
if (response.isSuccess) {
val result = response.getOrThrow()
emit(result)
currentOffset = result.nextOffset
} else {
if (onErrorContinueChecker(response.exceptionOrNull())) {
continue
} else {
break
}
}
} while (currentOffset != null)
}

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