mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-16 20:10:18 +00:00
Compare commits
1426 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cf3d07a20d | |||
| e40548e558 | |||
| 4cd8e823c6 | |||
| 9c7faec124 | |||
| 2856880a6e | |||
|
|
5445fdbfa5 | ||
| ba53d0c75d | |||
| 78f6cc5a97 | |||
| 6ab7c6f9d9 | |||
| cb6b33727e | |||
| bc4a2235c5 | |||
| 300f94fd48 | |||
| 40617ad9c8 | |||
| bea056bba3 | |||
| 9a33451f88 | |||
| c4659b558f | |||
| 5a30a07554 | |||
| b064becb8a | |||
| 463d5252bd | |||
| 8b5da90e28 | |||
| febd6ce63c | |||
| 8df8b87d54 | |||
| c882717bcc | |||
| 4aa5924615 | |||
| 2b8e728559 | |||
| 90ad34f114 | |||
| dbe2607994 | |||
| 692b668f92 | |||
| f2322e3e57 | |||
| ae002ead43 | |||
| 4197e13c54 | |||
| e09ea9a9b4 | |||
| 2a32654d57 | |||
| 0fff553ce1 | |||
| 33a1701f5b | |||
| f9a9f958ba | |||
| f686be0271 | |||
| 91307f3ebf | |||
| 8e64205f53 | |||
| 5434df1f02 | |||
| e56199ac9f | |||
| 3e199c6944 | |||
| b43d9aefb9 | |||
| fe133bbde0 | |||
| 332fe95adf | |||
| 1f416d4a28 | |||
| e626d8b5cc | |||
| b906d605f4 | |||
| d3584e793c | |||
| f71ac51461 | |||
| 5fe8cf948a | |||
| 85ea101641 | |||
| dc3ecec5c7 | |||
| ebd5e1a37b | |||
| 3da2e4fffb | |||
| 9aea59b44b | |||
| 7bab96a9cd | |||
| a0c10d9a9a | |||
| e2901cb9f9 | |||
| 3c60d074ba | |||
| f10cfdc5f1 | |||
| 270f9a60c1 | |||
| 2b49a75a42 | |||
| 9f7a348000 | |||
| 8cec74aa6a | |||
| d1914c8045 | |||
| baeb4848cf | |||
| dbadcb3f5a | |||
| 13dd73dd63 | |||
| ceba86abcb | |||
| f6a0b1a19d | |||
| 4ed6e5c7b2 | |||
| 7f43dc0815 | |||
| c72993017f | |||
| e8991f8f89 | |||
| 03cd4276a9 | |||
| 4427d76cd1 | |||
| 00f504a095 | |||
| d167f10724 | |||
| a1ccbbdd51 | |||
| 925c4dae6c | |||
| 1ec4507891 | |||
| 236e47478f | |||
| f2f15d7173 | |||
| 1b8ee5c4d7 | |||
| 304b281d80 | |||
| 733ad34289 | |||
| 39335b1dab | |||
| 46fdbc02e8 | |||
| fbe8c9419d | |||
| aba5810319 | |||
| 7d7658c64f | |||
| c4fdc350ce | |||
| f700fab33f | |||
| f078041dec | |||
| dd6b688ae4 | |||
| 0d37147a36 | |||
| ee0c017a79 | |||
| b5d5eeb62d | |||
| d715bc0a9e | |||
| 113621f619 | |||
| 6a899f1217 | |||
| 6bc96162a8 | |||
| 4736610aa8 | |||
| f6f07a5e8a | |||
| b32ce88a97 | |||
| 47f514a635 | |||
| a80ed2ec57 | |||
| b1bba43f29 | |||
| 9df258805d | |||
| 8654437293 | |||
| bdbca92fe5 | |||
| aca4d90608 | |||
| ad75aef64f | |||
| 5bf30bc6c6 | |||
| acd3298d4d | |||
| 3f6f04d00f | |||
| c7f372c1e3 | |||
| 1ed620df85 | |||
| 541e00fa03 | |||
| 867a46d397 | |||
| 8f4eb74e39 | |||
| 16cc49e412 | |||
| f58614e5be | |||
|
|
c3a09b53fc | ||
| c8413e1d18 | |||
| 8b15296ee7 | |||
| 0fcc717269 | |||
| 2ce26b4f1e | |||
| b5d499b623 | |||
| 102515dc8a | |||
| 777a58ce9a | |||
| 7471da4ff0 | |||
| e753db0e71 | |||
| 70984424e3 | |||
| c8354a330e | |||
| 037ad8b87c | |||
|
|
89550107d6 | ||
|
|
86cc7cfb3d | ||
|
|
858586e608 | ||
| d9846f27c9 | |||
| c10da2a10a | |||
| 8ed216619d | |||
| 62a9c687d5 | |||
| c2918c308f | |||
|
|
81fbff0bf5 | ||
| 54fb58de81 | |||
| 94ed4fed10 | |||
| 63ceec70ca | |||
| 636382fc8f | |||
| ac7bf60182 | |||
| bd91d4a0c0 | |||
|
|
7488eb9d4b | ||
| 6fcd248aff | |||
| 5fa1804003 | |||
|
|
0c9919e9e7 | ||
|
|
9405aa4467 | ||
| 4f75bc792d | |||
| fda53cf171 | |||
| b588622c3d | |||
| 8b64a0c94e | |||
| 959f0dffba | |||
| 8fc9185884 | |||
| 3a9cf03958 | |||
| 7cd97ac779 | |||
| c460b4eacc | |||
| 0aa58bd9f6 | |||
| a4a82f69c6 | |||
| d450ed9126 | |||
| 69c5f1ae7d | |||
| e4e8eadfb5 | |||
| c1374c118d | |||
| 6004b159ec | |||
| 67f95682d5 | |||
| 5aa5460a43 | |||
| e937845fc7 | |||
| 96f40e55bc | |||
| d3d8603c35 | |||
| 759650892c | |||
| b58550a9ec | |||
| e15817e7c5 | |||
| 4cd1316e27 | |||
| 3575a62f34 | |||
| 82f7d5bd4f | |||
| 7a5e6a69a1 | |||
| fd25db5633 | |||
| f539a24740 | |||
| 1d7b4ea862 | |||
| 2d6f296c20 | |||
| 0ba1aa1127 | |||
| ae8a461e9d | |||
| 99f16e33a6 | |||
| e029b29f7f | |||
| c04f795fdd | |||
| b873898100 | |||
| 61ac9df5e3 | |||
| b1931900e7 | |||
| fab3af48d6 | |||
| 8d7563b6e4 | |||
| 05112afe0c | |||
| 9ea06de27c | |||
| fff05a40d9 | |||
| 5c6428f220 | |||
| 766b7ca205 | |||
| 41e6c52369 | |||
| 06013f624f | |||
| d8bba89f3f | |||
| 141281f96d | |||
| be7aaa7845 | |||
| 78c224ffa8 | |||
| a08d07f7b3 | |||
| 69dde19543 | |||
| e8a3b93831 | |||
| e10caa3171 | |||
| d4fe4e09fc | |||
| ad453afba2 | |||
| a0daca28b1 | |||
| cd62a9ef3c | |||
| 3c084d70e5 | |||
| 2611d4ecc1 | |||
| b4d853dfa0 | |||
| 5044075adf | |||
| 5f2660b804 | |||
| c72dccc0f9 | |||
| 3fc1058491 | |||
| c3668e978b | |||
| 5a4a6d5710 | |||
| ed1d8beb2e | |||
| 881ede7d2a | |||
| 60d3d279e7 | |||
| 4b84518dbb | |||
| 8b451791dd | |||
| 771fb5c288 | |||
| d19ee74f8b | |||
| aaf489c2ed | |||
| 1b06b63703 | |||
| bf7fc25285 | |||
| 4df242747f | |||
| e831ca143e | |||
| 44838a2088 | |||
| 3823b03453 | |||
| ec48708195 | |||
| 6a06775bc4 | |||
| bbdff0b31a | |||
| cb4880bd00 | |||
| a18eda3db6 | |||
| d8f6429385 | |||
| be74249b67 | |||
| 69f658e4a8 | |||
| 8c51ca9d72 | |||
| 48c4a3156b | |||
| 92407c9010 | |||
| 86937cc096 | |||
| ea614b790b | |||
| c994332cb9 | |||
| 9d893ffa48 | |||
| 57d2fe85c5 | |||
| c68b148d5e | |||
| 0a0a7cea0e | |||
| ea981605f6 | |||
| fe1e65a83c | |||
| c85983bd59 | |||
| d72e1029d3 | |||
| 4b89563cff | |||
| 542079f4bf | |||
|
|
5c7164e864 | ||
| 6329905f62 | |||
| c54945e4cc | |||
| 8f20e1d617 | |||
|
|
edbfedb74e | ||
|
|
b5006cd1e0 | ||
| ca01ce7843 | |||
| 54fad3f338 | |||
| 15ef481fd7 | |||
| 91e1202674 | |||
| bdd39963a8 | |||
| 01dfedf540 | |||
| 8ded892b72 | |||
| d0b606469b | |||
| 678f79da04 | |||
| fde2c79f4c | |||
| acaf46e015 | |||
| 3f9237b5de | |||
| 3d7334dd62 | |||
| 26306f1567 | |||
| 247553d990 | |||
| 049a8a3263 | |||
| cc67a31e97 | |||
| 8791573145 | |||
| 5752f7a4fb | |||
| ade236eaa3 | |||
| e7340a483a | |||
| c7dc69d09f | |||
| c2487c5adc | |||
| 7c4808f163 | |||
| b91b516659 | |||
| 57cdc4ff2a | |||
| 864992aff0 | |||
| e18e8ba6df | |||
| 02cedc6626 | |||
| 619b890956 | |||
| 100a76a832 | |||
| c583ae6761 | |||
| 7429ffb514 | |||
| 95aeedfb94 | |||
| 095e318a78 | |||
| 4aa2d2ae41 | |||
| e936d25c13 | |||
| 97a2a5d9fd | |||
| 00ab532eac | |||
| c2cc6ee1ec | |||
| d20b94e52c | |||
| 9f3cc6eafb | |||
| f86a095421 | |||
| b0c6b80d8b | |||
| 1df653f428 | |||
| 8dfaca7648 | |||
| 04db76831f | |||
| f2e9bf6bd8 | |||
| cde8fdeffd | |||
| e74f339ae2 | |||
| ff7702486f | |||
| c7818fe4df | |||
| 8243acd69e | |||
| 8081602a39 | |||
| 6fd85dbc56 | |||
| 8d6f4ba136 | |||
| b95b339ad1 | |||
| 637979100b | |||
| 4067439a13 | |||
| 03583ff6c1 | |||
| c1330f8e32 | |||
| db36c6aacb | |||
| 757e317e70 | |||
| cb708a1ba4 | |||
| 551276f78e | |||
| 88339a4977 | |||
| a13371e14c | |||
| ad7fdc6211 | |||
| c870a48a22 | |||
| 3149fd0231 | |||
| 7430490499 | |||
| 416187e079 | |||
| e7aec75aca | |||
| 95a466a08b | |||
| 507cb2af26 | |||
| 126a07cdc7 | |||
| 27a24a18a6 | |||
| 562e8c7429 | |||
| be027efc43 | |||
| e55195b308 | |||
| 14afb59b5f | |||
| 6b23347d56 | |||
| f54843fb60 | |||
| 8a3538d9c7 | |||
| e3db4250bb | |||
| 4643ac906a | |||
| 497974e45c | |||
| 78a00f0efb | |||
| 14ecb9d948 | |||
| c759b9a466 | |||
| 58c1f2ee6a | |||
| 9d16ca3b7e | |||
| 9d40e598f1 | |||
| f1be8bf16e | |||
| 56a8804e99 | |||
| 1e73aac750 | |||
| 82c6eda0b7 | |||
| e9ff93cde1 | |||
| 9b179ea1c9 | |||
| 72d20d2344 | |||
| bcd288fe05 | |||
| 75477060e9 | |||
| 60df609486 | |||
| 556b492b35 | |||
| 53e8c53fb1 | |||
| 69d36c5c1b | |||
| ad97008f12 | |||
| 3e58114eeb | |||
| d55d8fa000 | |||
| bd32dbb3ab | |||
| 8e0389f032 | |||
| cb37b85234 | |||
| df01976ea8 | |||
| 7be74e468b | |||
| 437176203a | |||
| 7b25862035 | |||
| 45585caab0 | |||
| 6fea2a12d8 | |||
| ae639d38e0 | |||
| 0510f72859 | |||
| 233c789054 | |||
| 52f405c3b1 | |||
| 199856acce | |||
| f36d642ec8 | |||
| aa6e5b2284 | |||
| 32b83ac687 | |||
| a2206b99a2 | |||
| 90e0b1ac81 | |||
| 1b5b3af45b | |||
| 7ff6412ec5 | |||
| bd23d3fbdb | |||
| 08147fc33b | |||
| ba4c153659 | |||
| 3c3607d817 | |||
| d0add888c4 | |||
| 3e3adab46b | |||
| 89d13de307 | |||
| 32451f4e1c | |||
| 721c3f2430 | |||
| fc92df8fbe | |||
| ad50f41d1e | |||
| 8c9cd9df67 | |||
| 8e7f7a03c8 | |||
| 484e09374d | |||
|
|
619c82bb32 | ||
| 33fb75a5eb | |||
| 901c1e8956 | |||
| 2ae105cb15 | |||
|
|
db14eee3b6 | ||
| 6f8b881668 | |||
| d113d4f0f5 | |||
| dd893b14d3 | |||
| 19ddff2999 | |||
| 7f08fd9d66 | |||
| d3cb44490b | |||
| 4d3cad16a4 | |||
| a52f31f4c9 | |||
| 682f696866 | |||
| 87fff2e5d0 | |||
| 92b4ba2ff0 | |||
| 9014cdbc99 | |||
| d0709a509f | |||
| 0273d07777 | |||
| bafb0c2459 | |||
| 9be2b899cb | |||
| 37317a1055 | |||
| 60c21002e1 | |||
| 78a7a3546a | |||
| 4799617ced | |||
| c70484076d | |||
| 9f451f25f7 | |||
| 506c2b4a09 | |||
| 0c92e6eeb4 | |||
| efd1c8f83a | |||
| 7e57a0e4e0 | |||
| 6b977e67d0 | |||
| ab5937449c | |||
| 61d3131bf2 | |||
| 048f244449 | |||
| 6ebf4ff652 | |||
| b4c41d7dd8 | |||
| 6cbe313e42 | |||
| 930507ab80 | |||
| 56d3628dd3 | |||
| 56d7853f68 | |||
| 0a27d9bf28 | |||
| c74df3960c | |||
| f4b080cb45 | |||
| 350b77f6ff | |||
| 955e14f67c | |||
| ae88b7d94d | |||
| 88c62bd51c | |||
| 705bcbe352 | |||
| ffcc149c40 | |||
| 402d91f9f2 | |||
| c19bccc7d1 | |||
| 2c71377058 | |||
| 12d2c05110 | |||
| ddf46c1afd | |||
| dd0a8b99c7 | |||
| 75fb72936f | |||
| 1a6a010446 | |||
| 900ef28404 | |||
| a930423955 | |||
| 323c4de858 | |||
| cdd5649c04 | |||
| 2275a61d73 | |||
| bf8f4c75f8 | |||
| b5334c2b72 | |||
| 8331d4edd7 | |||
| 0e6a708eea | |||
| fbc5e9f8c4 | |||
| 040a996df6 | |||
| cf27600fb5 | |||
| 1d42f86623 | |||
| a9cb07fa0d | |||
| dd7567f43c | |||
| d0006bb089 | |||
| 7d8b990ec4 | |||
| 4d20e2cd1c | |||
| 4ffe6f915f | |||
| 22a7697447 | |||
| ef9941134e | |||
| ba85b8657d | |||
| 2dcbc0df32 | |||
| 7bac4a3a32 | |||
| 63bcc4bcf8 | |||
| 643f8e577e | |||
| 721b82f912 | |||
| 892aef738d | |||
| 4c7bfe99c0 | |||
|
|
1e4b8d405e | ||
| 007112e67a | |||
| a87c21273d | |||
| ff2d1615da | |||
| 08ef146daa | |||
| a404a6c59c | |||
| 1089c716f3 | |||
| 81ad55b19f | |||
| 863c872f35 | |||
| ece6a917ed | |||
| 12248aa702 | |||
| 83ea4f6435 | |||
| 52204d8df1 | |||
| 81b9ccdf6a | |||
| fa74f12505 | |||
| be284c4d96 | |||
| 1769fcacfd | |||
| 4207d89c92 | |||
| 87ee2f280b | |||
| 3d458b2dc6 | |||
| ee1c7c6533 | |||
| 97d122c770 | |||
| 49da0faf45 | |||
| d426cb1210 | |||
| af83ac79e7 | |||
| 602f15c206 | |||
| c2f40534e6 | |||
| 5693d4d808 | |||
| 9fe55aa6ef | |||
| 8f817f1492 | |||
| 0fd146655d | |||
| 94e5f74a90 | |||
| b9bffbb71b | |||
| 5ec5c3bdfd | |||
| a5ed2a82bb | |||
| 1b7dd11e75 | |||
| 8d0307fb7f | |||
| c500f0a281 | |||
| b3abeaa5ae | |||
| 8930a66134 | |||
| 76a2a2ca74 | |||
| 7dff8af460 | |||
| 5261ab1cf0 | |||
| f45c653fca | |||
| 5e03098ca8 | |||
| 2a3d8e6e73 | |||
| 8c3dac7932 | |||
| 83fb7f7bcb | |||
| 459414e7dd | |||
| 508d51f5a9 | |||
| 36f22579b2 | |||
| d3d5f7f2e6 | |||
| 1369680419 | |||
| f6e819be62 | |||
| 553da0a3ee | |||
| bace2724da | |||
| be710612b5 | |||
| ea19c10f41 | |||
| 1b88881c62 | |||
| be62c4fe37 | |||
| d3499cdde1 | |||
| 01d04f9d2b | |||
| d290992e40 | |||
| 867bdb8bd7 | |||
| 5f0a67187f | |||
| d9638849e2 | |||
| 5568720b5b | |||
| c0c591fe08 | |||
| 3c1f8421c9 | |||
| 35b20d102c | |||
| 70e6dc8fc9 | |||
| 4f0de376ab | |||
| 10c52c695c | |||
| 2d2c745527 | |||
| 1238843bde | |||
| 1ebaa1c387 | |||
| b2bc47ec04 | |||
| 514620b2bd | |||
| 054f06e18b | |||
| 00d467d091 | |||
| 6426ed6571 | |||
| fba6707f44 | |||
| 0c2fe6bce7 | |||
| eee9fe439f | |||
| 3547c09383 | |||
| 956f02d26d | |||
| 468fc0a49b | |||
| 441f3cee3d | |||
| 1ea79b9f7f | |||
| 094f88867d | |||
| 85a8a8eedc | |||
| 28fce0b4c1 | |||
| 2f5fdcdca0 | |||
| 21799d7e4a | |||
| ca409db0ee | |||
| 33c8ee0803 | |||
| 0c0ec22348 | |||
| 24bffbbd97 | |||
| a615d1c4fd | |||
| a76b7977b3 | |||
| 6004879aef | |||
| 98ff2558e9 | |||
| 61c00b38b1 | |||
| 2096671147 | |||
| 094d58f59f | |||
| 578a66b758 | |||
| b5bb40576b | |||
| 953638ddf5 | |||
| 1c9ca7a493 | |||
| c220412b02 | |||
| 41852dde7c | |||
| 3150cd6a37 | |||
| 07de18efd8 | |||
| 9552550198 | |||
| e1c94f772d | |||
| fbed81a1b3 | |||
| b61912d99a | |||
| 5efe74171d | |||
| 393981560c | |||
| 73b355df55 | |||
| 86885e7698 | |||
| 4d9be1a995 | |||
| 596176ee93 | |||
| 2348434048 | |||
| 5c6a430f38 | |||
| 148791ad68 | |||
| 5c5a19c91a | |||
| bd60c4f411 | |||
| e5a36225f8 | |||
| bd2c13c178 | |||
| 6f1f94299b | |||
| 72b8231eab | |||
| 323e5fb391 | |||
| dca5bb40e3 | |||
| c21975a150 | |||
| 8675833b99 | |||
| faf669c035 | |||
| 2f3a683fa0 | |||
| 2a617b5c4d | |||
|
|
aa1e7eea1d | ||
| 22eac5414c | |||
| 8206aefbb6 | |||
| fb8cfed382 | |||
| 2de22a08a3 | |||
| e8022a2ded | |||
| d6cef5984b | |||
| 49bea1bcef | |||
| 85a4459072 | |||
| ce74631580 | |||
| 1e5ce6bb5c | |||
| dc89e914a1 | |||
| ee815c7335 | |||
| 69f4033807 | |||
| 0581587adf | |||
| 23f93075a4 | |||
| 6c3425d5f9 | |||
| d285590348 | |||
| 2e0ad6dd3c | |||
| 96a5e55894 | |||
| 4e3b085cdb | |||
| 8baa601af7 | |||
|
|
facd732fa8 | ||
| e19561367e | |||
| 249efeee7e | |||
| b8cc2421b6 | |||
| 2fa1a064ec | |||
| 63e864741e | |||
| e4f35c0eba | |||
| 944fe6d820 | |||
| 8ea50f36aa | |||
| 17308a6d99 | |||
| 6eabea2529 | |||
| ffe9166fee | |||
| f1be3e2819 | |||
| c4c016c438 | |||
| a85e7d7387 | |||
| fc59ab0cdd | |||
| 9ed7ded967 | |||
| a76a7ae630 | |||
| 4715eb424f | |||
| c24d536d4c | |||
| c969d88bf0 | |||
| 44e9dc9253 | |||
| 10c62bf2c7 | |||
| 20b1645935 | |||
| c5bf9ab1a2 | |||
| cd6d108a9a | |||
| 5369a85faa | |||
| 45a895f32f | |||
| 8c1d7203d2 | |||
| 7394a6e94b | |||
| a962838012 | |||
|
|
a5cc80a1eb | ||
| 064b6222e6 | |||
|
|
8d97057d2c | ||
|
|
78f006e280 | ||
| db956a803c | |||
| aeb131b2f4 | |||
| 6d80c2bddc | |||
| 6e32d4e863 | |||
| 6b62070447 | |||
| ad8710db92 | |||
| f385101e22 | |||
| 15386a63f9 | |||
| 576b25190a | |||
| dd979d8626 | |||
| e60eb68b67 | |||
| 91212eaa3a | |||
| 65c1f018ac | |||
| 5b13d3dded | |||
|
|
2447d3e51f | ||
|
|
4203a0fdfe | ||
| ddd32a81c0 | |||
| db7a42fa9b | |||
| 5e2df1cb4a | |||
| 21c0e375f5 | |||
| 4ac01d0104 | |||
| 9c15410c4e | |||
| c5ff0dbc54 | |||
| 19d221fc29 | |||
| 179a724d20 | |||
| ad9bc36f8c | |||
| 5a192b00d4 | |||
| 2a33b22afb | |||
| db1e01688d | |||
| 22e71354dd | |||
| 2e560db865 | |||
| 016fc81b71 | |||
| b6e72c2399 | |||
| e1e2b93269 | |||
| 834e31906a | |||
| 5831cc6d37 | |||
| 0cce72de8d | |||
| 3919359f79 | |||
| e51a4b7702 | |||
| 702c1bc1ff | |||
| 6557e8af10 | |||
| edcebb03c0 | |||
| 9a3fc19992 | |||
| 7f9faa69c8 | |||
| 5b98c5f821 | |||
| 40bd8d0987 | |||
| 2aa6497374 | |||
| b9cb7b62fa | |||
| 04679beb52 | |||
| 64e9289afb | |||
| d4f24ee0cd | |||
| 3e5d939ea5 | |||
| 24f91e4aee | |||
| fe169fafaf | |||
| aeb6fad409 | |||
| 94ad758814 | |||
| 5f01e26377 | |||
| f82ac0ce9d | |||
| c8491765e9 | |||
| 53a3e11836 | |||
| fcccbe3252 | |||
| 584bf06109 | |||
| ef0083079e | |||
| 0d01e9bc78 | |||
| 89aef3d77b | |||
| 24c47b00d4 | |||
| a046a72392 | |||
| a5a530c9bd | |||
| 9cf82a3564 | |||
| 46cc37be62 | |||
| 1fbaf396aa | |||
| 76985501f5 | |||
| 8d8bcfba01 | |||
| e0f3957249 | |||
| 3f1b018808 | |||
| 7af5ab17b7 | |||
| 0fec35f0dc | |||
| ee81f49a75 | |||
| 807952201b | |||
| 5d6ba0f59e | |||
| 3a61b522ab | |||
| 83304023a6 | |||
| f62e13aaca | |||
| ae1fb25336 | |||
| 4e3ea6cd80 | |||
| 148203eabf | |||
| 4465b573ca | |||
| f0dda60630 | |||
| 47135a1b65 | |||
| d8f830c60f | |||
| 226b8dee21 | |||
| a109771d20 | |||
| c028434f30 | |||
| d5c6ce32bb | |||
| d92cac5e07 | |||
| 9b21b5290c | |||
| 13ca63d27d | |||
| ad917dda1b | |||
| 7b1344e9c8 | |||
| c4fbd2f1c6 | |||
| c90bcea42c | |||
| e75c93d626 | |||
| 58dcbe8751 | |||
| 17806cde25 | |||
| f147a3d620 | |||
| 9eb6008a73 | |||
| f7d2c8bbd2 | |||
| f42cf78969 | |||
| 9a14932511 | |||
| 149ecf175b | |||
| 2049fea82a | |||
| 40d94cca70 | |||
| c8ad68ea69 | |||
| c66d64adbc | |||
| b475976ff1 | |||
| ea8db5b851 | |||
| af2fabf1ca | |||
| abc0457a36 | |||
| 8dbdbdee13 | |||
| 0c31379ff5 | |||
| 3b3cf81aaa | |||
| 1642075a75 | |||
| 760c9f2916 | |||
| 219238cf19 | |||
| 762087fc09 | |||
| 142fae1ede | |||
| 95abc72bf3 | |||
| 1d37a7446c | |||
| 7d35114b5d | |||
| 75f4226772 | |||
| 96d980cb8a | |||
| ed077ae1bc | |||
| 9540797ffc | |||
| 217b01994e | |||
| 6b89c94ef1 | |||
| e25ce57f6a | |||
| 530394fd15 | |||
| 3e891d50fd | |||
| adf5fd6288 | |||
| e7a2dc51aa | |||
| 399793243b | |||
| 3801025ff1 | |||
| 0ad2d9afc4 | |||
| a303700b56 | |||
| 42bf896f7a | |||
| 0bce522101 | |||
| 3c75d6a2c7 | |||
| 93eebe37ce | |||
| f893803939 | |||
| 0b92edc05e | |||
| 190d83b22b | |||
| 7ec4fc460a | |||
| 75cebf5aa3 | |||
| a241c91adf | |||
| 4f920abb61 | |||
| 6ba9a31fb9 | |||
| 65801f5104 | |||
| 9e82211473 | |||
|
|
560179a574 | ||
|
|
cffcf2277e | ||
|
|
cb9a20a9d1 | ||
|
|
45ea103c9a | ||
|
|
c00adb0784 | ||
|
|
38826a5e7e | ||
| b2915857d7 | |||
| 067e36adc6 | |||
|
|
12a35da4b6 | ||
|
|
022e6f623a | ||
|
|
30c138029e | ||
| 732e2a3906 | |||
| c5e089a45d | |||
|
|
919b1590e3 | ||
| 0c1017901f | |||
| fd6e4b0522 | |||
| 21c5d42dc2 | |||
| 77dff639f0 | |||
| 47fe048b10 | |||
| ee8cc2aa46 | |||
| b9de002517 | |||
| 449f2727c4 | |||
| 8712914126 | |||
| 69b64e9908 | |||
| 656bb68739 | |||
| 7f69052dea | |||
| b60fab4871 | |||
| bf28a8b0a6 | |||
| 85270dd12d | |||
| e39dd2d086 | |||
| e10d47b7e4 | |||
| 1e181bc042 | |||
| 61cf9936fb | |||
| 65fd3ced36 | |||
| 66d37b72eb | |||
| 55b1d3734d | |||
| 45b32fd6f7 | |||
| fcd8f20a90 | |||
| 18e6b9e471 | |||
| f5b248f534 | |||
| 3ebcbe2860 | |||
| 3829e04b0c | |||
| 39fa36426f | |||
| a265e5ecbf | |||
| 86e78c4ba0 | |||
| a6451ca394 | |||
| 521a3a8c35 | |||
| 173839c677 | |||
| bb7d47a33b | |||
| 5c0e58caec | |||
| 72c3623d30 | |||
| fe1831fc19 | |||
| 7825ec3010 | |||
| 12184cd2be | |||
| e90e25ab01 | |||
| 004ff0b490 | |||
| 07faba7d38 | |||
| e5584cd8b4 | |||
| 6acc9ef2b0 | |||
| 169fc0401a | |||
| dcfcea65cb | |||
| eedb36ede7 | |||
| eaee334ff6 | |||
| 5c694e8625 | |||
| 0306c40fb2 | |||
| fd915553e3 | |||
| ec1c0ba8bb | |||
| 12a64ec1d1 | |||
| 59d7a7c781 | |||
| cabfd7c76b | |||
| f12f52899c | |||
|
|
ed067db20f | ||
| b055268979 | |||
| 2584839d66 | |||
| 63946e860d | |||
| 90df436c63 | |||
| d3c8b49b10 | |||
| c1372b55bc | |||
| b6c7ece995 | |||
| 44e7c80f43 | |||
| 1e41e95333 | |||
| 03d4d715c0 | |||
| ab060d02ea | |||
| f447be02dc | |||
| eb923a6338 | |||
| 0914710cc7 | |||
| 1f7450844f | |||
| 167c214e35 | |||
| 42a8d649cd | |||
| eb3f180cc6 | |||
| 70f96ac8fa | |||
| d69b2e09d5 | |||
| 946b0222df | |||
| 7da315dbaf | |||
| 87071ca52c | |||
| b2770e3ecc | |||
| df63ccfe07 | |||
| 694bec22a2 | |||
| 6a3588bb8d | |||
| a26568aa29 | |||
| cd30660256 | |||
| 1846d20b0d | |||
| f13207064e | |||
| 61be689aca | |||
| 03f8d65bb6 | |||
| 2dc8beba8a | |||
| 5451adf4ac | |||
| 9982534001 | |||
| c0451d4c8f | |||
| a9d65944e6 | |||
| 39598dcb69 | |||
| 3069a6084c | |||
| e7bbce3fa7 | |||
| 0b361163f2 | |||
| 6aba2ff641 | |||
| 6b761ab37d | |||
| b9c8a89af9 | |||
| a42c5c63c4 | |||
| fc1a029acb | |||
| f90ae2f918 | |||
| 019b260888 | |||
| 0831f2fa75 | |||
| 32ae9d2b16 | |||
| b975a1b036 | |||
| f4b1e4a150 | |||
| 97031512d4 | |||
| 353df43109 | |||
| 4e55460834 | |||
| e2e235bd6c | |||
| 8ced95bc2f | |||
| 685e4af8f5 | |||
| 0b2f7a3899 | |||
| 112c86c9da | |||
| 1ddd138ff7 | |||
| 1a5d1cde78 | |||
| 5b620014cb | |||
| 80093cb5a9 | |||
| 9f8e8ee21b | |||
| 3de3bb6133 | |||
| 308fb9274b | |||
| d14ca7bbdc | |||
| dbdd9b5ad2 | |||
| 6dd27cb0bf | |||
| 210a52485b | |||
| 5c11b60ea6 | |||
| 60c3a0d7af | |||
| 8d777e1c0e | |||
| 4e019eb8bb | |||
| bd80562c2a | |||
| 9fc07f2ff3 | |||
| a4bae5133a | |||
| 7bb272f2fa | |||
| 72cf38d3bb | |||
| 0adee13cba | |||
| f9e3e57f24 | |||
| d7d4adc8e4 | |||
| e9b074a36c | |||
| 65cba0f014 | |||
| 36202133a1 | |||
| 66f7801b32 | |||
| e7265829d1 | |||
| 9ad5bfbc57 | |||
| aba62ba930 | |||
| 40d702a311 | |||
| 233d893b5a | |||
| 0faca5838c | |||
| 838f62aa84 | |||
| bc21a680bc | |||
| 8bb60bea34 | |||
| 8daadcff95 | |||
| 2a1e624641 | |||
| 696822db02 | |||
| ded501d963 | |||
| 86e506c33d | |||
| 9902b00e85 | |||
| 53524abcbb | |||
| 7639b15dc6 | |||
| 61b720c61f | |||
| baf4c74b69 | |||
| 367cfff2cb | |||
| 75e8d0f62d | |||
| c521a5f9a4 | |||
| c5513365c2 | |||
| d184ce7a0f | |||
| a3bff3f24d | |||
| a835b1dcbb | |||
| ffed2b80a5 | |||
| ff24b9f35b | |||
| 1287852334 | |||
| fc2f177e38 | |||
| 1efd4dce6e | |||
| 69b5a16b17 | |||
| 77b531ad06 | |||
| a98d5d9abd | |||
| 104653ac41 | |||
| 63337b8285 | |||
| 5cc0bbb31b | |||
| 563d784603 | |||
| 0d9f18f346 | |||
| 23ceaf8e97 | |||
| fe2dffd8b5 | |||
| eeb46817c3 | |||
| 5ab00da31d | |||
| 841ae73f7c | |||
| 41b4d29917 | |||
| f8b3c44146 | |||
| f0eb670c3f | |||
| fe5d94f31e | |||
| 7901d0a223 | |||
| 799f9123ba | |||
| f77f010e66 | |||
| 67ddf8d809 | |||
| 81afa46253 | |||
| a5bba76f07 | |||
| d882cf9c97 | |||
| 2e27b8b64d | |||
| 4df800eaa9 | |||
| 8d27349868 | |||
| 2a89c41a58 | |||
| 098b5cc393 | |||
| 10f4817283 | |||
| 4449893608 | |||
| 3a53f41f66 | |||
| 7cd366d893 | |||
| 1309a4111c | |||
| 0ca815760b | |||
| eca0680f2f | |||
| d472d371ed | |||
| 4748b6813a | |||
| a2ea15d4b0 | |||
| 27dc302f5d | |||
| baf8ed3a77 | |||
| 18913af3c3 | |||
| 51871ea94c | |||
| 6a625d7b9f | |||
| 0b93b472a3 | |||
| ff16f9a315 | |||
| 86bfe043a5 | |||
| fa18e7299d | |||
| c986025075 | |||
| e8a7ea9ce4 | |||
| 30f35e5488 | |||
| b626974ea7 | |||
| 128b782a27 | |||
| dc83b8d77a | |||
| 2aac6c0bde | |||
| b637d0d2a6 | |||
| d12cba2343 | |||
| 450c7e6474 | |||
| a35fb40a66 | |||
| 8731aa2c26 | |||
| 32e305537d | |||
| ec0a10e36e | |||
| 131ec4d6d5 | |||
| ecc608f51a | |||
| 040654f131 | |||
| 9e73d0c461 | |||
| d67c80bc99 | |||
| b0eef4f82d | |||
| fbe91a6321 | |||
| 15066c9d63 | |||
| e0bf67d8f9 | |||
| 1dc3ce2fb5 | |||
| 0c71133969 | |||
| 1359dd549f | |||
| c425e2ecc3 | |||
| 4d63e3a17d | |||
| d34deade0d | |||
| 2f52ad45a4 | |||
| 1d99e632a4 | |||
| cdcfaf5a29 | |||
| f3590762f3 | |||
| e0ff14b7fe | |||
| 9983e111ec | |||
| 08b8710772 | |||
| fc71e028c4 | |||
| 30a4a7bd8b | |||
| b973278b0a | |||
| ae2f4579e2 | |||
| a4bf6911c7 | |||
| 73b3daa68b | |||
| 09748615ae | |||
| 2dc8521aed | |||
| 81de59f37c | |||
| fb61a94c5e | |||
| 26fd5e51bf | |||
| c1ab9da4c4 | |||
| 6b414d64b0 | |||
| 5a3edc2b44 | |||
| 6dcdc2ab7f | |||
| a2ae4f71de | |||
| 5d87b86afe | |||
| ef22735894 | |||
| c0ea479fe3 | |||
| 0846e816e9 | |||
| d837c9d605 | |||
| d1993842c3 | |||
| 4e8a9dcff0 | |||
| 10eb15e172 | |||
| 0320da7614 | |||
| 7aa3ff180e | |||
| a882a212c2 | |||
| 1b15748f65 | |||
| 044fe5eadf | |||
| 9453ec37e7 | |||
| 3d0cbc2d2b | |||
| 198b551ebf | |||
| 1452e32293 | |||
| 946b7abcae | |||
| 879943622a | |||
| c0b4b523cf | |||
| 49e6e9cfe3 | |||
| ffadb6355b | |||
| 9cc402b42d | |||
| b9341f89ac | |||
| ac07f44c81 | |||
| 2e53247726 | |||
| e2dddf96a1 | |||
| ce0fceb240 | |||
| 633239961a | |||
| 8b79b15777 | |||
| a28cf5ddff | |||
| 8c2cffc8e3 | |||
| b933361258 | |||
| 383e722d07 | |||
| 3125c2fc1b | |||
| 965b8c3c50 | |||
| 94745ef373 | |||
| aee5ab564b | |||
| c70f0b65dd | |||
| 30e6f68228 | |||
| 00873a255c | |||
| 6bd423dc11 | |||
| c5ada8cea0 | |||
| 0cb3df4d1a | |||
| b22118b400 | |||
| 2006e45b57 | |||
| c091098feb | |||
| 6cf8d47cbf | |||
| 3dc4e9dda4 | |||
| 6407ad1a93 | |||
| f974e5787f | |||
| 28a9bbd310 | |||
| 599d5a51e3 | |||
| 25f8d15a4b | |||
| 66c2cb2d30 | |||
| 74fb448378 | |||
| 3417ec060f | |||
| 4f54a00003 | |||
| 4fb187da30 | |||
| 7637b6f69a | |||
| 9df9af193c | |||
| ba4b4c4b64 | |||
| fa0861b8bc | |||
| 20494e1d4a | |||
| a404008dee | |||
| 881205dd80 | |||
| 2096c44811 | |||
| 1a3da33589 | |||
| be28c9bd5d | |||
| a193ef5fd5 | |||
| 7c43d3aaa5 | |||
| e034afc75c | |||
| 08e3326d1a | |||
| 6dd1825b98 | |||
| bd4eb29fc1 | |||
| 2cc66ef13c | |||
| 9a8175d1c8 | |||
| 25285b2e8a | |||
| bb09f05d7b | |||
| da5e46e59f | |||
| a3f315a73a | |||
| 43583a885a | |||
| ec02257ecd | |||
| 29ee4a9396 | |||
| 2717cb4fc6 | |||
| 1ce2526401 | |||
| 74c480b07e | |||
| 657e9aa770 | |||
| 0d19952ba7 | |||
| f8cccc3e17 | |||
| bc1b7c3f25 | |||
| ec74111a9d | |||
| 2dadeb7eb7 | |||
| 24bd65501b | |||
| 574ca803fa | |||
| 947e3bf34e | |||
| 488158d8fb | |||
| 41bf3c7f0b | |||
| c2032d21cd | |||
| 6650dd9cfe | |||
| af1d6d6f1a | |||
| a5861d659d | |||
| b36f80a6d3 | |||
| 7c4f034a6c | |||
| 3b08bc6dd2 | |||
| ed87c0ad95 | |||
| c8c0fc2ce8 | |||
| 1f40ce1a81 | |||
| b0219389fc | |||
| f6ec82b449 | |||
| 71dac70635 | |||
| 98f68a9e1e | |||
| e7199e7451 | |||
| 33b50c6c68 | |||
| e4ce6f8fc7 | |||
| 8764f18ca8 | |||
| b2fa7fee9d | |||
| 0121e3a104 | |||
| f6e5664632 | |||
| c5b7c4e1f5 | |||
| 53800d49bf | |||
| d83e3eb10a | |||
| 66b4d06064 | |||
| 4fab01b2a2 | |||
| b81086c4bb | |||
| d776071cac | |||
| 5f33d05deb | |||
| 912cc7217c | |||
| 96e00f6e31 | |||
| f8ea5f9515 | |||
| 9f11c4f1c4 | |||
| 9c91980d5d | |||
| 7376eb5b10 | |||
| 6654f27f9d | |||
| d29acce417 | |||
| f0f18209f3 | |||
| 324018a0f6 | |||
| b621325e92 | |||
| 43e92555c2 | |||
|
|
5f1ca51e60 | ||
| 83edda2dfe | |||
| 1974c20229 | |||
| 499d9b1791 | |||
| 6caa7dd428 | |||
| e8ded44562 | |||
| 1e6b0381ee | |||
| 1cf7ae7438 | |||
| 311512b5db | |||
| d73fa4076f | |||
| 3620350cc0 | |||
| 54cfea9adf | |||
| 6665b6ef03 | |||
| ee6f0f3d5d | |||
| 6ec0fcadd2 | |||
| c89aa7b9ba | |||
| cf47cee36a | |||
|
|
824fa9ba09 | ||
| 654d84b1b4 | |||
|
|
c7259e7699 | ||
| 00a75801a8 | |||
| e45f9cf46a | |||
| 3b1803e851 | |||
| bf1e353615 | |||
| 99bb8d6e0d | |||
| 98d7b9c651 | |||
| 765caefc32 | |||
| 6bdefb6f8f | |||
| d5e283e7ba | |||
| a5982ac881 | |||
| c0e81b1d6d | |||
| eb879963f8 | |||
| f835167f66 | |||
| ff34b23777 | |||
| ec806dfd83 | |||
|
|
0a73dfb799 | ||
| 53b8cc4625 | |||
| 201def826e | |||
| 609a959b99 | |||
| 6a05a7ecab | |||
| 159ea6f1cc | |||
| 0886781d61 | |||
| 60d5581ec6 | |||
| 2a33216006 | |||
| 179bb66183 | |||
| 7a2ecd2dbf | |||
| fd1a15cb5d | |||
| 86a472e814 | |||
| 6d6c544aaf | |||
| dd4d5cd15d | |||
| 23dfa4f69d | |||
| a10d766295 | |||
| ea6ab8f024 | |||
| f377d61bf0 | |||
| 18c9d4e468 | |||
| 20b931138c | |||
| d7bca15693 | |||
| 957649603b | |||
| bbc56fe94c | |||
| d048958423 | |||
| f0e9267664 | |||
| 5dd7207e09 | |||
| d96d47e32c | |||
| 1ee73dd406 | |||
| e9a05c4930 | |||
| 9e771fa04a | |||
| 06ba21fc1f | |||
| 7d72d72f2c | |||
| 80d4bdfe17 | |||
| b457d11067 | |||
| 46fe16fd73 | |||
| 8e1cafb1b6 | |||
| 68d971f874 | |||
| 37a23c7e79 | |||
| b053c29ea3 | |||
| 23a1fed7dd | |||
| 87d2537bda | |||
| 6d782f28c3 | |||
| d8dbbdf549 | |||
| f317e144e6 | |||
| 05c27804ce | |||
| eb97a8e151 | |||
|
|
06639e5f3c | ||
| 82b7bf676f | |||
| 4f9cb531c0 | |||
| 09bbb1945c | |||
| 7bedc4caf0 | |||
| 6a73aa1525 | |||
| e1ee541005 | |||
|
|
2d2fe01227 | ||
|
|
af53682b1f | ||
|
|
c8a5552c9e | ||
|
|
ffa78ebfe1 | ||
| e85e7d02f7 | |||
| 37ad279ab4 | |||
| 3b41dc1fbf | |||
| 5747383ed1 | |||
| 18a6efabb8 | |||
| dcb837b155 | |||
| 03755e9eef | |||
|
|
b9db2d544d | ||
| 800d14561e | |||
| 2378237fc5 | |||
| 35e28c00cb | |||
| 1913f1a900 | |||
| cbfd34098d | |||
| e5618f4705 | |||
| c9f2166e7d | |||
| eb960290c6 | |||
| 100f8b564a | |||
| 8e1ad9ffbc | |||
| 8875e2a986 | |||
| 7478b151eb | |||
| 959136479e | |||
| a52a62837e | |||
| 17dd694044 | |||
| 34fcfe2e20 | |||
| 64862ecd2d | |||
| c9edbbf7af | |||
| a2f9a5a432 | |||
| 8337da34ca | |||
| f45956b554 | |||
| bec1255d67 | |||
| 39ca29279f | |||
| 70b592baad | |||
| 403aa684a8 | |||
| 48c6f103b5 | |||
| e326d289cb | |||
| 7fd9c4c897 | |||
| 347a6212d4 | |||
| e10e257c80 | |||
| 5e7bc96b44 | |||
| 79d0eda61d | |||
| 9916b3f469 | |||
| 2bac5f0eed | |||
|
|
01eb072caa | ||
| 496af479b0 | |||
| 386e91e28b | |||
| 91dbcecefc | |||
| 2d743e4c19 |
4
.github/FUNDING.yml
vendored
4
.github/FUNDING.yml
vendored
@@ -1,5 +1,3 @@
|
|||||||
# These are supported funding model platforms
|
# These are supported funding model platforms
|
||||||
|
|
||||||
patreon: InsanusMokrassar
|
custom: ['https://www.tinkoff.ru/rm/ovsyannikov.aleksey113/ObMJ712472', 'https://boosty.to/insanusmokrassar']
|
||||||
|
|
||||||
custom: ['https://paypal.me/InsanusMokrassar?locale.x=ru_RU']
|
|
||||||
|
|||||||
11
.github/dependabot.yml
vendored
Normal file
11
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# To get started with Dependabot version updates, you'll need to specify which
|
||||||
|
# package ecosystems to update and where the package manifests are located.
|
||||||
|
# Please see the documentation for all configuration options:
|
||||||
|
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||||
|
|
||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "gradle" # See documentation for possible values
|
||||||
|
directory: "/tgbotapi.core" # Location of package manifests
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
||||||
8
.github/labeler.yml
vendored
8
.github/labeler.yml
vendored
@@ -1,6 +1,8 @@
|
|||||||
api: "TelegramBotAPI-extensions-api/**"
|
api: "TelegramBotAPI-api/**"
|
||||||
utils: "TelegramBotAPI-extensions-utils/**"
|
utils: "TelegramBotAPI-utils/**"
|
||||||
core: "TelegramBotAPI/**" # currently not work
|
behaviour-builder: "TelegramBotAPI-behaviour_builder/**"
|
||||||
|
behaviour-builder_fsm: "TelegramBotAPI-behaviour_builder-fsm/**"
|
||||||
|
core: "TelegramBotAPI-core/**" # currently not work
|
||||||
|
|
||||||
code: "**/*.kt"
|
code: "**/*.kt"
|
||||||
gradle: "**/*.gradle"
|
gradle: "**/*.gradle"
|
||||||
|
|||||||
2
.github/pull_request_template.md
vendored
Normal file
2
.github/pull_request_template.md
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
* Please, be sure that you have read [Contributing](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/CONTRIBUTING.md) file. Of course, this line must be removed during PR preparation :)
|
||||||
|
* Describe your changes, shortly. As example (or format) you can look at the body of any [Project releases](https://github.com/InsanusMokrassar/TelegramBotAPI/releases)
|
||||||
21
.github/workflows/kdocs.yml
vendored
Normal file
21
.github/workflows/kdocs.yml
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
name: Publish KDocs
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
jobs:
|
||||||
|
publishing:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: 11
|
||||||
|
- name: Build
|
||||||
|
run: ./gradlew dokkaHtml
|
||||||
|
- name: Publish KDocs
|
||||||
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
publish_dir: ./docs/build/dokka/html
|
||||||
|
publish_branch: kdocs
|
||||||
1
.github/workflows/label.yml
vendored
1
.github/workflows/label.yml
vendored
@@ -12,6 +12,7 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
triage:
|
triage:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
if: ${{ github.actor == github.repository_owner }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/labeler@v2
|
- uses: actions/labeler@v2
|
||||||
with:
|
with:
|
||||||
|
|||||||
29
.github/workflows/packages_publishing.yml
vendored
Normal file
29
.github/workflows/packages_publishing.yml
vendored
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
name: Publish package to GitHub Packages
|
||||||
|
on: [push]
|
||||||
|
jobs:
|
||||||
|
publishing:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: 11
|
||||||
|
- name: Rewrite version
|
||||||
|
run: |
|
||||||
|
branch="`echo "${{ github.ref }}" | grep -o "[^/]*$"`"
|
||||||
|
cat gradle.properties | sed -e "s/^library_version=\([0-9\.]*\)/library_version=\1-branch_$branch-build${{ github.run_number }}/" > gradle.properties.tmp
|
||||||
|
rm gradle.properties
|
||||||
|
mv gradle.properties.tmp gradle.properties
|
||||||
|
- name: Build
|
||||||
|
run: ./gradlew build
|
||||||
|
- name: Publish to Gitea
|
||||||
|
continue-on-error: true
|
||||||
|
run: ./gradlew publishAllPublicationsToGiteaRepository
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
- name: Publish to GithubPackages
|
||||||
|
continue-on-error: true
|
||||||
|
run: ./gradlew publishAllPublicationsToGithubPackagesRepository --no-parallel
|
||||||
|
env:
|
||||||
|
GITHUBPACKAGES_USER: ${{ github.actor }}
|
||||||
|
GITHUBPACKAGES_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
|
||||||
1
.github/write-good.yml
vendored
1
.github/write-good.yml
vendored
@@ -1 +0,0 @@
|
|||||||
spellchecker: true
|
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -10,4 +10,5 @@ build/
|
|||||||
out/
|
out/
|
||||||
|
|
||||||
local.properties
|
local.properties
|
||||||
|
kotlin-js-store/
|
||||||
secret.gradle
|
secret.gradle
|
||||||
|
|||||||
@@ -11,3 +11,5 @@ jobs:
|
|||||||
script: ./gradlew build -s -x jvmTest -x jsIrTest -x jsIrBrowserTest -x jsIrNodeTest -x jsLegacyTest -x jsLegacyBrowserTest -x jsLegacyNodeTest
|
script: ./gradlew build -s -x jvmTest -x jsIrTest -x jsIrBrowserTest -x jsIrNodeTest -x jsLegacyTest -x jsLegacyBrowserTest -x jsLegacyNodeTest
|
||||||
- state: test
|
- state: test
|
||||||
script: ./gradlew allTests
|
script: ./gradlew allTests
|
||||||
|
- state: dokka
|
||||||
|
script: ./gradlew dokkaHtml
|
||||||
|
|||||||
2774
CHANGELOG.md
2774
CHANGELOG.md
File diff suppressed because it is too large
Load Diff
10
CONTRIBUTING.md
Normal file
10
CONTRIBUTING.md
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# Contributing
|
||||||
|
|
||||||
|
In case you wish to contribute this project, there are several small things you must remember:
|
||||||
|
|
||||||
|
* Give maintainers opportunity to manage your Pull request. It is required for two reasons
|
||||||
|
* For more efficient Pull Requests handling (it is much easier for me to fix something small directly in your pull request than ask to fix some small things after each review)
|
||||||
|
* Usually, you will set as a target `master` branch, but I prefer to include code into separated version branch firstly. So, if you will give me opporunity to change Pull Request, I will be available to change base branch
|
||||||
|
* Currently in Pull Requests there are several bots. The most important is Travis bot and it must always successfuly build code from your Pull Request
|
||||||
|
|
||||||
|
This project was built on the idea of strongly-typed declaration of TelegramBotAPI. So, do not worry if maintaners will change your pull requests: you are already cool because you have contributed this project:)
|
||||||
211
README.md
211
README.md
@@ -1,137 +1,120 @@
|
|||||||
# TelegramBotAPI
|
# TelegramBotAPI [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#december-30-2022)
|
||||||
|
|
||||||
| Common info | [](https://github.com/KotlinBy/awesome-kotlin) [](https://travis-ci.com/InsanusMokrassar/TelegramBotAPI) [Small survey](https://forms.gle/tnjuExdSKEr32ygKA)|
|
| Docs | [](https://tgbotapi.inmo.dev/index.html) [](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) |
|
||||||
| -------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|:---:|:---:|
|
||||||
| Useful links | [](https://t.me/InMoTelegramBotAPI) [](https://tgbotapi.inmo.dev/docs/index.html) [Examples](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/), [Mini tutorial](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) |
|
| Useful repos | [](https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template/generate) [](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/) |
|
||||||
| TelegramBotAPI Core status | [](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI-core/_latestVersion) [](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI) |
|
| Misc | [](https://github.com/KotlinBy/awesome-kotlin) [](https://docs.google.com/forms/d/e/1FAIpQLSctdJHT_aEniyYT0-IUAEfo1hsIlezX2owlkEAYX4KPl2V2_A/viewform?usp=sf_link) |
|
||||||
| TelegramBotAPI Extensions status | [](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI-extensions-api/_latestVersion) [](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI-extensions-api) |
|
|
||||||
| TelegramBotAPI Util Extensions status | [](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI-extensions-utils/_latestVersion) [](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI-extensions-utils) |
|
|
||||||
| TelegramBotAPI All status | [](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI/_latestVersion) [](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI-all) |
|
|
||||||
|
|
||||||
**At the time of publication of version `0.28.0` there are errors in serialization plugins like
|
<!--- [](https://t.me/InMoTelegramBotAPI) --->
|
||||||
[kotlinx.serialization#1004](https://github.com/Kotlin/kotlinx.serialization/issues/1004). It is possible, that both JVM
|
|
||||||
and JS version may work improperly in some cases with `kotlinx.serialization` version `1.0.0-RC`**
|
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://t.me/InMoTelegramBotAPI">
|
||||||
|
<img src="./resources/tg_channel_qr.jpg">
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
It is a complex of libraries for working with `TelegramBotAPI` in type-safe and strict way as much as it possible. In
|
Hello! This is a set of libraries for working with Telegram Bot API.
|
||||||
the list of this complex currently next projects:
|
|
||||||
|
|
||||||
* [TelegramBotAPI-core](TelegramBotAPI-core/README.md) - core of library. In fact it is independent library and can be used alone
|
## Examples
|
||||||
without any additional library
|
|
||||||
* [TelegramBotAPI Extensions](TelegramBotAPI-extensions-api/README.md) - contains extensions (mostly for
|
|
||||||
`RequestsExecutor`), which allows to use the core library in more pleasant way
|
|
||||||
* [TelegramBotAPI Util Extensions](TelegramBotAPI-extensions-utils/README.md) - contains extensions for more comfortable
|
|
||||||
work with commands, updates and other different things
|
|
||||||
* [TelegramBotAPI](TelegramBotAPI/README.md) - concentration of all previously mentioned libraries
|
|
||||||
|
|
||||||
Most part of some specific solves or unuseful
|
There are several things you need to do to launch examples below:
|
||||||
moments are describing by official [Telegram Bot API](https://core.telegram.org/bots/api).
|
|
||||||
|
|
||||||
## JavaScript notes
|
* Add `mavenCentral()` to your project repositories
|
||||||
|
* [Maven variant](https://github.com/InsanusMokrassar/TelegramBotAPI/wiki/Including-in-your-project#pomxml)
|
||||||
|
* Add dependency `implementation "dev.inmo:tgbotapi:$tgbotapi_version"`
|
||||||
|
* Replace `tgbotapi_version` with exact version (see last one in the table above) or put variable with this name in project
|
||||||
|
* Alternative variant for maven [here](https://github.com/InsanusMokrassar/TelegramBotAPI/wiki/Including-in-your-project#telegrambotapi)
|
||||||
|
|
||||||
### Versions before `0.28.0`
|
More including instructions [available here](https://github.com/InsanusMokrassar/TelegramBotAPI/wiki/Including-in-your-project).
|
||||||
|
Other configuration examples:
|
||||||
|
|
||||||
In case if you are want to use this library inside of browser, you will need additional settings (thanks for help to [Alexander Nozik](https://research.jetbrains.org/researchers/altavir)):
|
* [For multiplatform](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/tree/master/ResenderBot)
|
||||||
|
* [For JVM](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/blob/master/GetMeBot/build.gradle)
|
||||||
|
|
||||||
<details>
|
### Most common example
|
||||||
<summary>Gradle build script help (for versions before 0.28.0)</summary>
|
|
||||||
|
|
||||||
```groovy
|
```kotlin
|
||||||
dependencies {
|
suspend fun main() {
|
||||||
/* ... */
|
val bot = telegramBot(TOKEN)
|
||||||
|
|
||||||
implementation "com.github.insanusmokrassar:TelegramBotAPI:$tgbot_api_version"
|
bot.buildBehaviourWithLongPolling {
|
||||||
implementation "com.github.insanusmokrassar:TelegramBotAPI-extensions-api:$tgbot_api_version" // optional
|
println(getMe())
|
||||||
implementation "com.github.insanusmokrassar:TelegramBotAPI-extensions-utils:$tgbot_api_version" // optional
|
|
||||||
|
onCommand("start") {
|
||||||
/* Block of dependencies for correct building in browser */
|
reply(it, "Hi:)")
|
||||||
implementation(npm("fs"))
|
|
||||||
implementation(npm("bufferutil"))
|
|
||||||
implementation(npm("utf-8-validate"))
|
|
||||||
implementation(npm("abort-controller"))
|
|
||||||
implementation(npm("text-encoding"))
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ... */
|
|
||||||
|
|
||||||
kotlin {
|
|
||||||
target {
|
|
||||||
browser {
|
|
||||||
/* Block for fix of exception in absence of some functionality, https://github.com/ktorio/ktor/issues/1339 */
|
|
||||||
dceTask {
|
|
||||||
dceOptions {
|
|
||||||
keep("ktor-ktor-io.\$\$importsForInline\$\$.ktor-ktor-io.io.ktor.utils.io")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}.join()
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
In this example you will see information about this bot at the moment of starting and answer with `Hi:)` every time it
|
||||||
|
gets message `/start`
|
||||||
|
|
||||||
## Ok, where should I start?
|
### Handling only last messages
|
||||||
|
|
||||||

|
```kotlin
|
||||||
|
suspend fun main() {
|
||||||
|
val bot = telegramBot(TOKEN)
|
||||||
|
|
||||||
In most cases, the most simple way will be to implement [TelegramBotAPI](TelegramBotAPI/README.md) - it contains
|
val flowsUpdatesFilter = FlowsUpdatesFilter()
|
||||||
all necessary tools for comfort usage of this library. If you want to exclude some libraries, you can implement just
|
bot.buildBehaviour(flowUpdatesFilter = flowsUpdatesFilter) {
|
||||||
[TelegramBotAPI API Extensions](TelegramBotAPI-extensions-api/README.md),
|
println(getMe())
|
||||||
[TelegramBotAPI Util Extensions](TelegramBotAPI-extensions-utils/README.md) or even
|
|
||||||
[TelegramBotAPI-core](TelegramBotAPI-core/README.md).
|
onCommand("start") {
|
||||||
|
reply(it, "Hi:)")
|
||||||
|
}
|
||||||
|
|
||||||
If you want to dive deeper in the core of library or develop something for it - welcome to learn more from
|
retrieveAccumulatedUpdates(this).join()
|
||||||
[TelegramBotAPI-core](TelegramBotAPI-core/README.md) and our [Telegram Chat](https://teleg.one/InMoTelegramBotAPIChat).
|
}
|
||||||
|
|
||||||
Anyway, all libraries are very typical inside of them. Examples:
|
|
||||||
|
|
||||||
* In `TelegramBotAPI` common request look like `requestsExecutor.execute(SomeRequest())`
|
|
||||||
* `TelegramBotAPI-extensions-api` typical syntax look like `requestsExecutor.someRequest()` (in most cases it would be
|
|
||||||
better to use `bot` name instead of `requestsExecutor`)
|
|
||||||
* `TelegramBotAPI-extensions-utils` will look like `filter.filterBaseMessageUpdates(chatId).filterExactCommands(Regex("^.*$"))...`
|
|
||||||
|
|
||||||
## Build instruction
|
|
||||||
|
|
||||||
If you want to build this project or to contribute, there are several recommendations:
|
|
||||||
|
|
||||||
### Build
|
|
||||||
|
|
||||||
In case if you want to just build project, run next command:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
./gradlew clean build
|
|
||||||
```
|
|
||||||
|
|
||||||
On windows:
|
|
||||||
|
|
||||||
```
|
|
||||||
gradlew.bat clean build
|
|
||||||
```
|
|
||||||
|
|
||||||
### Publishing for work with your version locally
|
|
||||||
|
|
||||||
In case, if you want to work in your other projects using your modification (or some state) of this library,
|
|
||||||
you can use next code:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
./gradlew clean build publishToMavenLocal
|
|
||||||
```
|
|
||||||
|
|
||||||
On windows:
|
|
||||||
|
|
||||||
```
|
|
||||||
gradlew.bat clean build publishToMavenLocal
|
|
||||||
```
|
|
||||||
|
|
||||||
But you must remember, that in this case your local maven repo must be the first one from
|
|
||||||
your project retrieving libraries:
|
|
||||||
|
|
||||||
```groovy
|
|
||||||
repositories {
|
|
||||||
mavenLocal() // that must be the first one
|
|
||||||
jcenter()
|
|
||||||
mavenCentral()
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Besides, for your own version you can change variable `library_version` in the file [gradle.properties](./gradle.properties).
|
The main difference with the previous example is that bot will get only last updates (accumulated before bot launch
|
||||||
|
and maybe some updates it got after launch)
|
||||||
|
|
||||||
|
### Build a little bit more complex behaviour
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
suspend fun main() {
|
||||||
|
val bot = telegramBot(TOKEN)
|
||||||
|
|
||||||
|
bot.buildBehaviourWithLongPolling {
|
||||||
|
println(getMe())
|
||||||
|
|
||||||
|
val nameReplyMarkup = ReplyKeyboardMarkup(
|
||||||
|
matrix {
|
||||||
|
row {
|
||||||
|
+SimpleKeyboardButton("nope")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
onCommand("start") {
|
||||||
|
val photo = waitPhoto(
|
||||||
|
SendTextMessage(it.chat.id, "Send me your photo please")
|
||||||
|
).first()
|
||||||
|
|
||||||
|
val name = waitText(
|
||||||
|
SendTextMessage(
|
||||||
|
it.chat.id,
|
||||||
|
"Send me your name or choose \"nope\"",
|
||||||
|
replyMarkup = nameReplyMarkup
|
||||||
|
)
|
||||||
|
).first().text.takeIf { it != "nope" }
|
||||||
|
|
||||||
|
sendPhoto(
|
||||||
|
it.chat,
|
||||||
|
photo.mediaCollection,
|
||||||
|
entities = buildEntities {
|
||||||
|
if (name != null) regular(name) // may be collapsed up to name ?.let(::regular)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}.join()
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### More examples
|
||||||
|
|
||||||
|
You may find examples in [this project](https://github.com/InsanusMokrassar/TelegramBotAPI-examples). Besides, you are
|
||||||
|
always welcome in our [bookstack](https://bookstack.inmo.dev/books/telegrambotapi) and
|
||||||
|
[chat](https://t.me/InMoTelegramBotAPIChat).
|
||||||
|
|||||||
@@ -1,91 +0,0 @@
|
|||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
mavenLocal()
|
|
||||||
jcenter()
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
||||||
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
|
||||||
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
id "org.jetbrains.kotlin.multiplatform"
|
|
||||||
id "org.jetbrains.kotlin.plugin.serialization"
|
|
||||||
}
|
|
||||||
|
|
||||||
project.version = "$library_version"
|
|
||||||
project.group = "$library_group"
|
|
||||||
|
|
||||||
apply from: "publish.gradle"
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenLocal()
|
|
||||||
jcenter()
|
|
||||||
mavenCentral()
|
|
||||||
maven { url "https://kotlin.bintray.com/kotlinx" }
|
|
||||||
}
|
|
||||||
|
|
||||||
kotlin {
|
|
||||||
jvm()
|
|
||||||
js(BOTH) {
|
|
||||||
browser()
|
|
||||||
nodejs()
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets {
|
|
||||||
commonMain {
|
|
||||||
dependencies {
|
|
||||||
implementation kotlin('stdlib')
|
|
||||||
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
|
|
||||||
api "org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlin_serialisation_runtime_version"
|
|
||||||
api "org.jetbrains.kotlinx:kotlinx-serialization-properties:$kotlin_serialisation_runtime_version"
|
|
||||||
|
|
||||||
api "com.soywiz.korlibs.klock:klock:$klock_version"
|
|
||||||
api "com.benasher44:uuid:$uuid_version"
|
|
||||||
|
|
||||||
api "io.ktor:ktor-client-core:$ktor_version"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
commonTest {
|
|
||||||
dependencies {
|
|
||||||
implementation kotlin('test-common')
|
|
||||||
implementation kotlin('test-annotations-common')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
jvmMain {
|
|
||||||
dependencies {
|
|
||||||
api "io.ktor:ktor-server:$ktor_version"
|
|
||||||
api "io.ktor:ktor-server-host-common:$ktor_version"
|
|
||||||
|
|
||||||
api "io.ktor:ktor-client-cio:$ktor_version"
|
|
||||||
|
|
||||||
api "javax.activation:activation:$javax_activation_version"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
jvmTest {
|
|
||||||
dependencies {
|
|
||||||
implementation kotlin('test-junit')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
jsTest {
|
|
||||||
dependencies {
|
|
||||||
implementation kotlin('test-junit')
|
|
||||||
implementation kotlin('test-js')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
targets.all {
|
|
||||||
compilations.all {
|
|
||||||
kotlinOptions {
|
|
||||||
freeCompilerArgs += ["-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi", "-Xopt-in=kotlin.RequiresOptIn"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
apply plugin: 'maven-publish'
|
|
||||||
|
|
||||||
task javadocsJar(type: Jar) {
|
|
||||||
classifier = 'javadoc'
|
|
||||||
}
|
|
||||||
|
|
||||||
afterEvaluate {
|
|
||||||
project.publishing.publications.all {
|
|
||||||
// rename artifacts
|
|
||||||
groupId "${project.group}"
|
|
||||||
if (it.name.contains('kotlinMultiplatform')) {
|
|
||||||
artifactId = "${project.name}"
|
|
||||||
} else {
|
|
||||||
artifactId = "${project.name}-$name"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
publishing {
|
|
||||||
publications.all {
|
|
||||||
artifact javadocsJar
|
|
||||||
|
|
||||||
pom {
|
|
||||||
description = "Library for Object-Oriented and type-safe work with Telegram Bot API"
|
|
||||||
name = "Telegram Bot API Core"
|
|
||||||
url = "https://insanusmokrassar.github.io/TelegramBotAPI"
|
|
||||||
|
|
||||||
scm {
|
|
||||||
developerConnection = "scm:git:[fetch=]https://github.com/insanusmokrassar/TelegramBotAPI.git[push=]https://github.com/insanusmokrassar/TelegramBotAPI.git"
|
|
||||||
url = "https://github.com/insanusmokrassar/TelegramBotAPI.git"
|
|
||||||
}
|
|
||||||
|
|
||||||
developers {
|
|
||||||
|
|
||||||
developer {
|
|
||||||
id = "InsanusMokrassar"
|
|
||||||
name = "Ovsiannikov Aleksei"
|
|
||||||
email = "ovsyannikov.alexey95@gmail.com"
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
licenses {
|
|
||||||
|
|
||||||
license {
|
|
||||||
name = "Apache Software License 2.0"
|
|
||||||
url = "https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"bintrayConfig":{"repo":"StandardRepository","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/TelegramBotAPI"},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API Core","description":"Library for Object-Oriented and type-safe work with Telegram Bot API","url":"https://insanusmokrassar.github.io/TelegramBotAPI","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]},"type":"Multiplatform"}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
apply plugin: 'com.jfrog.bintray'
|
|
||||||
|
|
||||||
apply from: "maven.publish.gradle"
|
|
||||||
|
|
||||||
bintray {
|
|
||||||
user = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER')
|
|
||||||
key = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY')
|
|
||||||
filesSpec {
|
|
||||||
from "${buildDir}/publications/"
|
|
||||||
eachFile {
|
|
||||||
String directorySubname = it.getFile().parentFile.name
|
|
||||||
if (it.getName() == "module.json") {
|
|
||||||
if (directorySubname == "kotlinMultiplatform") {
|
|
||||||
it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.module")
|
|
||||||
} else {
|
|
||||||
it.setPath("${project.name}-${directorySubname}/${project.version}/${project.name}-${directorySubname}-${project.version}.module")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (directorySubname == "kotlinMultiplatform" && it.getName() == "pom-default.xml") {
|
|
||||||
it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.pom")
|
|
||||||
} else {
|
|
||||||
it.exclude()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
into "${project.group}".replace(".", "/")
|
|
||||||
}
|
|
||||||
pkg {
|
|
||||||
repo = "StandardRepository"
|
|
||||||
name = "${project.name}"
|
|
||||||
vcsUrl = "https://github.com/InsanusMokrassar/TelegramBotAPI"
|
|
||||||
licenses = ["Apache-2.0"]
|
|
||||||
version {
|
|
||||||
name = "${project.version}"
|
|
||||||
released = new Date()
|
|
||||||
vcsTag = "${project.version}"
|
|
||||||
gpg {
|
|
||||||
sign = true
|
|
||||||
passphrase = project.hasProperty('signing.gnupg.passphrase') ? project.property('signing.gnupg.passphrase') : System.getenv('signing.gnupg.passphrase')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bintrayUpload.doFirst {
|
|
||||||
publications = publishing.publications.collect {
|
|
||||||
if (it.name.contains('kotlinMultiplatform')) {
|
|
||||||
null
|
|
||||||
} else {
|
|
||||||
it.name
|
|
||||||
}
|
|
||||||
} - null
|
|
||||||
}
|
|
||||||
|
|
||||||
bintrayUpload.dependsOn publishToMavenLocal
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.fullListOfSubSource
|
|
||||||
|
|
||||||
interface Captioned {
|
|
||||||
val caption: String?
|
|
||||||
}
|
|
||||||
|
|
||||||
interface CaptionedOutput : Captioned {
|
|
||||||
val parseMode: ParseMode?
|
|
||||||
}
|
|
||||||
|
|
||||||
interface CaptionedInput : Captioned {
|
|
||||||
/**
|
|
||||||
* Not full list of entities. This list WILL NOT contain [TextPart]s with [com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources.RegularTextSource]
|
|
||||||
* @see [CaptionedInput.fullEntitiesList]
|
|
||||||
*/
|
|
||||||
val captionEntities: List<TextPart>
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert its [CaptionedInput.captionEntities] to list of [com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource]
|
|
||||||
* with [com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources.RegularTextSource]
|
|
||||||
*/
|
|
||||||
fun CaptionedInput.fullEntitiesList(): FullTextSourcesList = caption ?.fullListOfSubSource(captionEntities) ?.map { it.source } ?: emptyList()
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts
|
|
||||||
|
|
||||||
interface CommonVenueData : Titled {
|
|
||||||
override val title: String
|
|
||||||
val address: String
|
|
||||||
val foursquareId: String?
|
|
||||||
val foursquareType: String? // TODO:: Rewrite with enum or interface
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.fullListOfSubSource
|
|
||||||
|
|
||||||
interface Explained {
|
|
||||||
val explanation: String?
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ExplainedOutput : Explained {
|
|
||||||
val parseMode: ParseMode?
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ExplainedInput : Explained {
|
|
||||||
/**
|
|
||||||
* Not full list of entities. This list WILL NOT contain [TextPart]s with [com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources.RegularTextSource]
|
|
||||||
* @see [ExplainedInput.fullEntitiesList]
|
|
||||||
*/
|
|
||||||
val explanationEntities: List<TextPart>
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert its [ExplainedInput.explanationEntities] to list of [com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource]
|
|
||||||
* with [com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources.RegularTextSource]
|
|
||||||
*/
|
|
||||||
fun ExplainedInput.fullEntitiesList(): FullTextSourcesList = explanation ?.fullListOfSubSource(explanationEntities) ?.map { it.source } ?: emptyList()
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts
|
|
||||||
|
|
||||||
interface Livable {
|
|
||||||
/**
|
|
||||||
* Period in SECONDS
|
|
||||||
*/
|
|
||||||
val livePeriod: Int?
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.MimeType
|
|
||||||
|
|
||||||
interface MimeTyped {
|
|
||||||
val mimeType: MimeType?
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts
|
|
||||||
|
|
||||||
interface Performerable {
|
|
||||||
val performer: String?
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts
|
|
||||||
|
|
||||||
typealias FullTextSourcesList = List<TextSource>
|
|
||||||
typealias FullTextPartsList = List<TextPart>
|
|
||||||
|
|
||||||
interface TextSource {
|
|
||||||
val asMarkdownSource: String
|
|
||||||
val asMarkdownV2Source: String
|
|
||||||
val asHtmlSource: String
|
|
||||||
val source: String
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
interface MultilevelTextSource : TextSource {
|
|
||||||
val textParts: List<TextPart>
|
|
||||||
}
|
|
||||||
|
|
||||||
data class TextPart(
|
|
||||||
val range: IntRange,
|
|
||||||
val source: TextSource
|
|
||||||
)
|
|
||||||
|
|
||||||
fun List<TextPart>.justTextSources() = map { it.source }
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts
|
|
||||||
|
|
||||||
interface Titled {
|
|
||||||
val title: String?
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
|
||||||
|
|
||||||
interface ChatRequest {
|
|
||||||
val chatId: ChatIdentifier
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types
|
|
||||||
|
|
||||||
interface DisableNotification {
|
|
||||||
val disableNotification: Boolean
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineMessageIdentifier
|
|
||||||
|
|
||||||
interface InlineMessageAction {
|
|
||||||
val inlineMessageId: InlineMessageIdentifier
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
|
||||||
|
|
||||||
interface MessageAction: ChatRequest {
|
|
||||||
val messageId: MessageIdentifier
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
|
||||||
|
|
||||||
interface ReplyMarkup {
|
|
||||||
val replyMarkup: KeyboardMarkup?
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
|
||||||
|
|
||||||
interface ReplyMessageId {
|
|
||||||
val replyToMessageId: MessageIdentifier?
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.TelegramDate
|
|
||||||
|
|
||||||
interface UntilDate {
|
|
||||||
val untilDate: TelegramDate?
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.bot
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.TelegramAPIUrlsKeeper
|
|
||||||
|
|
||||||
abstract class BaseRequestsExecutor(
|
|
||||||
protected val telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper
|
|
||||||
) : RequestsExecutor
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.BaseRequestsExecutor
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.base.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.exceptions.newRequestException
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.settings.limiters.EmptyLimiter
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.settings.limiters.RequestLimiter
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.Response
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.*
|
|
||||||
import io.ktor.client.HttpClient
|
|
||||||
import io.ktor.client.features.*
|
|
||||||
import io.ktor.client.statement.HttpStatement
|
|
||||||
import io.ktor.client.statement.readText
|
|
||||||
import kotlinx.serialization.json.Json
|
|
||||||
|
|
||||||
class KtorRequestsExecutor(
|
|
||||||
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
|
||||||
client: HttpClient = HttpClient(),
|
|
||||||
callsFactories: List<KtorCallFactory> = emptyList(),
|
|
||||||
excludeDefaultFactories: Boolean = false,
|
|
||||||
private val requestsLimiter: RequestLimiter = EmptyLimiter,
|
|
||||||
private val jsonFormatter: Json = nonstrictJsonFormat
|
|
||||||
) : BaseRequestsExecutor(telegramAPIUrlsKeeper) {
|
|
||||||
private val callsFactories: List<KtorCallFactory> = callsFactories.run {
|
|
||||||
if (!excludeDefaultFactories) {
|
|
||||||
this + listOf(SimpleRequestCallFactory, MultipartRequestCallFactory, DownloadFileRequestCallFactory)
|
|
||||||
} else {
|
|
||||||
this
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private val client = client.config {
|
|
||||||
if (client.feature(HttpTimeout) == null) {
|
|
||||||
install(HttpTimeout)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override suspend fun <T : Any> execute(request: Request<T>): T {
|
|
||||||
return handleSafely(
|
|
||||||
{ e ->
|
|
||||||
throw if (e is ClientRequestException) {
|
|
||||||
val content = e.response ?.readText() ?: throw e
|
|
||||||
val responseObject = jsonFormatter.decodeFromString(Response.serializer(), content)
|
|
||||||
newRequestException(
|
|
||||||
responseObject,
|
|
||||||
content,
|
|
||||||
"Can't get result object from $content"
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
e
|
|
||||||
}
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
requestsLimiter.limit {
|
|
||||||
var result: T? = null
|
|
||||||
for (potentialFactory in callsFactories) {
|
|
||||||
result = potentialFactory.makeCall(
|
|
||||||
client,
|
|
||||||
telegramAPIUrlsKeeper,
|
|
||||||
request,
|
|
||||||
jsonFormatter
|
|
||||||
)
|
|
||||||
if (result != null) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
result ?: error("Can't execute request: $request")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun close() {
|
|
||||||
client.close()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.base
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.KtorCallFactory
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.exceptions.newRequestException
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.GetUpdates
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.Response
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.RetryAfterError
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.TelegramAPIUrlsKeeper
|
|
||||||
import io.ktor.client.HttpClient
|
|
||||||
import io.ktor.client.call.receive
|
|
||||||
import io.ktor.client.features.timeout
|
|
||||||
import io.ktor.client.request.*
|
|
||||||
import io.ktor.client.statement.HttpResponse
|
|
||||||
import io.ktor.http.ContentType
|
|
||||||
import kotlinx.coroutines.delay
|
|
||||||
import kotlinx.serialization.json.Json
|
|
||||||
import kotlin.collections.set
|
|
||||||
|
|
||||||
abstract class AbstractRequestCallFactory : KtorCallFactory {
|
|
||||||
private val methodsCache: MutableMap<String, String> = mutableMapOf()
|
|
||||||
override suspend fun <T : Any> makeCall(
|
|
||||||
client: HttpClient,
|
|
||||||
urlsKeeper: TelegramAPIUrlsKeeper,
|
|
||||||
request: Request<T>,
|
|
||||||
jsonFormatter: Json
|
|
||||||
): T? {
|
|
||||||
val preparedBody = prepareCallBody(client, urlsKeeper, request) ?: return null
|
|
||||||
|
|
||||||
client.post<HttpResponse> {
|
|
||||||
url(
|
|
||||||
methodsCache[request.method()] ?: "${urlsKeeper.commonAPIUrl}/${request.method()}".also {
|
|
||||||
methodsCache[request.method()] = it
|
|
||||||
}
|
|
||||||
)
|
|
||||||
accept(ContentType.Application.Json)
|
|
||||||
|
|
||||||
if (request is GetUpdates) {
|
|
||||||
request.timeout?.times(1000L)?.let { customTimeoutMillis ->
|
|
||||||
if (customTimeoutMillis > 0) {
|
|
||||||
timeout {
|
|
||||||
requestTimeoutMillis = customTimeoutMillis
|
|
||||||
socketTimeoutMillis = customTimeoutMillis
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
body = preparedBody
|
|
||||||
}.let { response ->
|
|
||||||
val content = response.receive<String>()
|
|
||||||
val responseObject = jsonFormatter.decodeFromString(Response.serializer(), content)
|
|
||||||
|
|
||||||
return (responseObject.result?.let {
|
|
||||||
jsonFormatter.decodeFromJsonElement(request.resultDeserializer, it)
|
|
||||||
} ?: responseObject.parameters?.let {
|
|
||||||
val error = it.error
|
|
||||||
if (error is RetryAfterError) {
|
|
||||||
delay(error.leftToRetry)
|
|
||||||
makeCall(client, urlsKeeper, request, jsonFormatter)
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
} ?: response.let {
|
|
||||||
throw newRequestException(
|
|
||||||
responseObject,
|
|
||||||
content,
|
|
||||||
"Can't get result object from $content"
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract fun <T : Any> prepareCallBody(
|
|
||||||
client: HttpClient,
|
|
||||||
urlsKeeper: TelegramAPIUrlsKeeper,
|
|
||||||
request: Request<T>
|
|
||||||
): Any?
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.base
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.KtorCallFactory
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.DownloadFile
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.TelegramAPIUrlsKeeper
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.handleSafely
|
|
||||||
import io.ktor.client.HttpClient
|
|
||||||
import io.ktor.client.request.*
|
|
||||||
import io.ktor.client.statement.*
|
|
||||||
import io.ktor.http.HttpMethod
|
|
||||||
import kotlinx.serialization.json.Json
|
|
||||||
|
|
||||||
object DownloadFileRequestCallFactory : KtorCallFactory {
|
|
||||||
override suspend fun <T : Any> makeCall(
|
|
||||||
client: HttpClient,
|
|
||||||
urlsKeeper: TelegramAPIUrlsKeeper,
|
|
||||||
request: Request<T>,
|
|
||||||
jsonFormatter: Json
|
|
||||||
): T? = (request as? DownloadFile) ?.let {
|
|
||||||
val fullUrl = "${urlsKeeper.fileBaseUrl}/${it.filePath}"
|
|
||||||
|
|
||||||
return handleSafely {
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
|
||||||
client.get<ByteArray>(fullUrl) as T // always ByteArray
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.bot
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
|
||||||
import io.ktor.utils.io.core.Closeable
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interface for making requests to Telegram Bot API. Currently, there is only one built-in implementation -
|
|
||||||
* [com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.KtorRequestsExecutor]
|
|
||||||
*
|
|
||||||
* @see Request
|
|
||||||
* @see com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.KtorRequestsExecutor
|
|
||||||
*/
|
|
||||||
interface RequestsExecutor : Closeable {
|
|
||||||
/**
|
|
||||||
* Unsafe execution of incoming [request]. Can throw almost any exception. So, it is better to use
|
|
||||||
* something like [com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.shortcuts.executeAsync] or
|
|
||||||
* [com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.shortcuts.executeUnsafe]
|
|
||||||
*
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
suspend fun <T : Any> execute(request: Request<T>): T
|
|
||||||
}
|
|
||||||
|
|
||||||
typealias TelegramBot = RequestsExecutor
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.bot.exceptions
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.Response
|
|
||||||
import io.ktor.utils.io.errors.IOException
|
|
||||||
|
|
||||||
fun newRequestException(
|
|
||||||
response: Response,
|
|
||||||
plainAnswer: String,
|
|
||||||
message: String? = null,
|
|
||||||
cause: Throwable? = null
|
|
||||||
) = response.description ?.let { description ->
|
|
||||||
when {
|
|
||||||
description == "Bad Request: reply message not found" -> ReplyMessageNotFoundException(response, plainAnswer, message, cause)
|
|
||||||
description == "Bad Request: message to edit not found" -> MessageToEditNotFoundException(response, plainAnswer, message, cause)
|
|
||||||
description.contains("Bad Request: message is not modified") -> MessageIsNotModifiedException(response, plainAnswer, message, cause)
|
|
||||||
description == "Unauthorized" -> UnauthorizedException(response, plainAnswer, message, cause)
|
|
||||||
description.contains("PHOTO_INVALID_DIMENSIONS") -> InvalidPhotoDimensionsException(response, plainAnswer, message, cause)
|
|
||||||
else -> null
|
|
||||||
}
|
|
||||||
} ?: CommonRequestException(response, plainAnswer, message, cause)
|
|
||||||
|
|
||||||
sealed class RequestException constructor(
|
|
||||||
val response: Response,
|
|
||||||
val plainAnswer: String,
|
|
||||||
message: String? = null,
|
|
||||||
override val cause: Throwable? = null
|
|
||||||
) : IOException(
|
|
||||||
message ?: "Something went wrong"
|
|
||||||
)
|
|
||||||
|
|
||||||
class CommonRequestException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
|
|
||||||
RequestException(response, plainAnswer, message, cause)
|
|
||||||
|
|
||||||
class UnauthorizedException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
|
|
||||||
RequestException(response, plainAnswer, message, cause)
|
|
||||||
|
|
||||||
class ReplyMessageNotFoundException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
|
|
||||||
RequestException(response, plainAnswer, message, cause)
|
|
||||||
|
|
||||||
class MessageIsNotModifiedException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
|
|
||||||
RequestException(response, plainAnswer, message, cause)
|
|
||||||
|
|
||||||
class MessageToEditNotFoundException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
|
|
||||||
RequestException(response, plainAnswer, message, cause)
|
|
||||||
|
|
||||||
class InvalidPhotoDimensionsException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
|
|
||||||
RequestException(response, plainAnswer, message, cause)
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.bot.settings.limiters
|
|
||||||
|
|
||||||
import com.soywiz.klock.DateTime
|
|
||||||
import kotlinx.coroutines.*
|
|
||||||
import kotlinx.coroutines.channels.Channel
|
|
||||||
|
|
||||||
private fun now(): Long = DateTime.nowUnixLong()
|
|
||||||
|
|
||||||
class CommonLimiter(
|
|
||||||
private val lockCount: Int = 10,
|
|
||||||
private val regenTime: Long = 20 * 1000L // 20 seconds for full regen of opportunity to send message
|
|
||||||
) : RequestLimiter {
|
|
||||||
private var doLimit: Boolean = false
|
|
||||||
|
|
||||||
private val counterChannel = Channel<Unit>(Channel.UNLIMITED)
|
|
||||||
private val scope = CoroutineScope(Dispatchers.Default)
|
|
||||||
private val counterJob = scope.launch {
|
|
||||||
var wasLastSecond = 0
|
|
||||||
var lastCountTime = now()
|
|
||||||
var limitManagementJob: Job? = null
|
|
||||||
var removeLimitTime: Long = lastCountTime
|
|
||||||
for (counter in counterChannel) {
|
|
||||||
val now = now()
|
|
||||||
if (now - lastCountTime > 1000) {
|
|
||||||
lastCountTime = now
|
|
||||||
wasLastSecond = 1
|
|
||||||
} else {
|
|
||||||
wasLastSecond++
|
|
||||||
}
|
|
||||||
if (wasLastSecond >= lockCount) {
|
|
||||||
removeLimitTime = now + regenTime
|
|
||||||
if (limitManagementJob == null) {
|
|
||||||
limitManagementJob = launch {
|
|
||||||
doLimit = true
|
|
||||||
var internalNow = now()
|
|
||||||
while (internalNow < removeLimitTime) {
|
|
||||||
delay(removeLimitTime - internalNow)
|
|
||||||
internalNow = now()
|
|
||||||
}
|
|
||||||
doLimit = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (now > removeLimitTime) {
|
|
||||||
limitManagementJob = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private val quoterChannel = Channel<Unit>(Channel.CONFLATED)
|
|
||||||
private val tickerJob = scope.launch {
|
|
||||||
while (isActive) {
|
|
||||||
quoterChannel.send(Unit)
|
|
||||||
delay(1000L)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override suspend fun <T> limit(block: suspend () -> T): T {
|
|
||||||
counterChannel.send(Unit)
|
|
||||||
return if (!doLimit) {
|
|
||||||
block()
|
|
||||||
} else {
|
|
||||||
quoterChannel.receive()
|
|
||||||
block()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.bot.settings.limiters
|
|
||||||
|
|
||||||
object EmptyLimiter : RequestLimiter {
|
|
||||||
override suspend fun <T> limit(block: suspend () -> T): T = block()
|
|
||||||
}
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.bot.settings.limiters
|
|
||||||
|
|
||||||
import kotlinx.coroutines.*
|
|
||||||
import kotlinx.coroutines.channels.Channel
|
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
import kotlinx.serialization.Transient
|
|
||||||
import kotlin.coroutines.*
|
|
||||||
import kotlin.math.pow
|
|
||||||
|
|
||||||
private sealed class RequestEvent
|
|
||||||
private class AddRequest(
|
|
||||||
val continuation: Continuation<Long>
|
|
||||||
) : RequestEvent()
|
|
||||||
private object CompleteRequest : RequestEvent()
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class PowLimiter(
|
|
||||||
private val minAwaitTime: Long = 0L,
|
|
||||||
private val maxAwaitTime: Long = 10000L,
|
|
||||||
private val powValue: Double = 4.0,
|
|
||||||
private val powK: Double = 0.0016
|
|
||||||
) : RequestLimiter {
|
|
||||||
@Transient
|
|
||||||
private val scope = CoroutineScope(Dispatchers.Default)
|
|
||||||
@Transient
|
|
||||||
private val eventsChannel = Channel<RequestEvent>(Channel.UNLIMITED)
|
|
||||||
@Transient
|
|
||||||
private val awaitTimeRange = minAwaitTime .. maxAwaitTime
|
|
||||||
|
|
||||||
init {
|
|
||||||
scope.launch {
|
|
||||||
var requestsInWork: Double = 0.0
|
|
||||||
for (event in eventsChannel) {
|
|
||||||
when (event) {
|
|
||||||
is AddRequest -> {
|
|
||||||
val awaitTime = (((requestsInWork.pow(powValue) * powK) * 1000L).toLong())
|
|
||||||
requestsInWork++
|
|
||||||
|
|
||||||
event.continuation.resume(
|
|
||||||
if (awaitTime in awaitTimeRange) {
|
|
||||||
awaitTime
|
|
||||||
} else {
|
|
||||||
if (awaitTime < minAwaitTime) {
|
|
||||||
minAwaitTime
|
|
||||||
} else {
|
|
||||||
maxAwaitTime
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
is CompleteRequest -> requestsInWork--
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override suspend fun <T> limit(
|
|
||||||
block: suspend () -> T
|
|
||||||
): T {
|
|
||||||
val delayMillis = suspendCoroutine<Long> {
|
|
||||||
scope.launch { eventsChannel.send(AddRequest(it)) }
|
|
||||||
}
|
|
||||||
delay(delayMillis)
|
|
||||||
return try {
|
|
||||||
block()
|
|
||||||
} finally {
|
|
||||||
eventsChannel.send(CompleteRequest)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.bot.settings.limiters
|
|
||||||
|
|
||||||
interface RequestLimiter {
|
|
||||||
/**
|
|
||||||
* Use limit for working of block (like delay between or after, for example)
|
|
||||||
*/
|
|
||||||
suspend fun <T> limit(block: suspend () -> T): T
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.PossiblyForwardedMessage
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
private val AbleToBeForwardedMessageDeserializer = TelegramBotAPIMessageDeserializationStrategyClass<PossiblyForwardedMessage>()
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class ForwardMessage(
|
|
||||||
@SerialName(fromChatIdField)
|
|
||||||
val fromChatId: ChatIdentifier,
|
|
||||||
@SerialName(chatIdField)
|
|
||||||
val toChatId: ChatIdentifier,
|
|
||||||
@SerialName(messageIdField)
|
|
||||||
override val messageId: MessageIdentifier,
|
|
||||||
@SerialName(disableNotificationField)
|
|
||||||
val disableNotification: Boolean = false
|
|
||||||
): SimpleRequest<PossiblyForwardedMessage>, MessageAction {
|
|
||||||
override val chatId: ChatIdentifier
|
|
||||||
get() = fromChatId
|
|
||||||
|
|
||||||
override fun method(): String = "forwardMessage"
|
|
||||||
|
|
||||||
override val resultDeserializer: DeserializationStrategy<PossiblyForwardedMessage>
|
|
||||||
get() = AbleToBeForwardedMessageDeserializer
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ReplyMarkup
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class StopPoll(
|
|
||||||
@SerialName(chatIdField)
|
|
||||||
override val chatId: ChatIdentifier,
|
|
||||||
@SerialName(messageIdField)
|
|
||||||
override val messageId: MessageIdentifier,
|
|
||||||
@SerialName(replyMarkupField)
|
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) : MessageAction, SimpleRequest<Poll>, ReplyMarkup {
|
|
||||||
override fun method(): String = "stopPoll"
|
|
||||||
override val resultDeserializer: DeserializationStrategy<Poll>
|
|
||||||
get() = Poll.serializer()
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
}
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.toInputMediaFileAttachmentName
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.StorageFile
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
import kotlinx.serialization.descriptors.*
|
|
||||||
import kotlinx.serialization.encoding.Decoder
|
|
||||||
import kotlinx.serialization.encoding.Encoder
|
|
||||||
|
|
||||||
@Serializable(InputFileSerializer::class)
|
|
||||||
sealed class InputFile {
|
|
||||||
abstract val fileId: String
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO:: add checks for file url/file id regex
|
|
||||||
/**
|
|
||||||
* Contains file id or file url
|
|
||||||
*/
|
|
||||||
@Serializable(InputFileSerializer::class)
|
|
||||||
data class FileId(
|
|
||||||
override val fileId: String
|
|
||||||
) : InputFile()
|
|
||||||
|
|
||||||
fun String.toInputFile() = FileId(this)
|
|
||||||
|
|
||||||
@Serializer(InputFile::class)
|
|
||||||
internal object InputFileSerializer : KSerializer<InputFile> {
|
|
||||||
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor(FileId::class.toString(), PrimitiveKind.STRING)
|
|
||||||
override fun serialize(encoder: Encoder, value: InputFile) = encoder.encodeString(value.fileId)
|
|
||||||
override fun deserialize(decoder: Decoder): FileId = FileId(decoder.decodeString())
|
|
||||||
}
|
|
||||||
|
|
||||||
internal val InputFile.asMediaData: String
|
|
||||||
get() = when (this) {
|
|
||||||
is FileId -> fileId
|
|
||||||
is MultipartFile -> fileId.toInputMediaFileAttachmentName()
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO:: add checks for files size
|
|
||||||
/**
|
|
||||||
* Contains info about file for sending
|
|
||||||
*/
|
|
||||||
@Serializable(InputFileSerializer::class)
|
|
||||||
data class MultipartFile (
|
|
||||||
val file: StorageFile,
|
|
||||||
val mimeType: String = file.storageFileInfo.contentType,
|
|
||||||
val filename: String = file.storageFileInfo.fileName
|
|
||||||
) : InputFile() {
|
|
||||||
override val fileId: String = file.storageFileInfo.generateCustomName()
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.bot
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.BotCommand
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
import kotlinx.serialization.builtins.ListSerializer
|
|
||||||
|
|
||||||
private val getMyCommandsSerializer = ListSerializer(BotCommand.serializer())
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
object GetMyCommands : SimpleRequest<List<BotCommand>> {
|
|
||||||
override fun method(): String = "getMyCommands"
|
|
||||||
override val resultDeserializer: DeserializationStrategy<List<BotCommand>>
|
|
||||||
get() = getMyCommandsSerializer
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.bot
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
import kotlinx.serialization.builtins.serializer
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
class SetMyCommands(
|
|
||||||
@SerialName(botCommandsField)
|
|
||||||
val commands: List<BotCommand>
|
|
||||||
) : SimpleRequest<Boolean> {
|
|
||||||
override fun method(): String = "setMyCommands"
|
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
|
||||||
get() = Boolean.serializer()
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
|
|
||||||
init {
|
|
||||||
if (commands.size !in botCommandsLimit) {
|
|
||||||
error("Bot commands list size able to be in range $botCommandsLimit, but incoming size is ${commands.size}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.UserId
|
|
||||||
|
|
||||||
interface ChatMemberRequest<T: Any> : ChatRequest, SimpleRequest<T> {
|
|
||||||
val userId: UserId
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.get
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ExtendedChatSerializer
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.extended.ExtendedChat
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class GetChat(
|
|
||||||
@SerialName(chatIdField)
|
|
||||||
override val chatId: ChatIdentifier
|
|
||||||
): ChatRequest, SimpleRequest<ExtendedChat> {
|
|
||||||
override fun method(): String = "getChat"
|
|
||||||
override val resultDeserializer: DeserializationStrategy<ExtendedChat>
|
|
||||||
get() = ExtendedChatSerializer
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.get
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.AdministratorChatMember
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.AdministratorChatMemberSerializerWithoutDeserialization
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
import kotlinx.serialization.builtins.ListSerializer
|
|
||||||
|
|
||||||
private val chatMembersListSerializer = ListSerializer(
|
|
||||||
AdministratorChatMemberSerializerWithoutDeserialization
|
|
||||||
)
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class GetChatAdministrators(
|
|
||||||
@SerialName(chatIdField)
|
|
||||||
override val chatId: ChatIdentifier
|
|
||||||
): ChatRequest, SimpleRequest<List<AdministratorChatMember>> {
|
|
||||||
override fun method(): String = "getChatAdministrators"
|
|
||||||
override val resultDeserializer: DeserializationStrategy<List<AdministratorChatMember>>
|
|
||||||
get() = chatMembersListSerializer
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.get
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
import kotlinx.serialization.builtins.serializer
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class GetChatMembersCount(
|
|
||||||
@SerialName(chatIdField)
|
|
||||||
override val chatId: ChatIdentifier
|
|
||||||
): ChatRequest, SimpleRequest<Int> {
|
|
||||||
override fun method(): String = "getChatMembersCount"
|
|
||||||
override val resultDeserializer: DeserializationStrategy<Int>
|
|
||||||
get() = Int.serializer()
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMemberRequest
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMember
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMemberDeserializationStrategy
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class GetChatMember(
|
|
||||||
@SerialName(chatIdField)
|
|
||||||
override val chatId: ChatIdentifier,
|
|
||||||
@SerialName(userIdField)
|
|
||||||
override val userId: UserId
|
|
||||||
) : ChatMemberRequest<ChatMember> {
|
|
||||||
override fun method(): String = "getChatMember"
|
|
||||||
override val resultDeserializer: DeserializationStrategy<ChatMember>
|
|
||||||
get() = ChatMemberDeserializationStrategy
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.LocationContent
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
private val commonResultDeserializer = TelegramBotAPIMessageDeserializationStrategyClass<ContentMessage<LocationContent>>()
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class EditChatMessageLiveLocation(
|
|
||||||
@SerialName(chatIdField)
|
|
||||||
override val chatId: ChatIdentifier,
|
|
||||||
@SerialName(messageIdField)
|
|
||||||
override val messageId: MessageIdentifier,
|
|
||||||
@SerialName(latitudeField)
|
|
||||||
override val latitude: Double,
|
|
||||||
@SerialName(longitudeField)
|
|
||||||
override val longitude: Double,
|
|
||||||
@SerialName(replyMarkupField)
|
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) : EditChatMessage<LocationContent>, EditReplyMessage, EditLocationMessage {
|
|
||||||
override fun method(): String = "editMessageLiveLocation"
|
|
||||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<LocationContent>>
|
|
||||||
get() = commonResultDeserializer
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class EditInlineMessageLiveLocation(
|
|
||||||
@SerialName(inlineMessageIdField)
|
|
||||||
override val inlineMessageId: InlineMessageIdentifier,
|
|
||||||
@SerialName(latitudeField)
|
|
||||||
override val latitude: Double,
|
|
||||||
@SerialName(longitudeField)
|
|
||||||
override val longitude: Double,
|
|
||||||
@SerialName(replyMarkupField)
|
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) : EditInlineMessage, EditReplyMessage, EditLocationMessage {
|
|
||||||
override fun method(): String = "editMessageLiveLocation"
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditChatMessage
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.LocationContent
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
private val commonResultDeserializer = TelegramBotAPIMessageDeserializationStrategyClass<ContentMessage<LocationContent>>()
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class StopChatMessageLiveLocation(
|
|
||||||
@SerialName(chatIdField)
|
|
||||||
override val chatId: ChatIdentifier,
|
|
||||||
@SerialName(messageIdField)
|
|
||||||
override val messageId: MessageIdentifier,
|
|
||||||
@SerialName(replyMarkupField)
|
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) : EditChatMessage<LocationContent>, EditReplyMessage {
|
|
||||||
override fun method(): String = "stopMessageLiveLocation"
|
|
||||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<LocationContent>>
|
|
||||||
get() = commonResultDeserializer
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditInlineMessage
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class StopInlineMessageLiveLocation(
|
|
||||||
@SerialName(inlineMessageIdField)
|
|
||||||
override val inlineMessageId: InlineMessageIdentifier,
|
|
||||||
@SerialName(replyMarkupField)
|
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) : EditInlineMessage, EditReplyMessage {
|
|
||||||
override fun method(): String = "stopMessageLiveLocation"
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
|
||||||
|
|
||||||
interface EditChatMessage<MT: MessageContent> : SimpleRequest<ContentMessage<MT>>, MessageAction
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts
|
|
||||||
|
|
||||||
interface EditLocationMessage {
|
|
||||||
val latitude: Double
|
|
||||||
val longitude: Double
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.InputMedia
|
|
||||||
|
|
||||||
interface EditMediaMessage {
|
|
||||||
val media: InputMedia
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ReplyMarkup
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
|
||||||
|
|
||||||
interface EditReplyMessage : ReplyMarkup {
|
|
||||||
override val replyMarkup: InlineKeyboardMarkup?
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
|
||||||
|
|
||||||
interface EditTextChatMessage {
|
|
||||||
val text: String
|
|
||||||
val parseMode: ParseMode?
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.caption
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media.MediaContentMessageResultDeserializer
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
const val editMessageCaptionMethod = "editMessageCaption"
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class EditChatMessageCaption(
|
|
||||||
@SerialName(chatIdField)
|
|
||||||
override val chatId: ChatIdentifier,
|
|
||||||
@SerialName(messageIdField)
|
|
||||||
override val messageId: MessageIdentifier,
|
|
||||||
@SerialName(captionField)
|
|
||||||
override val text: String,
|
|
||||||
@SerialName(parseModeField)
|
|
||||||
override val parseMode: ParseMode? = null,
|
|
||||||
@SerialName(replyMarkupField)
|
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) : EditChatMessage<MediaContent>, EditTextChatMessage, EditReplyMessage {
|
|
||||||
|
|
||||||
override fun method(): String = editMessageCaptionMethod
|
|
||||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<MediaContent>>
|
|
||||||
get() = MediaContentMessageResultDeserializer
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.caption
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class EditInlineMessageCaption(
|
|
||||||
@SerialName(inlineMessageIdField)
|
|
||||||
override val inlineMessageId: InlineMessageIdentifier,
|
|
||||||
@SerialName(captionField)
|
|
||||||
override val text: String,
|
|
||||||
@SerialName(parseModeField)
|
|
||||||
override val parseMode: ParseMode? = null,
|
|
||||||
@SerialName(replyMarkupField)
|
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) : EditInlineMessage, EditTextChatMessage, EditReplyMessage {
|
|
||||||
override fun method(): String = editMessageCaptionMethod
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.text
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.TextContentMessageResultDeserializer
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
const val editMessageTextMethod = "editMessageText"
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class EditChatMessageText(
|
|
||||||
@SerialName(chatIdField)
|
|
||||||
override val chatId: ChatIdentifier,
|
|
||||||
@SerialName(messageIdField)
|
|
||||||
override val messageId: MessageIdentifier,
|
|
||||||
@SerialName(textField)
|
|
||||||
override val text: String,
|
|
||||||
@SerialName(parseModeField)
|
|
||||||
override val parseMode: ParseMode? = null,
|
|
||||||
@SerialName(disableWebPagePreviewField)
|
|
||||||
override val disableWebPagePreview: Boolean? = null,
|
|
||||||
@SerialName(replyMarkupField)
|
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) : EditChatMessage<TextContent>, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
|
|
||||||
|
|
||||||
override fun method(): String = editMessageTextMethod
|
|
||||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<TextContent>>
|
|
||||||
get() = TextContentMessageResultDeserializer
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.text
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media.editMessageMediaMethod
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class EditInlineMessageText(
|
|
||||||
@SerialName(inlineMessageIdField)
|
|
||||||
override val inlineMessageId: InlineMessageIdentifier,
|
|
||||||
@SerialName(textField)
|
|
||||||
override val text: String,
|
|
||||||
@SerialName(parseModeField)
|
|
||||||
override val parseMode: ParseMode? = null,
|
|
||||||
@SerialName(disableWebPagePreviewField)
|
|
||||||
override val disableWebPagePreview: Boolean? = null,
|
|
||||||
@SerialName(replyMarkupField)
|
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) : EditInlineMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
|
|
||||||
override fun method(): String = editMessageMediaMethod
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.games
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.GetGameHighScores
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class GetGameHighScoresByChat (
|
|
||||||
@SerialName(userIdField)
|
|
||||||
override val userId: UserId,
|
|
||||||
@SerialName(chatIdField)
|
|
||||||
override val chatId: ChatId,
|
|
||||||
@SerialName(messageIdField)
|
|
||||||
override val messageId: MessageIdentifier
|
|
||||||
) : GetGameHighScores, MessageAction {
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.LocationContent
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
|
|
||||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<LocationContent>>
|
|
||||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class SendLocation(
|
|
||||||
@SerialName(chatIdField)
|
|
||||||
override val chatId: ChatIdentifier,
|
|
||||||
@SerialName(latitudeField)
|
|
||||||
override val latitude: Double,
|
|
||||||
@SerialName(longitudeField)
|
|
||||||
override val longitude: Double,
|
|
||||||
@SerialName(livePeriodField)
|
|
||||||
val livePeriod: Long? = null,
|
|
||||||
@SerialName(disableNotificationField)
|
|
||||||
override val disableNotification: Boolean = false,
|
|
||||||
@SerialName(replyToMessageIdField)
|
|
||||||
override val replyToMessageId: MessageIdentifier? = null,
|
|
||||||
@SerialName(replyMarkupField)
|
|
||||||
override val replyMarkup: KeyboardMarkup? = null
|
|
||||||
) : SendMessageRequest<ContentMessage<LocationContent>>,
|
|
||||||
ReplyingMarkupSendMessageRequest<ContentMessage<LocationContent>>,
|
|
||||||
PositionedSendMessageRequest<ContentMessage<LocationContent>>
|
|
||||||
{
|
|
||||||
override fun method(): String = "sendLocation"
|
|
||||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<LocationContent>>
|
|
||||||
get() = commonResultDeserializer
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
|
|
||||||
init {
|
|
||||||
if (livePeriod != null && livePeriod !in livePeriodLimit) {
|
|
||||||
error("Live period for sending location must be in $livePeriodLimit, but was $livePeriod")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.DisableWebPagePreview
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.throwRangeError
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
internal val TextContentMessageResultDeserializer: DeserializationStrategy<ContentMessage<TextContent>>
|
|
||||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class SendTextMessage(
|
|
||||||
@SerialName(chatIdField)
|
|
||||||
override val chatId: ChatIdentifier,
|
|
||||||
@SerialName(textField)
|
|
||||||
override val text: String,
|
|
||||||
@SerialName(parseModeField)
|
|
||||||
override val parseMode: ParseMode? = null,
|
|
||||||
@SerialName(disableWebPagePreviewField)
|
|
||||||
override val disableWebPagePreview: Boolean? = null,
|
|
||||||
@SerialName(disableNotificationField)
|
|
||||||
override val disableNotification: Boolean = false,
|
|
||||||
@SerialName(replyToMessageIdField)
|
|
||||||
override val replyToMessageId: MessageIdentifier? = null,
|
|
||||||
@SerialName(replyMarkupField)
|
|
||||||
override val replyMarkup: KeyboardMarkup? = null
|
|
||||||
) : SendMessageRequest<ContentMessage<TextContent>>,
|
|
||||||
ReplyingMarkupSendMessageRequest<ContentMessage<TextContent>>,
|
|
||||||
TextableSendMessageRequest<ContentMessage<TextContent>>,
|
|
||||||
DisableWebPagePreview
|
|
||||||
{
|
|
||||||
init {
|
|
||||||
if (text.length !in textLength) {
|
|
||||||
throwRangeError("Text length", textLength, text.length)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun method(): String = "sendMessage"
|
|
||||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<TextContent>>
|
|
||||||
get() = TextContentMessageResultDeserializer
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
}
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.VenueContent
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.venue.Venue
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<VenueContent>>
|
|
||||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class SendVenue(
|
|
||||||
@SerialName(chatIdField)
|
|
||||||
override val chatId: ChatIdentifier,
|
|
||||||
@SerialName(latitudeField)
|
|
||||||
override val latitude: Double,
|
|
||||||
@SerialName(longitudeField)
|
|
||||||
override val longitude: Double,
|
|
||||||
@SerialName(titleField)
|
|
||||||
override val title: String,
|
|
||||||
@SerialName(addressField)
|
|
||||||
val address: String,
|
|
||||||
@SerialName(foursquareIdField)
|
|
||||||
val foursquareId: String? = null,
|
|
||||||
@SerialName(disableNotificationField)
|
|
||||||
override val disableNotification: Boolean = false,
|
|
||||||
@SerialName(replyToMessageIdField)
|
|
||||||
override val replyToMessageId: MessageIdentifier? = null,
|
|
||||||
@SerialName(replyMarkupField)
|
|
||||||
override val replyMarkup: KeyboardMarkup? = null
|
|
||||||
) : SendMessageRequest<ContentMessage<VenueContent>>,
|
|
||||||
PositionedSendMessageRequest<ContentMessage<VenueContent>>,
|
|
||||||
TitledSendMessageRequest<ContentMessage<VenueContent>>,
|
|
||||||
ReplyingMarkupSendMessageRequest<ContentMessage<VenueContent>>
|
|
||||||
{
|
|
||||||
constructor(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
venue: Venue,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
): this(
|
|
||||||
chatId,
|
|
||||||
venue.location.latitude,
|
|
||||||
venue.location.longitude,
|
|
||||||
venue.title,
|
|
||||||
venue.address,
|
|
||||||
venue.foursquareId,
|
|
||||||
disableNotification,
|
|
||||||
replyToMessageId,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
override fun method(): String = "sendVenue"
|
|
||||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<VenueContent>>
|
|
||||||
get() = commonResultDeserializer
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Venue.toRequest(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
): SendVenue = SendVenue(
|
|
||||||
chatId,
|
|
||||||
this,
|
|
||||||
disableNotification,
|
|
||||||
replyToMessageId,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts
|
|
||||||
|
|
||||||
interface PositionedSendMessageRequest<T: Any>: SendMessageRequest<T> {
|
|
||||||
val latitude: Double
|
|
||||||
val longitude: Double
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ReplyMarkup
|
|
||||||
|
|
||||||
interface ReplyingMarkupSendMessageRequest<T: Any>: SendMessageRequest<T>, ReplyMarkup
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
|
||||||
|
|
||||||
interface SendChatMessageRequest<T: Any> : SimpleRequest<T>, ChatRequest
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.DisableNotification
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ReplyMessageId
|
|
||||||
|
|
||||||
interface SendMessageRequest<T: Any> : SendChatMessageRequest<T>, ReplyMessageId, DisableNotification
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
|
||||||
|
|
||||||
interface TextableSendMessageRequest<T: Any>: SendMessageRequest<T> {
|
|
||||||
val text: String?
|
|
||||||
val parseMode: ParseMode?
|
|
||||||
}
|
|
||||||
@@ -1,115 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.AnimationContent
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.throwRangeError
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
fun SendAnimation(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
animation: InputFile,
|
|
||||||
thumb: InputFile? = null,
|
|
||||||
caption: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
duration: Long? = null,
|
|
||||||
width: Int? = null,
|
|
||||||
height: Int? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
): Request<ContentMessage<AnimationContent>> {
|
|
||||||
val animationAsFileId = (animation as? FileId) ?.fileId
|
|
||||||
val animationAsFile = animation as? MultipartFile
|
|
||||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
|
||||||
val thumbAsFile = thumb as? MultipartFile
|
|
||||||
|
|
||||||
val data = SendAnimationData(
|
|
||||||
chatId,
|
|
||||||
animationAsFileId,
|
|
||||||
thumbAsFileId,
|
|
||||||
caption,
|
|
||||||
parseMode,
|
|
||||||
duration,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
disableNotification,
|
|
||||||
replyToMessageId,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
return if (animationAsFile == null && thumbAsFile == null) {
|
|
||||||
data
|
|
||||||
} else {
|
|
||||||
MultipartRequestImpl(
|
|
||||||
data,
|
|
||||||
SendAnimationFiles(animationAsFile, thumbAsFile)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<AnimationContent>>
|
|
||||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class SendAnimationData internal constructor(
|
|
||||||
@SerialName(chatIdField)
|
|
||||||
override val chatId: ChatIdentifier,
|
|
||||||
@SerialName(animationField)
|
|
||||||
val animation: String? = null,
|
|
||||||
@SerialName(thumbField)
|
|
||||||
override val thumb: String? = null,
|
|
||||||
@SerialName(captionField)
|
|
||||||
override val text: String? = null,
|
|
||||||
@SerialName(parseModeField)
|
|
||||||
override val parseMode: ParseMode? = null,
|
|
||||||
@SerialName(durationField)
|
|
||||||
override val duration: Long? = null,
|
|
||||||
@SerialName(widthField)
|
|
||||||
override val width: Int? = null,
|
|
||||||
@SerialName(heightField)
|
|
||||||
override val height: Int? = null,
|
|
||||||
@SerialName(disableNotificationField)
|
|
||||||
override val disableNotification: Boolean = false,
|
|
||||||
@SerialName(replyToMessageIdField)
|
|
||||||
override val replyToMessageId: MessageIdentifier? = null,
|
|
||||||
@SerialName(replyMarkupField)
|
|
||||||
override val replyMarkup: KeyboardMarkup? = null
|
|
||||||
) : DataRequest<ContentMessage<AnimationContent>>,
|
|
||||||
SendMessageRequest<ContentMessage<AnimationContent>>,
|
|
||||||
ReplyingMarkupSendMessageRequest<ContentMessage<AnimationContent>>,
|
|
||||||
TextableSendMessageRequest<ContentMessage<AnimationContent>>,
|
|
||||||
ThumbedSendMessageRequest<ContentMessage<AnimationContent>>,
|
|
||||||
DuratedSendMessageRequest<ContentMessage<AnimationContent>>,
|
|
||||||
SizedSendMessageRequest<ContentMessage<AnimationContent>>
|
|
||||||
{
|
|
||||||
init {
|
|
||||||
text ?.let {
|
|
||||||
if (it.length !in captionLength) {
|
|
||||||
throwRangeError("Caption length", captionLength, it.length)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun method(): String = "sendAnimation"
|
|
||||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<AnimationContent>>
|
|
||||||
get() = commonResultDeserializer
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
}
|
|
||||||
|
|
||||||
data class SendAnimationFiles internal constructor(
|
|
||||||
val animation: MultipartFile? = null,
|
|
||||||
val thumb: MultipartFile? = null
|
|
||||||
) : Files by mapOfNotNull(
|
|
||||||
animationField to animation,
|
|
||||||
thumbField to thumb
|
|
||||||
)
|
|
||||||
@@ -1,117 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Performerable
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.AudioContent
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.throwRangeError
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
fun SendAudio(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
audio: InputFile,
|
|
||||||
thumb: InputFile? = null,
|
|
||||||
caption: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
duration: Long? = null,
|
|
||||||
performer: String? = null,
|
|
||||||
title: String? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
): Request<ContentMessage<AudioContent>> {
|
|
||||||
val audioAsFileId = (audio as? FileId) ?.fileId
|
|
||||||
val audioAsFile = audio as? MultipartFile
|
|
||||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
|
||||||
val thumbAsFile = thumb as? MultipartFile
|
|
||||||
|
|
||||||
val data = SendAudioData(
|
|
||||||
chatId,
|
|
||||||
audioAsFileId,
|
|
||||||
thumbAsFileId,
|
|
||||||
caption,
|
|
||||||
parseMode,
|
|
||||||
duration,
|
|
||||||
performer,
|
|
||||||
title,
|
|
||||||
disableNotification,
|
|
||||||
replyToMessageId,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
return if (audioAsFile == null && thumbAsFile == null) {
|
|
||||||
data
|
|
||||||
} else {
|
|
||||||
MultipartRequestImpl(
|
|
||||||
data,
|
|
||||||
SendAudioFiles(audioAsFile, thumbAsFile)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<AudioContent>>
|
|
||||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class SendAudioData internal constructor(
|
|
||||||
@SerialName(chatIdField)
|
|
||||||
override val chatId: ChatIdentifier,
|
|
||||||
@SerialName(audioField)
|
|
||||||
val audio: String? = null,
|
|
||||||
@SerialName(thumbField)
|
|
||||||
override val thumb: String? = null,
|
|
||||||
@SerialName(captionField)
|
|
||||||
override val text: String? = null,
|
|
||||||
@SerialName(parseModeField)
|
|
||||||
override val parseMode: ParseMode? = null,
|
|
||||||
@SerialName(durationField)
|
|
||||||
override val duration: Long? = null,
|
|
||||||
@SerialName(performerField)
|
|
||||||
override val performer: String? = null,
|
|
||||||
@SerialName(titleField)
|
|
||||||
override val title: String? = null,
|
|
||||||
@SerialName(disableNotificationField)
|
|
||||||
override val disableNotification: Boolean = false,
|
|
||||||
@SerialName(replyToMessageIdField)
|
|
||||||
override val replyToMessageId: MessageIdentifier? = null,
|
|
||||||
@SerialName(replyMarkupField)
|
|
||||||
override val replyMarkup: KeyboardMarkup? = null
|
|
||||||
) : DataRequest<ContentMessage<AudioContent>>,
|
|
||||||
SendMessageRequest<ContentMessage<AudioContent>>,
|
|
||||||
ReplyingMarkupSendMessageRequest<ContentMessage<AudioContent>>,
|
|
||||||
TextableSendMessageRequest<ContentMessage<AudioContent>>,
|
|
||||||
ThumbedSendMessageRequest<ContentMessage<AudioContent>>,
|
|
||||||
TitledSendMessageRequest<ContentMessage<AudioContent>>,
|
|
||||||
DuratedSendMessageRequest<ContentMessage<AudioContent>>,
|
|
||||||
Performerable
|
|
||||||
{
|
|
||||||
init {
|
|
||||||
text ?.let {
|
|
||||||
if (it.length !in captionLength) {
|
|
||||||
throwRangeError("Caption length", captionLength, it.length)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun method(): String = "sendAudio"
|
|
||||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<AudioContent>>
|
|
||||||
get() = commonResultDeserializer
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
}
|
|
||||||
|
|
||||||
data class SendAudioFiles internal constructor(
|
|
||||||
val audio: MultipartFile? = null,
|
|
||||||
val thumb: MultipartFile? = null
|
|
||||||
) : Files by mapOfNotNull(
|
|
||||||
audioField to audio,
|
|
||||||
thumbField to thumb
|
|
||||||
)
|
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.DocumentContent
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.throwRangeError
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
fun SendDocument(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
document: InputFile,
|
|
||||||
thumb: InputFile? = null,
|
|
||||||
caption: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
): Request<ContentMessage<DocumentContent>> {
|
|
||||||
val documentAsFileId = (document as? FileId) ?.fileId
|
|
||||||
val documentAsFile = document as? MultipartFile
|
|
||||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
|
||||||
val thumbAsFile = thumb as? MultipartFile
|
|
||||||
|
|
||||||
val data = SendDocumentData(
|
|
||||||
chatId,
|
|
||||||
documentAsFileId,
|
|
||||||
thumbAsFileId,
|
|
||||||
caption,
|
|
||||||
parseMode,
|
|
||||||
disableNotification,
|
|
||||||
replyToMessageId,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
return if (documentAsFile == null && thumbAsFile == null) {
|
|
||||||
data
|
|
||||||
} else {
|
|
||||||
MultipartRequestImpl(
|
|
||||||
data,
|
|
||||||
SendDocumentFiles(documentAsFile, thumbAsFile)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<DocumentContent>>
|
|
||||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class SendDocumentData internal constructor(
|
|
||||||
@SerialName(chatIdField)
|
|
||||||
override val chatId: ChatIdentifier,
|
|
||||||
@SerialName(documentField)
|
|
||||||
val document: String? = null,
|
|
||||||
@SerialName(thumbField)
|
|
||||||
override val thumb: String? = null,
|
|
||||||
@SerialName(captionField)
|
|
||||||
override val text: String? = null,
|
|
||||||
@SerialName(parseModeField)
|
|
||||||
override val parseMode: ParseMode? = null,
|
|
||||||
@SerialName(disableNotificationField)
|
|
||||||
override val disableNotification: Boolean = false,
|
|
||||||
@SerialName(replyToMessageIdField)
|
|
||||||
override val replyToMessageId: MessageIdentifier? = null,
|
|
||||||
@SerialName(replyMarkupField)
|
|
||||||
override val replyMarkup: KeyboardMarkup? = null
|
|
||||||
) : DataRequest<ContentMessage<DocumentContent>>,
|
|
||||||
SendMessageRequest<ContentMessage<DocumentContent>>,
|
|
||||||
ReplyingMarkupSendMessageRequest<ContentMessage<DocumentContent>>,
|
|
||||||
TextableSendMessageRequest<ContentMessage<DocumentContent>>,
|
|
||||||
ThumbedSendMessageRequest<ContentMessage<DocumentContent>>
|
|
||||||
{
|
|
||||||
init {
|
|
||||||
text ?.let {
|
|
||||||
if (it.length !in captionLength) {
|
|
||||||
throwRangeError("Caption length", captionLength, it.length)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun method(): String = "sendDocument"
|
|
||||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<DocumentContent>>
|
|
||||||
get() = commonResultDeserializer
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
}
|
|
||||||
|
|
||||||
data class SendDocumentFiles internal constructor(
|
|
||||||
val document: MultipartFile? = null,
|
|
||||||
val thumb: MultipartFile? = null
|
|
||||||
) : Files by mapOfNotNull(
|
|
||||||
documentField to document,
|
|
||||||
thumbField to thumb
|
|
||||||
)
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaGroupMessage
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializerClass
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.throwRangeError
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
import kotlinx.serialization.builtins.ListSerializer
|
|
||||||
import kotlinx.serialization.json.buildJsonArray
|
|
||||||
|
|
||||||
fun SendMediaGroup(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
media: List<MediaGroupMemberInputMedia>,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null
|
|
||||||
): Request<List<MediaGroupMessage>> {
|
|
||||||
if (media.size !in mediaCountInMediaGroup) {
|
|
||||||
throwRangeError("Count of members in media group", mediaCountInMediaGroup, media.size)
|
|
||||||
}
|
|
||||||
|
|
||||||
val files: List<MultipartFile> = media.flatMap {
|
|
||||||
listOfNotNull(
|
|
||||||
it.file as? MultipartFile,
|
|
||||||
if (it is ThumbedInputMedia) {
|
|
||||||
it.thumb as? MultipartFile
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
val data = SendMediaGroupData(
|
|
||||||
chatId,
|
|
||||||
media,
|
|
||||||
disableNotification,
|
|
||||||
replyToMessageId
|
|
||||||
)
|
|
||||||
|
|
||||||
return if (files.isEmpty()) {
|
|
||||||
data
|
|
||||||
} else {
|
|
||||||
MultipartRequestImpl(
|
|
||||||
data,
|
|
||||||
SendMediaGroupFiles(files)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private val messagesListSerializer: KSerializer<List<MediaGroupMessage>>
|
|
||||||
= ListSerializer(TelegramBotAPIMessageDeserializeOnlySerializerClass())
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class SendMediaGroupData internal constructor(
|
|
||||||
@SerialName(chatIdField)
|
|
||||||
override val chatId: ChatIdentifier,
|
|
||||||
val media: List<MediaGroupMemberInputMedia> = emptyList(),
|
|
||||||
@SerialName(disableNotificationField)
|
|
||||||
override val disableNotification: Boolean = false,
|
|
||||||
@SerialName(replyToMessageIdField)
|
|
||||||
override val replyToMessageId: MessageIdentifier? = null
|
|
||||||
) : DataRequest<List<MediaGroupMessage>>, SendMessageRequest<List<MediaGroupMessage>> {
|
|
||||||
@SerialName(mediaField)
|
|
||||||
private val convertedMedia: String
|
|
||||||
get() = buildJsonArray {
|
|
||||||
media.forEach {
|
|
||||||
add(it.toJsonWithoutNulls(MediaGroupMemberInputMediaSerializer))
|
|
||||||
}
|
|
||||||
}.toString()
|
|
||||||
|
|
||||||
|
|
||||||
override fun method(): String = "sendMediaGroup"
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
override val resultDeserializer: DeserializationStrategy<List<MediaGroupMessage>>
|
|
||||||
get() = messagesListSerializer
|
|
||||||
}
|
|
||||||
|
|
||||||
data class SendMediaGroupFiles internal constructor(
|
|
||||||
val files: List<MultipartFile>
|
|
||||||
) : Files by (files.map { it.fileId to it }.toMap())
|
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.PhotoContent
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.throwRangeError
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
fun SendPhoto(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
photo: InputFile,
|
|
||||||
caption: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
): Request<ContentMessage<PhotoContent>> {
|
|
||||||
val data = SendPhotoData(
|
|
||||||
chatId,
|
|
||||||
(photo as? FileId) ?.fileId,
|
|
||||||
caption,
|
|
||||||
parseMode,
|
|
||||||
disableNotification,
|
|
||||||
replyToMessageId,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
return data.photo ?.let {
|
|
||||||
data
|
|
||||||
} ?: MultipartRequestImpl(
|
|
||||||
data,
|
|
||||||
SendPhotoFiles(photo as MultipartFile)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<PhotoContent>>
|
|
||||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class SendPhotoData internal constructor(
|
|
||||||
@SerialName(chatIdField)
|
|
||||||
override val chatId: ChatIdentifier,
|
|
||||||
@SerialName(photoField)
|
|
||||||
val photo: String? = null,
|
|
||||||
@SerialName(captionField)
|
|
||||||
override val text: String? = null,
|
|
||||||
@SerialName(parseModeField)
|
|
||||||
override val parseMode: ParseMode? = null,
|
|
||||||
@SerialName(disableNotificationField)
|
|
||||||
override val disableNotification: Boolean = false,
|
|
||||||
@SerialName(replyToMessageIdField)
|
|
||||||
override val replyToMessageId: MessageIdentifier? = null,
|
|
||||||
@SerialName(replyMarkupField)
|
|
||||||
override val replyMarkup: KeyboardMarkup? = null
|
|
||||||
) : DataRequest<ContentMessage<PhotoContent>>,
|
|
||||||
SendMessageRequest<ContentMessage<PhotoContent>>,
|
|
||||||
ReplyingMarkupSendMessageRequest<ContentMessage<PhotoContent>>,
|
|
||||||
TextableSendMessageRequest<ContentMessage<PhotoContent>>
|
|
||||||
{
|
|
||||||
init {
|
|
||||||
text ?.let {
|
|
||||||
if (it.length !in captionLength) {
|
|
||||||
throwRangeError("Caption length", captionLength, it.length)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun method(): String = "sendPhoto"
|
|
||||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<PhotoContent>>
|
|
||||||
get() = commonResultDeserializer
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
}
|
|
||||||
|
|
||||||
data class SendPhotoFiles internal constructor(
|
|
||||||
val photo: MultipartFile
|
|
||||||
) : Files by mapOf(
|
|
||||||
photoField to photo
|
|
||||||
)
|
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.VideoContent
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.throwRangeError
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
fun SendVideo(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
video: InputFile,
|
|
||||||
thumb: InputFile? = null,
|
|
||||||
caption: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
duration: Long? = null,
|
|
||||||
width: Int? = null,
|
|
||||||
height: Int? = null,
|
|
||||||
supportStreaming: Boolean? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
): Request<ContentMessage<VideoContent>> {
|
|
||||||
val videoAsFileId = (video as? FileId) ?.fileId
|
|
||||||
val videoAsFile = video as? MultipartFile
|
|
||||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
|
||||||
val thumbAsFile = thumb as? MultipartFile
|
|
||||||
|
|
||||||
val data = SendVideoData(
|
|
||||||
chatId,
|
|
||||||
videoAsFileId,
|
|
||||||
thumbAsFileId,
|
|
||||||
caption,
|
|
||||||
parseMode,
|
|
||||||
duration,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
supportStreaming,
|
|
||||||
disableNotification,
|
|
||||||
replyToMessageId,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
return if (videoAsFile == null && thumbAsFile == null) {
|
|
||||||
data
|
|
||||||
} else {
|
|
||||||
MultipartRequestImpl(
|
|
||||||
data,
|
|
||||||
SendVideoFiles(videoAsFile, thumbAsFile)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<VideoContent>>
|
|
||||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class SendVideoData internal constructor(
|
|
||||||
@SerialName(chatIdField)
|
|
||||||
override val chatId: ChatIdentifier,
|
|
||||||
@SerialName(videoField)
|
|
||||||
val video: String? = null,
|
|
||||||
@SerialName(thumbField)
|
|
||||||
override val thumb: String? = null,
|
|
||||||
@SerialName(captionField)
|
|
||||||
override val text: String? = null,
|
|
||||||
@SerialName(parseModeField)
|
|
||||||
override val parseMode: ParseMode? = null,
|
|
||||||
@SerialName(durationField)
|
|
||||||
override val duration: Long? = null,
|
|
||||||
@SerialName(widthField)
|
|
||||||
override val width: Int? = null,
|
|
||||||
@SerialName(heightField)
|
|
||||||
override val height: Int? = null,
|
|
||||||
@SerialName(supportStreamingField)
|
|
||||||
val supportStreaming: Boolean? = null,
|
|
||||||
@SerialName(disableNotificationField)
|
|
||||||
override val disableNotification: Boolean = false,
|
|
||||||
@SerialName(replyToMessageIdField)
|
|
||||||
override val replyToMessageId: MessageIdentifier? = null,
|
|
||||||
@SerialName(replyMarkupField)
|
|
||||||
override val replyMarkup: KeyboardMarkup? = null
|
|
||||||
) : DataRequest<ContentMessage<VideoContent>>,
|
|
||||||
SendMessageRequest<ContentMessage<VideoContent>>,
|
|
||||||
ReplyingMarkupSendMessageRequest<ContentMessage<VideoContent>>,
|
|
||||||
TextableSendMessageRequest<ContentMessage<VideoContent>>,
|
|
||||||
ThumbedSendMessageRequest<ContentMessage<VideoContent>>,
|
|
||||||
DuratedSendMessageRequest<ContentMessage<VideoContent>>,
|
|
||||||
SizedSendMessageRequest<ContentMessage<VideoContent>>
|
|
||||||
{
|
|
||||||
init {
|
|
||||||
text ?.let {
|
|
||||||
if (it.length !in captionLength) {
|
|
||||||
throwRangeError("Caption length", captionLength, it.length)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun method(): String = "sendVideo"
|
|
||||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<VideoContent>>
|
|
||||||
get() = commonResultDeserializer
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
}
|
|
||||||
|
|
||||||
data class SendVideoFiles internal constructor(
|
|
||||||
val video: MultipartFile? = null,
|
|
||||||
val thumb: MultipartFile? = null
|
|
||||||
) : Files by mapOfNotNull(
|
|
||||||
videoField to video,
|
|
||||||
thumbField to thumb
|
|
||||||
)
|
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.VoiceContent
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.throwRangeError
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
fun SendVoice(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
voice: InputFile,
|
|
||||||
thumb: InputFile? = null,
|
|
||||||
caption: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
duration: Long? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
): Request<ContentMessage<VoiceContent>> {
|
|
||||||
val voiceAsFileId = (voice as? FileId) ?.fileId
|
|
||||||
val voiceAsFile = voice as? MultipartFile
|
|
||||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
|
||||||
val thumbAsFile = thumb as? MultipartFile
|
|
||||||
|
|
||||||
val data = SendVoiceData(
|
|
||||||
chatId,
|
|
||||||
voiceAsFileId,
|
|
||||||
thumbAsFileId,
|
|
||||||
caption,
|
|
||||||
parseMode,
|
|
||||||
duration,
|
|
||||||
disableNotification,
|
|
||||||
replyToMessageId,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
return if (voiceAsFile == null && thumbAsFile == null) {
|
|
||||||
data
|
|
||||||
} else {
|
|
||||||
MultipartRequestImpl(
|
|
||||||
data,
|
|
||||||
SendVoiceFiles(voiceAsFile, thumbAsFile)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<VoiceContent>>
|
|
||||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class SendVoiceData internal constructor(
|
|
||||||
@SerialName(chatIdField)
|
|
||||||
override val chatId: ChatIdentifier,
|
|
||||||
@SerialName(voiceField)
|
|
||||||
val voice: String? = null,
|
|
||||||
@SerialName(thumbField)
|
|
||||||
override val thumb: String? = null,
|
|
||||||
@SerialName(captionField)
|
|
||||||
override val text: String? = null,
|
|
||||||
@SerialName(parseModeField)
|
|
||||||
override val parseMode: ParseMode? = null,
|
|
||||||
@SerialName(durationField)
|
|
||||||
override val duration: Long? = null,
|
|
||||||
@SerialName(disableNotificationField)
|
|
||||||
override val disableNotification: Boolean = false,
|
|
||||||
@SerialName(replyToMessageIdField)
|
|
||||||
override val replyToMessageId: MessageIdentifier? = null,
|
|
||||||
@SerialName(replyMarkupField)
|
|
||||||
override val replyMarkup: KeyboardMarkup? = null
|
|
||||||
) : DataRequest<ContentMessage<VoiceContent>>,
|
|
||||||
SendMessageRequest<ContentMessage<VoiceContent>>,
|
|
||||||
ReplyingMarkupSendMessageRequest<ContentMessage<VoiceContent>>,
|
|
||||||
TextableSendMessageRequest<ContentMessage<VoiceContent>>,
|
|
||||||
ThumbedSendMessageRequest<ContentMessage<VoiceContent>>,
|
|
||||||
DuratedSendMessageRequest<ContentMessage<VoiceContent>>
|
|
||||||
{
|
|
||||||
init {
|
|
||||||
text ?.let {
|
|
||||||
if (it.length !in captionLength) {
|
|
||||||
throwRangeError("Caption length", captionLength, it.length)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun method(): String = "sendVoice"
|
|
||||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<VoiceContent>>
|
|
||||||
get() = commonResultDeserializer
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
}
|
|
||||||
|
|
||||||
data class SendVoiceFiles internal constructor(
|
|
||||||
val voice: MultipartFile? = null,
|
|
||||||
val thumb: MultipartFile? = null
|
|
||||||
) : Files by mapOfNotNull(
|
|
||||||
voiceField to voice,
|
|
||||||
thumbField to thumb
|
|
||||||
)
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
|
||||||
|
|
||||||
interface DataRequest<T: Any> : SimpleRequest<T>
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
|
||||||
|
|
||||||
typealias Files = Map<String, MultipartFile>
|
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.payments
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.InvoiceContent
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.LabeledPrice
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.LabeledPricesSerializer
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.abstracts.*
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
private val invoiceMessageSerializer: DeserializationStrategy<ContentMessage<InvoiceContent>>
|
|
||||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param providerData - JSON-ENCODED FIELD
|
|
||||||
*/
|
|
||||||
@Serializable
|
|
||||||
data class SendInvoice(
|
|
||||||
@SerialName(chatIdField)
|
|
||||||
override val chatId: ChatId,
|
|
||||||
@SerialName(titleField)
|
|
||||||
val title: String,
|
|
||||||
@SerialName(descriptionField)
|
|
||||||
val description: String,
|
|
||||||
@SerialName(payloadField)
|
|
||||||
val payload: String,
|
|
||||||
@SerialName(providerTokenField)
|
|
||||||
val providerToken: String,
|
|
||||||
@SerialName(startParameterField)
|
|
||||||
val startParameter: StartParameter,
|
|
||||||
@SerialName(currencyField)
|
|
||||||
override val currency: Currency,
|
|
||||||
@Serializable(LabeledPricesSerializer::class)
|
|
||||||
@SerialName(pricesField)
|
|
||||||
override val prices: List<LabeledPrice>,
|
|
||||||
@SerialName(providerDataField)
|
|
||||||
val providerData: String? = null,
|
|
||||||
@SerialName(requireNameField)
|
|
||||||
val requireName: Boolean = false,
|
|
||||||
@SerialName(requirePhoneNumberField)
|
|
||||||
val requirePhoneNumber: Boolean = false,
|
|
||||||
@SerialName(requireEmailField)
|
|
||||||
val requireEmail: Boolean = false,
|
|
||||||
@SerialName(requireShippingAddressField)
|
|
||||||
val requireShippingAddress: Boolean = false,
|
|
||||||
@SerialName(shouldSendPhoneNumberToProviderField)
|
|
||||||
val shouldSendPhoneNumberToProvider: Boolean = false,
|
|
||||||
@SerialName(shouldSendEmailToProviderField)
|
|
||||||
val shouldSendEmailToProvider: Boolean = false,
|
|
||||||
@SerialName(priceDependOnShipAddressField)
|
|
||||||
val priceDependOnShipAddress: Boolean = false,
|
|
||||||
@SerialName(disableNotificationField)
|
|
||||||
override val disableNotification: Boolean = false,
|
|
||||||
@SerialName(replyToMessageIdField)
|
|
||||||
override val replyToMessageId: MessageIdentifier? = null,
|
|
||||||
@SerialName(replyMarkupField)
|
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
|
||||||
) : Currencied,
|
|
||||||
Priced,
|
|
||||||
ChatRequest,
|
|
||||||
DisableNotification,
|
|
||||||
ReplyMessageId,
|
|
||||||
ReplyMarkup,
|
|
||||||
SendMessageRequest<ContentMessage<InvoiceContent>> {
|
|
||||||
override fun method(): String = "sendInvoice"
|
|
||||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<InvoiceContent>>
|
|
||||||
get() = invoiceMessageSerializer
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
|
|
||||||
@SerialName(photoUrlField)
|
|
||||||
var photoUrl: String? = null
|
|
||||||
private set
|
|
||||||
@SerialName(photoSizeField)
|
|
||||||
var photoSize: Long? = null
|
|
||||||
private set
|
|
||||||
|
|
||||||
@SerialName(photoWidthField)
|
|
||||||
var photoWidth: Int? = null
|
|
||||||
private set
|
|
||||||
@SerialName(photoHeightField)
|
|
||||||
var photoHeight: Int? = null
|
|
||||||
private set
|
|
||||||
|
|
||||||
fun setPhoto(
|
|
||||||
photoUrl: String,
|
|
||||||
photoSize: Long? = null,
|
|
||||||
photoWidth: Int? = null,
|
|
||||||
photoHeight: Int? = null
|
|
||||||
) {
|
|
||||||
this.photoUrl = photoUrl
|
|
||||||
this.photoSize = photoSize
|
|
||||||
this.photoWidth = photoWidth
|
|
||||||
this.photoHeight = photoHeight
|
|
||||||
}
|
|
||||||
|
|
||||||
fun unsetPhoto() {
|
|
||||||
photoUrl = null
|
|
||||||
photoSize = null
|
|
||||||
photoWidth = null
|
|
||||||
photoHeight = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,241 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.polls
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.ReplyingMarkupSendMessageRequest
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.MarkdownV2
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.PollContent
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.fullListOfSubSource
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownV2Captions
|
|
||||||
import com.soywiz.klock.DateTime
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<PollContent>> = TelegramBotAPIMessageDeserializationStrategyClass()
|
|
||||||
|
|
||||||
private fun checkPollInfo(
|
|
||||||
question: String,
|
|
||||||
options: List<String>
|
|
||||||
) {
|
|
||||||
if (question.length !in pollQuestionTextLength) {
|
|
||||||
throw IllegalArgumentException("The length of questions for polls must be in $pollQuestionTextLength range, but was ${question.length}")
|
|
||||||
}
|
|
||||||
options.forEach {
|
|
||||||
if (it.length !in pollOptionTextLength) {
|
|
||||||
throw IllegalArgumentException("The length of question option text for polls must be in $pollOptionTextLength range, but was ${it.length}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (options.size !in pollOptionsLimit) {
|
|
||||||
throw IllegalArgumentException("The amount of question options for polls must be in $pollOptionsLimit range, but was ${options.size}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun SendPoll(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
question: String,
|
|
||||||
options: List<String>,
|
|
||||||
isAnonymous: Boolean = true,
|
|
||||||
isClosed: Boolean = false,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = SendRegularPoll(
|
|
||||||
chatId,
|
|
||||||
question,
|
|
||||||
options,
|
|
||||||
isAnonymous,
|
|
||||||
isClosed,
|
|
||||||
disableNotification = disableNotification,
|
|
||||||
replyToMessageId = replyToMessageId,
|
|
||||||
replyMarkup = replyMarkup
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return [SendPoll] in case when all is right. It can return [SendRegularPoll] for [QuizPoll] in case if
|
|
||||||
* [QuizPoll.correctOptionId] equal to null
|
|
||||||
*/
|
|
||||||
fun Poll.createRequest(
|
|
||||||
chatId: ChatIdentifier,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = when (this) {
|
|
||||||
is RegularPoll -> SendRegularPoll(
|
|
||||||
chatId,
|
|
||||||
question,
|
|
||||||
options.map { it.text },
|
|
||||||
isAnonymous,
|
|
||||||
isClosed,
|
|
||||||
allowMultipleAnswers,
|
|
||||||
scheduledCloseInfo,
|
|
||||||
disableNotification,
|
|
||||||
replyToMessageId,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
is QuizPoll -> correctOptionId ?.let { correctOptionId ->
|
|
||||||
SendQuizPoll(
|
|
||||||
chatId,
|
|
||||||
question,
|
|
||||||
options.map { it.text },
|
|
||||||
correctOptionId,
|
|
||||||
isAnonymous,
|
|
||||||
isClosed,
|
|
||||||
explanation ?.fullListOfSubSource(explanationEntities) ?.justTextSources() ?.toMarkdownV2Captions() ?.firstOrNull(),
|
|
||||||
MarkdownV2,
|
|
||||||
scheduledCloseInfo,
|
|
||||||
disableNotification,
|
|
||||||
replyToMessageId,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
} ?: SendRegularPoll(
|
|
||||||
chatId,
|
|
||||||
question,
|
|
||||||
options.map { it.text },
|
|
||||||
isAnonymous,
|
|
||||||
isClosed,
|
|
||||||
false,
|
|
||||||
scheduledCloseInfo,
|
|
||||||
disableNotification,
|
|
||||||
replyToMessageId,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
is UnknownPollType -> SendRegularPoll(
|
|
||||||
chatId,
|
|
||||||
question,
|
|
||||||
options.map { it.text },
|
|
||||||
isAnonymous,
|
|
||||||
isClosed,
|
|
||||||
false,
|
|
||||||
scheduledCloseInfo,
|
|
||||||
disableNotification,
|
|
||||||
replyToMessageId,
|
|
||||||
replyMarkup
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun ScheduledCloseInfo.checkSendData() {
|
|
||||||
val span = when (this) {
|
|
||||||
is ExactScheduledCloseInfo -> (closeDateTime - DateTime.now()).seconds
|
|
||||||
is ApproximateScheduledCloseInfo -> openDuration.seconds
|
|
||||||
}.toInt()
|
|
||||||
if (span !in openPeriodPollSecondsLimit) {
|
|
||||||
error("Duration of autoclose for polls must be in range $openPeriodPollSecondsLimit, but was $span")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sealed class SendPoll : SendMessageRequest<ContentMessage<PollContent>>,
|
|
||||||
ReplyingMarkupSendMessageRequest<ContentMessage<PollContent>> {
|
|
||||||
abstract val question: String
|
|
||||||
abstract val options: List<String>
|
|
||||||
abstract val isAnonymous: Boolean
|
|
||||||
abstract val isClosed: Boolean
|
|
||||||
abstract val closeInfo: ScheduledCloseInfo?
|
|
||||||
abstract val type: String
|
|
||||||
|
|
||||||
internal abstract val openPeriod: LongSeconds?
|
|
||||||
internal abstract val closeDate: LongSeconds?
|
|
||||||
|
|
||||||
override fun method(): String = "sendPoll"
|
|
||||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<PollContent>>
|
|
||||||
get() = commonResultDeserializer
|
|
||||||
}
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class SendRegularPoll(
|
|
||||||
@SerialName(chatIdField)
|
|
||||||
override val chatId: ChatIdentifier,
|
|
||||||
@SerialName(questionField)
|
|
||||||
override val question: String,
|
|
||||||
@SerialName(optionsField)
|
|
||||||
override val options: List<String>,
|
|
||||||
@SerialName(isAnonymousField)
|
|
||||||
override val isAnonymous: Boolean = true,
|
|
||||||
@SerialName(isClosedField)
|
|
||||||
override val isClosed: Boolean = false,
|
|
||||||
@SerialName(allowsMultipleAnswersField)
|
|
||||||
val allowMultipleAnswers: Boolean = false,
|
|
||||||
@Transient
|
|
||||||
override val closeInfo: ScheduledCloseInfo? = null,
|
|
||||||
@SerialName(disableNotificationField)
|
|
||||||
override val disableNotification: Boolean = false,
|
|
||||||
@SerialName(replyToMessageIdField)
|
|
||||||
override val replyToMessageId: MessageIdentifier? = null,
|
|
||||||
@SerialName(replyMarkupField)
|
|
||||||
override val replyMarkup: KeyboardMarkup? = null
|
|
||||||
) : SendPoll() {
|
|
||||||
override val type: String = regularPollType
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
|
|
||||||
@SerialName(openPeriodField)
|
|
||||||
override val openPeriod: LongSeconds?
|
|
||||||
= (closeInfo as? ApproximateScheduledCloseInfo) ?.openDuration ?.millisecondsLong ?.div(1000)
|
|
||||||
|
|
||||||
@SerialName(closeDateField)
|
|
||||||
override val closeDate: LongSeconds?
|
|
||||||
= (closeInfo as? ExactScheduledCloseInfo) ?.closeDateTime ?.unixMillisLong ?.div(1000)
|
|
||||||
|
|
||||||
init {
|
|
||||||
checkPollInfo(question, options)
|
|
||||||
closeInfo ?.checkSendData()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class SendQuizPoll(
|
|
||||||
@SerialName(chatIdField)
|
|
||||||
override val chatId: ChatIdentifier,
|
|
||||||
@SerialName(questionField)
|
|
||||||
override val question: String,
|
|
||||||
@SerialName(optionsField)
|
|
||||||
override val options: List<String>,
|
|
||||||
@SerialName(correctOptionIdField)
|
|
||||||
val correctOptionId: Int,
|
|
||||||
@SerialName(isAnonymousField)
|
|
||||||
override val isAnonymous: Boolean = true,
|
|
||||||
@SerialName(isClosedField)
|
|
||||||
override val isClosed: Boolean = false,
|
|
||||||
@SerialName(explanationField)
|
|
||||||
override val explanation: String? = null,
|
|
||||||
@SerialName(explanationParseModeField)
|
|
||||||
override val parseMode: ParseMode? = null,
|
|
||||||
@Transient
|
|
||||||
override val closeInfo: ScheduledCloseInfo? = null,
|
|
||||||
@SerialName(disableNotificationField)
|
|
||||||
override val disableNotification: Boolean = false,
|
|
||||||
@SerialName(replyToMessageIdField)
|
|
||||||
override val replyToMessageId: MessageIdentifier? = null,
|
|
||||||
@SerialName(replyMarkupField)
|
|
||||||
override val replyMarkup: KeyboardMarkup? = null
|
|
||||||
) : SendPoll(), ExplainedOutput {
|
|
||||||
override val type: String = quizPollType
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
|
|
||||||
@SerialName(openPeriodField)
|
|
||||||
override val openPeriod: LongSeconds?
|
|
||||||
= (closeInfo as? ApproximateScheduledCloseInfo) ?.openDuration ?.millisecondsLong ?.div(1000)
|
|
||||||
|
|
||||||
@SerialName(closeDateField)
|
|
||||||
override val closeDate: LongSeconds?
|
|
||||||
= (closeInfo as? ExactScheduledCloseInfo) ?.closeDateTime ?.unixMillisLong ?.div(1000)
|
|
||||||
|
|
||||||
init {
|
|
||||||
checkPollInfo(question, options)
|
|
||||||
closeInfo ?.checkSendData()
|
|
||||||
val correctOptionIdRange = 0 .. options.size
|
|
||||||
if (correctOptionId !in correctOptionIdRange) {
|
|
||||||
throw IllegalArgumentException("Correct option id must be in range of $correctOptionIdRange, but actual " +
|
|
||||||
"value is $correctOptionId")
|
|
||||||
}
|
|
||||||
if (explanation != null && explanation.length !in explanationLimit) {
|
|
||||||
error("Quiz poll explanation size must be in range $explanationLimit," +
|
|
||||||
"but actual explanation contains ${explanation.length} symbols")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.common.CommonMultipartFileRequest
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StandardStickerSetAction
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
fun CreateNewAnimatedStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
sticker: InputFile,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
): Request<Boolean> {
|
|
||||||
val data = CreateNewAnimatedStickerSet(userId, name, emojis, sticker as? FileId, containsMasks, maskPosition)
|
|
||||||
return when (sticker) {
|
|
||||||
is MultipartFile -> CommonMultipartFileRequest(
|
|
||||||
data,
|
|
||||||
mapOf(pngStickerField to sticker)
|
|
||||||
)
|
|
||||||
is FileId -> data
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class CreateNewAnimatedStickerSet internal constructor(
|
|
||||||
@SerialName(userIdField)
|
|
||||||
override val userId: UserId,
|
|
||||||
@SerialName(nameField)
|
|
||||||
override val name: String,
|
|
||||||
@SerialName(emojisField)
|
|
||||||
override val emojis: String,
|
|
||||||
@SerialName(tgsStickerField)
|
|
||||||
val sticker: FileId? = null,
|
|
||||||
@SerialName(containsMasksField)
|
|
||||||
val containsMasks: Boolean? = null,
|
|
||||||
@SerialName(maskPositionField)
|
|
||||||
override val maskPosition: MaskPosition? = null
|
|
||||||
) : StandardStickerSetAction {
|
|
||||||
init {
|
|
||||||
if(emojis.isEmpty()) {
|
|
||||||
throw IllegalArgumentException("Emojis must not be empty")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
|
|
||||||
override fun method(): String = "createNewStickerSet"
|
|
||||||
}
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.common.CommonMultipartFileRequest
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StandardStickerSetAction
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
fun CreateNewStaticStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
sticker: InputFile,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
): Request<Boolean> {
|
|
||||||
val data = CreateNewStaticStickerSet(userId, name, emojis, sticker as? FileId, containsMasks, maskPosition)
|
|
||||||
return when (sticker) {
|
|
||||||
is MultipartFile -> CommonMultipartFileRequest(
|
|
||||||
data,
|
|
||||||
mapOf(pngStickerField to sticker)
|
|
||||||
)
|
|
||||||
is FileId -> data
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun CreateNewStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
sticker: InputFile,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
): Request<Boolean> = CreateNewStaticStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition)
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class CreateNewStaticStickerSet internal constructor(
|
|
||||||
@SerialName(userIdField)
|
|
||||||
override val userId: UserId,
|
|
||||||
@SerialName(nameField)
|
|
||||||
override val name: String,
|
|
||||||
@SerialName(emojisField)
|
|
||||||
override val emojis: String,
|
|
||||||
@SerialName(pngStickerField)
|
|
||||||
val sticker: FileId? = null,
|
|
||||||
@SerialName(containsMasksField)
|
|
||||||
val containsMasks: Boolean? = null,
|
|
||||||
@SerialName(maskPositionField)
|
|
||||||
override val maskPosition: MaskPosition? = null
|
|
||||||
) : StandardStickerSetAction {
|
|
||||||
init {
|
|
||||||
if(emojis.isEmpty()) {
|
|
||||||
throw IllegalArgumentException("Emojis must not be empty")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
|
|
||||||
override fun method(): String = "createNewStickerSet"
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
|
||||||
|
|
||||||
interface StandardStickerSetAction : StickerSetAction {
|
|
||||||
val emojis: String // must be more than one
|
|
||||||
val maskPosition: MaskPosition?
|
|
||||||
}
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.webhook
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.DataRequest
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.MultipartRequestImpl
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
import kotlinx.serialization.builtins.serializer
|
|
||||||
|
|
||||||
private fun correctWebhookUrl(sourceUrl: String) = if (sourceUrl.contains("://")) {
|
|
||||||
sourceUrl
|
|
||||||
} else {
|
|
||||||
"https://$sourceUrl"
|
|
||||||
}
|
|
||||||
|
|
||||||
fun SetWebhook(
|
|
||||||
url: String,
|
|
||||||
certificate: MultipartFile,
|
|
||||||
maxAllowedConnections: Int? = null,
|
|
||||||
allowedUpdates: List<String>? = null
|
|
||||||
): MultipartRequestImpl<SetWebhook, Map<String, MultipartFile>, Boolean> = MultipartRequestImpl(
|
|
||||||
SetWebhook(
|
|
||||||
correctWebhookUrl(url),
|
|
||||||
null,
|
|
||||||
maxAllowedConnections,
|
|
||||||
allowedUpdates
|
|
||||||
),
|
|
||||||
mapOf(certificateField to certificate)
|
|
||||||
)
|
|
||||||
|
|
||||||
fun SetWebhook(
|
|
||||||
url: String,
|
|
||||||
certificate: FileId,
|
|
||||||
maxAllowedConnections: Int? = null,
|
|
||||||
allowedUpdates: List<String>? = null
|
|
||||||
): SetWebhook = SetWebhook(
|
|
||||||
correctWebhookUrl(url),
|
|
||||||
certificate.fileId,
|
|
||||||
maxAllowedConnections,
|
|
||||||
allowedUpdates
|
|
||||||
)
|
|
||||||
|
|
||||||
@Suppress("USELESS_CAST")
|
|
||||||
fun SetWebhook(
|
|
||||||
url: String,
|
|
||||||
certificate: InputFile,
|
|
||||||
maxAllowedConnections: Int? = null,
|
|
||||||
allowedUpdates: List<String>? = null
|
|
||||||
): Request<Boolean> = when (certificate) {
|
|
||||||
is MultipartFile -> SetWebhook(correctWebhookUrl(url), certificate as MultipartFile, maxAllowedConnections, allowedUpdates)
|
|
||||||
is FileId -> SetWebhook(correctWebhookUrl(url), certificate as FileId, maxAllowedConnections, allowedUpdates)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun SetWebhook(
|
|
||||||
url: String,
|
|
||||||
maxAllowedConnections: Int? = null,
|
|
||||||
allowedUpdates: List<String>? = null
|
|
||||||
) = SetWebhook(
|
|
||||||
correctWebhookUrl(url),
|
|
||||||
null,
|
|
||||||
maxAllowedConnections,
|
|
||||||
allowedUpdates
|
|
||||||
)
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class SetWebhook internal constructor(
|
|
||||||
@SerialName(urlField)
|
|
||||||
val url: String,
|
|
||||||
@SerialName(certificateField)
|
|
||||||
val certificateFile: String? = null,
|
|
||||||
@SerialName(maxAllowedConnectionsField)
|
|
||||||
val maxAllowedConnections: Int? = null,
|
|
||||||
@SerialName(allowedUpdatesField)
|
|
||||||
val allowedUpdates: List<String>? = null
|
|
||||||
) : DataRequest<Boolean> {
|
|
||||||
override fun method(): String = "setWebhook"
|
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
|
||||||
get() = Boolean.serializer()
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
|
|
||||||
init {
|
|
||||||
maxAllowedConnections ?.let {
|
|
||||||
if (it !in allowedConnectionsLength) {
|
|
||||||
throw IllegalArgumentException("Allowed connection for webhook must be in $allowedConnectionsLength range (but passed $it)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.CallbackQuery
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.CallbackQueryIdentifier
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.User
|
|
||||||
|
|
||||||
interface CallbackQuery {
|
|
||||||
val id: CallbackQueryIdentifier
|
|
||||||
val user: User
|
|
||||||
val chatInstance: String
|
|
||||||
}
|
|
||||||
|
|
||||||
data class UnknownCallbackQueryType(
|
|
||||||
override val id: CallbackQueryIdentifier,
|
|
||||||
override val user: User,
|
|
||||||
override val chatInstance: String,
|
|
||||||
val raw: String
|
|
||||||
) : CallbackQuery
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.CallbackQuery
|
|
||||||
|
|
||||||
interface DataCallbackQuery : CallbackQuery {
|
|
||||||
val data: String
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.CallbackQuery
|
|
||||||
|
|
||||||
interface GameShortNameCallbackQuery : CallbackQuery {
|
|
||||||
val gameShortName: String
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.CallbackQuery
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineMessageIdentifier
|
|
||||||
|
|
||||||
interface InlineMessageIdCallbackQuery : CallbackQuery {
|
|
||||||
val inlineMessageId: InlineMessageIdentifier
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.CallbackQuery
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
|
||||||
|
|
||||||
interface MessageCallbackQuery : CallbackQuery {
|
|
||||||
val message: Message
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.CallbackQuery
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.CallbackQueryIdentifier
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.User
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
|
||||||
|
|
||||||
data class MessageDataCallbackQuery(
|
|
||||||
override val id: CallbackQueryIdentifier,
|
|
||||||
override val user: User,
|
|
||||||
override val chatInstance: String,
|
|
||||||
override val message: Message,
|
|
||||||
override val data: String
|
|
||||||
) : DataCallbackQuery, MessageCallbackQuery
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.CallbackQuery
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.CallbackQueryIdentifier
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.User
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
|
||||||
|
|
||||||
data class MessageGameShortNameCallbackQuery(
|
|
||||||
override val id: CallbackQueryIdentifier,
|
|
||||||
override val user: User,
|
|
||||||
override val chatInstance: String,
|
|
||||||
override val message: Message,
|
|
||||||
override val gameShortName: String
|
|
||||||
) : GameShortNameCallbackQuery, MessageCallbackQuery
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types
|
|
||||||
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
import kotlinx.serialization.encoding.Decoder
|
|
||||||
import kotlinx.serialization.encoding.Encoder
|
|
||||||
import kotlinx.serialization.json.*
|
|
||||||
|
|
||||||
@Serializable(ChatIdentifierSerializer::class)
|
|
||||||
sealed class ChatIdentifier
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Also used as User Identifier
|
|
||||||
*/
|
|
||||||
@Serializable(ChatIdentifierSerializer::class)
|
|
||||||
data class ChatId(
|
|
||||||
val chatId: Identifier
|
|
||||||
) : ChatIdentifier()
|
|
||||||
|
|
||||||
|
|
||||||
val ChatId.link: String
|
|
||||||
get() = "tg://user?id=$chatId"
|
|
||||||
|
|
||||||
typealias UserId = ChatId
|
|
||||||
|
|
||||||
fun Identifier.toChatId(): ChatId = ChatId(this)
|
|
||||||
fun Int.toChatId(): ChatId = toLong().toChatId()
|
|
||||||
fun Byte.toChatId(): ChatId = toLong().toChatId()
|
|
||||||
|
|
||||||
@Serializable(ChatIdentifierSerializer::class)
|
|
||||||
data class Username(
|
|
||||||
val username: String
|
|
||||||
) : ChatIdentifier() {
|
|
||||||
init {
|
|
||||||
if (!username.startsWith("@")) {
|
|
||||||
throw IllegalArgumentException("Username must starts with `@`")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun String.toUsername(): Username = Username(this)
|
|
||||||
|
|
||||||
@Serializer(ChatIdentifier::class)
|
|
||||||
internal object ChatIdentifierSerializer : KSerializer<ChatIdentifier> {
|
|
||||||
override fun deserialize(decoder: Decoder): ChatIdentifier {
|
|
||||||
val id = JsonPrimitive.serializer().deserialize(decoder)
|
|
||||||
return id.longOrNull ?.let {
|
|
||||||
ChatId(it)
|
|
||||||
} ?: id.content.let {
|
|
||||||
if (!it.startsWith("@")) {
|
|
||||||
Username("@$it")
|
|
||||||
} else {
|
|
||||||
Username(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun serialize(encoder: Encoder, value: ChatIdentifier) {
|
|
||||||
when (value) {
|
|
||||||
is ChatId -> encoder.encodeLong(value.chatId)
|
|
||||||
is Username -> encoder.encodeString(value.username)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.AdministratorChatMember
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.User
|
|
||||||
|
|
||||||
data class AdministratorChatMemberImpl(
|
|
||||||
override val user: User,
|
|
||||||
override val canBeEdited: Boolean,
|
|
||||||
override val canChangeInfo: Boolean,
|
|
||||||
override val canPostMessages: Boolean,
|
|
||||||
override val canEditMessages: Boolean,
|
|
||||||
override val canRemoveMessages: Boolean,
|
|
||||||
override val canInviteUsers: Boolean,
|
|
||||||
override val canRestrictMembers: Boolean,
|
|
||||||
override val canPinMessages: Boolean,
|
|
||||||
override val canPromoteMembers: Boolean,
|
|
||||||
override val customTitle: String?
|
|
||||||
) : AdministratorChatMember
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.AdministratorChatMember
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.User
|
|
||||||
|
|
||||||
data class CreatorChatMember(
|
|
||||||
override val user: User,
|
|
||||||
override val customTitle: String?
|
|
||||||
) : AdministratorChatMember {
|
|
||||||
override val canBeEdited: Boolean = true
|
|
||||||
override val canChangeInfo: Boolean = true
|
|
||||||
override val canPostMessages: Boolean = true
|
|
||||||
override val canEditMessages: Boolean = true
|
|
||||||
override val canRemoveMessages: Boolean = true
|
|
||||||
override val canInviteUsers: Boolean = true
|
|
||||||
override val canRestrictMembers: Boolean = true
|
|
||||||
override val canPinMessages: Boolean = true
|
|
||||||
override val canPromoteMembers: Boolean = true
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember
|
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.BannedChatMember
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.TelegramDate
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.User
|
|
||||||
|
|
||||||
data class KickedChatMember(
|
|
||||||
override val user: User,
|
|
||||||
override val untilDate: TelegramDate?
|
|
||||||
) : BannedChatMember
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user