mm-telegram 0.0.6__py3-none-any.whl → 0.0.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
mm_telegram/simple_message.py
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
+
import asyncio
|
1
2
|
import time
|
2
3
|
|
3
|
-
import anyio
|
4
4
|
import pydash
|
5
|
-
from mm_std import Err, Ok, Result,
|
5
|
+
from mm_std import Err, Ok, Result, hr, hra
|
6
6
|
|
7
7
|
|
8
8
|
def send_message(bot_token: str, chat_id: int, message: str, long_message_delay: int = 3) -> Result[list[int]]:
|
@@ -37,7 +37,7 @@ async def async_send_message(bot_token: str, chat_id: int, message: str, long_me
|
|
37
37
|
while True:
|
38
38
|
text = messages.pop(0)
|
39
39
|
params = {"chat_id": chat_id, "text": text}
|
40
|
-
res = await
|
40
|
+
res = await hra(f"https://api.telegram.org/bot{bot_token}/sendMessage", method="post", params=params)
|
41
41
|
responses.append(res.json)
|
42
42
|
if res.error is not None:
|
43
43
|
return Err(res.error, data={"last_res": res.to_dict(), "responses": responses})
|
@@ -49,7 +49,7 @@ async def async_send_message(bot_token: str, chat_id: int, message: str, long_me
|
|
49
49
|
return Err("unknown_response", data={"last_res": res.to_dict(), "responses": responses})
|
50
50
|
|
51
51
|
if len(messages):
|
52
|
-
await
|
52
|
+
await asyncio.sleep(long_message_delay)
|
53
53
|
else:
|
54
54
|
break
|
55
55
|
return Ok(result, data={"responses": responses})
|
@@ -0,0 +1,6 @@
|
|
1
|
+
mm_telegram/__init__.py,sha256=Lt7dNthxAyeswHnf72il9uFGq1c083CA9c8OCRZU0jY,126
|
2
|
+
mm_telegram/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
+
mm_telegram/simple_message.py,sha256=O0ubcTHBBCruByDr6l9DiL14BeVQFeBHTYyURz1ckRc,2175
|
4
|
+
mm_telegram-0.0.8.dist-info/METADATA,sha256=MixRPCFyPcPOddqHb1f2bIzkKgjBWCwJpVrRV-SxEv4,109
|
5
|
+
mm_telegram-0.0.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
6
|
+
mm_telegram-0.0.8.dist-info/RECORD,,
|
@@ -1,6 +0,0 @@
|
|
1
|
-
mm_telegram/__init__.py,sha256=Lt7dNthxAyeswHnf72il9uFGq1c083CA9c8OCRZU0jY,126
|
2
|
-
mm_telegram/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
-
mm_telegram/simple_message.py,sha256=bKhKHcDlXghnxhDtg46U30HFw9gYTd0hyK5ay7heUww,2171
|
4
|
-
mm_telegram-0.0.6.dist-info/METADATA,sha256=gUT6viVA2DDRPF7hiLobscnAm4rVhK5Lawu9s5Clt6w,109
|
5
|
-
mm_telegram-0.0.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
6
|
-
mm_telegram-0.0.6.dist-info/RECORD,,
|
File without changes
|