def delayed(*args, **kwargs): chat_id, m = args u = User.get(user_id=chat_id) u.state = s.stop u.save() timer = threading.Timer(kwargs['delay'], func, args=args, kwargs=kwargs) timer.start()
def send_photo_delay(chat_id, p, state=None, delay=0, disable_notification=None): u = User.get(user_id=chat_id) if state != None: u.state = state u.save() bot.send_photo(chat_id, p, disable_notification=disable_notification)
def day_2(user_id): u = User.get(user_id=user_id) u.day = 2 u.save() send_message_delay(user_id, s.day_2_start.format(u.first_name), state=s.day_2, delay=1) bot.send_chat_action(user_id, 'typing') send_message_delay( user_id, "Продолжайте присылать фото всего, что Вы едите и пьёте", delay=6)
def send_message_delay(chat_id, m, state=None, delay=0, reply_markup=None, disable_notification=None, parse_mode='Markdown'): u = User.get(user_id=chat_id) bot.send_chat_action(chat_id, 'typing') if state != None: u.state = state u.save() bot.send_message(chat_id, m, reply_markup=reply_markup, parse_mode=parse_mode, disable_notification=disable_notification)
def day_3(user_id): u = User.get(user_id=user_id) u.day = 3 u.save() bot.send_message(user_id, s.greeting_3.format(u.first_name)) send_message_delay(user_id, s.waiting_from_you, state=s.day_3, delay=5)