-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend_file_async.py
More file actions
28 lines (23 loc) · 880 Bytes
/
send_file_async.py
File metadata and controls
28 lines (23 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import asyncio
from maxbot_api_client_python import API, Config
from maxbot_api_client_python.types.models import SendFileReq
async def main():
try:
async with API(Config(
base_url="https://platform-api.max.ru",
token="YOUR_BOT_TOKEN"
)) as bot:
request = SendFileReq(
user_id=123456789, # recipient user ID
text="Check this!",
file_source="https://storage.yandexcloud.net/sw-prod-03-test/ChatBot/corgi.jpg"
)
response = await bot.helpers.send_file_async(request)
if response:
print("send_file_async success!")
else:
print("send_file_async failed to process the file.")
except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
asyncio.run(main())