Advertisement
disk6969

click buttons

Jul 16th, 2024 (edited)
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.08 KB | None | 0 0
  1. async def main():
  2.  
  3.     chat = 'send'
  4.  
  5.     async def click_button(message, button_text):
  6.         buttons = message.buttons
  7.         if not buttons:
  8.             return
  9.         for row in buttons:
  10.             for btn in row:
  11.                 if button_text in btn.text:
  12.                     await btn.click()
  13.                     print(f'Нажата кнопка: {btn.text}')
  14.         await asyncio.sleep(0.3)
  15.         return await client.get_messages(chat, ids=message.id)
  16.  
  17.     async def check_announcements():
  18.         async with client.conversation(chat) as conv:
  19.             await conv.send_message('/start')
  20.             response = await conv.get_response()
  21.             message = await click_button(response, 'P2P')
  22.             message = await click_button(message, 'Купить')
  23.             message = await click_button(message, 'Tether (USDT)')
  24.             await click_button(message, 'MONOBANK')
  25.  
  26.     print('Скрипт запущен. Ожидание новых сообщений...')
  27.     while True:
  28.         await check_announcements()
  29.         await asyncio.sleep(60)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement