testing.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import asyncio
  2. import datetime
  3. from pyexpat.errors import messages
  4. from random import randint
  5. from typing import Iterable
  6. from aiogram.types import Message
  7. import queu
  8. from async_db import Database
  9. from handlers import users_message
  10. from loader import scheduler, logger
  11. from utils import ScheduledMessage
  12. db = Database()
  13. def chat_id_in_list(chat_id):
  14. return
  15. async def main():
  16. scheduler.start()
  17. for i in range(0, 50):
  18. await db.jobs_add(2, -814326413, f'Добрый день, message-{i}')
  19. await db.jobs_add(2, -1001517227500, f'Добрый день, message-{i}')
  20. # db.jobs_add(0, randint(1111,9999), 'message to send')
  21. # db.jobs_add(2, randint(1111,9999), 'message to delete')
  22. # db.jobs_add(1234, randint(1111,9999), 'message delete')
  23. # list_jobs = await db.get_jobs()
  24. # scheduler.add_job(queu.create_tasks, trigger='interval', seconds=60, next_run_time=datetime.datetime.now())
  25. """`
  26. каждые 5 секунд до 20 сообщений по 10 в один чат
  27. in: [(10 messages in chat1), (5 messages in chat1)], [(10 messages in chat2),], [(10 messages in chat3),]
  28. out: [
  29. [10 messages in chat1 and 10 messages in chat2],
  30. [5 messages in chat1 and 10 messages in chat2 and 5 messages in chat3], ...]
  31. """
  32. await asyncio.sleep(2000)
  33. if __name__ == '__main__':
  34. asyncio.run(main())