-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetUpdatesAsync.py
More file actions
29 lines (25 loc) · 920 Bytes
/
GetUpdatesAsync.py
File metadata and controls
29 lines (25 loc) · 920 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
29
import asyncio, logging
from maxbot_api_client_python.api import API, Config
from maxbot_api_client_python.types.models import *
logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s")
log = logging.getLogger(__name__)
async def main():
try:
bot = API(Config(
base_url="https://platform-api.max.ru", # Base url for MAX API requests
token="YOUR_BOT_TOKEN", # Max bot token
global_rps=25,
timeout=35
))
except ValueError as e:
log.error(f"Initialization error: {e}")
return
try:
response = await bot.subscriptions.GetUpdatesAsync(GetUpdatesReq())
log.info(f"New update received: {response.model_dump()}")
except Exception as e:
log.error(f"GetUpdatesAsync error: {e}")
finally:
await bot.aclose()
if __name__ == "__main__":
asyncio.run(main())