Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- from loguru import logger
- from asyncio import sleep, create_task, get_event_loop
- from pyrogram import Client, filters
- from concurrent.futures import ThreadPoolExecutor
- def create_app(api_id, api_hash, session_name):
- return Client(session_name, api_id=api_id, api_hash=api_hash)
- async def spam_messages(app, message, my_message):
- global spam_enabled
- while spam_enabled:
- await app.send_message(message.chat.id, my_message)
- logger.info(f"Отправил сообщение в {message.chat.id}")
- await sleep(float(TIME_SLEEP))
- async def enable_spam(_, message, my_message):
- global spam_enabled
- await message.delete()
- spam_enabled = False if message.text.split()[1] == "1" else True if message.text.split()[1] == "2" else True
- [create_task(spam_messages(_, message, my_message)) for _ in range(5)]
- if __name__ == '__main__':
- if len(sys.argv) != 2:
- print("Использование: python ваш_скрипт.py \"ваше_сообщение\"")
- sys.exit(1)
- my_message = sys.argv[1]
- api_id_1, api_hash_1, session_name_1 = "your_api_id_1", "your_api_hash_1", "session_name_1"
- api_id_2, api_hash_2, session_name_2 = "your_api_id_2", "your_api_hash_2", "session_name_2"
- app_1 = create_app(api_id_1, api_hash_1, session_name_1)
- app_2 = create_app(api_id_2, api_hash_2, session_name_2)
- loop = get_event_loop()
- with ThreadPoolExecutor() as executor:
- loop.run_in_executor(executor, app_1.run)
- loop.run_in_executor(executor, app_2.run)
- loop.run_forever()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement