Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.54 KB | None | 0 0
  1. @dp.callback_query_handler(text='forward')
  2. async def forward(call):
  3.     try:
  4.         user = await mongo.find_user(str(call.from_user.id))
  5.         now = time.time()
  6.         called = user['throttle']
  7.         delta = now - called
  8.         #print('Found!')
  9.  
  10.         if delta >= 3:
  11.             await bot.answer_callback_query(call.id)
  12.             await mongo.throttle(str(call.from_user.id), now)
  13.  
  14.             status = pagtask.move_forw(call.from_user.id)
  15.             #print('moved', status)
  16.  
  17.             # get all tasks
  18.             tasks = await shelf.tasks()
  19.             #print(tasks)
  20.             if tasks:
  21.                 one_task = tasks[status]
  22.                 frmt = {'task_id': one_task['task_id'],
  23.                         'task_date': one_task['date'],
  24.                         'task_msg': one_task['message'],
  25.                         'task_photo': one_task['photo']}
  26.  
  27.                 #infolog.info(texts.one_task.format(**frmt))
  28.  
  29.                 await bot.edit_message_text(chat_id=call.from_user.id,
  30.                                             message_id=call.message.message_id,
  31.                                             text=texts.one_task.format(**frmt),
  32.                                             parse_mode='HTML',
  33.                                             reply_markup=keyboards.tasks(one_task['task_id']))
  34.  
  35.         else:
  36.             await bot.answer_callback_query(call.id, 'Антифлуд, не так быстро)')
  37.             print('--------------ANTIFLOOOD')
  38.     except Exception as e:
  39.         erlog.exception(e)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement