Compare commits
630 commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5bff732814 | ||
![]() |
c52d2f3601 | ||
![]() |
f9741c250d | ||
![]() |
07ff3c4d2b | ||
![]() |
c4fdd71bdc | ||
![]() |
3c692424f7 | ||
![]() |
8408430ef8 | ||
![]() |
a66f27b5e6 | ||
![]() |
14c1aaaa44 | ||
![]() |
17318e5724 | ||
![]() |
69916fed3e | ||
![]() |
47f47f2110 | ||
![]() |
cb016a7fff | ||
![]() |
ca4bce7052 | ||
![]() |
f3af237d02 | ||
![]() |
1e151f9ce6 | ||
![]() |
d7d6ebda23 | ||
![]() |
3959680e15 | ||
![]() |
8fb2d3a943 | ||
![]() |
b8e5b59241 | ||
![]() |
8aac6544a6 | ||
![]() |
939c736e1e | ||
![]() |
2cdd327abf | ||
![]() |
25e62db274 | ||
![]() |
02ce45a643 | ||
![]() |
4dfa3f3c59 | ||
![]() |
2db766529e | ||
![]() |
fb99adae74 | ||
![]() |
ca194cfb52 | ||
![]() |
73a09760b1 | ||
![]() |
4886173e89 | ||
![]() |
d19c74e35a | ||
![]() |
ecac3c6ae5 | ||
![]() |
6119b39ec7 | ||
![]() |
d206d20dd5 | ||
![]() |
7ea986a555 | ||
![]() |
e22792cc8e | ||
![]() |
d8dc131df6 | ||
![]() |
990a7bbfca | ||
![]() |
53acc6c664 | ||
![]() |
672ab564c2 | ||
![]() |
932178d203 | ||
![]() |
791362e9c1 | ||
![]() |
7c895ec9bc | ||
![]() |
79b5869ae4 | ||
![]() |
4735af473f | ||
![]() |
cef24db929 | ||
![]() |
4ace03c02d | ||
![]() |
c4b08b5ab9 | ||
![]() |
ee5f8fb06f | ||
![]() |
9468bdda90 | ||
![]() |
c5e0e1992a | ||
![]() |
f5a09f90e9 | ||
![]() |
c7196005ac | ||
![]() |
3bfdb2491c | ||
![]() |
c18a5778bc | ||
![]() |
cd03e91807 | ||
![]() |
9a7fb4194f | ||
![]() |
a4e36af33c | ||
![]() |
94de6b6d54 | ||
![]() |
36bc36e208 | ||
![]() |
58a04ba94c | ||
![]() |
36e2305ce7 | ||
![]() |
a5b472794d | ||
![]() |
ea6fe91d9d | ||
![]() |
c01b8653c5 | ||
![]() |
ae7facc255 | ||
![]() |
06b57feb9c | ||
![]() |
491137d5a4 | ||
![]() |
91770ecbf6 | ||
![]() |
fe14ea249a | ||
![]() |
fccb461e34 | ||
![]() |
fe42f8747f | ||
![]() |
6e6e207c54 | ||
![]() |
0486a7f0ab | ||
![]() |
d0519193eb | ||
![]() |
e0543413e3 | ||
![]() |
c61c37be02 | ||
![]() |
95020c9ed9 | ||
![]() |
61c73a13d1 | ||
![]() |
50d6ddd152 | ||
![]() |
e1f6b63bb7 | ||
![]() |
d45bf4f261 | ||
![]() |
3d996ba892 | ||
![]() |
bf648ec2af | ||
![]() |
d6f13f3177 | ||
![]() |
c1d515de0c | ||
![]() |
c48dbda47b | ||
![]() |
c7eec21824 | ||
![]() |
b9a46da443 | ||
![]() |
527d546a78 | ||
![]() |
af7473aa05 | ||
![]() |
69f796b951 | ||
![]() |
be210c5411 | ||
![]() |
17369210d5 | ||
![]() |
ec7c4b5882 | ||
![]() |
18bd8ce69e | ||
![]() |
89af7589cb | ||
![]() |
9ea36578df | ||
![]() |
175754649c | ||
![]() |
524475a757 | ||
![]() |
44dfe821c1 | ||
![]() |
cad5face2d | ||
![]() |
9e3d5dcaaf | ||
![]() |
588d1b099d | ||
![]() |
530cc3e402 | ||
![]() |
4accf1713c | ||
![]() |
fedf177803 | ||
![]() |
f000bc422d | ||
![]() |
4893a23bfa | ||
![]() |
576deca185 | ||
![]() |
7a18d72419 | ||
![]() |
4be031f96c | ||
![]() |
1661e744ab | ||
![]() |
7ee714b36c | ||
![]() |
94d8922a49 | ||
![]() |
2aca204f16 | ||
![]() |
5bf3dde316 | ||
![]() |
3acdb17d46 | ||
![]() |
4d40f8f3a3 | ||
![]() |
17f1599797 | ||
![]() |
9889abf149 | ||
![]() |
78b4f8c24d | ||
![]() |
5b05fe155b | ||
![]() |
b116ec4447 | ||
![]() |
59af689364 | ||
![]() |
9817608eb7 | ||
![]() |
646c77c4ba | ||
![]() |
24fe2f2b91 | ||
![]() |
6315f5840d | ||
![]() |
2f2fefbe9d | ||
![]() |
307521debc | ||
![]() |
db3500d46e | ||
![]() |
3757b9106a | ||
![]() |
c535977bac | ||
![]() |
47fde54d40 | ||
![]() |
8119e791e4 | ||
![]() |
2377b239f3 | ||
![]() |
9e2e19d593 | ||
![]() |
d9dd03f601 | ||
![]() |
3cac471f1e | ||
![]() |
44260ccaee | ||
![]() |
ee2dff1e31 | ||
![]() |
2900b708da | ||
![]() |
12a091ce80 | ||
![]() |
b826d0d4dd | ||
![]() |
6c6d7abb56 | ||
![]() |
946e110131 | ||
![]() |
87f9321280 | ||
![]() |
f03490cb6c | ||
![]() |
439ccdb123 | ||
![]() |
a4af8fd1b7 | ||
![]() |
42c3138d3b | ||
![]() |
e2bc3010af | ||
![]() |
ba6e991b23 | ||
![]() |
513344b4a6 | ||
![]() |
7cfd6c0c5f | ||
![]() |
6b9ecaa153 | ||
![]() |
53824b7126 | ||
![]() |
1cf82401c3 | ||
![]() |
89d52f81aa | ||
![]() |
3e860ea089 | ||
![]() |
e88e18995e | ||
![]() |
1eaf2e7d91 | ||
![]() |
7623f488ee | ||
![]() |
a24c617c9f | ||
![]() |
a89e968a40 | ||
![]() |
32d8e233b8 | ||
![]() |
7b16b2bbc6 | ||
![]() |
547c19888a | ||
![]() |
e6f80ae85c | ||
![]() |
76b6590f79 | ||
![]() |
e7f89d7e0d | ||
![]() |
f26f1c963f | ||
![]() |
56c7fb04d2 | ||
![]() |
4829853d0e | ||
![]() |
2a08cc51de | ||
![]() |
041c2dc84c | ||
![]() |
325e29a930 | ||
![]() |
2b8f9afa49 | ||
![]() |
2f87996bd3 | ||
![]() |
b40ee01d6e | ||
![]() |
775a5ab71f | ||
![]() |
b4a7d69c3c | ||
![]() |
bcf23f3834 | ||
![]() |
ada256566e | ||
![]() |
ac431136de | ||
![]() |
a212671c49 | ||
![]() |
709e5794d5 | ||
![]() |
e843c8ca4f | ||
![]() |
f1342e3f42 | ||
![]() |
c57cdfe05c | ||
![]() |
39821585e4 | ||
![]() |
95e9118bfb | ||
![]() |
31550fc1dc | ||
![]() |
d56cc3dd22 | ||
![]() |
3ce87cabcb | ||
![]() |
73d14179b1 | ||
![]() |
b8b1a87639 | ||
![]() |
c7edc420f3 | ||
![]() |
cd691703ee | ||
![]() |
ff245ad315 | ||
![]() |
95346f78cd | ||
![]() |
b58aa3a5fc | ||
![]() |
f83b5ac40f | ||
![]() |
da553c3bc9 | ||
![]() |
374e3907c4 | ||
![]() |
734adf2f7d | ||
![]() |
27d1dce80f | ||
![]() |
6787654243 | ||
![]() |
40fd31cc79 | ||
![]() |
1db75f74f6 | ||
![]() |
d702ddb120 | ||
![]() |
f8e5b0f632 | ||
![]() |
f2f26998ad | ||
![]() |
845a0d3b3c | ||
![]() |
ead1347f34 | ||
![]() |
97346e217c | ||
![]() |
b8f6c81833 | ||
![]() |
64e40f62cb | ||
![]() |
d875d7282d | ||
![]() |
868d2d3748 | ||
![]() |
1dd3be5802 | ||
![]() |
1a130d948c | ||
![]() |
705bbe6b3c | ||
![]() |
e991cf8183 | ||
![]() |
2b67b085ad | ||
![]() |
bc27a597eb | ||
![]() |
b7d2d4072a | ||
![]() |
88f1ebddeb | ||
![]() |
a116697e24 | ||
![]() |
20aeccc2ba | ||
![]() |
db18d8b826 | ||
![]() |
a3049d3355 | ||
![]() |
9a4e537294 | ||
![]() |
33f7a094fc | ||
![]() |
561542bc62 | ||
![]() |
012fc4fe0f | ||
![]() |
e4787b90a1 | ||
![]() |
891bd6f183 | ||
![]() |
0145279516 | ||
![]() |
427102a635 | ||
![]() |
19b4d2ef45 | ||
![]() |
0298049ca2 | ||
![]() |
560721ffc8 | ||
![]() |
744771445e | ||
![]() |
b58943c7c2 | ||
![]() |
0fec9211af | ||
![]() |
de3a887af7 | ||
![]() |
27ffc3408d | ||
![]() |
5d1b07c4c4 | ||
![]() |
e7c438bc6a | ||
![]() |
d528993069 | ||
![]() |
738e6bd0f4 | ||
![]() |
4935373cda | ||
![]() |
02d9fe69d9 | ||
![]() |
4558ebb9a7 | ||
![]() |
22f28c5711 | ||
![]() |
f17915bab6 | ||
![]() |
54a7f410af | ||
![]() |
cd2967ee06 | ||
![]() |
c044bf0909 | ||
![]() |
e797266008 | ||
![]() |
e1f0b459d8 | ||
![]() |
dc9ca57e52 | ||
![]() |
3623b63eaa | ||
![]() |
a9a6d5a2b3 | ||
![]() |
294b25ad26 | ||
![]() |
ebea95b930 | ||
![]() |
ae5a9130b6 | ||
![]() |
75ed7676ac | ||
![]() |
d02cab3846 | ||
![]() |
2e58fcf108 | ||
![]() |
5e52ceea4b | ||
![]() |
17ff223461 | ||
![]() |
4d45add53e | ||
![]() |
1ed547eb86 | ||
![]() |
1835ccc08e | ||
![]() |
b132c2c982 | ||
![]() |
458ebac946 | ||
![]() |
1930ed5c1c | ||
![]() |
9a113db0a0 | ||
![]() |
b2fe2bdec3 | ||
![]() |
2b0309cd6d | ||
![]() |
b30d70db98 | ||
![]() |
3b207469bd | ||
![]() |
93b4c68d29 | ||
![]() |
77d30bd9bd | ||
![]() |
d04d2b019e | ||
![]() |
9a3d0b8188 | ||
![]() |
b3d26446e6 | ||
![]() |
7b32ae835e | ||
![]() |
2b0432788c | ||
![]() |
f6a6bff387 | ||
![]() |
71c9050b88 | ||
![]() |
71589e1871 | ||
![]() |
75acf6aad5 | ||
![]() |
5631201880 | ||
![]() |
cd2d070a1a | ||
![]() |
286df9b684 | ||
![]() |
5e6cc4c827 | ||
![]() |
96797a17bc | ||
![]() |
e4ff11c005 | ||
![]() |
96cec88e74 | ||
![]() |
ac1234d1e5 | ||
![]() |
23aa1ace92 | ||
![]() |
49db80523f | ||
![]() |
a357451a9d | ||
![]() |
bdcce70ce4 | ||
![]() |
3b0d131582 | ||
![]() |
c645d6a727 | ||
![]() |
5703ce9987 | ||
![]() |
220100c4b5 | ||
![]() |
bf0b8268de | ||
![]() |
0f7e2641e7 | ||
![]() |
3196c357f1 | ||
![]() |
7738851797 | ||
![]() |
a214a7c736 | ||
![]() |
5557a49e17 | ||
![]() |
3564e2a29d | ||
![]() |
a04140dc8f | ||
![]() |
af6cab91f7 | ||
![]() |
40816a586f | ||
![]() |
9a58bf51f4 | ||
![]() |
d3c5bf4f51 | ||
![]() |
f72c044df8 | ||
![]() |
60d2f1b9fd | ||
![]() |
38657c128d | ||
![]() |
fb1be54bb7 | ||
![]() |
2afeada5d5 | ||
![]() |
f2dbe173b5 | ||
![]() |
a54ad4bf1e | ||
![]() |
e8a6e7a6e1 | ||
![]() |
3b02d5a5c2 | ||
![]() |
63949a2f2f | ||
![]() |
092e5234a2 | ||
![]() |
19333f5876 | ||
![]() |
af7a33b1c1 | ||
![]() |
e246741b5a | ||
![]() |
d10e2f7dfc | ||
![]() |
f254735b46 | ||
![]() |
1cd64da6af | ||
![]() |
af22e993b9 | ||
![]() |
e5e07fe314 | ||
![]() |
6f32bba06e | ||
![]() |
75fb759100 | ||
![]() |
dba35af7f6 | ||
![]() |
5d99aa5e14 | ||
![]() |
d0b4a7cf5c | ||
![]() |
b19ed2f36d | ||
![]() |
0a91098f98 | ||
![]() |
6f6cd1d936 | ||
![]() |
154dcbe3c6 | ||
![]() |
cd84917d8f | ||
![]() |
26162a1a7c | ||
![]() |
b2c8877294 | ||
![]() |
115379e5ab | ||
![]() |
aa62427906 | ||
![]() |
adbf591b2e | ||
![]() |
63970f807e | ||
![]() |
3746009e4e | ||
![]() |
35c9710d3f | ||
![]() |
d56654a512 | ||
![]() |
4558409da5 | ||
![]() |
6280b8c026 | ||
![]() |
0fedf2cc54 | ||
![]() |
89d0165fb6 | ||
![]() |
0a411cec79 | ||
![]() |
c22ef6e2ff | ||
![]() |
f7a6df10df | ||
![]() |
89e3f9c575 | ||
![]() |
8d074ef36a | ||
![]() |
926ab06c51 | ||
![]() |
2f6a39d863 | ||
![]() |
6aa95f305a | ||
![]() |
c1eec26a2c | ||
![]() |
d386d1a553 | ||
![]() |
ce22cb4b0a | ||
![]() |
e12979d7af | ||
![]() |
c546a44b78 | ||
![]() |
f966d6809f | ||
![]() |
6f75038bf5 | ||
![]() |
eef9ab5624 | ||
![]() |
07140aa08f | ||
![]() |
6839980fdb | ||
![]() |
c4d7fc0f41 | ||
![]() |
ac8b629dc5 | ||
![]() |
20cd2aeacf | ||
![]() |
22eeeca427 | ||
![]() |
7f7f353ed5 | ||
![]() |
147e4141b9 | ||
![]() |
f20f86a2fb | ||
![]() |
fdf6e3addc | ||
![]() |
196d4a063c | ||
![]() |
a84b20e0fb | ||
![]() |
6c9af0b1d8 | ||
![]() |
0b8603ec75 | ||
![]() |
02dedd3e03 | ||
![]() |
0662c64ed6 | ||
![]() |
7dce9a5f8e | ||
![]() |
3eae8f43c8 | ||
![]() |
1aec926fd6 | ||
![]() |
746201b395 | ||
![]() |
bc1000fa1d | ||
![]() |
108f64d924 | ||
![]() |
7fdfce0cc6 | ||
![]() |
7b54b8572d | ||
![]() |
741356c5b5 | ||
![]() |
0272c7b3ed | ||
![]() |
65845b53de | ||
![]() |
e894375aae | ||
![]() |
f331ab7ede | ||
![]() |
11b3fbc6a7 | ||
![]() |
ef06cf4afb | ||
![]() |
742f177145 | ||
![]() |
ba5e446bd2 | ||
![]() |
18ba52b376 | ||
![]() |
94119c461c | ||
![]() |
f0982e0c3a | ||
![]() |
7bf5939a07 | ||
![]() |
1ad1ac969b | ||
![]() |
17ceeeda5a | ||
![]() |
6c2219f1ae | ||
![]() |
7d9caf38b3 | ||
![]() |
f6df3bf9da | ||
![]() |
d2f283afdd | ||
![]() |
16b4ba587b | ||
![]() |
6e7536e3c4 | ||
![]() |
fd2f55eb90 | ||
![]() |
5cddbc44d8 | ||
![]() |
68bb270dc1 | ||
![]() |
cade220d0a | ||
![]() |
46d6cdf124 | ||
![]() |
2405873510 | ||
![]() |
5426dd9e1c | ||
![]() |
3774b7f8c0 | ||
![]() |
1d11ef3b2a | ||
![]() |
f5dc29804c | ||
![]() |
e8221c11ec | ||
![]() |
fe1fd3083b | ||
![]() |
ad1094de38 | ||
![]() |
aaacd8851e | ||
![]() |
9dd11af87d | ||
![]() |
3ed338d49a | ||
![]() |
0395f3d32a | ||
![]() |
4c0ad925d7 | ||
![]() |
fb2a06024d | ||
![]() |
dfb812237b | ||
![]() |
59f6875edf | ||
![]() |
73de7d82f0 | ||
![]() |
1625a1d829 | ||
![]() |
b1e9753b58 | ||
![]() |
aa80be21d0 | ||
![]() |
c66d5ebe1b | ||
![]() |
669ec19f46 | ||
![]() |
58849813e9 | ||
![]() |
6a7668c427 | ||
![]() |
b14dd43eb7 | ||
![]() |
79278e7748 | ||
![]() |
6c67e97a4b | ||
![]() |
848a2a78e3 | ||
![]() |
8ee69052b1 | ||
![]() |
285a8fe8b8 | ||
![]() |
93e408be17 | ||
![]() |
3691445841 | ||
![]() |
811d2c6d4a | ||
![]() |
85a22771b4 | ||
![]() |
b144627a70 | ||
![]() |
dfe522d965 | ||
![]() |
054f76d144 | ||
![]() |
088eac6b88 | ||
![]() |
c2ba0bf68e | ||
![]() |
649004a844 | ||
![]() |
eb15ca3ee9 | ||
![]() |
c0146c97ab | ||
![]() |
8a7df394f0 | ||
![]() |
aae9e737da | ||
![]() |
b256812da6 | ||
![]() |
cb383d3183 | ||
![]() |
a4bc96d00b | ||
![]() |
b3b3302f00 | ||
![]() |
ac603b1635 | ||
![]() |
c4c307fcf1 | ||
![]() |
1e3824a87a | ||
![]() |
67230e35ba | ||
![]() |
9c4e964a15 | ||
![]() |
1720455918 | ||
![]() |
b37eeaf09c | ||
![]() |
fb381c5138 | ||
![]() |
3dd46c8d27 | ||
![]() |
20735b36db | ||
![]() |
17e31c9bce | ||
![]() |
1231e7d387 | ||
![]() |
ee5f204fc1 | ||
![]() |
46167099bf | ||
![]() |
7aa6be4e9a | ||
![]() |
69f7ff6a5a | ||
![]() |
55e65e8948 | ||
![]() |
2f701a899f | ||
![]() |
323c3531ba | ||
![]() |
eac0490ae8 | ||
![]() |
3e035e5d7d | ||
![]() |
ae61b3fadf | ||
a9b314879a | |||
8c664e8127 | |||
0dbf477f7b | |||
ada7676ef9 | |||
db38d46fb3 | |||
54e81b4137 | |||
fbc472d8de | |||
8a4dfddae6 | |||
857d20774d | |||
1b4e4a806f | |||
1deb1aaa6c | |||
77ce3969aa | |||
a1ec9fdb13 | |||
96c3e190cb | |||
8e45540d78 | |||
ddf897f143 | |||
d80637250d | |||
32f089203a | |||
7573fc2205 | |||
b81fa4fa4f | |||
3d99e58d25 | |||
5ec6f7271a | |||
176ea791bf | |||
40d25a15f1 | |||
5ce6f737f5 | |||
2389839a37 | |||
3c91058235 | |||
e025f34a2e | |||
d0219425c1 | |||
b8d3a20a5c | |||
4ce61e5af7 | |||
26c0a197dc | |||
3d6cc15894 | |||
581fa42715 | |||
e463b81948 | |||
bcbb742b9f | |||
6fb6f74406 | |||
c0b25c7b0e | |||
22a99eb06a | |||
61249cb18d | |||
89b240f2eb | |||
144095b228 | |||
05b877d38a | |||
9deb9e2c00 | |||
d14ee4eae4 | |||
c3ecb75d6c | |||
51cce667f7 | |||
b1db812097 | |||
41c1d0fc4c | |||
277a33f2d3 | |||
67b7b68b4c | |||
1707a44796 | |||
01399f0723 | |||
79446bfcbd | |||
f518ca0030 | |||
8ca48b008e | |||
b2928875cd | |||
f8c02bceb3 | |||
6a4128090c | |||
7970313d88 | |||
841d4ff11d | |||
269baf7d26 | |||
9ffc0a2105 | |||
f54c30b320 | |||
1b569e4972 | |||
ec93f9ffd7 | |||
ce94585752 | |||
ac27d427e1 | |||
ed41bcea2f | |||
18a3c7ef6f | |||
![]() |
ad83558169 | ||
![]() |
949017a123 | ||
![]() |
b3b66a2634 | ||
![]() |
fb1a844526 | ||
![]() |
54fc17b549 | ||
![]() |
174210da67 | ||
![]() |
d171c61e7f | ||
![]() |
5283416292 | ||
![]() |
917077c19a | ||
![]() |
b4e0f62e99 | ||
![]() |
97fe1f33ad | ||
![]() |
da8108c196 | ||
![]() |
70c6181cd8 | ||
![]() |
3ae16b96e1 | ||
![]() |
688ea4f5b1 | ||
![]() |
c6caabfcb4 | ||
![]() |
af8fabceaa | ||
![]() |
4d3ba7004e | ||
![]() |
007304c8ca | ||
![]() |
595872c997 | ||
![]() |
4dc5e9e20d | ||
![]() |
37a136adce | ||
![]() |
65564ecb2a | ||
![]() |
c17773e5d2 | ||
![]() |
8965ac3aff | ||
![]() |
38012104ae | ||
![]() |
5c1bb7c936 | ||
![]() |
4869c439ff | ||
![]() |
8730f82abf | ||
![]() |
ccd910938b | ||
![]() |
7252854c44 | ||
![]() |
855925d4bd | ||
![]() |
fb2f7dc94e | ||
![]() |
711990af3c | ||
![]() |
e7b9947094 | ||
![]() |
6c8a919a2a | ||
![]() |
bfa19191a2 | ||
![]() |
d06f012797 | ||
![]() |
72a09a2663 | ||
![]() |
ffe62c1ae2 | ||
![]() |
2e1f699e29 | ||
![]() |
cc22e23a06 | ||
![]() |
2a0ba0eaf7 | ||
![]() |
7aa24bea13 | ||
![]() |
7be37db679 | ||
![]() |
85559ea360 | ||
![]() |
f612140eb8 | ||
![]() |
8900abeb4a | ||
![]() |
33088ee486 | ||
![]() |
47ed640857 | ||
![]() |
5aa2a4928e | ||
![]() |
a9023f116c | ||
![]() |
e09252baad | ||
![]() |
9002de8026 | ||
![]() |
98d2798fc2 | ||
![]() |
f9c6f80310 | ||
![]() |
84cc1ba93b |
493 changed files with 31509 additions and 10520 deletions
555
.github/workflows/ncc_workflow.yml
vendored
Normal file
555
.github/workflows/ncc_workflow.yml
vendored
Normal file
|
@ -0,0 +1,555 @@
|
|||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '**'
|
||||
release:
|
||||
types: [created]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: php:8.3
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
apt update -yqq
|
||||
apt install git libpq-dev libzip-dev zip make wget gnupg -yqq
|
||||
|
||||
- name: Install phive
|
||||
run: |
|
||||
wget -O phive.phar https://phar.io/releases/phive.phar
|
||||
wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc
|
||||
gpg --keyserver hkps://keys.openpgp.org --recv-keys 0x9D8A98B29B2D5D79
|
||||
gpg --verify phive.phar.asc phive.phar
|
||||
chmod +x phive.phar
|
||||
mv phive.phar /usr/local/bin/phive
|
||||
|
||||
- name: Install phab
|
||||
run: |
|
||||
phive install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C
|
||||
|
||||
- name: Install latest version of NCC
|
||||
run: |
|
||||
git clone https://git.n64.cc/nosial/ncc.git
|
||||
cd ncc
|
||||
make redist
|
||||
NCC_DIR=$(find build/ -type d -name "ncc_*" | head -n 1)
|
||||
if [ -z "$NCC_DIR" ]; then
|
||||
echo "NCC build directory not found"
|
||||
exit 1
|
||||
fi
|
||||
php "$NCC_DIR/INSTALL" --auto
|
||||
cd .. && rm -rf ncc
|
||||
|
||||
- name: Build project
|
||||
run: |
|
||||
ncc build --config release --build-source --log-level debug
|
||||
|
||||
- name: Upload build artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: release
|
||||
path: build/release/net.nosial.tgbotlib.ncc
|
||||
release-compressed:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: php:8.3
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
apt update -yqq
|
||||
apt install git libpq-dev libzip-dev zip make wget gnupg -yqq
|
||||
|
||||
- name: Install phive
|
||||
run: |
|
||||
wget -O phive.phar https://phar.io/releases/phive.phar
|
||||
wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc
|
||||
gpg --keyserver hkps://keys.openpgp.org --recv-keys 0x9D8A98B29B2D5D79
|
||||
gpg --verify phive.phar.asc phive.phar
|
||||
chmod +x phive.phar
|
||||
mv phive.phar /usr/local/bin/phive
|
||||
|
||||
- name: Install phab
|
||||
run: |
|
||||
phive install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C
|
||||
|
||||
- name: Install latest version of NCC
|
||||
run: |
|
||||
git clone https://git.n64.cc/nosial/ncc.git
|
||||
cd ncc
|
||||
make redist
|
||||
NCC_DIR=$(find build/ -type d -name "ncc_*" | head -n 1)
|
||||
if [ -z "$NCC_DIR" ]; then
|
||||
echo "NCC build directory not found"
|
||||
exit 1
|
||||
fi
|
||||
php "$NCC_DIR/INSTALL" --auto
|
||||
cd .. && rm -rf ncc
|
||||
|
||||
- name: Build project
|
||||
run: |
|
||||
ncc build --config release-compressed --build-source --log-level debug
|
||||
|
||||
- name: Upload build artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: release-compressed
|
||||
path: build/release/net.nosial.tgbotlib.gz.ncc
|
||||
release-executable:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: php:8.3
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
apt update -yqq
|
||||
apt install git libpq-dev libzip-dev zip make wget gnupg -yqq
|
||||
|
||||
- name: Install phive
|
||||
run: |
|
||||
wget -O phive.phar https://phar.io/releases/phive.phar
|
||||
wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc
|
||||
gpg --keyserver hkps://keys.openpgp.org --recv-keys 0x9D8A98B29B2D5D79
|
||||
gpg --verify phive.phar.asc phive.phar
|
||||
chmod +x phive.phar
|
||||
mv phive.phar /usr/local/bin/phive
|
||||
|
||||
- name: Install phab
|
||||
run: |
|
||||
phive install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C
|
||||
|
||||
- name: Install latest version of NCC
|
||||
run: |
|
||||
git clone https://git.n64.cc/nosial/ncc.git
|
||||
cd ncc
|
||||
make redist
|
||||
NCC_DIR=$(find build/ -type d -name "ncc_*" | head -n 1)
|
||||
if [ -z "$NCC_DIR" ]; then
|
||||
echo "NCC build directory not found"
|
||||
exit 1
|
||||
fi
|
||||
php "$NCC_DIR/INSTALL" --auto
|
||||
cd .. && rm -rf ncc
|
||||
|
||||
- name: Build project
|
||||
run: |
|
||||
ncc build --config release-executable --build-source --log-level debug
|
||||
|
||||
- name: Upload build artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: release-executable
|
||||
path: build/release/TgBotLib
|
||||
release-executable-compressed:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: php:8.3
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
apt update -yqq
|
||||
apt install git libpq-dev libzip-dev zip make wget gnupg -yqq
|
||||
|
||||
- name: Install phive
|
||||
run: |
|
||||
wget -O phive.phar https://phar.io/releases/phive.phar
|
||||
wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc
|
||||
gpg --keyserver hkps://keys.openpgp.org --recv-keys 0x9D8A98B29B2D5D79
|
||||
gpg --verify phive.phar.asc phive.phar
|
||||
chmod +x phive.phar
|
||||
mv phive.phar /usr/local/bin/phive
|
||||
|
||||
- name: Install phab
|
||||
run: |
|
||||
phive install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C
|
||||
|
||||
- name: Install latest version of NCC
|
||||
run: |
|
||||
git clone https://git.n64.cc/nosial/ncc.git
|
||||
cd ncc
|
||||
make redist
|
||||
NCC_DIR=$(find build/ -type d -name "ncc_*" | head -n 1)
|
||||
if [ -z "$NCC_DIR" ]; then
|
||||
echo "NCC build directory not found"
|
||||
exit 1
|
||||
fi
|
||||
php "$NCC_DIR/INSTALL" --auto
|
||||
cd .. && rm -rf ncc
|
||||
|
||||
- name: Build project
|
||||
run: |
|
||||
ncc build --config release-executable-compressed --build-source --log-level debug
|
||||
|
||||
- name: Upload build artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: release-executable-compressed
|
||||
path: build/release/TgBotLib_gz
|
||||
debug:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: php:8.3
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
apt update -yqq
|
||||
apt install git libpq-dev libzip-dev zip make wget gnupg -yqq
|
||||
|
||||
- name: Install phive
|
||||
run: |
|
||||
wget -O phive.phar https://phar.io/releases/phive.phar
|
||||
wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc
|
||||
gpg --keyserver hkps://keys.openpgp.org --recv-keys 0x9D8A98B29B2D5D79
|
||||
gpg --verify phive.phar.asc phive.phar
|
||||
chmod +x phive.phar
|
||||
mv phive.phar /usr/local/bin/phive
|
||||
|
||||
- name: Install phab
|
||||
run: |
|
||||
phive install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C
|
||||
|
||||
- name: Install latest version of NCC
|
||||
run: |
|
||||
git clone https://git.n64.cc/nosial/ncc.git
|
||||
cd ncc
|
||||
make redist
|
||||
NCC_DIR=$(find build/ -type d -name "ncc_*" | head -n 1)
|
||||
if [ -z "$NCC_DIR" ]; then
|
||||
echo "NCC build directory not found"
|
||||
exit 1
|
||||
fi
|
||||
php "$NCC_DIR/INSTALL" --auto
|
||||
cd .. && rm -rf ncc
|
||||
|
||||
- name: Build project
|
||||
run: |
|
||||
ncc build --config debug --build-source --log-level debug
|
||||
|
||||
- name: Upload build artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: debug
|
||||
path: build/debug/net.nosial.tgbotlib.ncc
|
||||
debug-compressed:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: php:8.3
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
apt update -yqq
|
||||
apt install git libpq-dev libzip-dev zip make wget gnupg -yqq
|
||||
|
||||
- name: Install phive
|
||||
run: |
|
||||
wget -O phive.phar https://phar.io/releases/phive.phar
|
||||
wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc
|
||||
gpg --keyserver hkps://keys.openpgp.org --recv-keys 0x9D8A98B29B2D5D79
|
||||
gpg --verify phive.phar.asc phive.phar
|
||||
chmod +x phive.phar
|
||||
mv phive.phar /usr/local/bin/phive
|
||||
|
||||
- name: Install phab
|
||||
run: |
|
||||
phive install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C
|
||||
|
||||
- name: Install latest version of NCC
|
||||
run: |
|
||||
git clone https://git.n64.cc/nosial/ncc.git
|
||||
cd ncc
|
||||
make redist
|
||||
NCC_DIR=$(find build/ -type d -name "ncc_*" | head -n 1)
|
||||
if [ -z "$NCC_DIR" ]; then
|
||||
echo "NCC build directory not found"
|
||||
exit 1
|
||||
fi
|
||||
php "$NCC_DIR/INSTALL" --auto
|
||||
cd .. && rm -rf ncc
|
||||
|
||||
- name: Build project
|
||||
run: |
|
||||
ncc build --config debug-compressed --build-source --log-level debug
|
||||
|
||||
- name: Upload build artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: debug-compressed
|
||||
path: build/debug/net.nosial.tgbotlib.gz.ncc
|
||||
|
||||
|
||||
# Checking for phpunit.xml
|
||||
check-phpunit:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
phpunit-exists: ${{ steps.check.outputs.phpunit-exists }}
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Check for phpunit.xml
|
||||
id: check
|
||||
run: |
|
||||
if [ -f phpunit.xml ]; then
|
||||
echo "phpunit-exists=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "phpunit-exists=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
# Checking for phpdoc.dist.xml
|
||||
check-phpdoc:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
phpdoc-exists: ${{ steps.check.outputs.phpdoc-exists }}
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Check for phpdoc.dist.xml
|
||||
id: check
|
||||
run: |
|
||||
if [ -f phpdoc.dist.xml ]; then
|
||||
echo "phpdoc-exists=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "phpdoc-exists=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
generate-phpdoc:
|
||||
needs: [release, check-phpdoc]
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: php:8.3
|
||||
if: needs.check-phpdoc.outputs.phpdoc-exists == 'true'
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
apt update -yqq
|
||||
apt install git libpq-dev libzip-dev zip make wget gnupg -yqq
|
||||
|
||||
- name: Download PHPDocumentor
|
||||
run: |
|
||||
wget https://phpdoc.org/phpDocumentor.phar
|
||||
chmod +x phpDocumentor.phar
|
||||
|
||||
- name: Generate PHPDoc
|
||||
run: |
|
||||
php phpDocumentor.phar -d src -t docs
|
||||
|
||||
- name: Archive PHPDoc
|
||||
run: |
|
||||
zip -r docs.zip docs
|
||||
|
||||
- name: Upload PHPDoc
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: documentation
|
||||
path: docs.zip
|
||||
|
||||
test:
|
||||
needs: [release, release-compressed, release-executable, release-executable-compressed, debug, debug-compressed, check-phpunit]
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: php:8.3
|
||||
if: needs.check-phpunit.outputs.phpunit-exists == 'true'
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download build artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: release
|
||||
path: release
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
apt update -yqq
|
||||
apt install git libpq-dev libzip-dev zip make wget gnupg -yqq
|
||||
curl -sSLf -o /usr/local/bin/install-php-extensions https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions
|
||||
chmod +x /usr/local/bin/install-php-extensions
|
||||
install-php-extensions zip
|
||||
|
||||
- name: Install phive
|
||||
run: |
|
||||
wget -O phive.phar https://phar.io/releases/phive.phar
|
||||
wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc
|
||||
gpg --keyserver hkps://keys.openpgp.org --recv-keys 0x9D8A98B29B2D5D79
|
||||
gpg --verify phive.phar.asc phive.phar
|
||||
chmod +x phive.phar
|
||||
mv phive.phar /usr/local/bin/phive
|
||||
|
||||
- name: Install phab
|
||||
run: |
|
||||
phive install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C
|
||||
|
||||
- name: Install latest version of NCC
|
||||
run: |
|
||||
git clone https://git.n64.cc/nosial/ncc.git
|
||||
cd ncc
|
||||
make redist
|
||||
NCC_DIR=$(find build/ -type d -name "ncc_*" | head -n 1)
|
||||
if [ -z "$NCC_DIR" ]; then
|
||||
echo "NCC build directory not found"
|
||||
exit 1
|
||||
fi
|
||||
php "$NCC_DIR/INSTALL" --auto
|
||||
cd .. && rm -rf ncc
|
||||
|
||||
- name: Install NCC packages
|
||||
run: |
|
||||
ncc package install --package="release/net.nosial.tgbotlib.ncc" --build-source --reinstall -y --log-level debug
|
||||
|
||||
- name: Export token.txt
|
||||
run: echo "${{ secrets.TELEGRAM_TEST_TOKEN }}" > tests/token.txt
|
||||
|
||||
- name: Run PHPUnit tests
|
||||
run: |
|
||||
wget https://phar.phpunit.de/phpunit-11.3.phar
|
||||
php phpunit-11.3.phar --configuration phpunit.xml --log-junit reports/junit.xml --log-teamcity reports/teamcity --testdox-html reports/testdox.html --testdox-text reports/testdox.txt
|
||||
|
||||
- name: Upload test reports
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: reports
|
||||
path: reports
|
||||
|
||||
|
||||
release-documentation:
|
||||
needs: generate-phpdoc
|
||||
permissions: write-all
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: php:8.3
|
||||
if: github.event_name == 'release'
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download documentation artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: documentation
|
||||
path: documentation
|
||||
|
||||
- name: Upload documentation artifact
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: |
|
||||
documentation/*
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
|
||||
release-artifacts:
|
||||
needs: [release, release-compressed, release-executable, release-executable-compressed, debug, debug-compressed]
|
||||
permissions: write-all
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: php:8.3
|
||||
if: github.event_name == 'release'
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download release artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: release
|
||||
path: release
|
||||
- name: Upload release artifact to release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: |
|
||||
release/*
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Download release-compressed artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: release-compressed
|
||||
path: release-compressed
|
||||
- name: Upload release-compressed artifact to release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: |
|
||||
release-compressed/*
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Download release-executable artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: release-executable
|
||||
path: release-executable
|
||||
- name: Upload release-executable artifact to release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: |
|
||||
release-executable/*
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Download release-executable-compressed artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: release-executable-compressed
|
||||
path: release-executable-compressed
|
||||
- name: Upload release-executable-compressed artifact to release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: |
|
||||
release-executable-compressed/*
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Download debug artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: debug
|
||||
path: debug
|
||||
- name: Upload debug artifact to release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: |
|
||||
debug/*
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Download debug-compressed artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: debug-compressed
|
||||
path: debug-compressed
|
||||
- name: Upload debug-compressed artifact to release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: |
|
||||
debug-compressed/*
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
8
.gitignore
vendored
8
.gitignore
vendored
|
@ -1 +1,7 @@
|
|||
build/
|
||||
build/
|
||||
tests/token.txt
|
||||
/.phpunit.result.cache
|
||||
/.idea/php-test-framework.xml
|
||||
/.idea/gbrowser_project.xml
|
||||
/.phpdoc/
|
||||
!/.github/workflows/ncc_workflow.yml
|
||||
|
|
|
@ -24,6 +24,7 @@ before_script:
|
|||
- cd .. && rm -rf ncc
|
||||
|
||||
build:
|
||||
stage: build
|
||||
script:
|
||||
- ncc build --config release --log-level debug
|
||||
artifacts:
|
||||
|
@ -36,6 +37,8 @@ release:
|
|||
stage: deploy
|
||||
script:
|
||||
- ncc build --config release --log-level debug
|
||||
- >
|
||||
curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file build/release/net.nosial.tgbotlib.ncc "$CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/generic/net.nosial.tgbotlib/$CI_COMMIT_REF_NAME/net.nosial.tgbotlib.ncc"
|
||||
artifacts:
|
||||
paths:
|
||||
- build/
|
||||
|
|
8
.idea/inspectionProfiles/Project_Default.xml
generated
8
.idea/inspectionProfiles/Project_Default.xml
generated
|
@ -1,6 +1,11 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||
<Languages>
|
||||
<language minSize="102" name="PHP" />
|
||||
</Languages>
|
||||
</inspection_tool>
|
||||
<inspection_tool class="IncorrectHttpHeaderInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="customHeaders">
|
||||
<set>
|
||||
|
@ -19,6 +24,9 @@
|
|||
<option value="X-Args-3" />
|
||||
<option value="X-Args-4" />
|
||||
<option value="X-Args-5" />
|
||||
<option value="X-Temperature" />
|
||||
<option value="X-Model" />
|
||||
<option value="X-OPENAI-API-KEY" />
|
||||
</set>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
|
|
13
.idea/php.xml
generated
13
.idea/php.xml
generated
|
@ -9,20 +9,25 @@
|
|||
<component name="PHPCodeSnifferOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PhpAnalysisConfiguration" call_tree_analysis_depth="3" />
|
||||
<component name="PhpIncludePathManager">
|
||||
<include_path>
|
||||
<path value="/var/ncc/packages/net.nosial.optslib=1.1.2" />
|
||||
<path value="/var/ncc/packages/net.nosial.loglib=2.0.2" />
|
||||
<path value="/usr/share/php" />
|
||||
<path value="/etc/ncc" />
|
||||
<path value="/var/ncc/packages/net.nosial.tamerlib=1.0.0" />
|
||||
<path value="/var/ncc/packages/net.nosial.loglib=1.0.0" />
|
||||
</include_path>
|
||||
</component>
|
||||
<component name="PhpProjectSharedConfiguration" php_language_level="8.0">
|
||||
<component name="PhpProjectSharedConfiguration" php_language_level="8.3">
|
||||
<option name="suggestChangeDefaultLanguageLevel" value="false" />
|
||||
</component>
|
||||
<component name="PhpStanOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PhpUnit">
|
||||
<phpunit_settings>
|
||||
<PhpUnitSettings load_method="PHPUNIT_PHAR" bootstrap_file_path="$PROJECT_DIR$/bootstrap.php" custom_loader_path="" phpunit_phar_path="$USER_HOME$/phpunit.phar" use_bootstrap_file="true" />
|
||||
</phpunit_settings>
|
||||
</component>
|
||||
<component name="PsalmOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
|
|
10
.idea/runConfigurations/Build.xml
generated
Normal file
10
.idea/runConfigurations/Build.xml
generated
Normal file
|
@ -0,0 +1,10 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Build" type="MAKEFILE_TARGET_RUN_CONFIGURATION" factoryName="Makefile" activateToolWindowBeforeRun="false">
|
||||
<makefile filename="$PROJECT_DIR$/Makefile" target="build" workingDirectory="" arguments="">
|
||||
<envs />
|
||||
</makefile>
|
||||
<method v="2">
|
||||
<option name="RunConfigurationTask" enabled="true" run_configuration_name="Clean" run_configuration_type="MAKEFILE_TARGET_RUN_CONFIGURATION" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
8
.idea/runConfigurations/Clean.xml
generated
Normal file
8
.idea/runConfigurations/Clean.xml
generated
Normal file
|
@ -0,0 +1,8 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Clean" type="MAKEFILE_TARGET_RUN_CONFIGURATION" factoryName="Makefile" activateToolWindowBeforeRun="false">
|
||||
<makefile filename="$PROJECT_DIR$/Makefile" target="clean" workingDirectory="" arguments="">
|
||||
<envs />
|
||||
</makefile>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
10
.idea/runConfigurations/Install.xml
generated
Normal file
10
.idea/runConfigurations/Install.xml
generated
Normal file
|
@ -0,0 +1,10 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Install" type="MAKEFILE_TARGET_RUN_CONFIGURATION" factoryName="Makefile" activateToolWindowBeforeRun="false">
|
||||
<makefile filename="$PROJECT_DIR$/Makefile" target="install" workingDirectory="" arguments="">
|
||||
<envs />
|
||||
</makefile>
|
||||
<method v="2">
|
||||
<option name="RunConfigurationTask" enabled="true" run_configuration_name="Build" run_configuration_type="MAKEFILE_TARGET_RUN_CONFIGURATION" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
177
CHANGELOG.md
177
CHANGELOG.md
|
@ -1,17 +1,188 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [8.0.2] - 2024-12-09
|
||||
|
||||
This update introduces some quality of life improvements.
|
||||
|
||||
### Added
|
||||
* Added `containsMedia` method to `Message` object to check if the message contains media.
|
||||
* Add support for handling callback query events
|
||||
|
||||
|
||||
## [8.0.1] - 2024-12-04
|
||||
|
||||
This update introduces bug fixes and improvements
|
||||
|
||||
### Changed
|
||||
* Refactor PollingBot to use PsyncLib for updates
|
||||
* Refactor optional parameters in method signatures
|
||||
* Improve command check with method existence validation
|
||||
|
||||
### Fixed
|
||||
* Reposition debug log for event handler execution.
|
||||
* Improve command check with method existence validation
|
||||
* Allow nullable type for MessageEntity type
|
||||
* Encode arrays as JSON in SendAudio parameters
|
||||
* Refactor fromArray method for null data handling
|
||||
|
||||
|
||||
## [8.0.0] - 2024-11-29
|
||||
|
||||
This is a new major update which makes the previous versions of this library deprecated
|
||||
|
||||
### Added
|
||||
* Added unit tests
|
||||
* Added `can_connect_to_business` & `has_main_web_app` to User object
|
||||
|
||||
### Changed
|
||||
* Refactored the way HTTP requests are handled & methods are called
|
||||
* Refactor enums to use native PHP 8.1 syntax
|
||||
* Moved Types to their own namespace
|
||||
* Refactored all Objects & Methods to use a different system
|
||||
* Refactored the event system to allow for more event types
|
||||
|
||||
|
||||
## [6.7.0] - 2023-08-10
|
||||
|
||||
This update accompanies the release of the [Telegram Bot API 6.7](https://core.telegram.org/bots/api#april-21-2023).
|
||||
Additionally, this update includes some bug fixes and improvements such as the ability for some objects to be treated as
|
||||
input objects for methods that require input objects.
|
||||
|
||||
### Added
|
||||
* Added object `\TgBotLib\Objects\Telegram\InputMessageContent\InputTextMessageContent` to represent the content of a text message to be sent as the result of an inline query.
|
||||
* Added object `\TgBotLib\Objects\Telegram\InputMessageContent\InputLocationMessageContent` to represent the content of a location message to be sent as the result of an inline query.
|
||||
* Added object `\TgBotLib\Objects\Telegram\InputMessageContent\InputVenueMessageContent` to represent the content of a venue message to be sent as the result of an inline query.
|
||||
* Added object `\TgBotLib\Objects\Telegram\InputMessageContent\InputContactMessageContent` to represent the content of a contact message to be sent as the result of an inline query.
|
||||
* Added object `\TgBotLib\Objects\Telegram\InputMessageContent\InputInvoiceMessageContent` to represent the content of an invoice message to be sent as the result of an inline query.
|
||||
* Added new exception class `NotImplementedException` to represent the case when a method is not implemented yet or the method is not applicable to the current object.
|
||||
* Added object `\TgBotLib\Objects\Telegram\InlineQueryResult\InlineQueryResultArticle`, see [InlineQueryResultArticle](https://core.telegram.org/bots/api#inlinequeryresultarticle) for more information.
|
||||
* Added object `\TgBotLib\Objects\Telegram\InlineQueryResult\InlineQueryResultPhoto`, see [InlineQueryResultPhoto](hthttps://git.n64.cc/nosial/libs/tgbot/-/issues/3https://git.n64.cc/nosial/libs/tgbot/-/issues/3tps://core.telegram.org/bots/api#inlinequeryresultphoto) for more information.
|
||||
* Added object `\TgBotLib\Objects\Telegram\InlineQueryResult\InlineQueryResultGif`, see [InlineQueryResultGif](https://core.telegram.org/bots/api#inlinequeryresultgif) for more information.
|
||||
* Added abstract class `\TgBotLib\Abstracts\ThumbnailMimeType` to represent the mime type of thumbnail, photo, or a file / sticker thumbnail.
|
||||
* Added object `\TgBotLib\Objects\Telegram\InlineQueryResult\InlineQueryResultMpeg4Gif`, see [InlineQueryResultMpeg4Gif](https://core.telegram.org/bots/api#inlinequeryresultmpeg4gif) for more information.
|
||||
* Added field `via_chat_folder_invite_link` to `\TgBotLib\Objects\Telegram\ChatMemberUpdated` to represent the invite link, which was used by the user to join the chat; for joining by invite link events only.
|
||||
* Added object `\TgBotLib\Objects\Telegram\InlineQueryResult\InlineQueryResultVideo`, see [InlineQueryResultVideo](https://core.telegram.org/bots/api#inlinequeryresultvideo) for more information.
|
||||
* Added object `\TgBotLib\Objects\Telegram\InlineQueryResult\InlineQueryResultAudio`, see [InlineQueryResultAudio](https://core.telegram.org/bots/api#inlinequeryresultaudio) for more information.
|
||||
* Added object `\TgBotLib\Objects\Telegram\InlineQueryResult\InlineQueryResultVoice`, see [InlineQueryResultVoice](https://core.telegram.org/bots/api#inlinequeryresultvoice) for more information.
|
||||
* Added object `\TgBotLib\Objects\Telegram\InlineQueryResult\InlineQueryResultDocument`, see [InlineQueryResultDocument](https://core.telegram.org/bots/api#inlinequeryresultdocument) for more information.
|
||||
* Added object `\TgBotLib\Objects\Telegram\InlineQueryResult\InlineQueryResultLocation`, see [InlineQueryResultLocation](https://core.telegram.org/bots/api#inlinequeryresultlocation) for more information.
|
||||
* Added object `\TgBotLib\Objects\Telegram\InlineQueryResult\InlineQueryResultVenue`, see [InlineQueryResultVenue](https://core.telegram.org/bots/api#inlinequeryresultvenue) for more information.
|
||||
* Added object `\TgBotLib\Objects\Telegram\InlineQueryResult\InlineQueryResultContact`, see [InlineQueryResultContact](https://core.telegram.org/bots/api#inlinequeryresultcontact) for more information.
|
||||
* Added object `\TgBotLib\Objects\Telegram\InlineQueryResult\InlineQueryResultGame`, see [InlineQueryResultGame](https://core.telegram.org/bots/api#inlinequeryresultgame) for more information.
|
||||
* Added class `\TgBotLib\Objects\Telegram\InlineQueryResult` which is the base class for all inline query results, additionally added `\TgBotLib\Abstracts\InlineQueryResultType` to represent the type of inline query result object.
|
||||
* Added method `\TgBotLib\Bot::answerWebAppQuery` to answer a callback query sent from a web app, which returns the newly added `\TgBotLib\Objects\Telegram\SentWebAppMessage` object on success.
|
||||
* Implemented Telegram's currency API `\TgBotLib\Classes\Utilities::getCurrency` to get basic information about the currency of the specified country, see [Telegram's currency API](https://core.telegram.org/bots/payments) for more information.
|
||||
|
||||
### Changed
|
||||
* Refactored InputMessageContent types to its own namespace so InputMessageContent can always return the correct InputMessageContent object type when calling `fromArray()`
|
||||
* Added methods `\TgBotLib\Objects\Telegram\InlineKeyboardButton::setUrl`, `\TgBotLib\Objects\Telegram\InlineKeyboardButton::setText`, `\TgBotLib\Objects\Telegram\InlineKeyboardButton::setCallbackData`,
|
||||
`\TgBotLib\Objects\Telegram\InlineKeyboardButton::setWebApp`, `\TgBotLib\Objects\Telegram\InlineKeyboardButton::setLoginUrl`,
|
||||
`\TgBotLib\Objects\Telegram\InlineKeyboardButton::setSwitchInlineQuery`, `\TgBotLib\Objects\Telegram\InlineKeyboardButton::setSwitchInlineQueryCurrentChat`,
|
||||
`\TgBotLib\Objects\Telegram\InlineKeyboardButton::setCallbackGame`, `\TgBotLib\Objects\Telegram\InlineKeyboardButton::setPay`
|
||||
to `\TgBotLib\Objects\Telegram\InlineKeyboardButton`
|
||||
* Added methods `\TgBotLib\Objects\Telegram\InlineKeyboardMarkup::removeRow` & `\TgBotLib\Objects\Telegram\InlineKeyboardMarkup::addRow` to `\TgBotLib\Objects\Telegram\InlineKeyboardMarkup`
|
||||
* Added method `\TgBotLib\Objects\Telegram\WebAppInfo::setUrl` to `\TgBotLib\Objects\Telegram\WebAppInfo`
|
||||
* Added methods `\TgBotLib\Classes\Validate::url`, `\TgBotLib\Classes\Validate::length`, & `\TgBotLib\Classes\Validate::isHttps` to `\TgBotLib\Classes\Validate`
|
||||
* Updated documentation for `\TgBotLib\Bot::editMessageMedia`
|
||||
* Renamed namespace from `\TgBotLib\Abstracts` to `\TgBotLib\Enums`
|
||||
* Updated class type to `final class` in `\TgBotLib\Enums > BotCommandScopeType`
|
||||
* Updated class type to `final class` in `\TgBotLib\Enums > ChatActionType`
|
||||
* Updated class type to `final class` in `\TgBotLib\Enums > ChatMemberStatus`
|
||||
* Updated class type to `final class` in `\TgBotLib\Enums > ChatType`
|
||||
* Updated class type to `final class` in `\TgBotLib\Enums > EventType`
|
||||
* Updated class type to `final class` in `\TgBotLib\Enums > InlineQueryResultType`
|
||||
* Updated class type to `final class` in `\TgBotLib\Enums > InputMediaType`
|
||||
* Updated class type to `final class` in `\TgBotLib\Enums > InputButtonType`
|
||||
* Updated class type to `final class` in `\TgBotLib\Enums > MessageEntityType`
|
||||
* Updated class type to `final class` in `\TgBotLib\Enums > PassportElementType`
|
||||
* Updated class type to `final class` in `\TgBotLib\Enums > PollType`
|
||||
* Updated class type to `final class` in `\TgBotLib\Enums > StickerFormat`
|
||||
* Updated class type to `final class` in `\TgBotLib\Enums > StickerType`
|
||||
* Updated class type to `final class` in `\TgBotLib\Enums > ThumbnailMimeType`
|
||||
* Updated class type to `final class` in `\TgBotLib\Enums > UpdateEventType`
|
||||
* Updated method `\TgBotLib > Bot > handleGetUpdates()` to handle exceptions
|
||||
* Updated README.md to reflect the new changes with TamerLib 2.+
|
||||
|
||||
|
||||
### Fixed
|
||||
* Fixed type in `\TgBotLib\Objects\Telegram > Message > fromArray()` where `forum_topic_created` is being parsed for
|
||||
forum_topic_edited instead of `forum_topic_edited`
|
||||
|
||||
|
||||
|
||||
## [6.6.0] - 2023-04-10
|
||||
|
||||
This update accompanies the release of the [Telegram Bot API 6.6](https://core.telegram.org/bots/api#march-9-2023).
|
||||
|
||||
### Added
|
||||
* Added the ability to set different bot descriptions for different user languages using the method `\TgBotLib\Bot\setMyDescription()`
|
||||
see [setMyDescription](https://core.telegram.org/bots/api#setmydescription) for more information.
|
||||
* Added the ability to get the current bot description in the given language as the class [BotDescription](https://core.telegram.org/bots/api#botdescription)
|
||||
using the method `\TgBotLib\Bot\getMyDescription()` see [getMyDescription](https://core.telegram.org/bots/api#getmydescription) for more information.
|
||||
* Added the ability to set different bot short descriptions for different user languages using the method `\TgBotLib\Bot\setMyShortDescription()`
|
||||
see [setMyShortDescription](https://core.telegram.org/bots/api#setmyshortdescription) for more information.
|
||||
* Added the ability to get the current bot short description in the given language as the class [BotShortDescription](https://core.telegram.org/bots/api#botshortdescription)
|
||||
using the method `\TgBotLib\Bot\getMyShortDescription()` see [getMyShortDescription](https://core.telegram.org/bots/api#getmyshortdescription) for more information.
|
||||
* Added method `\TgBotLib\Bot\sendSticker()` to send a sticker to a chat. See [sendSticker](https://core.telegram.org/bots/api#sendsticker) for more information.
|
||||
* Added method `\TgBotLib\Bot\createNewStickerSet()` to create a new sticker set owned by a user. See [createNewStickerSet](https://core.telegram.org/bots/api#createnewstickerset) for more information.
|
||||
* Added the field _needs_repainting_ to the [Sticker](https://core.telegram.org/bots/api#sticker) class
|
||||
which can be obtained via `TgBotLib\Objects\Telegram\Sticker\needsRepainting()`
|
||||
* Added method `\TgBotLib\Bot\addStickerToSet()` to add a new sticker to a set created by the bot.
|
||||
See [addStickerToSet](https://core.telegram.org/bots/api#addstickertoset) for more information.
|
||||
* Added abstract class `\TgBotLib\Abstracts\StickerFormat` to represent a sticker format ("`static`", "`animated`" or "`video`")
|
||||
* Added method `\TgBotLib\Bot\uploadStickerFile()` to upload a sticker file with a sticker for later use in `createNewStickerSet` and `addStickerToSet` methods (can be used multiple times).
|
||||
See [uploadStickerFile](https://core.telegram.org/bots/api#uploadstickerfile) for more information.
|
||||
* Added method `\TgBotLib\Bot\setCustomEmojiStickerSetThumbnail()` to set the thumbnail of a sticker set.
|
||||
See [setCustomEmojiStickerSetThumbnail](https://core.telegram.org/bots/api#setcustomemojistickersetthumbnail) for more information.
|
||||
* Added object `\TgBotLib\Objects\Telegram\StickerSet` to represent a sticker set.
|
||||
* Added method `\TgBotLib\Bot\setStickerSetThumbnail()` to set the thumbnail of a sticker set.
|
||||
See [setStickerSetThumbnail](https://core.telegram.org/bots/api#setstickersetthumbnail) for more information.
|
||||
* Added method `\TgBotLib\Bot\setStickerSetTitle()` to set the title of a sticker set.
|
||||
See [setStickerSetTitle](https://core.telegram.org/bots/api#setstickersettitle) for more information.
|
||||
* Added method `\TgBotLib\Bot\deleteStickerSet()` to delete a sticker set.
|
||||
See [deleteStickerSet](https://core.telegram.org/bots/api#deletestickerset) for more information.
|
||||
* Added method `\TgBotLib\Bot\setStickerEmojiList()` to set the list of emojis for a sticker set.
|
||||
See [setStickerEmojiList](https://core.telegram.org/bots/api#setstickeremojilist) for more information.
|
||||
* Added method `\TgBotLib\Bot\setStickerKeywords()` to set the list of emojis for a sticker set.
|
||||
See [setStickerKeywords](https://core.telegram.org/bots/api#setstickerkeywords) for more information.
|
||||
* Added method `\TgBotLib\Bot\setStickerMaskPosition()` to change the mask position of a mask sticker.
|
||||
See [setStickerMaskPosition](https://core.telegram.org/bots/api#setstickermaskposition) for more information.
|
||||
|
||||
### Changed
|
||||
* Removed unused `__destruct()` method from `\TgBotLib\Bot`
|
||||
* Added proper construction for `PollOption[]` objects in `TgBotLib\Objects\Telegram\Poll`
|
||||
* Renamed `thumb` field in `TgBotLib\Objects\Telegram\Animation` to `thumbnail`
|
||||
* Renamed `thumb` field in `TgBotLib\Objects\Telegram\Audio` to `thumbnail`
|
||||
* Renamed `thumb` field in `TgBotLib\Objects\Telegram\Document` to `thumbnail`
|
||||
* Renamed `thumb` field in `TgBotLib\Objects\Telegram\Sticker` to `thumbnail`
|
||||
* Renamed `thumb` field in `TgBotLib\Objects\Telegram\Video` to `thumbnail`
|
||||
* Renamed `thumb` field in `TgBotLib\Objects\Telegram\VideoNote` to `thumbnail`
|
||||
|
||||
### Fixed
|
||||
* Fixed `TgBotLib\Objects\Telegram\Sticker\toArray()` to properly return the `premium_animation` field
|
||||
|
||||
## [6.5.2] - 2023-02-26
|
||||
|
||||
### Added
|
||||
* Added dependency `net.nosial.tempfile` to create temporary files when uploading content from memory.
|
||||
* Added `\TgBotLib\Abstracts\ChatActionType`
|
||||
* Added logging events to `\TgBotLib\Bot\handleUpdate()`
|
||||
|
||||
### Fixed
|
||||
* Fixed file uploads when trying to upload content from memory.
|
||||
|
||||
|
||||
## [6.5.1] - 2023-02-23
|
||||
|
||||
### Fixed
|
||||
* Added a null-safe check for `Poll`'s `explanation_entities` field. [#1](https://git.n64.cc/nosial/libs/tgbot/-/issues/1)
|
||||
* Added a null-safe check for `Poll`'s `explanation_entities` field. [#1](https://git.n64.cc/nosial/libs/tgbot/-/issues/1)
|
||||
|
||||
|
||||
## [6.5.0] - 2023-02-20
|
||||
|
||||
### Added
|
||||
* First Release
|
||||
* First Release
|
35
Makefile
35
Makefile
|
@ -1,8 +1,33 @@
|
|||
# Variables
|
||||
DEFAULT_CONFIGURATION ?= release
|
||||
LOG_LEVEL = debug
|
||||
|
||||
# Default Target
|
||||
all: release release-compressed release-executable release-executable-compressed debug debug-compressed
|
||||
|
||||
# Build Steps
|
||||
release:
|
||||
ncc build --config="release"
|
||||
ncc build --config=release --log-level $(LOG_LEVEL)
|
||||
release-compressed:
|
||||
ncc build --config=release-compressed --log-level $(LOG_LEVEL)
|
||||
release-executable:
|
||||
ncc build --config=release-executable --log-level $(LOG_LEVEL)
|
||||
release-executable-compressed:
|
||||
ncc build --config=release-executable-compressed --log-level $(LOG_LEVEL)
|
||||
debug:
|
||||
ncc build --config=debug --log-level $(LOG_LEVEL)
|
||||
debug-compressed:
|
||||
ncc build --config=debug-compressed --log-level $(LOG_LEVEL)
|
||||
|
||||
install:
|
||||
ncc package install --package="build/release/net.nosial.tgbotlib.ncc" --skip-dependencies --reinstall -y
|
||||
|
||||
uninstall:
|
||||
ncc package uninstall -y --package="net.nosial.tgbotlib"
|
||||
install: release
|
||||
ncc package install --package=build/release/net.nosial.tgbotlib.ncc --skip-dependencies --build-source --reinstall -y --log-level $(LOG_LEVEL)
|
||||
|
||||
test: release
|
||||
[ -f phpunit.xml ] || { echo "phpunit.xml not found"; exit 1; }
|
||||
phpunit
|
||||
|
||||
clean:
|
||||
rm -rf build
|
||||
|
||||
.PHONY: all install test clean release release-compressed release-executable release-executable-compressed debug debug-compressed
|
295
README.md
295
README.md
|
@ -12,17 +12,7 @@ native around the API.
|
|||
* [TgBotLib](#tgbotlib)
|
||||
* [Table of contents](#table-of-contents)
|
||||
* [Versioning](#versioning)
|
||||
* [Installation](#installation)
|
||||
* [Compile from source](#compile-from-source)
|
||||
* [Requirements](#requirements)
|
||||
* [Usage](#usage)
|
||||
* [Documentation](#documentation)
|
||||
* [Single-Threaded & Multi-Threaded Bots](#single-threaded--multi-threaded-bots)
|
||||
* [Single-Threaded Bots](#single-threaded-bots)
|
||||
* [Multi-Threaded Bots](#multi-threaded-bots)
|
||||
* [Commands & Event Handlers](#commands--event-handlers)
|
||||
* [Commands](#commands)
|
||||
* [Event Handlers](#event-handlers)
|
||||
* [TODO](#todo)
|
||||
* [License](#license)
|
||||
<!-- TOC -->
|
||||
|
||||
|
@ -36,288 +26,9 @@ version is `4`. Library patches are used to fix bugs or add improvements in the
|
|||
Telegram Bot API version.
|
||||
|
||||
|
||||
## Installation
|
||||
## TODO
|
||||
|
||||
The library can be installed using ncc:
|
||||
|
||||
```bash
|
||||
ncc install -p "nosial/libs.tgbot=latest@n64"
|
||||
```
|
||||
|
||||
or by adding the following to your project.json file under the `build.dependencies` section:
|
||||
```json
|
||||
{
|
||||
"name": "net.nosial.tgbotlib",
|
||||
"version": "latest",
|
||||
"source_type": "remote",
|
||||
"source": "nosial/libs.tgbot=latest@n64"
|
||||
}
|
||||
```
|
||||
|
||||
If you don't have the n64 source configured, you can add it by running the following command:
|
||||
```bash
|
||||
ncc source add --name n64 --type gitlab --host git.n64.cc
|
||||
```
|
||||
|
||||
|
||||
## Compile from source
|
||||
|
||||
To compile the library from source, you need to have [ncc](https://git.n64.cc/nosial/ncc) installed, then run the
|
||||
following command:
|
||||
|
||||
```bash
|
||||
ncc build
|
||||
```
|
||||
|
||||
|
||||
## Requirements
|
||||
|
||||
The library requires PHP 8.0 or higher.
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
1. Import the library using `import('net.nosial.tgbotlib');`
|
||||
2. Create a new instance of the `TgBotLib\Bot` class, passing the bot token as the first argument
|
||||
3. Profit
|
||||
|
||||
```php
|
||||
require 'ncc';
|
||||
import('net.nosial.tgbotlib');
|
||||
|
||||
$bot = new TgBotLib\Bot('<BOT TOKEN>');
|
||||
|
||||
/** @var \TgBotLib\Objects\Telegram\Update $update */
|
||||
foreach ($bot->getUpdates() as $update)
|
||||
{
|
||||
$bot->sendMessage($update->getMessage()->getChat()->getId(), 'Hello World!');
|
||||
}
|
||||
```
|
||||
|
||||
Each method of the `TgBotLib\Bot` class is named after the corresponding method of the Telegram Bot API, all methods
|
||||
contains an optional `$parameters` argument that can be used to pass additional parameters to the API method.
|
||||
|
||||
But for methods that has required parameters, the library provides a more convenient way to pass them, by using
|
||||
named parameters. For example, the `sendMessage` method requires the `chat_id` and `text` parameters, but instead
|
||||
of passing them as an array, you can pass them as named parameters:
|
||||
|
||||
```php
|
||||
$bot->sendMessage(
|
||||
chat_id: '<CHAT ID>',
|
||||
text: 'Hello World!',
|
||||
options: [
|
||||
'parse_mode' => 'Markdown',
|
||||
'disable_web_page_preview' => true,
|
||||
]
|
||||
);
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
Almost everything in the library has PhpDoc documentation, so you can use your IDE to get documentation for the
|
||||
library. For example, in PhpStorm, you can press `Ctrl+Q` on a method to get the documentation for it:
|
||||
|
||||

|
||||
|
||||
## Single-Threaded & Multi-Threaded Bots
|
||||
|
||||
This part will explain how to implement single-threaded and multi-threaded bots using the library.
|
||||
For more examples see the [tests](tests) directory.
|
||||
|
||||
### Single-Threaded Bots
|
||||
|
||||
To implement a single-threaded bot, it's very self-explanatory, you just need to create a new instance of the
|
||||
`TgBotLib\Bot` class and use it to handle the updates:
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
// Import ncc
|
||||
require 'ncc';
|
||||
|
||||
import('net.nosial.tgbotlib');
|
||||
|
||||
// Require commands & event handlers
|
||||
require 'commands' . DIRECTORY_SEPARATOR . 'StartCommand.php';
|
||||
require 'commands' . DIRECTORY_SEPARATOR . 'HashCommand.php';
|
||||
|
||||
// Create a new instance of the bot
|
||||
$bot = new TgBotLib\Bot(getenv('BOT_TOKEN'));
|
||||
|
||||
// Loop forever
|
||||
while(true)
|
||||
{
|
||||
/** @var \TgBotLib\Objects\Telegram\Update $update */
|
||||
foreach ($bot->getUpdates() as $update)
|
||||
{
|
||||
$bot->sendMessage($update->getMessage()->getChat()->getId(), 'Hello World!');
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This approach is very simple and allows for easier debugging, but it's not recommended for production use, because
|
||||
it will block the script until the updates are handled, and if the bot receives a lot of updates, it will take a
|
||||
long time to handle them. So it's recommended to use a multithreaded approach for production bots.
|
||||
|
||||
|
||||
### Multi-Threaded Bots
|
||||
|
||||
To implement a multi-threaded bot, you need to install [TamerLib](https://git.n64.cc/nosial/libs/tamer) which will allow
|
||||
you to run parallel operations using a Message Server
|
||||
|
||||
First create a worker process that will handle the updates:
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
// Import ncc
|
||||
require 'ncc';
|
||||
|
||||
// Import packages
|
||||
import('net.nosial.tgbotlib');
|
||||
import('net.nosial.tamerlib');
|
||||
|
||||
// Require commands
|
||||
require 'commands' . DIRECTORY_SEPARATOR . 'StartCommand.php';
|
||||
require 'commands' . DIRECTORY_SEPARATOR . 'HashCommand.php';
|
||||
|
||||
// Initialize the bot
|
||||
$bot = new TgBotLib\Bot('bot_token');
|
||||
|
||||
// Set the command handlers
|
||||
$bot->setCommandHandler('start', new \commands\StartCommand());
|
||||
$bot->setCommandHandler('hash', new \commands\HashCommand());
|
||||
|
||||
// Initialize the worker & register the handle_update function
|
||||
TamerLib\Tamer::initWorker();
|
||||
TamerLib\Tamer::addFunction('handle_update', function (\TamerLib\Objects\Job $job) use ($bot)
|
||||
{
|
||||
$bot->handleUpdate(\TgBotLib\Objects\Telegram\Update::fromArray(json_decode($job->getData(), true)));
|
||||
});
|
||||
|
||||
// Work forever
|
||||
TamerLib\Tamer::work();
|
||||
```
|
||||
|
||||
Then create a master process that will send the updates to the worker:
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
// Import ncc
|
||||
require 'ncc';
|
||||
|
||||
// Import packages
|
||||
import('net.nosial.tgbotlib');
|
||||
import('net.nosial.tamerlib');
|
||||
|
||||
// Require commands
|
||||
require 'commands' . DIRECTORY_SEPARATOR . 'StartCommand.php';
|
||||
require 'commands' . DIRECTORY_SEPARATOR . 'HashCommand.php';
|
||||
|
||||
// Initialize the bot
|
||||
$bot = new TgBotLib\Bot('bot_token');
|
||||
|
||||
// Initialize the master & add the worker
|
||||
TamerLib\Tamer::init(\TamerLib\Abstracts\ProtocolType::Gearman, [
|
||||
'127.0.0.1:4730'
|
||||
]);
|
||||
TamerLib\Tamer::addWorker('handle_update', 4);
|
||||
|
||||
// Start the workers
|
||||
TamerLib\Tamer::startWorkers();
|
||||
|
||||
// Handle updates forever
|
||||
while(true)
|
||||
{
|
||||
/** @var \TgBotLib\Objects\Telegram\Update $update */
|
||||
foreach ($bot->getUpdates() as $update)
|
||||
{
|
||||
TamerLib\Tamer::do('handle_update', json_encode($update->toArray()));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Commands & Event Handlers
|
||||
|
||||
Commands and event handlers are a way to handle commands and events sent by the user, for example, when the user
|
||||
sends the `/start` command, you can send a welcome message to the user.
|
||||
|
||||
|
||||
### Commands
|
||||
|
||||
The library provides a way to handle commands and events using the `TgBotLib\Bot` class, for example, to handle
|
||||
the `/start` command, you can use the `setCommandHandler` method:
|
||||
|
||||
```php
|
||||
<?php
|
||||
require 'ncc';
|
||||
import('net.nosial.tgbotlib');
|
||||
|
||||
$bot = new TgBotLib\Bot(getenv('BOT_TOKEN'));
|
||||
$bot->setCommandHandler('start', new \commands\StartCommand());
|
||||
```
|
||||
|
||||
The `setCommandHandler` method takes two arguments, the first being the command name (without the `/` prefix), and
|
||||
the second being a class that implements the `TgBotLib\Interfaces\CommandInterface` interface.
|
||||
|
||||
The interface has only one method, `handle`, which takes two arguments, the first being an instance of the
|
||||
`TgBotLib\Bot` class which is used to invoke the API without having to recreate the instance, and the second being
|
||||
the update object. The update object is an instance of the `TgBotLib\Objects\Telegram\Update` class, which contains
|
||||
all the information about the update.
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
namespace commands;
|
||||
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Interfaces\CommandInterface;
|
||||
use TgBotLib\Objects\Telegram\Update;
|
||||
|
||||
class StartCommand extends CommandInterface
|
||||
{
|
||||
public function handle(Bot $bot, Update $update): void
|
||||
{
|
||||
$bot->sendMessage($update->getMessage()->getChat()->getId(), 'Hello World!');
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Event Handlers
|
||||
|
||||
Event handles are similarly implemented, but instead of using the `setCommandHandler` method, you use the
|
||||
`setEventHandler` method:
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
require __DIR__ . DIRECTORY_SEPARATOR . 'autoload.php';
|
||||
|
||||
$bot = new TgBotLib\Bot(getenv('BOT_TOKEN'));
|
||||
|
||||
$bot->setEventHandler('message', new \events\MessageEvent());
|
||||
```
|
||||
|
||||
And the interface EventInterface is used instead of CommandInterface:
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
namespace events;
|
||||
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Interfaces\EventInterface;
|
||||
use TgBotLib\Objects\Telegram\Update;
|
||||
|
||||
class MessageEvent implements EventInterface
|
||||
{
|
||||
public function handle(Bot $bot, Update $update): void
|
||||
{
|
||||
$bot->sendMessage($update->getMessage()->getChat()->getId(), 'Hello World!');
|
||||
}
|
||||
}
|
||||
```
|
||||
Documentation will be redone
|
||||
|
||||
|
||||
# License
|
||||
|
|
14
bootstrap.php
Normal file
14
bootstrap.php
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
require 'ncc';
|
||||
|
||||
$token_path = __DIR__ . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'token.txt';
|
||||
|
||||
if(!file_exists($token_path))
|
||||
{
|
||||
throw new Exception(sprintf('The token file "%s" does not exist.', $token_path));
|
||||
}
|
||||
|
||||
define('BOT_TOKEN', trim(file_get_contents($token_path)));
|
||||
const TEST_CHAT_ID = -1001301191379;
|
||||
|
||||
import('net.nosial.tgbotlib');
|
15
phpdoc.dist.xml
Normal file
15
phpdoc.dist.xml
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<phpdocumentor configVersion="3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://www.phpdoc.org" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/phpDocumentor/phpDocumentor/master/data/xsd/phpdoc.xsd">
|
||||
<paths>
|
||||
<output>build/docs</output>
|
||||
<cache>build/cache</cache>
|
||||
</paths>
|
||||
<version number="latest">
|
||||
<api>
|
||||
<source dsn=".">
|
||||
<path>src/TgBotLib</path>
|
||||
</source>
|
||||
<default-package-name>TgBotLib</default-package-name>
|
||||
</api>
|
||||
</version>
|
||||
</phpdocumentor>
|
11
phpunit.xml
Normal file
11
phpunit.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<phpunit bootstrap="bootstrap.php">
|
||||
<testsuites>
|
||||
<testsuite name="TgBotLib Test Suite">
|
||||
<directory>tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<php>
|
||||
<ini name="error_reporting" value="-1"/>
|
||||
<server name="KERNEL_DIR" value="app/"/>
|
||||
</php>
|
||||
</phpunit>
|
68
project.json
68
project.json
|
@ -12,7 +12,7 @@
|
|||
"package": "net.nosial.tgbotlib",
|
||||
"description": "TgBotLib is a library for interacting with the Telegram Bot API",
|
||||
"company": "Nosial",
|
||||
"version": "6.5.1",
|
||||
"version": "8.0.2",
|
||||
"uuid": "b409e036-ab04-11ed-b32e-9d3f57a644ae"
|
||||
},
|
||||
"build": {
|
||||
|
@ -24,13 +24,75 @@
|
|||
"version": "latest",
|
||||
"source_type": "remote",
|
||||
"source": "nosial/libs.log=latest@n64"
|
||||
},
|
||||
{
|
||||
"name": "net.nosial.tempfile",
|
||||
"version": "latest",
|
||||
"source_type": "remote",
|
||||
"source": "nosial/libs.tempfile=latest@n64"
|
||||
},
|
||||
{
|
||||
"name": "net.nosial.optslib",
|
||||
"version": "latest",
|
||||
"source_type": "remote",
|
||||
"source": "nosial/libs.opts=latest@n64"
|
||||
},
|
||||
{
|
||||
"name": "net.nosial.psynclib",
|
||||
"version": "latest",
|
||||
"source_type": "remote",
|
||||
"source": "nosial/libs.psync=latest@n64"
|
||||
}
|
||||
],
|
||||
"configurations": [
|
||||
{
|
||||
"name": "release",
|
||||
"output_path": "build/release"
|
||||
"build_type": "ncc",
|
||||
"output": "build/release/%ASSEMBLY.PACKAGE%.ncc"
|
||||
},
|
||||
{
|
||||
"name": "release-compressed",
|
||||
"build_type": "ncc",
|
||||
"output": "build/release/%ASSEMBLY.PACKAGE%.gz.ncc",
|
||||
"options": {
|
||||
"compression": "high"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "release-executable",
|
||||
"build_type": "executable",
|
||||
"output": "build/release/%ASSEMBLY.NAME%",
|
||||
"options": {
|
||||
"ncc_configuration": "release"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "release-executable-compressed",
|
||||
"build_type": "executable",
|
||||
"output": "build/release/%ASSEMBLY.NAME%_gz",
|
||||
"options": {
|
||||
"ncc_configuration": "release-compressed"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "debug",
|
||||
"build_type": "ncc",
|
||||
"output": "build/debug/%ASSEMBLY.PACKAGE%.ncc",
|
||||
"define_constants": {
|
||||
"DEBUG": "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "debug-compressed",
|
||||
"build_type": "ncc",
|
||||
"output": "build/debug/%ASSEMBLY.PACKAGE%.gz.ncc",
|
||||
"define_constants": {
|
||||
"DEBUG": "1"
|
||||
},
|
||||
"options": {
|
||||
"compression": "high"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Abstracts;
|
||||
|
||||
abstract class BotCommandScopeType
|
||||
{
|
||||
const Default = 'default';
|
||||
const AllPrivateChats = 'all_private_chats';
|
||||
const AllGroupChats = 'all_group_chats';
|
||||
const AllChatAdministrators = 'all_chat_administrators';
|
||||
const Chat = 'chat';
|
||||
const ChatAdministrators = 'chat_administrators';
|
||||
const ChatMember = 'chat_member';
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Abstracts;
|
||||
|
||||
abstract class ChatMemberStatus
|
||||
{
|
||||
const Creator = 'creator';
|
||||
const Administrator = 'administrator';
|
||||
const Member = 'member';
|
||||
const Restricted = 'restricted';
|
||||
const Left = 'left';
|
||||
const Kicked = 'kicked';
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Abstracts;
|
||||
|
||||
abstract class ChatType
|
||||
{
|
||||
const Private = 'private';
|
||||
const Group = 'group';
|
||||
const Supergroup = 'supergroup';
|
||||
const Channel = 'channel';
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Abstracts;
|
||||
|
||||
abstract class EventType
|
||||
{
|
||||
const GenericUpdate = 'generic_update';
|
||||
const Message = 'message';
|
||||
const EditedMessage = 'edited_message';
|
||||
const GenericCommandMessage = 'generic_command_message';
|
||||
const ChatMemberJoined = 'chat_member_joined';
|
||||
const ChatMemberLeft = 'chat_member_left';
|
||||
const ChatMemberKicked = 'chat_member_kicked';
|
||||
const ChatMemberBanned = 'chat_member_banned';
|
||||
const ChatMemberUnbanned = 'chat_member_unbanned';
|
||||
const ChatMemberPromoted = 'chat_member_promoted';
|
||||
const ChatMemberDemoted = 'chat_member_demoted';
|
||||
const ChatMemberRestricted = 'chat_member_restricted';
|
||||
const ChatMemberUnrestricted = 'chat_member_unrestricted';
|
||||
const ChatTitleChanged = 'chat_title_changed';
|
||||
const ChatPhotoChanged = 'chat_photo_changed';
|
||||
Const CallbackQuery = 'callback_query';
|
||||
|
||||
const All = [
|
||||
self::GenericUpdate,
|
||||
self::Message,
|
||||
self::EditedMessage,
|
||||
self::GenericCommandMessage,
|
||||
self::ChatMemberJoined,
|
||||
self::ChatMemberLeft,
|
||||
self::ChatMemberKicked,
|
||||
self::ChatMemberBanned,
|
||||
self::ChatMemberUnbanned,
|
||||
self::ChatMemberPromoted,
|
||||
self::ChatMemberDemoted,
|
||||
self::ChatMemberRestricted,
|
||||
self::ChatMemberUnrestricted,
|
||||
self::ChatTitleChanged,
|
||||
self::ChatPhotoChanged,
|
||||
self::CallbackQuery,
|
||||
];
|
||||
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Abstracts;
|
||||
|
||||
abstract class InputMediaType
|
||||
{
|
||||
const Photo = 'photo';
|
||||
const Video = 'video';
|
||||
const Animation = 'animation';
|
||||
const Audio = 'audio';
|
||||
const Document = 'document';
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Abstracts;
|
||||
|
||||
abstract class MenuButtonType
|
||||
{
|
||||
const Commands = 'commands';
|
||||
const WebApp = 'web_app';
|
||||
const Default = 'default';
|
||||
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Abstracts;
|
||||
|
||||
abstract class MessageEntityType
|
||||
{
|
||||
const Mention = 'mention';
|
||||
|
||||
const Hashtag = 'hashtag';
|
||||
|
||||
const CashTag = 'cashtag';
|
||||
|
||||
const BotCommand = 'bot_command';
|
||||
|
||||
const Url = 'url';
|
||||
|
||||
const Email = 'email';
|
||||
|
||||
const PhoneNumber = 'phone_number';
|
||||
|
||||
const Bold = 'bold';
|
||||
|
||||
const Italic = 'italic';
|
||||
|
||||
const Underline = 'underline';
|
||||
|
||||
const Strikethrough = 'strikethrough';
|
||||
|
||||
const Spoiler = 'spoiler';
|
||||
|
||||
const Code = 'code';
|
||||
|
||||
const Pre = 'pre';
|
||||
|
||||
const TextLink = 'text_link';
|
||||
|
||||
const TextMention = 'text_mention';
|
||||
|
||||
const CustomEmoji = 'custom_emoji';
|
||||
|
||||
}
|
153
src/TgBotLib/Abstracts/Method.php
Normal file
153
src/TgBotLib/Abstracts/Method.php
Normal file
|
@ -0,0 +1,153 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Abstracts;
|
||||
|
||||
use CURLFile;
|
||||
use CurlHandle;
|
||||
use InvalidArgumentException;
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Exceptions\TelegramException;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
|
||||
abstract class Method
|
||||
{
|
||||
/**
|
||||
* Executes a bot command with the given parameters.
|
||||
*
|
||||
* @param Bot $bot The bot instance on which the command is to be executed.
|
||||
* @param array $parameters The parameters required for the bot command.
|
||||
* @return ObjectTypeInterface|ObjectTypeInterface[]|mixed The result of the bot command.
|
||||
* @throws TelegramException if the response from the bot command is not valid.
|
||||
* @throws InvalidArgumentException if the required parameters are not provided.
|
||||
*/
|
||||
public abstract static function execute(Bot $bot, array $parameters=[]): mixed;
|
||||
|
||||
/**
|
||||
* Retrieves a list of required parameters for a specific operation.
|
||||
*
|
||||
* @return array|null An array of required parameters.
|
||||
*/
|
||||
public abstract static function getRequiredParameters(): ?array;
|
||||
|
||||
/**
|
||||
* Retrieves the optional parameters for a request.
|
||||
*
|
||||
* @return array|null An array of optional parameters.
|
||||
*/
|
||||
public abstract static function getOptionalParameters(): ?array;
|
||||
|
||||
/**
|
||||
* Builds a cURL handle for making a POST request to a bot's endpoint.
|
||||
*
|
||||
* @param Bot $bot The bot object containing the endpoint information.
|
||||
* @param string $method
|
||||
* @param array|null $parameters An array of parameters to be sent in the POST request.
|
||||
* @return CurlHandle The configured cURL handle ready for execution.
|
||||
*/
|
||||
protected static function buildPost(Bot $bot, string $method, ?array $parameters = null): CurlHandle {
|
||||
$curl = curl_init(sprintf('%s/bot%s/%s', $bot->getEndpoint(), $bot->getToken(), $method));
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
if ($parameters === null)
|
||||
{
|
||||
curl_setopt($curl, CURLOPT_POST, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($parameters));
|
||||
}
|
||||
|
||||
return $curl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a cURL handle for uploading a file to the Telegram API.
|
||||
*
|
||||
* @param Bot $bot The bot instance used to get the endpoint.
|
||||
* @param string $file_param The parameter name for the file to be uploaded.
|
||||
* @param string $file_path The file path of the file to be uploaded.
|
||||
* @param array $parameters Additional parameters to be included in the request.
|
||||
* @return CurlHandle The cURL handle configured for the file upload.
|
||||
*/
|
||||
protected static function buildUpload(Bot $bot, string $method, string $file_param, string $file_path, array $parameters): CurlHandle
|
||||
{
|
||||
$curl = curl_init(sprintf('%s/bot%s/%s', $bot->getEndpoint(), $bot->getToken(), $method));
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, ['Content-Type: multipart/form-data']);
|
||||
|
||||
// Merge file with other parameters
|
||||
$parameters[$file_param] = new CURLFile($file_path);
|
||||
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $parameters);
|
||||
|
||||
return $curl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a cURL handle for a multi-part file upload request to a bot API.
|
||||
*
|
||||
* @param Bot $bot The bot instance to configure the request for.
|
||||
* @param string $method The API method to call.
|
||||
* @param array $files An associative array of parameter names and file paths to upload.
|
||||
* @param array $parameters An associative array of additional parameters for the request.
|
||||
* @return CurlHandle The configured cURL handle.
|
||||
*/
|
||||
protected static function buildMultiUpload(Bot $bot, string $method, array $files, array $parameters): CurlHandle
|
||||
{
|
||||
$curl = curl_init(sprintf('%s/bot%s/%s', $bot->getEndpoint(), $bot->getToken(), $method));
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, ['Content-Type: multipart/form-data']);
|
||||
|
||||
$postFields = [];
|
||||
|
||||
foreach ($files as $param => $file)
|
||||
{
|
||||
$postFields[$param] = new CURLFile($file);
|
||||
}
|
||||
|
||||
foreach ($parameters as $key => $value)
|
||||
{
|
||||
$postFields[$key] = $value;
|
||||
}
|
||||
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postFields);
|
||||
|
||||
return $curl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a cURL request and processes the response.
|
||||
*
|
||||
* @param CurlHandle $curl The cURL handle to be executed.
|
||||
* @return array The decoded response from the cURL request.
|
||||
* @throws TelegramException if the response is not a valid array,
|
||||
* or if the 'ok' field is not set or is false.
|
||||
*/
|
||||
protected static function executeCurl(CurlHandle $curl): mixed
|
||||
{
|
||||
$response = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
$result = json_decode($response, true);
|
||||
|
||||
if(!is_array($result))
|
||||
{
|
||||
throw new TelegramException('Invalid response from Telegram API');
|
||||
}
|
||||
|
||||
if(!isset($result['ok']))
|
||||
{
|
||||
throw new TelegramException('Invalid response from Telegram API');
|
||||
}
|
||||
|
||||
if($result['ok'] === false)
|
||||
{
|
||||
throw new TelegramException($result['description'], (int)$result['error_code']);
|
||||
}
|
||||
|
||||
return $result['result'];
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Abstracts;
|
||||
|
||||
abstract class PassportElementType
|
||||
{
|
||||
const PersonalDetails = 'personal_details';
|
||||
const Passport = 'passport';
|
||||
const DriverLicense = 'driver_license';
|
||||
const IdentityCard = 'identity_card';
|
||||
const InternalPassport = 'internal_passport';
|
||||
const Address = 'address';
|
||||
const UtilityBill = 'utility_bill';
|
||||
const BankStatement = 'bank_statement';
|
||||
const RentalAgreement = 'rental_agreement';
|
||||
const PassportRegistration = 'passport_registration';
|
||||
const TemporaryRegistration = 'temporary_registration';
|
||||
const PhoneNumber = 'phone_number';
|
||||
const Email = 'email';
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Abstracts;
|
||||
|
||||
abstract class PollType
|
||||
{
|
||||
const Regular = 'regular';
|
||||
|
||||
const Quiz = 'quiz';
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Abstracts;
|
||||
|
||||
abstract class StickerType
|
||||
{
|
||||
const Regular = 'regular';
|
||||
|
||||
const Mask = 'mask';
|
||||
|
||||
const CustomEmoji = 'custom_emoji';
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Abstracts;
|
||||
|
||||
abstract class UpdateEventType
|
||||
{
|
||||
const GenericUpdate = 'generic_update';
|
||||
|
||||
const Message = 'message';
|
||||
|
||||
const EditedMessage = 'edited_message';
|
||||
}
|
2676
src/TgBotLib/Bot.php
2676
src/TgBotLib/Bot.php
File diff suppressed because it is too large
Load diff
28
src/TgBotLib/Classes/Logger.php
Normal file
28
src/TgBotLib/Classes/Logger.php
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Classes;
|
||||
|
||||
use LogLib\Log;
|
||||
|
||||
class Logger
|
||||
{
|
||||
private static ?\LogLib\Logger $logger = null;
|
||||
|
||||
/**
|
||||
* Retrieves the instance of the logger. If the logger instance does not
|
||||
* exist, it initializes a new logger for the application and registers
|
||||
* the exception handler.
|
||||
*
|
||||
* @return \LogLib\Logger The logger instance.
|
||||
*/
|
||||
public static function getLogger(): \LogLib\Logger
|
||||
{
|
||||
if(self::$logger === null)
|
||||
{
|
||||
self::$logger = new \LogLib\Logger('net.nosial.tgbotlib');
|
||||
Log::registerExceptionHandler();
|
||||
}
|
||||
|
||||
return self::$logger;
|
||||
}
|
||||
}
|
|
@ -1,8 +1,53 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace TgBotLib\Classes;
|
||||
|
||||
use Exception;
|
||||
use LogLib\Log;
|
||||
use TgBotLib\Objects\Currency;
|
||||
|
||||
class Utilities
|
||||
{
|
||||
/**
|
||||
* @var Currency[]|null
|
||||
*/
|
||||
private static ?array $currencies_cache = null;
|
||||
|
||||
/**
|
||||
* Retrieves the currency object associated with the given currency code.
|
||||
*
|
||||
* @param string $code The currency code to look up.
|
||||
* @return Currency The currency object corresponding to the given code.
|
||||
* @throws Exception If the currency code is not found or fetching currencies fails.
|
||||
* @deprecated Not used
|
||||
*/
|
||||
public static function getCurrency(string $code): Currency
|
||||
{
|
||||
if (self::$currencies_cache === null)
|
||||
{
|
||||
$source = "https://core.telegram.org/bots/payments/currencies.json";
|
||||
Log::verbose('net.nosial.tgbotlib', "Fetching currencies from $source");
|
||||
|
||||
$data = json_decode(file_get_contents($source), true);
|
||||
|
||||
if ($data === null)
|
||||
throw new Exception("Failed to fetch currencies");
|
||||
|
||||
self::$currencies_cache = [];
|
||||
foreach ($data as $currency)
|
||||
{
|
||||
self::$currencies_cache[strtolower($currency['code'])] = Currency::fromArray($currency);
|
||||
}
|
||||
|
||||
Log::verbose('net.nosial.tgbotlib', "Fetched " . count(self::$currencies_cache) . " supported currencies");
|
||||
}
|
||||
|
||||
if(!isset(self::$currencies_cache[strtolower($code)]))
|
||||
{
|
||||
throw new Exception("Currency $code not found");
|
||||
}
|
||||
|
||||
return self::$currencies_cache[strtolower($code)];
|
||||
}
|
||||
}
|
|
@ -4,5 +4,39 @@
|
|||
|
||||
class Validate
|
||||
{
|
||||
/**
|
||||
* Validates if a URL is valid or not
|
||||
*
|
||||
* @param string $url
|
||||
* @return bool
|
||||
*/
|
||||
public static function url(string $url): bool
|
||||
{
|
||||
return filter_var($url, FILTER_VALIDATE_URL) !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given input is within the specified length range
|
||||
*
|
||||
* @param string $input
|
||||
* @param int $min_length
|
||||
* @param int $max_length
|
||||
* @return bool
|
||||
*/
|
||||
public static function length(string $input, int $min_length, int $max_length): bool
|
||||
{
|
||||
$length = strlen($input);
|
||||
return $length >= $min_length && $length <= $max_length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the given URL is an HTTPS URL
|
||||
*
|
||||
* @param string $url
|
||||
* @return bool
|
||||
*/
|
||||
public static function isHttps(string $url): bool
|
||||
{
|
||||
return strpos($url, 'https://') === 0;
|
||||
}
|
||||
}
|
180
src/TgBotLib/Enums/EventType.php
Normal file
180
src/TgBotLib/Enums/EventType.php
Normal file
|
@ -0,0 +1,180 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Enums;
|
||||
|
||||
use TgBotLib\Events\BusinessConnectionEvent;
|
||||
use TgBotLib\Events\BusinessMessageEvent;
|
||||
use TgBotLib\Events\CallbackQueryEvent;
|
||||
use TgBotLib\Events\ChannelPostEvent;
|
||||
use TgBotLib\Events\ChatBoostEvent;
|
||||
use TgBotLib\Events\ChatJoinRequestEvent;
|
||||
use TgBotLib\Events\ChatMemberUpdatedEvent;
|
||||
use TgBotLib\Events\ChosenInlineResultEvent;
|
||||
use TgBotLib\Events\CommandEvent;
|
||||
use TgBotLib\Events\DeletedBusinessMessagesEvent;
|
||||
use TgBotLib\Events\EditedBusinessMessageEvent;
|
||||
use TgBotLib\Events\EditedChannelPostEvent;
|
||||
use TgBotLib\Events\EditedMessageEvent;
|
||||
use TgBotLib\Events\InlineQueryEvent;
|
||||
use TgBotLib\Events\MessageEvent;
|
||||
use TgBotLib\Events\MessageReactionCountEvent;
|
||||
use TgBotLib\Events\MessageReactionEvent;
|
||||
use TgBotLib\Events\MyChatMemberUpdatedEvent;
|
||||
use TgBotLib\Events\PaidMediaPurchasedEvent;
|
||||
use TgBotLib\Events\PollAnswerEvent;
|
||||
use TgBotLib\Events\PollEvent;
|
||||
use TgBotLib\Events\PreCheckoutQueryEvent;
|
||||
use TgBotLib\Events\RemovedChatBoostEvent;
|
||||
use TgBotLib\Events\ShippingQueryEvent;
|
||||
use TgBotLib\Events\UpdateEvent;
|
||||
use TgBotLib\Objects\Update;
|
||||
|
||||
enum EventType : string
|
||||
{
|
||||
case UPDATE_EVENT = UpdateEvent::class;
|
||||
case REMOVED_CHAT_BOOST_EVENT = RemovedChatBoostEvent::class;
|
||||
case CHAT_BOOST_EVENT = ChatBoostEvent::class;
|
||||
case CHAT_JOIN_REQUEST_EVENT = ChatJoinRequestEvent::class;
|
||||
case CHAT_MEMBER_UPDATED = ChatMemberUpdatedEvent::class;
|
||||
case MY_CHAT_MEMBER_UPDATED = MyChatMemberUpdatedEvent::class;
|
||||
case POLL_ANSWER = PollAnswerEvent::class;
|
||||
case POLL = PollEvent::class;
|
||||
case PAID_MEDIA_PURCHASED = PaidMediaPurchasedEvent::class;
|
||||
case PRE_CHECKOUT_QUERY = PreCheckoutQueryEvent::class;
|
||||
case SHIPPING_QUERY = ShippingQueryEvent::class;
|
||||
case CALLBACK_QUERY = CallbackQueryEvent::class;
|
||||
case CHOSEN_INLINE_RESULT = ChosenInlineResultEvent::class;
|
||||
case INLINE_QUERY = InlineQueryEvent::class;
|
||||
case MESSAGE_REACTION_COUNT = MessageReactionCountEvent::class;
|
||||
case MESSAGE_REACTION = MessageReactionEvent::class;
|
||||
case DELETED_BUSINESS_MESSAGES = DeletedBusinessMessagesEvent::class;
|
||||
case EDITED_BUSINESS_MESSAGE = EditedBusinessMessageEvent::class;
|
||||
case BUSINESS_MESSAGE = BusinessMessageEvent::class;
|
||||
case BUSINESS_CONNECTION = BusinessConnectionEvent::class;
|
||||
case EDITED_CHANNEL_POST = EditedChannelPostEvent::class;
|
||||
case CHANNEL_POST = ChannelPostEvent::class;
|
||||
case EDITED_MESSAGE = EditedMessageEvent::class;
|
||||
case MESSAGE = MessageEvent::class;
|
||||
case COMMAND = CommandEvent::class;
|
||||
|
||||
/**
|
||||
* Determines the type of event based on the provided Update object.
|
||||
*
|
||||
* @param Update $update The update object containing event details.
|
||||
* @return EventType The type of event detected from the update.
|
||||
*/
|
||||
public static function determineEventType(Update $update): EventType
|
||||
{
|
||||
if($update->getRemovedChatBoost() !== null)
|
||||
{
|
||||
return EventType::REMOVED_CHAT_BOOST_EVENT;
|
||||
}
|
||||
|
||||
if($update->getChatBoost() !== null)
|
||||
{
|
||||
return EventType::CHAT_BOOST_EVENT;
|
||||
}
|
||||
|
||||
if($update->getChatJoinRequest() !== null)
|
||||
{
|
||||
return EventType::CHAT_JOIN_REQUEST_EVENT;
|
||||
}
|
||||
|
||||
if($update->getChatMember() !== null)
|
||||
{
|
||||
return EventType::CHAT_MEMBER_UPDATED;
|
||||
}
|
||||
|
||||
if($update->getMyChatMember() !== null)
|
||||
{
|
||||
return EventType::MY_CHAT_MEMBER_UPDATED;
|
||||
}
|
||||
|
||||
if($update->getPollAnswer() !== null)
|
||||
{
|
||||
return EventType::POLL_ANSWER;
|
||||
}
|
||||
|
||||
if($update->getPoll() !== null)
|
||||
{
|
||||
return EventType::POLL;
|
||||
}
|
||||
|
||||
if($update->getPurchasedPaidMedia() !== null)
|
||||
{
|
||||
return EventType::PAID_MEDIA_PURCHASED;
|
||||
}
|
||||
|
||||
if($update->getPreCheckoutQuery() !== null)
|
||||
{
|
||||
return EventType::PRE_CHECKOUT_QUERY;
|
||||
}
|
||||
|
||||
if($update->getShippingQuery() !== null)
|
||||
{
|
||||
return EventType::SHIPPING_QUERY;
|
||||
}
|
||||
|
||||
if($update->getChosenInlineResult() !== null)
|
||||
{
|
||||
return EventType::CHOSEN_INLINE_RESULT;
|
||||
}
|
||||
|
||||
if($update->getInlineQuery() !== null)
|
||||
{
|
||||
return EventType::INLINE_QUERY;
|
||||
}
|
||||
|
||||
if($update->getMessageReactionCount() !== null)
|
||||
{
|
||||
return EventType::MESSAGE_REACTION_COUNT;
|
||||
}
|
||||
|
||||
if($update->getMessageReaction() !== null)
|
||||
{
|
||||
return EventType::MESSAGE_REACTION;
|
||||
}
|
||||
|
||||
if($update->getDeletedBusinessMessages() !== null)
|
||||
{
|
||||
return EventType::DELETED_BUSINESS_MESSAGES;
|
||||
}
|
||||
|
||||
if($update->getEditedBusinessMessage() !== null)
|
||||
{
|
||||
return EventType::EDITED_BUSINESS_MESSAGE;
|
||||
}
|
||||
|
||||
if($update->getBusinessMessage() !== null)
|
||||
{
|
||||
return EventType::BUSINESS_MESSAGE;
|
||||
}
|
||||
|
||||
if($update->getBusinessConnection() !== null)
|
||||
{
|
||||
return EventType::BUSINESS_CONNECTION;
|
||||
}
|
||||
|
||||
if($update->getEditedChannelPost() !== null)
|
||||
{
|
||||
return EventType::EDITED_CHANNEL_POST;
|
||||
}
|
||||
|
||||
if($update->getChannelPost() !== null)
|
||||
{
|
||||
return EventType::CHANNEL_POST;
|
||||
}
|
||||
|
||||
if($update->getEditedMessage() !== null)
|
||||
{
|
||||
return EventType::EDITED_MESSAGE;
|
||||
}
|
||||
|
||||
if($update->getMessage() !== null)
|
||||
{
|
||||
return EventType::MESSAGE;
|
||||
}
|
||||
|
||||
return EventType::UPDATE_EVENT;
|
||||
}
|
||||
}
|
407
src/TgBotLib/Enums/Methods.php
Normal file
407
src/TgBotLib/Enums/Methods.php
Normal file
|
@ -0,0 +1,407 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Enums;
|
||||
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Exceptions\TelegramException;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Methods\AddStickerToSet;
|
||||
use TgBotLib\Methods\AnswerCallbackQuery;
|
||||
use TgBotLib\Methods\AnswerInlineQuery;
|
||||
use TgBotLib\Methods\AnswerPreCheckoutQuery;
|
||||
use TgBotLib\Methods\AnswerShippingQuery;
|
||||
use TgBotLib\Methods\AnswerWebAppQuery;
|
||||
use TgBotLib\Methods\ApproveChatJoinRequest;
|
||||
use TgBotLib\Methods\BanChatMember;
|
||||
use TgBotLib\Methods\BanChatSenderChat;
|
||||
use TgBotLib\Methods\Close;
|
||||
use TgBotLib\Methods\CloseForumTopic;
|
||||
use TgBotLib\Methods\CloseGeneralForumTopic;
|
||||
use TgBotLib\Methods\CopyMessage;
|
||||
use TgBotLib\Methods\CopyMessages;
|
||||
use TgBotLib\Methods\CreateChatInviteLink;
|
||||
use TgBotLib\Methods\CreateChatSubscriptionInviteLink;
|
||||
use TgBotLib\Methods\CreateForumTopic;
|
||||
use TgBotLib\Methods\CreateInvoiceLink;
|
||||
use TgBotLib\Methods\CreateNewStickerSet;
|
||||
use TgBotLib\Methods\DeclineChatJoinRequest;
|
||||
use TgBotLib\Methods\DeleteChatPhoto;
|
||||
use TgBotLib\Methods\DeleteChatStickerSet;
|
||||
use TgBotLib\Methods\DeleteForumTopic;
|
||||
use TgBotLib\Methods\DeleteMessage;
|
||||
use TgBotLib\Methods\DeleteMessages;
|
||||
use TgBotLib\Methods\DeleteMyCommands;
|
||||
use TgBotLib\Methods\DeleteStickerFromSet;
|
||||
use TgBotLib\Methods\DeleteStickerSet;
|
||||
use TgBotLib\Methods\DeleteWebhook;
|
||||
use TgBotLib\Methods\EditChatInviteLink;
|
||||
use TgBotLib\Methods\EditChatSubscriptionInviteLink;
|
||||
use TgBotLib\Methods\EditForumTopic;
|
||||
use TgBotLib\Methods\EditGeneralForumTopic;
|
||||
use TgBotLib\Methods\EditMessageCaption;
|
||||
use TgBotLib\Methods\EditMessageLiveLocation;
|
||||
use TgBotLib\Methods\EditMessageMedia;
|
||||
use TgBotLib\Methods\EditMessageReplyMarkup;
|
||||
use TgBotLib\Methods\EditMessageText;
|
||||
use TgBotLib\Methods\ExportChatInviteLink;
|
||||
use TgBotLib\Methods\ForwardMessage;
|
||||
use TgBotLib\Methods\ForwardMessages;
|
||||
use TgBotLib\Methods\GetAvailableGifts;
|
||||
use TgBotLib\Methods\GetBusinessConnection;
|
||||
use TgBotLib\Methods\GetChat;
|
||||
use TgBotLib\Methods\GetChatAdministrators;
|
||||
use TgBotLib\Methods\GetChatMember;
|
||||
use TgBotLib\Methods\GetChatMemberCount;
|
||||
use TgBotLib\Methods\GetChatMenuButton;
|
||||
use TgBotLib\Methods\GetCustomEmojiStickers;
|
||||
use TgBotLib\Methods\GetFile;
|
||||
use TgBotLib\Methods\GetForumTopicIconStickers;
|
||||
use TgBotLib\Methods\GetGameHighScores;
|
||||
use TgBotLib\Methods\GetMe;
|
||||
use TgBotLib\Methods\GetMyCommands;
|
||||
use TgBotLib\Methods\GetMyDefaultAdministratorRights;
|
||||
use TgBotLib\Methods\GetMyDescription;
|
||||
use TgBotLib\Methods\GetMyName;
|
||||
use TgBotLib\Methods\GetMyShortDescription;
|
||||
use TgBotLib\Methods\GetStarTransactions;
|
||||
use TgBotLib\Methods\GetStickerSet;
|
||||
use TgBotLib\Methods\GetUpdates;
|
||||
use TgBotLib\Methods\GetUserChatBoosts;
|
||||
use TgBotLib\Methods\GetUserProfilePhotos;
|
||||
use TgBotLib\Methods\GetWebhookInfo;
|
||||
use TgBotLib\Methods\HideGeneralForumTopic;
|
||||
use TgBotLib\Methods\LeaveChat;
|
||||
use TgBotLib\Methods\Logout;
|
||||
use TgBotLib\Methods\PinChatMessage;
|
||||
use TgBotLib\Methods\PromoteChatMember;
|
||||
use TgBotLib\Methods\ReopenForumTopic;
|
||||
use TgBotLib\Methods\ReopenGeneralForumTopic;
|
||||
use TgBotLib\Methods\ReplaceStickerInSet;
|
||||
use TgBotLib\Methods\RestrictChatMember;
|
||||
use TgBotLib\Methods\RevokeChatInviteLink;
|
||||
use TgBotLib\Methods\SavePreparedInlineMessage;
|
||||
use TgBotLib\Methods\SendAnimation;
|
||||
use TgBotLib\Methods\SendAudio;
|
||||
use TgBotLib\Methods\SendChatAction;
|
||||
use TgBotLib\Methods\SendContact;
|
||||
use TgBotLib\Methods\SendDice;
|
||||
use TgBotLib\Methods\SendDocument;
|
||||
use TgBotLib\Methods\SendGame;
|
||||
use TgBotLib\Methods\SendGift;
|
||||
use TgBotLib\Methods\SendInvoice;
|
||||
use TgBotLib\Methods\SendLocation;
|
||||
use TgBotLib\Methods\SendMediaGroup;
|
||||
use TgBotLib\Methods\SendMessage;
|
||||
use TgBotLib\Methods\SendPaidMedia;
|
||||
use TgBotLib\Methods\SendPhoto;
|
||||
use TgBotLib\Methods\SendPoll;
|
||||
use TgBotLib\Methods\SendSticker;
|
||||
use TgBotLib\Methods\SendVenue;
|
||||
use TgBotLib\Methods\SendVideo;
|
||||
use TgBotLib\Methods\SendVideoNote;
|
||||
use TgBotLib\Methods\SendVoice;
|
||||
use TgBotLib\Methods\SetChatAdministratorCustomTitle;
|
||||
use TgBotLib\Methods\SetChatDescription;
|
||||
use TgBotLib\Methods\SetChatMenuButton;
|
||||
use TgBotLib\Methods\SetChatPermissions;
|
||||
use TgBotLib\Methods\SetChatPhoto;
|
||||
use TgBotLib\Methods\SetChatStickerSet;
|
||||
use TgBotLib\Methods\SetChatTitle;
|
||||
use TgBotLib\Methods\SetCustomEmojiStickerSetThumbnail;
|
||||
use TgBotLib\Methods\SetGameScore;
|
||||
use TgBotLib\Methods\SetMessageReaction;
|
||||
use TgBotLib\Methods\SetMyCommands;
|
||||
use TgBotLib\Methods\SetMyDefaultAdministratorRights;
|
||||
use TgBotLib\Methods\SetMyDescription;
|
||||
use TgBotLib\Methods\SetMyName;
|
||||
use TgBotLib\Methods\SetMyShortDescription;
|
||||
use TgBotLib\Methods\SetPassportDataErrors;
|
||||
use TgBotLib\Methods\SetStickerEmojiList;
|
||||
use TgBotLib\Methods\SetStickerMaskPosition;
|
||||
use TgBotLib\Methods\SetStickerPositionInSet;
|
||||
use TgBotLib\Methods\SetStickerSetThumbnail;
|
||||
use TgBotLib\Methods\SetStickerSetTitle;
|
||||
use TgBotLib\Methods\SetWebhook;
|
||||
use TgBotLib\Methods\StopMessageLiveLocation;
|
||||
use TgBotLib\Methods\StopPoll;
|
||||
use TgBotLib\Methods\UnbanChatMember;
|
||||
use TgBotLib\Methods\UnbanChatSenderChat;
|
||||
use TgBotLib\Methods\UnhideGeneralForumTopic;
|
||||
use TgBotLib\Methods\UnpinAllChatMessages;
|
||||
use TgBotLib\Methods\UnpinAllForumTopicMessages;
|
||||
use TgBotLib\Methods\UnpinAllGeneralForumTopicMessages;
|
||||
use TgBotLib\Methods\UnpinChatMessage;
|
||||
use TgBotLib\Methods\UploadStickerFile;
|
||||
|
||||
enum Methods : string
|
||||
{
|
||||
case GET_UPDATES = 'getUpdates';
|
||||
case SET_WEBHOOK = 'setWebhook';
|
||||
case DELETE_WEBHOOK = 'deleteWebhook';
|
||||
case GET_WEBHOOK_INFO = 'getWebhookInfo';
|
||||
case GET_ME = 'getMe';
|
||||
case LOGOUT = 'logOut';
|
||||
case CLOSE = 'close';
|
||||
case SEND_MESSAGE = 'sendMessage';
|
||||
case FORWARD_MESSAGE = 'forwardMessage';
|
||||
case FORWARD_MESSAGES = 'forwardMessages';
|
||||
case COPY_MESSAGE = 'copyMessage';
|
||||
case COPY_MESSAGES = 'copyMessages';
|
||||
case SEND_PHOTO = 'sendPhoto';
|
||||
case SEND_AUDIO = 'sendAudio';
|
||||
case SEND_DOCUMENT = 'sendDocument';
|
||||
case SEND_VIDEO = 'sendVideo';
|
||||
case SEND_ANIMATION = 'sendAnimation';
|
||||
case SEND_VOICE = 'sendVoice';
|
||||
case SEND_VIDEO_NOTE = 'sendVideoNote';
|
||||
case SEND_PAID_MEDIA = 'sendPaidMedia';
|
||||
case SEND_MEDIA_GROUP = 'sendMediaGroup';
|
||||
case SEND_LOCATION = 'sendLocation';
|
||||
case SEND_VENUE = 'sendVenue';
|
||||
case SEND_CONTACT = 'sendContact';
|
||||
case SEND_POLL = 'sendPoll';
|
||||
case SEND_DICE = 'sendDice';
|
||||
case SEND_CHAT_ACTION = 'sendChatAction';
|
||||
case SET_MESSAGE_REACTION = 'setMessageReaction';
|
||||
case GET_USER_PROFILE_PHOTOS = 'getUserProfilePhotos';
|
||||
case GET_FILE = 'getFile';
|
||||
case BAN_CHAT_MEMBER = 'banChatMember';
|
||||
case UNBAN_CHAT_MEMBER = 'unbanChatMember';
|
||||
case RESTRICT_CHAT_MEMBER = 'restrictChatMember';
|
||||
case PROMOTE_CHAT_MEMBER = 'promoteChatMember';
|
||||
case SET_CHAT_ADMINISTRATOR_CUSTOM_TITLE = 'setChatAdministratorCustomTitle';
|
||||
case BAN_CHAT_SENDER_CHAT = 'banChatSenderChat';
|
||||
case UNBAN_CHAT_SENDER_CHAT = 'unbanChatSenderChat';
|
||||
case SET_CHAT_PERMISSIONS = 'setChatPermissions';
|
||||
case EXPORT_CHAT_INVITE_LINK = 'exportChatInviteLink';
|
||||
case CREATE_CHAT_INVITE_LINK = 'createChatInviteLink';
|
||||
case EDIT_CHAT_INVITE_LINK = 'editChatInviteLink';
|
||||
case CREATE_CHAT_SUBSCRIPTION_INVITE_LINK = 'createChatSubscriptionInviteLink';
|
||||
case EDIT_CHAT_SUBSCRIPTION_INVITE_LINK = 'editChatSubscriptionInviteLink';
|
||||
case REVOKE_CHAT_INVITE_LINK = 'revokeChatInviteLink';
|
||||
case APPROVE_CHAT_JOIN_REQUEST = 'approveChatJoinRequest';
|
||||
case DECLINE_CHAT_JOIN_REQUEST = 'declineChatJoinRequest';
|
||||
case SET_CHAT_PHOTO = 'setChatPhoto';
|
||||
case DELETE_CHAT_PHOTO = 'deleteChatPhoto';
|
||||
case SET_CHAT_TITLE = 'setChatTitle';
|
||||
case SET_CHAT_DESCRIPTION = 'setChatDescription';
|
||||
case PIN_CHAT_MESSAGE = 'pinChatMessage';
|
||||
case UNPIN_CHAT_MESSAGE = 'unpinChatMessage';
|
||||
case UNPIN_ALL_CHAT_MESSAGES = 'unpinAllChatMessages';
|
||||
case LEAVE_CHAT = 'leaveChat';
|
||||
case GET_CHAT = 'getChat';
|
||||
case GET_CHAT_ADMINISTRATORS = 'getChatAdministrators';
|
||||
case GET_CHAT_MEMBER_COUNT = 'getChatMemberCount';
|
||||
case GET_CHAT_MEMBER = 'getChatMember';
|
||||
case SET_CHAT_STICKER_SET = 'setChatStickerSet';
|
||||
case DELETE_CHAT_STICKER_SET = 'deleteChatStickerSet';
|
||||
case GET_FORUM_TOPIC_ICON_STICKERS = 'getForumTopicIconStickers';
|
||||
case CREATE_FORUM_TOPIC = 'createForumTopic';
|
||||
case EDIT_FORUM_TOPIC = 'editForumTopic';
|
||||
case CLOSE_FORUM_TOPIC = 'closeForumTopic';
|
||||
case REOPEN_FORUM_TOPIC = 'reopenForumTopic';
|
||||
case DELETE_FORUM_TOPIC = 'deleteForumTopic';
|
||||
case UNPIN_ALL_FORUM_TOPIC_MESSAGES = 'unpinAllForumTopicMessages';
|
||||
case EDIT_GENERAL_FORUM_TOPIC = 'editGeneralForumTopic';
|
||||
case CLOSE_GENERAL_FORUM_TOPIC = 'closeGeneralForumTopic';
|
||||
case REOPEN_GENERAL_FORUM_TOPIC = 'reopenGeneralForumTopic';
|
||||
case HIDE_GENERAL_FORUM_TOPIC = 'hideGeneralForumTopic';
|
||||
case UNHIDE_GENERAL_FORUM_TOPIC = 'unhideGeneralForumTopic';
|
||||
case UNPIN_ALL_GENERAL_FORUM_TOPIC_MESSAGES = 'unpinAllGeneralForumTopicMessages';
|
||||
case ANSWER_CALLBACK_QUERY = 'answerCallbackQuery';
|
||||
case GET_USER_CHAT_BOOSTS = 'getUserChatBoosts';
|
||||
case GET_BUSINESS_CONNECTION = 'getBusinessConnection';
|
||||
case SET_MY_COMMANDS = 'setMyCommands';
|
||||
case DELETE_MY_COMMANDS = 'deleteMyCommands';
|
||||
case GET_MY_COMMANDS = 'getMyCommands';
|
||||
case SET_MY_NAME = 'setMyName';
|
||||
case GET_MY_NAME = 'getMyName';
|
||||
case SET_MY_DESCRIPTION = 'setMyDescription';
|
||||
case GET_MY_DESCRIPTION = 'getMyDescription';
|
||||
case SET_MY_SHORT_DESCRIPTION = 'setMyShortDescription';
|
||||
case GET_MY_SHORT_DESCRIPTION = 'getMyShortDescription';
|
||||
case SET_CHAT_MENU_BUTTON = 'setChatMenuButton';
|
||||
case GET_CHAT_MENU_BUTTON = 'getChatMenuButton';
|
||||
case SET_MY_DEFAULT_ADMINISTRATOR_RIGHTS = 'setMyDefaultAdministratorRights';
|
||||
case GET_MY_DEFAULT_ADMINISTRATOR_RIGHTS = 'getMyDefaultAdministratorRights';
|
||||
case EDIT_MESSAGE_TEXT = 'editMessageText';
|
||||
case EDIT_MESSAGE_CAPTION = 'editMessageCaption';
|
||||
case EDIT_MESSAGE_MEDIA = 'editMessageMedia';
|
||||
case EDIT_MESSAGE_LIVE_LOCATION = 'editMessageLiveLocation';
|
||||
case STOP_MESSAGE_LIVE_LOCATION = 'stopMessageLiveLocation';
|
||||
case EDIT_MESSAGE_REPLY_MARKUP = 'editMessageReplyMarkup';
|
||||
case STOP_POLL = 'stopPoll';
|
||||
case DELETE_MESSAGE = 'deleteMessage';
|
||||
case DELETE_MESSAGES = 'deleteMessages';
|
||||
case SEND_STICKER = 'sendSticker';
|
||||
case GET_STICKER_SET = 'getStickerSet';
|
||||
case GET_CUSTOM_EMOJI_STICKERS = 'getCustomEmojiStickers';
|
||||
case UPLOAD_STICKER_FILE = 'uploadStickerFile';
|
||||
case CREATE_NEW_STICKER_SET = 'createNewStickerSet';
|
||||
case ADD_STICKER_TO_SET = 'addStickerToSet';
|
||||
case SET_STICKER_POSITION_IN_SET = 'setStickerPositionInSet';
|
||||
case DELETE_STICKER_FROM_SET = 'deleteStickerFromSet';
|
||||
case REPLACE_STICKER_IN_SET = 'replaceStickerInSet';
|
||||
case SET_STICKER_EMOJI_LIST = 'setStickerEmojiList';
|
||||
case SET_STICKER_MASK_POSITION = 'setStickerMaskPosition';
|
||||
case SET_STICKER_SET_TITLE = 'setStickerSetTitle';
|
||||
case SET_STICKER_SET_THUMBNAIL = 'setStickerSetThumbnail';
|
||||
case SET_CUSTOM_EMOJI_STICKER_SET_THUMBNAIL = 'setCustomEmojiStickerSetThumbnail';
|
||||
case DELETE_STICKER_SET = 'deleteStickerSet';
|
||||
case GET_AVAILABLE_GIFTS = 'getAvailableGifts';
|
||||
case SEND_GIFT = 'sendGift';
|
||||
case ANSWER_INLINE_QUERY = 'answerInlineQuery';
|
||||
case ANSWER_WEB_APP_QUERY = 'answerWebAppQuery';
|
||||
case SAVE_PREPARED_INLINE_MESSAGE = 'savePreparedInlineMessage';
|
||||
case SEND_INVOICE = 'sendInvoice';
|
||||
case CREATE_INVOICE_LINK = 'createInvoiceLink';
|
||||
case ANSWER_SHIPPING_QUERY = 'answerShippingQuery';
|
||||
case ANSWER_PRE_CHECKOUT_QUERY = 'answerPreCheckoutQuery';
|
||||
case GET_STAR_TRANSACTIONS = 'getStarTransactions';
|
||||
case SET_PASSPORT_DATA_ERRORS = 'setPassportDataErrors';
|
||||
case SEND_GAME = 'sendGame';
|
||||
case SET_GAME_SCORE = 'setGameScore';
|
||||
case GET_GAME_HIGH_SCORES = 'getGameHighScores';
|
||||
|
||||
/**
|
||||
* Executes a command on the provided bot with the given parameters.
|
||||
*
|
||||
* @param Bot $bot The bot instance on which the command will be executed.
|
||||
* @param array $parameters Optional parameters for the command.
|
||||
* @return ObjectTypeInterface|mixed The result of the command execution, varies based on the command.
|
||||
* @throws TelegramException if the command execution fails.
|
||||
*/
|
||||
public function execute(Bot $bot, array $parameters=[]): mixed
|
||||
{
|
||||
return match($this)
|
||||
{
|
||||
self::GET_UPDATES => GetUpdates::execute($bot, $parameters),
|
||||
self::SET_WEBHOOK => SetWebhook::execute($bot, $parameters),
|
||||
self::DELETE_WEBHOOK => DeleteWebhook::execute($bot, $parameters),
|
||||
self::GET_WEBHOOK_INFO => GetWebhookInfo::execute($bot, $parameters),
|
||||
self::GET_ME => GetMe::execute($bot, $parameters),
|
||||
self::LOGOUT => LogOut::execute($bot, $parameters),
|
||||
self::CLOSE => Close::execute($bot, $parameters),
|
||||
self::SEND_MESSAGE => SendMessage::execute($bot, $parameters),
|
||||
self::FORWARD_MESSAGE => ForwardMessage::execute($bot, $parameters),
|
||||
self::FORWARD_MESSAGES => ForwardMessages::execute($bot, $parameters),
|
||||
self::COPY_MESSAGE => CopyMessage::execute($bot, $parameters),
|
||||
self::COPY_MESSAGES => CopyMessages::execute($bot, $parameters),
|
||||
self::SEND_PHOTO => SendPhoto::execute($bot, $parameters),
|
||||
self::SEND_AUDIO => SendAudio::execute($bot, $parameters),
|
||||
self::SEND_DOCUMENT => SendDocument::execute($bot, $parameters),
|
||||
self::SEND_VIDEO => SendVideo::execute($bot, $parameters),
|
||||
self::SEND_ANIMATION => SendAnimation::execute($bot, $parameters),
|
||||
self::SEND_VOICE => SendVoice::execute($bot, $parameters),
|
||||
self::SEND_VIDEO_NOTE => SendVideoNote::execute($bot, $parameters),
|
||||
self::SEND_PAID_MEDIA => SendPaidMedia::execute($bot, $parameters),
|
||||
self::SEND_MEDIA_GROUP => SendMediaGroup::execute($bot, $parameters),
|
||||
self::SEND_LOCATION => SendLocation::execute($bot, $parameters),
|
||||
self::SEND_VENUE => SendVenue::execute($bot, $parameters),
|
||||
self::SEND_CONTACT => SendContact::execute($bot, $parameters),
|
||||
self::SEND_POLL => SendPoll::execute($bot, $parameters),
|
||||
self::SEND_DICE => SendDice::execute($bot, $parameters),
|
||||
self::SEND_CHAT_ACTION => SendChatAction::execute($bot, $parameters),
|
||||
self::SET_MESSAGE_REACTION => SetMessageReaction::execute($bot, $parameters),
|
||||
self::GET_USER_PROFILE_PHOTOS => GetUserProfilePhotos::execute($bot, $parameters),
|
||||
self::GET_FILE => GetFile::execute($bot, $parameters),
|
||||
self::BAN_CHAT_MEMBER => BanChatMember::execute($bot, $parameters),
|
||||
self::UNBAN_CHAT_MEMBER => UnbanChatMember::execute($bot, $parameters),
|
||||
self::RESTRICT_CHAT_MEMBER => RestrictChatMember::execute($bot, $parameters),
|
||||
self::PROMOTE_CHAT_MEMBER => PromoteChatMember::execute($bot, $parameters),
|
||||
self::SET_CHAT_ADMINISTRATOR_CUSTOM_TITLE => SetChatAdministratorCustomTitle::execute($bot, $parameters),
|
||||
self::BAN_CHAT_SENDER_CHAT => BanChatSenderChat::execute($bot, $parameters),
|
||||
self::UNBAN_CHAT_SENDER_CHAT => UnbanChatSenderChat::execute($bot, $parameters),
|
||||
self::SET_CHAT_PERMISSIONS => SetChatPermissions::execute($bot, $parameters),
|
||||
self::EXPORT_CHAT_INVITE_LINK => ExportChatInviteLink::execute($bot, $parameters),
|
||||
self::CREATE_CHAT_INVITE_LINK => CreateChatInviteLink::execute($bot, $parameters),
|
||||
self::EDIT_CHAT_INVITE_LINK => EditChatInviteLink::execute($bot, $parameters),
|
||||
self::CREATE_CHAT_SUBSCRIPTION_INVITE_LINK => CreateChatSubscriptionInviteLink::execute($bot, $parameters),
|
||||
self::EDIT_CHAT_SUBSCRIPTION_INVITE_LINK => EditChatSubscriptionInviteLink::execute($bot, $parameters),
|
||||
self::REVOKE_CHAT_INVITE_LINK => RevokeChatInviteLink::execute($bot, $parameters),
|
||||
self::APPROVE_CHAT_JOIN_REQUEST => ApproveChatJoinRequest::execute($bot, $parameters),
|
||||
self::DECLINE_CHAT_JOIN_REQUEST => DeclineChatJoinRequest::execute($bot, $parameters),
|
||||
self::SET_CHAT_PHOTO => SetChatPhoto::execute($bot, $parameters),
|
||||
self::DELETE_CHAT_PHOTO => DeleteChatPhoto::execute($bot, $parameters),
|
||||
self::SET_CHAT_TITLE => SetChatTitle::execute($bot, $parameters),
|
||||
self::SET_CHAT_DESCRIPTION => SetChatDescription::execute($bot, $parameters),
|
||||
self::PIN_CHAT_MESSAGE => PinChatMessage::execute($bot, $parameters),
|
||||
self::UNPIN_CHAT_MESSAGE => UnpinChatMessage::execute($bot, $parameters),
|
||||
self::UNPIN_ALL_CHAT_MESSAGES => UnpinAllChatMessages::execute($bot, $parameters),
|
||||
self::LEAVE_CHAT => LeaveChat::execute($bot, $parameters),
|
||||
self::GET_CHAT => GetChat::execute($bot, $parameters),
|
||||
self::GET_CHAT_ADMINISTRATORS => GetChatAdministrators::execute($bot, $parameters),
|
||||
self::GET_CHAT_MEMBER_COUNT => GetChatMemberCount::execute($bot, $parameters),
|
||||
self::GET_CHAT_MEMBER => GetChatMember::execute($bot, $parameters),
|
||||
self::SET_CHAT_STICKER_SET => SetChatStickerSet::execute($bot, $parameters),
|
||||
self::DELETE_CHAT_STICKER_SET => DeleteChatStickerSet::execute($bot, $parameters),
|
||||
self::GET_FORUM_TOPIC_ICON_STICKERS => GetForumTopicIconStickers::execute($bot, $parameters),
|
||||
self::CREATE_FORUM_TOPIC => CreateForumTopic::execute($bot, $parameters),
|
||||
self::EDIT_FORUM_TOPIC => EditForumTopic::execute($bot, $parameters),
|
||||
self::CLOSE_FORUM_TOPIC => CloseForumTopic::execute($bot, $parameters),
|
||||
self::REOPEN_FORUM_TOPIC => ReopenForumTopic::execute($bot, $parameters),
|
||||
self::DELETE_FORUM_TOPIC => DeleteForumTopic::execute($bot, $parameters),
|
||||
self::UNPIN_ALL_FORUM_TOPIC_MESSAGES => UnpinAllForumTopicMessages::execute($bot, $parameters),
|
||||
self::EDIT_GENERAL_FORUM_TOPIC => EditGeneralForumTopic::execute($bot, $parameters),
|
||||
self::CLOSE_GENERAL_FORUM_TOPIC => CloseGeneralForumTopic::execute($bot, $parameters),
|
||||
self::REOPEN_GENERAL_FORUM_TOPIC => ReopenGeneralForumTopic::execute($bot, $parameters),
|
||||
self::HIDE_GENERAL_FORUM_TOPIC => HideGeneralForumTopic::execute($bot, $parameters),
|
||||
self::UNHIDE_GENERAL_FORUM_TOPIC => UnhideGeneralForumTopic::execute($bot, $parameters),
|
||||
self::UNPIN_ALL_GENERAL_FORUM_TOPIC_MESSAGES => UnpinAllGeneralForumTopicMessages::execute($bot, $parameters),
|
||||
self::ANSWER_CALLBACK_QUERY => AnswerCallbackQuery::execute($bot, $parameters),
|
||||
self::GET_USER_CHAT_BOOSTS => GetUserChatBoosts::execute($bot, $parameters),
|
||||
self::GET_BUSINESS_CONNECTION => GetBusinessConnection::execute($bot, $parameters),
|
||||
self::SET_MY_COMMANDS => SetMyCommands::execute($bot, $parameters),
|
||||
self::DELETE_MY_COMMANDS => DeleteMyCommands::execute($bot, $parameters),
|
||||
self::GET_MY_COMMANDS => GetMyCommands::execute($bot, $parameters),
|
||||
self::SET_MY_NAME => SetMyName::execute($bot, $parameters),
|
||||
self::GET_MY_NAME => GetMyName::execute($bot, $parameters),
|
||||
self::SET_MY_DESCRIPTION => SetMyDescription::execute($bot, $parameters),
|
||||
self::GET_MY_DESCRIPTION => GetMyDescription::execute($bot, $parameters),
|
||||
self::SET_MY_SHORT_DESCRIPTION => SetMyShortDescription::execute($bot, $parameters),
|
||||
self::GET_MY_SHORT_DESCRIPTION => GetMyShortDescription::execute($bot, $parameters),
|
||||
self::SET_CHAT_MENU_BUTTON => SetChatMenuButton::execute($bot, $parameters),
|
||||
self::GET_CHAT_MENU_BUTTON => GetChatMenuButton::execute($bot, $parameters),
|
||||
self::SET_MY_DEFAULT_ADMINISTRATOR_RIGHTS => SetMyDefaultAdministratorRights::execute($bot, $parameters),
|
||||
self::GET_MY_DEFAULT_ADMINISTRATOR_RIGHTS => GetMyDefaultAdministratorRights::execute($bot, $parameters),
|
||||
self::EDIT_MESSAGE_TEXT => EditMessageText::execute($bot, $parameters),
|
||||
self::EDIT_MESSAGE_CAPTION => EditMessageCaption::execute($bot, $parameters),
|
||||
self::EDIT_MESSAGE_MEDIA => EditMessageMedia::execute($bot, $parameters),
|
||||
self::EDIT_MESSAGE_LIVE_LOCATION => EditMessageLiveLocation::execute($bot, $parameters),
|
||||
self::STOP_MESSAGE_LIVE_LOCATION => StopMessageLiveLocation::execute($bot, $parameters),
|
||||
self::EDIT_MESSAGE_REPLY_MARKUP => EditMessageReplyMarkup::execute($bot, $parameters),
|
||||
self::STOP_POLL => StopPoll::execute($bot, $parameters),
|
||||
self::DELETE_MESSAGE => DeleteMessage::execute($bot, $parameters),
|
||||
self::DELETE_MESSAGES => DeleteMessages::execute($bot, $parameters),
|
||||
self::SEND_STICKER => SendSticker::execute($bot, $parameters),
|
||||
self::GET_STICKER_SET => GetStickerSet::execute($bot, $parameters),
|
||||
self::GET_CUSTOM_EMOJI_STICKERS => GetCustomEmojiStickers::execute($bot, $parameters),
|
||||
self::UPLOAD_STICKER_FILE => UploadStickerFile::execute($bot, $parameters),
|
||||
self::CREATE_NEW_STICKER_SET => CreateNewStickerSet::execute($bot, $parameters),
|
||||
self::ADD_STICKER_TO_SET => AddStickerToSet::execute($bot, $parameters),
|
||||
self::SET_STICKER_POSITION_IN_SET => SetStickerPositionInSet::execute($bot, $parameters),
|
||||
self::DELETE_STICKER_FROM_SET => DeleteStickerFromSet::execute($bot, $parameters),
|
||||
self::REPLACE_STICKER_IN_SET => ReplaceStickerInSet::execute($bot, $parameters),
|
||||
self::SET_STICKER_EMOJI_LIST => SetStickerEmojiList::execute($bot, $parameters),
|
||||
self::SET_STICKER_MASK_POSITION => SetStickerMaskPosition::execute($bot, $parameters),
|
||||
self::SET_STICKER_SET_TITLE => SetStickerSetTitle::execute($bot, $parameters),
|
||||
self::SET_STICKER_SET_THUMBNAIL => SetStickerSetThumbnail::execute($bot, $parameters),
|
||||
self::SET_CUSTOM_EMOJI_STICKER_SET_THUMBNAIL => SetCustomEmojiStickerSetThumbnail::execute($bot, $parameters),
|
||||
self::DELETE_STICKER_SET => DeleteStickerSet::execute($bot, $parameters),
|
||||
self::GET_AVAILABLE_GIFTS => GetAvailableGifts::execute($bot, $parameters),
|
||||
self::SEND_GIFT => SendGift::execute($bot, $parameters),
|
||||
self::ANSWER_INLINE_QUERY => AnswerInlineQuery::execute($bot, $parameters),
|
||||
self::ANSWER_WEB_APP_QUERY => AnswerWebAppQuery::execute($bot, $parameters),
|
||||
self::SAVE_PREPARED_INLINE_MESSAGE => SavePreparedInlineMessage::execute($bot, $parameters),
|
||||
self::SEND_INVOICE => SendInvoice::execute($bot, $parameters),
|
||||
self::CREATE_INVOICE_LINK => CreateInvoiceLink::execute($bot, $parameters),
|
||||
self::ANSWER_SHIPPING_QUERY => AnswerShippingQuery::execute($bot, $parameters),
|
||||
self::ANSWER_PRE_CHECKOUT_QUERY => AnswerPreCheckoutQuery::execute($bot, $parameters),
|
||||
self::GET_STAR_TRANSACTIONS => GetStarTransactions::execute($bot, $parameters),
|
||||
self::SET_PASSPORT_DATA_ERRORS => SetPassportDataErrors::execute($bot, $parameters),
|
||||
self::SEND_GAME => SendGame::execute($bot, $parameters),
|
||||
self::SET_GAME_SCORE => SetGameScore::execute($bot, $parameters),
|
||||
self::GET_GAME_HIGH_SCORES => GetGameHighScores::execute($bot, $parameters)
|
||||
};
|
||||
}
|
||||
}
|
10
src/TgBotLib/Enums/Types/BackgroundFillType.php
Normal file
10
src/TgBotLib/Enums/Types/BackgroundFillType.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Enums\Types;
|
||||
|
||||
enum BackgroundFillType : string
|
||||
{
|
||||
case SOLID = 'solid';
|
||||
case GRADIENT = 'gradient';
|
||||
case FREEFORM_GRADIENT = 'freeform_gradient';
|
||||
}
|
11
src/TgBotLib/Enums/Types/BackgroundType.php
Normal file
11
src/TgBotLib/Enums/Types/BackgroundType.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Enums\Types;
|
||||
|
||||
enum BackgroundType : string
|
||||
{
|
||||
case FILL = 'fill';
|
||||
case WALLPAPER = 'wallpaper';
|
||||
case PATTERN = 'pattern';
|
||||
case CHAT_THEME = 'chat_theme';
|
||||
}
|
14
src/TgBotLib/Enums/Types/BotCommandScopeType.php
Normal file
14
src/TgBotLib/Enums/Types/BotCommandScopeType.php
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Enums\Types;
|
||||
|
||||
enum BotCommandScopeType : string
|
||||
{
|
||||
case DEFAULT = 'default';
|
||||
case ALL_PRIVATE_CHATS = 'all_private_chats';
|
||||
case ALL_CHAT_GROUPS = 'all_group_chats';
|
||||
case ALL_CHAT_ADMINISTRATORS = 'all_chat_administrators';
|
||||
case CHAT = 'chat';
|
||||
case CHAT_ADMINISTRATORS = 'chat_administrators';
|
||||
case CHAT_MEMBER = 'chat_member';
|
||||
}
|
16
src/TgBotLib/Enums/Types/ChatActionType.php
Normal file
16
src/TgBotLib/Enums/Types/ChatActionType.php
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Enums\Types;
|
||||
|
||||
enum ChatActionType : string
|
||||
{
|
||||
case TYPING = 'typing';
|
||||
case UPLOAD_PHOTO = 'upload_photo';
|
||||
case RECORD_VIDEO = 'record_video';
|
||||
case UPLOAD_VIDEO = 'upload_video';
|
||||
case RECORD_VOICE = 'record_voice';
|
||||
case CHOOSE_STICKER = 'choose_sticker';
|
||||
case FIND_LOCATION = 'find_location';
|
||||
case RECORD_VIDEO_NOTE = 'record_video_note';
|
||||
case UPLOAD_VIDEO_NOTE = 'upload_video_note';
|
||||
}
|
10
src/TgBotLib/Enums/Types/ChatBoostSourceType.php
Normal file
10
src/TgBotLib/Enums/Types/ChatBoostSourceType.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Enums\Types;
|
||||
|
||||
enum ChatBoostSourceType : string
|
||||
{
|
||||
case PREMIUM = 'premium';
|
||||
case GIFT_CODE = 'gift_code';
|
||||
case GIVEAWAY = 'giveaway';
|
||||
}
|
13
src/TgBotLib/Enums/Types/ChatMemberStatus.php
Normal file
13
src/TgBotLib/Enums/Types/ChatMemberStatus.php
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Enums\Types;
|
||||
|
||||
enum ChatMemberStatus : string
|
||||
{
|
||||
case CREATOR = 'creator';
|
||||
case ADMINISTRATOR = 'administrator';
|
||||
case MEMBER = 'member';
|
||||
case RESTRICTED = 'restricted';
|
||||
case LEFT = 'left';
|
||||
case KICKED = 'kicked';
|
||||
}
|
11
src/TgBotLib/Enums/Types/ChatType.php
Normal file
11
src/TgBotLib/Enums/Types/ChatType.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Enums\Types;
|
||||
|
||||
enum ChatType : string
|
||||
{
|
||||
case PRIVATE = 'private';
|
||||
case GROUP = 'group';
|
||||
case SUPERGROUP = 'supergroup';
|
||||
case CHANNEL = 'channel';
|
||||
}
|
66
src/TgBotLib/Enums/Types/InlineQueryResultType.php
Normal file
66
src/TgBotLib/Enums/Types/InlineQueryResultType.php
Normal file
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Enums\Types;
|
||||
|
||||
enum InlineQueryResultType : string
|
||||
{
|
||||
/**
|
||||
* @link https://core.telegram.org/bots/api#inlinequeryresultarticle
|
||||
*/
|
||||
case ARTICLE = 'article';
|
||||
|
||||
/**
|
||||
* @link https://core.telegram.org/bots/api#inlinequeryresultphoto
|
||||
*/
|
||||
case PHOTO = 'photo';
|
||||
|
||||
/**
|
||||
* @link https://core.telegram.org/bots/api#inlinequeryresultgif
|
||||
*/
|
||||
case GIF = 'gif';
|
||||
|
||||
/**
|
||||
* @link https://core.telegram.org/bots/api#inlinequeryresultmpeg4gif
|
||||
*/
|
||||
case MPEG_4_GIF = 'mpeg4_gif';
|
||||
|
||||
/**
|
||||
* @link https://core.telegram.org/bots/api#inlinequeryresultvideompeg4
|
||||
*/
|
||||
case VIDEO = 'video';
|
||||
|
||||
/**
|
||||
* @link https://core.telegram.org/bots/api#inlinequeryresultaudio
|
||||
*/
|
||||
case AUDIO = 'audio';
|
||||
|
||||
/**
|
||||
* @link https://core.telegram.org/bots/api#inlinequeryresultvoice
|
||||
*/
|
||||
case VOICE = 'voice';
|
||||
|
||||
/**
|
||||
* @link https://core.telegram.org/bots/api#inlinequeryresultdocument
|
||||
*/
|
||||
case DOCUMENT = 'document';
|
||||
|
||||
/**
|
||||
* @link https://core.telegram.org/bots/api#inlinequeryresultlocation
|
||||
*/
|
||||
case LOCATION = 'location';
|
||||
|
||||
/**
|
||||
* @link https://core.telegram.org/bots/api#inlinequeryresultvenue
|
||||
*/
|
||||
case VENUE = 'venue';
|
||||
|
||||
/**
|
||||
* @link https://core.telegram.org/bots/api#inlinequeryresultcontact
|
||||
*/
|
||||
case CONTACT = 'contact';
|
||||
|
||||
/**
|
||||
* @link https://core.telegram.org/bots/api#inlinequeryresultgame
|
||||
*/
|
||||
case GAME = 'game';
|
||||
}
|
12
src/TgBotLib/Enums/Types/InputMediaType.php
Normal file
12
src/TgBotLib/Enums/Types/InputMediaType.php
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Enums\Types;
|
||||
|
||||
enum InputMediaType : string
|
||||
{
|
||||
case PHOTO = 'photo';
|
||||
case VIDEO = 'video';
|
||||
case ANIMATION = 'animation';
|
||||
case AUDIO = 'audio';
|
||||
case DOCUMENT = 'document';
|
||||
}
|
12
src/TgBotLib/Enums/Types/InputMessageContentType.php
Normal file
12
src/TgBotLib/Enums/Types/InputMessageContentType.php
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Enums\Types;
|
||||
|
||||
enum InputMessageContentType : string
|
||||
{
|
||||
case TEXT = 'text';
|
||||
case LOCATION = 'location';
|
||||
case VENUE = 'venue';
|
||||
case CONTACT = 'contact';
|
||||
case INVOICE = 'invoice';
|
||||
}
|
9
src/TgBotLib/Enums/Types/KeyboardButtonPollType.php
Normal file
9
src/TgBotLib/Enums/Types/KeyboardButtonPollType.php
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Enums\Types;
|
||||
|
||||
enum KeyboardButtonPollType : string
|
||||
{
|
||||
case QUIZ = 'quiz';
|
||||
case REGULAR = 'regular';
|
||||
}
|
10
src/TgBotLib/Enums/Types/MenuButtonType.php
Normal file
10
src/TgBotLib/Enums/Types/MenuButtonType.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Enums\Types;
|
||||
|
||||
enum MenuButtonType : string
|
||||
{
|
||||
case COMMANDS = 'commands';
|
||||
case WEB_APP = 'web_app';
|
||||
case DEFAULT = 'default';
|
||||
}
|
41
src/TgBotLib/Enums/Types/MessageEntityType.php
Normal file
41
src/TgBotLib/Enums/Types/MessageEntityType.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Enums\Types;
|
||||
|
||||
enum MessageEntityType : string
|
||||
{
|
||||
case MENTION = 'mention';
|
||||
|
||||
case HASHTAG = 'hashtag';
|
||||
|
||||
case CASHTAG = 'cashtag';
|
||||
|
||||
case BOT_COMMAND = 'bot_command';
|
||||
|
||||
case URL = 'url';
|
||||
|
||||
case EMAIL = 'email';
|
||||
|
||||
case PHONE_NUMBER = 'phone_number';
|
||||
|
||||
case BOLD = 'bold';
|
||||
|
||||
case ITALIC = 'italic';
|
||||
|
||||
case UNDERLINE = 'underline';
|
||||
|
||||
case STRIKETHROUGH = 'strikethrough';
|
||||
|
||||
case SPOILER = 'spoiler';
|
||||
|
||||
case CODE = 'code';
|
||||
|
||||
case PRE = 'pre';
|
||||
|
||||
case TEXT_LINK = 'text_link';
|
||||
|
||||
case TEXT_MENTION = 'text_mention';
|
||||
|
||||
case CUSTOM_EMOJI = 'custom_emoji';
|
||||
|
||||
}
|
11
src/TgBotLib/Enums/Types/MessageOriginType.php
Normal file
11
src/TgBotLib/Enums/Types/MessageOriginType.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Enums\Types;
|
||||
|
||||
enum MessageOriginType : string
|
||||
{
|
||||
case USER = 'user';
|
||||
case HIDDEN_USER = 'hidden_user';
|
||||
case CHAT = 'chat';
|
||||
case CHANNEL = 'channel';
|
||||
}
|
10
src/TgBotLib/Enums/Types/PaidMediaType.php
Normal file
10
src/TgBotLib/Enums/Types/PaidMediaType.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Enums\Types;
|
||||
|
||||
enum PaidMediaType : string
|
||||
{
|
||||
case PREVIEW = 'preview';
|
||||
case PHOTO = 'photo';
|
||||
case VIDEO = 'video';
|
||||
}
|
10
src/TgBotLib/Enums/Types/ParseMode.php
Normal file
10
src/TgBotLib/Enums/Types/ParseMode.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Enums\Types;
|
||||
|
||||
enum ParseMode : string
|
||||
{
|
||||
case HTML = 'HTML';
|
||||
case MARKDOWN = 'Markdown';
|
||||
case MARKDOWN_V2 = 'MarkdownV2';
|
||||
}
|
16
src/TgBotLib/Enums/Types/PassportElementErrorSourceType.php
Normal file
16
src/TgBotLib/Enums/Types/PassportElementErrorSourceType.php
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Enums\Types;
|
||||
|
||||
enum PassportElementErrorSourceType : string
|
||||
{
|
||||
case DATA = 'data';
|
||||
case FRONT_SIDE = 'front_side';
|
||||
case REVERSE_SIDE = 'reverse_side';
|
||||
case SELFIE = 'selfie';
|
||||
case FILE = 'file';
|
||||
case FILES = 'files';
|
||||
case TRANSLATION_FILE = 'translation_file';
|
||||
case TRANSLATION_FILES = 'translation_files';
|
||||
case UNSPECIFIED = 'unspecified';
|
||||
}
|
13
src/TgBotLib/Enums/Types/PassportElementErrorType.php
Normal file
13
src/TgBotLib/Enums/Types/PassportElementErrorType.php
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Enums\Types;
|
||||
|
||||
enum PassportElementErrorType : string
|
||||
{
|
||||
case PERSONAL_DETAILS = 'personal_details';
|
||||
case PASSPORT = 'passport';
|
||||
case DRIVER_LICENSE = 'driver_license';
|
||||
case IDENTITY_CARD = 'identity_card';
|
||||
case INTERNAL_PASSPORT = 'internal_passport';
|
||||
case ADDRESS = 'address';
|
||||
}
|
20
src/TgBotLib/Enums/Types/PassportElementType.php
Normal file
20
src/TgBotLib/Enums/Types/PassportElementType.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Enums\Types;
|
||||
|
||||
enum PassportElementType : string
|
||||
{
|
||||
case PERSONAL_DETAILS = 'personal_details';
|
||||
case PASSPORT = 'passport';
|
||||
case DRIVER_LICENSE = 'driver_license';
|
||||
case IDENTITY_CARD = 'identity_card';
|
||||
case INTERNAL_PASSPORT = 'internal_passport';
|
||||
case ADDRESS = 'address';
|
||||
case UTILITY_BILL = 'utility_bill';
|
||||
case BANK_STATEMENT = 'bank_statement';
|
||||
case RENTAL_AGREEMENT = 'rental_agreement';
|
||||
case PASSPORT_REGISTRATION = 'passport_registration';
|
||||
case TEMPORARY_REGISTRATION = 'temporary_registration';
|
||||
case PHONE_NUMBER = 'phone_number';
|
||||
case EMAIL = 'email';
|
||||
}
|
10
src/TgBotLib/Enums/Types/PollType.php
Normal file
10
src/TgBotLib/Enums/Types/PollType.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Enums\Types;
|
||||
|
||||
enum PollType : string
|
||||
{
|
||||
case REGULAR = 'regular';
|
||||
|
||||
case QUIZ = 'quiz';
|
||||
}
|
10
src/TgBotLib/Enums/Types/ReactionTypes.php
Normal file
10
src/TgBotLib/Enums/Types/ReactionTypes.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Enums\Types;
|
||||
|
||||
enum ReactionTypes : string
|
||||
{
|
||||
case EMOJI = 'emoji';
|
||||
case CUSTOM_EMOJI = 'custom_emoji';
|
||||
case PAID = 'paid';
|
||||
}
|
10
src/TgBotLib/Enums/Types/RevenueWithdrawalType.php
Normal file
10
src/TgBotLib/Enums/Types/RevenueWithdrawalType.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Enums\Types;
|
||||
|
||||
enum RevenueWithdrawalType : string
|
||||
{
|
||||
case PENDING = 'pending';
|
||||
case SUCCEEDED = 'succeed';
|
||||
case FAILED = 'failed';
|
||||
}
|
10
src/TgBotLib/Enums/Types/StickerFormat.php
Normal file
10
src/TgBotLib/Enums/Types/StickerFormat.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Enums\Types;
|
||||
|
||||
enum StickerFormat : string
|
||||
{
|
||||
case STATIC = 'static';
|
||||
case ANIMATED = 'animated';
|
||||
case VIDEO = 'video';
|
||||
}
|
10
src/TgBotLib/Enums/Types/StickerType.php
Normal file
10
src/TgBotLib/Enums/Types/StickerType.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Enums\Types;
|
||||
|
||||
enum StickerType : string
|
||||
{
|
||||
case REGULAR = 'regular';
|
||||
case MASK = 'mask';
|
||||
case CUSTOM_EMOJI = 'custom_emoji';
|
||||
}
|
10
src/TgBotLib/Enums/Types/ThumbnailMimeType.php
Normal file
10
src/TgBotLib/Enums/Types/ThumbnailMimeType.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Enums\Types;
|
||||
|
||||
enum ThumbnailMimeType : string
|
||||
{
|
||||
case IMAGE_JPEG = 'image/jpeg';
|
||||
case IMAGE_GIF = 'image/gif';
|
||||
case VIDEO_MP4 = 'video/mp4';
|
||||
}
|
11
src/TgBotLib/Enums/Types/TransactionPartnerType.php
Normal file
11
src/TgBotLib/Enums/Types/TransactionPartnerType.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Enums\Types;
|
||||
|
||||
enum TransactionPartnerType : string
|
||||
{
|
||||
case USER = 'user';
|
||||
case FRAGMENT = 'fragment';
|
||||
case TELEGRAM_ADS = 'telegram_ads';
|
||||
case OTHER = 'other';
|
||||
}
|
27
src/TgBotLib/Events/BusinessConnectionEvent.php
Normal file
27
src/TgBotLib/Events/BusinessConnectionEvent.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Events;
|
||||
|
||||
use TgBotLib\Enums\EventType;
|
||||
use TgBotLib\Objects\BusinessConnection;
|
||||
|
||||
abstract class BusinessConnectionEvent extends UpdateEvent
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getEventType(): EventType
|
||||
{
|
||||
return EventType::BUSINESS_CONNECTION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the BusinessConnection instance associated with this update.
|
||||
*
|
||||
* @return BusinessConnection The business connection associated with this update.
|
||||
*/
|
||||
protected function getBusinessConnection(): BusinessConnection
|
||||
{
|
||||
return $this->update->getBusinessConnection();
|
||||
}
|
||||
}
|
27
src/TgBotLib/Events/BusinessMessageEvent.php
Normal file
27
src/TgBotLib/Events/BusinessMessageEvent.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Events;
|
||||
|
||||
use TgBotLib\Enums\EventType;
|
||||
use TgBotLib\Objects\Message;
|
||||
|
||||
abstract class BusinessMessageEvent extends UpdateEvent
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getEventType(): EventType
|
||||
{
|
||||
return EventType::BUSINESS_MESSAGE;
|
||||
}
|
||||
|
||||
/**
|
||||
* New incoming business message
|
||||
*
|
||||
* @return Message
|
||||
*/
|
||||
protected function getBusinessMessage(): Message
|
||||
{
|
||||
return $this->update->getBusinessMessage();
|
||||
}
|
||||
}
|
35
src/TgBotLib/Events/CallbackQueryEvent.php
Normal file
35
src/TgBotLib/Events/CallbackQueryEvent.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Events;
|
||||
|
||||
use LogicException;
|
||||
use TgBotLib\Enums\EventType;
|
||||
use TgBotLib\Objects\CallbackQuery;
|
||||
|
||||
abstract class CallbackQueryEvent extends UpdateEvent
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getEventType(): EventType
|
||||
{
|
||||
return EventType::CALLBACK_QUERY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves data associated with the callback.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public abstract static function getCallbackData(): string;
|
||||
|
||||
/**
|
||||
* New incoming callback query
|
||||
*
|
||||
* @return CallbackQuery
|
||||
*/
|
||||
protected function getCallbackQuery(): CallbackQuery
|
||||
{
|
||||
return $this->update->getCallbackQuery();
|
||||
}
|
||||
}
|
27
src/TgBotLib/Events/ChannelPostEvent.php
Normal file
27
src/TgBotLib/Events/ChannelPostEvent.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Events;
|
||||
|
||||
use TgBotLib\Enums\EventType;
|
||||
use TgBotLib\Objects\Message;
|
||||
|
||||
abstract class ChannelPostEvent extends UpdateEvent
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getEventType(): EventType
|
||||
{
|
||||
return EventType::CHANNEL_POST;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the current channel post.
|
||||
*
|
||||
* @return Message The channel post message.
|
||||
*/
|
||||
protected function getChannelPost(): Message
|
||||
{
|
||||
return $this->update->getChannelPost();
|
||||
}
|
||||
}
|
27
src/TgBotLib/Events/ChatBoostEvent.php
Normal file
27
src/TgBotLib/Events/ChatBoostEvent.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Events;
|
||||
|
||||
use TgBotLib\Enums\EventType;
|
||||
use TgBotLib\Objects\ChatBoostUpdated;
|
||||
|
||||
abstract class ChatBoostEvent extends UpdateEvent
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getEventType(): EventType
|
||||
{
|
||||
return EventType::CHAT_BOOST_EVENT;
|
||||
}
|
||||
|
||||
/**
|
||||
* A chat boost was added or changed. The bot must be an administrator in the chat to receive these updates.
|
||||
*
|
||||
* @return ChatBoostUpdated The updated chat boost information.
|
||||
*/
|
||||
protected function getChatBoost(): ChatBoostUpdated
|
||||
{
|
||||
return $this->update->getChatBoost();
|
||||
}
|
||||
}
|
28
src/TgBotLib/Events/ChatJoinRequestEvent.php
Normal file
28
src/TgBotLib/Events/ChatJoinRequestEvent.php
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Events;
|
||||
|
||||
use TgBotLib\Enums\EventType;
|
||||
use TgBotLib\Objects\ChatJoinRequest;
|
||||
|
||||
abstract class ChatJoinRequestEvent extends UpdateEvent
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getEventType(): EventType
|
||||
{
|
||||
return EventType::CHAT_JOIN_REQUEST_EVENT;
|
||||
}
|
||||
|
||||
/**
|
||||
* A request to join the chat has been sent. The bot must have the can_invite_users
|
||||
* administrator right in the chat to receive these updates.
|
||||
*
|
||||
* @return ChatJoinRequest The chat join request data.
|
||||
*/
|
||||
protected function getChatJoinRequest(): ChatJoinRequest
|
||||
{
|
||||
return $this->update->getChatJoinRequest();
|
||||
}
|
||||
}
|
28
src/TgBotLib/Events/ChatMemberUpdatedEvent.php
Normal file
28
src/TgBotLib/Events/ChatMemberUpdatedEvent.php
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Events;
|
||||
|
||||
use TgBotLib\Enums\EventType;
|
||||
use TgBotLib\Objects\ChatMemberUpdated;
|
||||
|
||||
abstract class ChatMemberUpdatedEvent extends UpdateEvent
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getEventType(): EventType
|
||||
{
|
||||
return EventType::CHAT_MEMBER_UPDATED;
|
||||
}
|
||||
|
||||
/**
|
||||
* A chat member's status was updated in a chat. The bot must be an administrator in the chat and must
|
||||
* explicitly specify "chat_member" in the list of allowed_updates to receive these updates.
|
||||
*
|
||||
* @return ChatMemberUpdated The updated chat member instance.
|
||||
*/
|
||||
protected function getChatMemberUpdated(): ChatMemberUpdated
|
||||
{
|
||||
return $this->update->getChatMember();
|
||||
}
|
||||
}
|
27
src/TgBotLib/Events/ChosenInlineResultEvent.php
Normal file
27
src/TgBotLib/Events/ChosenInlineResultEvent.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Events;
|
||||
|
||||
use TgBotLib\Enums\EventType;
|
||||
use TgBotLib\Objects\Inline\ChosenInlineResult;
|
||||
|
||||
abstract class ChosenInlineResultEvent extends UpdateEvent
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getEventType(): EventType
|
||||
{
|
||||
return EventType::CHOSEN_INLINE_RESULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* The result of an inline query that was chosen by a user and sent to their chat partner.
|
||||
*
|
||||
* @return ChosenInlineResult The chosen inline result associated with the current update.
|
||||
*/
|
||||
protected function getChosenInlineResult(): ChosenInlineResult
|
||||
{
|
||||
return $this->update->getChosenInlineResult();
|
||||
}
|
||||
}
|
63
src/TgBotLib/Events/CommandEvent.php
Normal file
63
src/TgBotLib/Events/CommandEvent.php
Normal file
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Events;
|
||||
|
||||
use OptsLib\Parse;
|
||||
use TgBotLib\Enums\EventType;
|
||||
use TgBotLib\Objects\Message;
|
||||
|
||||
abstract class CommandEvent extends UpdateEvent
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getEventType(): EventType
|
||||
{
|
||||
return EventType::COMMAND;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the command to be executed.
|
||||
*
|
||||
* In the format of a string, this method should return the command to be executed.
|
||||
* for example if the command is "/start", this method should return "start".
|
||||
*
|
||||
* @return string The command to be executed.
|
||||
*/
|
||||
public abstract static function getCommand(): string;
|
||||
|
||||
/**
|
||||
* Retrieves the message from the update.
|
||||
*
|
||||
* @return Message The message contained within the update.
|
||||
*/
|
||||
protected function getMessage(): Message
|
||||
{
|
||||
return $this->update->getAnyMessage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts and returns the arguments of the command from the message text.
|
||||
*
|
||||
* @return string The arguments of the command.
|
||||
*/
|
||||
protected function getArguments(): string
|
||||
{
|
||||
if(strlen($this->getMessage()->getCommand()) <= strlen(static::getCommand()) + 1)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
return substr($this->getMessage()->getCommand(), strlen(static::getCommand()) + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses and returns the command arguments as an array.
|
||||
*
|
||||
* @return array The parsed command arguments.
|
||||
*/
|
||||
protected function getParsedArguments(): array
|
||||
{
|
||||
return Parse::parseArgument($this->getArguments());
|
||||
}
|
||||
}
|
27
src/TgBotLib/Events/DeletedBusinessMessagesEvent.php
Normal file
27
src/TgBotLib/Events/DeletedBusinessMessagesEvent.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Events;
|
||||
|
||||
use TgBotLib\Enums\EventType;
|
||||
use TgBotLib\Objects\BusinessMessagesDeleted;
|
||||
|
||||
abstract class DeletedBusinessMessagesEvent extends UpdateEvent
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getEventType(): EventType
|
||||
{
|
||||
return EventType::DELETED_BUSINESS_MESSAGES;
|
||||
}
|
||||
|
||||
/**
|
||||
* Messages were deleted from a connected business account
|
||||
*
|
||||
* @return BusinessMessagesDeleted
|
||||
*/
|
||||
protected function getBusinessMessagesDeleted(): BusinessMessagesDeleted
|
||||
{
|
||||
return $this->update->getDeletedBusinessMessages();
|
||||
}
|
||||
}
|
27
src/TgBotLib/Events/EditedBusinessMessageEvent.php
Normal file
27
src/TgBotLib/Events/EditedBusinessMessageEvent.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Events;
|
||||
|
||||
use TgBotLib\Enums\EventType;
|
||||
use TgBotLib\Objects\Message;
|
||||
|
||||
abstract class EditedBusinessMessageEvent extends UpdateEvent
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getEventType(): EventType
|
||||
{
|
||||
return EventType::EDITED_BUSINESS_MESSAGE;
|
||||
}
|
||||
|
||||
/**
|
||||
* New incoming edited business message
|
||||
*
|
||||
* @return Message
|
||||
*/
|
||||
protected function getEditedBusinessMessage(): Message
|
||||
{
|
||||
return $this->update->getEditedBusinessMessage();
|
||||
}
|
||||
}
|
27
src/TgBotLib/Events/EditedChannelPostEvent.php
Normal file
27
src/TgBotLib/Events/EditedChannelPostEvent.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Events;
|
||||
|
||||
use TgBotLib\Enums\EventType;
|
||||
use TgBotLib\Objects\Message;
|
||||
|
||||
abstract class EditedChannelPostEvent extends UpdateEvent
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getEventType(): EventType
|
||||
{
|
||||
return EventType::EDITED_CHANNEL_POST;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the edited channel post from the update.
|
||||
*
|
||||
* @return Message The edited channel post.
|
||||
*/
|
||||
protected function getEditedChannelPost(): Message
|
||||
{
|
||||
return $this->update->getEditedChannelPost();
|
||||
}
|
||||
}
|
27
src/TgBotLib/Events/EditedMessageEvent.php
Normal file
27
src/TgBotLib/Events/EditedMessageEvent.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Events;
|
||||
|
||||
use TgBotLib\Enums\EventType;
|
||||
use TgBotLib\Objects\Message;
|
||||
|
||||
abstract class EditedMessageEvent extends UpdateEvent
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getEventType(): EventType
|
||||
{
|
||||
return EventType::EDITED_MESSAGE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the current edited message.
|
||||
*
|
||||
* @return Message The edited message.
|
||||
*/
|
||||
protected function getEditedMessage(): Message
|
||||
{
|
||||
return $this->update->getEditedMessage();
|
||||
}
|
||||
}
|
27
src/TgBotLib/Events/InlineQueryEvent.php
Normal file
27
src/TgBotLib/Events/InlineQueryEvent.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Events;
|
||||
|
||||
use TgBotLib\Enums\EventType;
|
||||
use TgBotLib\Objects\Inline\InlineQuery;
|
||||
|
||||
abstract class InlineQueryEvent extends UpdateEvent
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getEventType(): EventType
|
||||
{
|
||||
return EventType::INLINE_QUERY;
|
||||
}
|
||||
|
||||
/**C
|
||||
* New incoming inline query
|
||||
*
|
||||
* @return InlineQuery
|
||||
*/
|
||||
protected function getInlineQuery(): InlineQuery
|
||||
{
|
||||
return $this->update->getInlineQuery();
|
||||
}
|
||||
}
|
27
src/TgBotLib/Events/MessageEvent.php
Normal file
27
src/TgBotLib/Events/MessageEvent.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Events;
|
||||
|
||||
use TgBotLib\Enums\EventType;
|
||||
use TgBotLib\Objects\Message;
|
||||
|
||||
abstract class MessageEvent extends UpdateEvent
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getEventType(): EventType
|
||||
{
|
||||
return EventType::MESSAGE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the current message.
|
||||
*
|
||||
* @return Message The message.
|
||||
*/
|
||||
protected function getMessage(): Message
|
||||
{
|
||||
return $this->update->getMessage();
|
||||
}
|
||||
}
|
29
src/TgBotLib/Events/MessageReactionCountEvent.php
Normal file
29
src/TgBotLib/Events/MessageReactionCountEvent.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Events;
|
||||
|
||||
use TgBotLib\Enums\EventType;
|
||||
use TgBotLib\Objects\MessageReactionCountUpdated;
|
||||
|
||||
abstract class MessageReactionCountEvent extends UpdateEvent
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getEventType(): EventType
|
||||
{
|
||||
return EventType::MESSAGE_REACTION_COUNT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reactions to a message with anonymous reactions were changed. The bot must be an administrator in the chat
|
||||
* and must explicitly specify "message_reaction_count" in the list of allowed_updates to receive these updates.
|
||||
* The updates are grouped and can be sent with delay up to a few minutes.
|
||||
*
|
||||
* @return MessageReactionCountUpdated
|
||||
*/
|
||||
protected function getMessageReactionCount(): MessageReactionCountUpdated
|
||||
{
|
||||
return $this->update->getMessageReactionCount();
|
||||
}
|
||||
}
|
29
src/TgBotLib/Events/MessageReactionEvent.php
Normal file
29
src/TgBotLib/Events/MessageReactionEvent.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Events;
|
||||
|
||||
use TgBotLib\Enums\EventType;
|
||||
use TgBotLib\Objects\MessageReactionUpdated;
|
||||
|
||||
abstract class MessageReactionEvent extends UpdateEvent
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getEventType(): EventType
|
||||
{
|
||||
return EventType::MESSAGE_REACTION;
|
||||
}
|
||||
|
||||
/**
|
||||
* A reaction to a message was changed by a user. The bot must be an administrator in the chat and must
|
||||
* explicitly specify "message_reaction" in the list of allowed_updates to receive these updates.
|
||||
* The update isn't received for reactions set by bots.
|
||||
*
|
||||
* @return MessageReactionUpdated
|
||||
*/
|
||||
protected function getMessageReactionUpdated(): MessageReactionUpdated
|
||||
{
|
||||
return $this->update->getMessageReaction();
|
||||
}
|
||||
}
|
29
src/TgBotLib/Events/MyChatMemberUpdatedEvent.php
Normal file
29
src/TgBotLib/Events/MyChatMemberUpdatedEvent.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Events;
|
||||
|
||||
|
||||
use TgBotLib\Enums\EventType;
|
||||
use TgBotLib\Objects\ChatMemberUpdated;
|
||||
|
||||
abstract class MyChatMemberUpdatedEvent extends UpdateEvent
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getEventType(): EventType
|
||||
{
|
||||
return EventType::MY_CHAT_MEMBER_UPDATED;
|
||||
}
|
||||
|
||||
/**
|
||||
* The bot's chat member status was updated in a chat. For private chats,
|
||||
* this update is received only when the bot is blocked or unblocked by the user.
|
||||
*
|
||||
* @return ChatMemberUpdated The updated chat member information.
|
||||
*/
|
||||
protected function getMyChatMemberUpdated(): ChatMemberUpdated
|
||||
{
|
||||
return $this->update->getMyChatMember();
|
||||
}
|
||||
}
|
27
src/TgBotLib/Events/PaidMediaPurchasedEvent.php
Normal file
27
src/TgBotLib/Events/PaidMediaPurchasedEvent.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Events;
|
||||
|
||||
use TgBotLib\Enums\EventType;
|
||||
use TgBotLib\Objects\Payments\PaidMediaPurchased;
|
||||
|
||||
abstract class PaidMediaPurchasedEvent extends UpdateEvent
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getEventType(): EventType
|
||||
{
|
||||
return EventType::PAID_MEDIA_PURCHASED;
|
||||
}
|
||||
|
||||
/**
|
||||
* A user purchased paid media with a non-empty payload sent by the bot in a non-channel chat
|
||||
*
|
||||
* @return PaidMediaPurchased
|
||||
*/
|
||||
protected function getPurchasedPaidMedia(): PaidMediaPurchased
|
||||
{
|
||||
return $this->update->getPurchasedPaidMedia();
|
||||
}
|
||||
}
|
28
src/TgBotLib/Events/PollAnswerEvent.php
Normal file
28
src/TgBotLib/Events/PollAnswerEvent.php
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Events;
|
||||
|
||||
use TgBotLib\Enums\EventType;
|
||||
use TgBotLib\Objects\PollAnswer;
|
||||
|
||||
abstract class PollAnswerEvent extends UpdateEvent
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getEventType(): EventType
|
||||
{
|
||||
return EventType::POLL_ANSWER;
|
||||
}
|
||||
|
||||
/**
|
||||
* A user changed their answer in a non-anonymous poll.
|
||||
* Bots receive new votes only in polls that were sent by the bot itself.
|
||||
*
|
||||
* @return PollAnswer The poll answer associated with the current update.
|
||||
*/
|
||||
protected function getPollAnswer(): PollAnswer
|
||||
{
|
||||
return $this->update->getPollAnswer();
|
||||
}
|
||||
}
|
28
src/TgBotLib/Events/PollEvent.php
Normal file
28
src/TgBotLib/Events/PollEvent.php
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Events;
|
||||
|
||||
use TgBotLib\Enums\EventType;
|
||||
use TgBotLib\Objects\Poll;
|
||||
|
||||
abstract class PollEvent extends UpdateEvent
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getEventType(): EventType
|
||||
{
|
||||
return EventType::POLL;
|
||||
}
|
||||
|
||||
/**
|
||||
* A user changed their answer in a non-anonymous poll.
|
||||
* Bots receive new votes only in polls that were sent by the bot itself.
|
||||
*
|
||||
* @return Poll The poll.
|
||||
*/
|
||||
protected function getPoll(): Poll
|
||||
{
|
||||
return $this->update->getPoll();
|
||||
}
|
||||
}
|
27
src/TgBotLib/Events/PreCheckoutQueryEvent.php
Normal file
27
src/TgBotLib/Events/PreCheckoutQueryEvent.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Events;
|
||||
|
||||
use TgBotLib\Enums\EventType;
|
||||
use TgBotLib\Objects\Payments\PreCheckoutQuery;
|
||||
|
||||
abstract class PreCheckoutQueryEvent extends UpdateEvent
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getEventType(): EventType
|
||||
{
|
||||
return EventType::PRE_CHECKOUT_QUERY;
|
||||
}
|
||||
|
||||
/**
|
||||
* New incoming pre-checkout query. Contains full information about checkout
|
||||
*
|
||||
* @return PreCheckoutQuery
|
||||
*/
|
||||
protected function getPreCheckoutQuery(): PreCheckoutQuery
|
||||
{
|
||||
return $this->update->getPreCheckoutQuery();
|
||||
}
|
||||
}
|
27
src/TgBotLib/Events/RemovedChatBoostEvent.php
Normal file
27
src/TgBotLib/Events/RemovedChatBoostEvent.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Events;
|
||||
|
||||
use TgBotLib\Enums\EventType;
|
||||
use TgBotLib\Objects\ChatBoostRemoved;
|
||||
|
||||
abstract class RemovedChatBoostEvent extends UpdateEvent
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getEventType(): EventType
|
||||
{
|
||||
return EventType::REMOVED_CHAT_BOOST_EVENT;
|
||||
}
|
||||
|
||||
/**
|
||||
* A boost was removed from a chat. The bot must be an administrator in the chat to receive these updates.
|
||||
*
|
||||
* @return ChatBoostRemoved The chat boost that was removed.
|
||||
*/
|
||||
protected function getChatBoostRemoved(): ChatBoostRemoved
|
||||
{
|
||||
return $this->update->getRemovedChatBoost();
|
||||
}
|
||||
}
|
27
src/TgBotLib/Events/ShippingQueryEvent.php
Normal file
27
src/TgBotLib/Events/ShippingQueryEvent.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Events;
|
||||
|
||||
use TgBotLib\Enums\EventType;
|
||||
use TgBotLib\Objects\Payments\ShippingQuery;
|
||||
|
||||
abstract class ShippingQueryEvent extends UpdateEvent
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getEventType(): EventType
|
||||
{
|
||||
return EventType::SHIPPING_QUERY;
|
||||
}
|
||||
|
||||
/**
|
||||
* New incoming shipping query. Only for invoices with flexible price
|
||||
*
|
||||
* @return ShippingQuery
|
||||
*/
|
||||
protected function getShippingQuery(): ShippingQuery
|
||||
{
|
||||
return $this->update->getShippingQuery();
|
||||
}
|
||||
}
|
42
src/TgBotLib/Events/UpdateEvent.php
Normal file
42
src/TgBotLib/Events/UpdateEvent.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Events;
|
||||
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Enums\EventType;
|
||||
use TgBotLib\Exceptions\TelegramException;
|
||||
use TgBotLib\Objects\Update;
|
||||
|
||||
abstract class UpdateEvent
|
||||
{
|
||||
protected Update $update;
|
||||
|
||||
/**
|
||||
* Constructor for the class.
|
||||
*
|
||||
* @param Update $update The update instance to be used.
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Update $update)
|
||||
{
|
||||
$this->update = $update;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the event type.
|
||||
* @return EventType The event type of the current instance.
|
||||
*/
|
||||
public static function getEventType(): EventType
|
||||
{
|
||||
return EventType::UPDATE_EVENT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract method to handle the bot instance.
|
||||
*
|
||||
* @param Bot $bot The bot instance to be handled.
|
||||
* @return void
|
||||
* @throws TelegramException
|
||||
*/
|
||||
public abstract function handle(Bot $bot): void;
|
||||
}
|
13
src/TgBotLib/Exceptions/NotImplementedException.php
Normal file
13
src/TgBotLib/Exceptions/NotImplementedException.php
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Exceptions;
|
||||
|
||||
use Throwable;
|
||||
|
||||
class NotImplementedException extends \Exception
|
||||
{
|
||||
public function __construct(string $message = "", int $code = 0, ?Throwable $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
|
@ -16,6 +16,6 @@
|
|||
*/
|
||||
public function __construct(string $message = "", int $code = 0, ?Throwable $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
parent::__construct(sprintf("%s (Error code %s)", $message, $code), $code, $previous);
|
||||
}
|
||||
}
|
|
@ -2,17 +2,17 @@
|
|||
|
||||
namespace TgBotLib\Interfaces;
|
||||
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Objects\Telegram\Update;
|
||||
use TgBotLib\BotOld;
|
||||
use TgBotLib\Objects\Update;
|
||||
|
||||
interface CommandInterface
|
||||
{
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param Bot $bot
|
||||
* @param BotOld $bot
|
||||
* @param Update $update
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Bot $bot, Update $update): void;
|
||||
public function handle(BotOld $bot, Update $update): void;
|
||||
}
|
|
@ -2,17 +2,17 @@
|
|||
|
||||
namespace TgBotLib\Interfaces;
|
||||
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Objects\Telegram\Update;
|
||||
use TgBotLib\BotOld;
|
||||
use TgBotLib\Objects\Update;
|
||||
|
||||
interface EventInterface
|
||||
{
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param Bot $bot
|
||||
* @param BotOld $bot
|
||||
* @param Update $update
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Bot $bot, Update $update): void;
|
||||
public function handle(BotOld $bot, Update $update): void;
|
||||
}
|
|
@ -7,15 +7,15 @@
|
|||
/**
|
||||
* Returns an array representation of the object
|
||||
*
|
||||
* @return array
|
||||
* @return array|null
|
||||
*/
|
||||
public function toArray(): array;
|
||||
public function toArray(): ?array;
|
||||
|
||||
/**
|
||||
* Reconstruction of the object from an array
|
||||
*
|
||||
* @param array $data
|
||||
* @return ObjectTypeInterface
|
||||
* @param array|null $data
|
||||
* @return ObjectTypeInterface|null
|
||||
*/
|
||||
public static function fromArray(array $data): ObjectTypeInterface;
|
||||
public static function fromArray(?array $data): ?ObjectTypeInterface;
|
||||
}
|
40
src/TgBotLib/Methods/AddStickerToSet.php
Normal file
40
src/TgBotLib/Methods/AddStickerToSet.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Methods;
|
||||
|
||||
use TgBotLib\Abstracts\Method;
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Enums\Methods;
|
||||
use TgBotLib\Exceptions\NotImplementedException;
|
||||
|
||||
class AddStickerToSet extends Method
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function execute(Bot $bot, array $parameters = []): true
|
||||
{
|
||||
throw new NotImplementedException('Method not implemented yet, check back later');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getRequiredParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'user_id',
|
||||
'name',
|
||||
'sticker'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getOptionalParameters(): ?array
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
42
src/TgBotLib/Methods/AnswerCallbackQuery.php
Normal file
42
src/TgBotLib/Methods/AnswerCallbackQuery.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Methods;
|
||||
|
||||
use TgBotLib\Abstracts\Method;
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Enums\Methods;
|
||||
|
||||
class AnswerCallbackQuery extends Method
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function execute(Bot $bot, array $parameters = []): true
|
||||
{
|
||||
return (bool)(self::executeCurl(self::buildPost($bot, Methods::ANSWER_CALLBACK_QUERY->value, $parameters)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getRequiredParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'callback_query_id'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getOptionalParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'text',
|
||||
'show_alert',
|
||||
'url',
|
||||
'cache_time'
|
||||
];
|
||||
}
|
||||
}
|
77
src/TgBotLib/Methods/AnswerInlineQuery.php
Normal file
77
src/TgBotLib/Methods/AnswerInlineQuery.php
Normal file
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Methods;
|
||||
|
||||
use TgBotLib\Abstracts\Method;
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Enums\Methods;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
|
||||
class AnswerInlineQuery extends Method
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function execute(Bot $bot, array $parameters = []): true
|
||||
{
|
||||
if(isset($parameters['results']))
|
||||
{
|
||||
$results = [];
|
||||
foreach($parameters['results'] as $result)
|
||||
{
|
||||
if($result instanceof ObjectTypeInterface)
|
||||
{
|
||||
$result[] = $result->toArray();
|
||||
continue;
|
||||
}
|
||||
|
||||
if(is_array($result))
|
||||
{
|
||||
$result[] = $result;
|
||||
}
|
||||
}
|
||||
|
||||
$parameters['results'] = json_encode($results);
|
||||
}
|
||||
|
||||
if(isset($parameters['button']))
|
||||
{
|
||||
if($parameters['button'] instanceof ObjectTypeInterface)
|
||||
{
|
||||
$parameters['button'] = json_encode($parameters['button']->toArray());
|
||||
}
|
||||
|
||||
if(is_array($parameters['button']))
|
||||
{
|
||||
$parameters['button'] = json_encode($parameters['button']);
|
||||
}
|
||||
}
|
||||
|
||||
return (bool)self::executeCurl(self::buildPost($bot, Methods::ANSWER_INLINE_QUERY->value, $parameters));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getRequiredParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'inline_query_id',
|
||||
'results'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getOptionalParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'cache_time',
|
||||
'is_personal',
|
||||
'next_offset',
|
||||
'button'
|
||||
];
|
||||
}
|
||||
}
|
40
src/TgBotLib/Methods/AnswerPreCheckoutQuery.php
Normal file
40
src/TgBotLib/Methods/AnswerPreCheckoutQuery.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Methods;
|
||||
|
||||
use TgBotLib\Abstracts\Method;
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Enums\Methods;
|
||||
|
||||
class AnswerPreCheckoutQuery extends Method
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function execute(Bot $bot, array $parameters = []): true
|
||||
{
|
||||
return (bool)self::executeCurl(self::buildPost($bot, Methods::ANSWER_PRE_CHECKOUT_QUERY->value, $parameters));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getRequiredParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'pre_checkout_query_id',
|
||||
'ok'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getOptionalParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'error_message'
|
||||
];
|
||||
}
|
||||
}
|
50
src/TgBotLib/Methods/AnswerShippingQuery.php
Normal file
50
src/TgBotLib/Methods/AnswerShippingQuery.php
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Methods;
|
||||
|
||||
use TgBotLib\Abstracts\Method;
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Enums\Methods;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
|
||||
class AnswerShippingQuery extends Method
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function execute(Bot $bot, array $parameters = []): true
|
||||
{
|
||||
if(isset($parameters['shipping_options']))
|
||||
{
|
||||
if($parameters['shipping_options'] instanceof ObjectTypeInterface)
|
||||
{
|
||||
$parameters['shipping_options'] = json_encode($parameters['shipping_options']->toArray());
|
||||
}
|
||||
}
|
||||
|
||||
return (bool)self::executeCurl(self::buildPost($bot, Methods::ANSWER_SHIPPING_QUERY->value, $parameters));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getRequiredParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'shipping_query_id',
|
||||
'ok'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getOptionalParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'shipping_options',
|
||||
'error_message'
|
||||
];
|
||||
}
|
||||
}
|
53
src/TgBotLib/Methods/AnswerWebAppQuery.php
Normal file
53
src/TgBotLib/Methods/AnswerWebAppQuery.php
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Methods;
|
||||
|
||||
use TgBotLib\Abstracts\Method;
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Enums\Methods;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\Inline\SentWebAppMessage;
|
||||
|
||||
class AnswerWebAppQuery extends Method
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function execute(Bot $bot, array $parameters = []): SentWebAppMessage
|
||||
{
|
||||
if(isset($parameters['result']))
|
||||
{
|
||||
if($parameters['result'] instanceof ObjectTypeInterface)
|
||||
{
|
||||
$parameters['result'] = json_encode($parameters['result']->toArray());
|
||||
}
|
||||
|
||||
if(is_array($parameters['result']))
|
||||
{
|
||||
$parameters['result'] = json_encode($parameters['result']);
|
||||
}
|
||||
}
|
||||
|
||||
return SentWebAppMessage::fromArray(self::executeCurl(self::buildPost($bot, Methods::ANSWER_WEB_APP_QUERY->value, $parameters)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getRequiredParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'web_app_query_id',
|
||||
'result'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getOptionalParameters(): ?array
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
39
src/TgBotLib/Methods/ApproveChatJoinRequest.php
Normal file
39
src/TgBotLib/Methods/ApproveChatJoinRequest.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Methods;
|
||||
|
||||
use TgBotLib\Abstracts\Method;
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Enums\Methods;
|
||||
use TgBotLib\Objects\ChatInviteLink;
|
||||
|
||||
class ApproveChatJoinRequest extends Method
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function execute(Bot $bot, array $parameters = []): true
|
||||
{
|
||||
return (bool)self::executeCurl(self::buildPost($bot, Methods::APPROVE_CHAT_JOIN_REQUEST->value, $parameters));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getRequiredParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'chat_id',
|
||||
'invite_link'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getOptionalParameters(): ?array
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
41
src/TgBotLib/Methods/BanChatMember.php
Normal file
41
src/TgBotLib/Methods/BanChatMember.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Methods;
|
||||
|
||||
use TgBotLib\Abstracts\Method;
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Enums\Methods;
|
||||
|
||||
class BanChatMember extends Method
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function execute(Bot $bot, array $parameters = []): true
|
||||
{
|
||||
return (bool)self::executeCurl(self::buildPost($bot, Methods::BAN_CHAT_MEMBER->value, $parameters));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getRequiredParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'chat_id',
|
||||
'user_id'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getOptionalParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'until_date',
|
||||
'revoke_messages'
|
||||
];
|
||||
}
|
||||
}
|
38
src/TgBotLib/Methods/BanChatSenderChat.php
Normal file
38
src/TgBotLib/Methods/BanChatSenderChat.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Methods;
|
||||
|
||||
use TgBotLib\Abstracts\Method;
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Enums\Methods;
|
||||
|
||||
class BanChatSenderChat extends Method
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function execute(Bot $bot, array $parameters = []): true
|
||||
{
|
||||
return (bool)self::executeCurl(self::buildPost($bot, Methods::BAN_CHAT_SENDER_CHAT->value, $parameters));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getRequiredParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'chat_id',
|
||||
'sender_chat_id'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getOptionalParameters(): ?array
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
43
src/TgBotLib/Methods/Close.php
Normal file
43
src/TgBotLib/Methods/Close.php
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Methods;
|
||||
|
||||
use TgBotLib\Abstracts\Method;
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Enums\Methods;
|
||||
use TgBotLib\Exceptions\TelegramException;
|
||||
|
||||
class Close extends Method
|
||||
{
|
||||
/**
|
||||
* Use this method to close the bot instance before moving it from one local server to another.
|
||||
* You need to delete the webhook before calling this method to ensure that the bot isn't launched again
|
||||
* after server restart. The method will return error 429 in the first 10 minutes after the bot is launched.
|
||||
* Returns True on success. Requires no parameters.
|
||||
*
|
||||
* @param Bot $bot
|
||||
* @param array $parameters
|
||||
* @return bool
|
||||
* @throws TelegramException
|
||||
*/
|
||||
public static function execute(Bot $bot, array $parameters = []): bool
|
||||
{
|
||||
return (bool) self::executeCurl(self::buildPost($bot, Methods::CLOSE->value));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getRequiredParameters(): ?array
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getOptionalParameters(): ?array
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
38
src/TgBotLib/Methods/CloseForumTopic.php
Normal file
38
src/TgBotLib/Methods/CloseForumTopic.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Methods;
|
||||
|
||||
use TgBotLib\Abstracts\Method;
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Enums\Methods;
|
||||
|
||||
class CloseForumTopic extends Method
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function execute(Bot $bot, array $parameters = []): true
|
||||
{
|
||||
return (bool)(self::executeCurl(self::buildPost($bot, Methods::CLOSE_FORUM_TOPIC->value, $parameters)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getRequiredParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'chat_id',
|
||||
'message_thread_id'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getOptionalParameters(): ?array
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue