Advertisement
frecnbr

mail.ru-01

Nov 10th, 2023
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. import sys
  2. from loguru import logger
  3. from asyncio import sleep, create_task, get_event_loop
  4. from pyrogram import Client, filters
  5. from concurrent.futures import ThreadPoolExecutor
  6.  
  7. def create_app(api_id, api_hash, session_name):
  8. return Client(session_name, api_id=api_id, api_hash=api_hash)
  9.  
  10. async def spam_messages(app, message, my_message):
  11. global spam_enabled
  12. while spam_enabled:
  13. await app.send_message(message.chat.id, my_message)
  14. logger.info(f"Отправил сообщение в {message.chat.id}")
  15. await sleep(float(TIME_SLEEP))
  16.  
  17. async def enable_spam(_, message, my_message):
  18. global spam_enabled
  19. await message.delete()
  20. spam_enabled = False if message.text.split()[1] == "1" else True if message.text.split()[1] == "2" else True
  21. [create_task(spam_messages(_, message, my_message)) for _ in range(5)]
  22.  
  23. if __name__ == '__main__':
  24. if len(sys.argv) != 2:
  25. print("Использование: python ваш_скрипт.py \"ваше_сообщение\"")
  26. sys.exit(1)
  27.  
  28. my_message = sys.argv[1]
  29.  
  30. api_id_1, api_hash_1, session_name_1 = "your_api_id_1", "your_api_hash_1", "session_name_1"
  31. api_id_2, api_hash_2, session_name_2 = "your_api_id_2", "your_api_hash_2", "session_name_2"
  32.  
  33. app_1 = create_app(api_id_1, api_hash_1, session_name_1)
  34. app_2 = create_app(api_id_2, api_hash_2, session_name_2)
  35.  
  36. loop = get_event_loop()
  37.  
  38. with ThreadPoolExecutor() as executor:
  39. loop.run_in_executor(executor, app_1.run)
  40. loop.run_in_executor(executor, app_2.run)
  41.  
  42. loop.run_forever()
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement