Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @run_async
- def request_acceptable_price(bot, update):
- do_stuff()
- job_queue.run_once(wait_for_price, when=1, context={
- 'client': get_uber_client(update.message.chat.id),
- 'chat_id': update.message.chat.id,
- 'message_id': data['last_message_id'],
- 'from_latitude': data['from_latitude'],
- 'from_longitude': data['from_longitude'],
- 'to_latitude': data['to_latitude'],
- 'to_longitude': data['to_longitude'],
- 'capacity': data['wait']['capacity'],
- 'price': price,
- 'msg_ln': msg_ln
- }, name=update.message.chat.id)
- return CANCEL_REQ
- def wait_for_price(bot, job):
- do_stuff()
- job_queue.run_once(wait_for_price, when=10, context=job.context, name=int(job.context['chat_id']))
- return CANCEL_REQ
- @run_async
- def cancel_request(bot, update):
- connection = persist.connection()
- cursor = connection.cursor()
- cursor.execute("SELECT `data` FROM `chat` WHERE `chat_id` = %s LIMIT 1", [
- update.callback_query.message.chat.id
- ])
- data = json.loads(cursor.fetchone()[0])
- if 'ride' in data:
- client = get_uber_client(update.callback_query.message.chat.id)
- client.cancel_current_ride()
- else:
- jobs = job_queue.get_jobs_by_name(name=update.callback_query.message.chat.id)
- for job in jobs:
- job.schedule_removal()
- updater.bot.edit_message_text(
- chat_id=update.callback_query.message.chat.id,
- message_id=data['last_message_id'],
- text=EMOJI_STATUS + 'You have cancelled'
- )
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement