def reply_message(bot, telegram, message_id, text, index): bot.edit_message_text(chat_id=telegram, message_id=message_id, text=text, reply_markup=menu[index].get('button'), parse_mode='HTML') check_connect() where = 'telegram = %s' % telegram connect_mysql.update('menu', where, **{'message_id': message_id, 'text': text, 'index': index})
def check_state_of_deal(active_orders): # 'order_number', 'telegram', 'name', 'phone', 'goods', # 'amount', 'sum', 'deal_id', 'status', 'street', 'added' print('active_orders', active_orders) print('______________________________') for active_order in active_orders: print('active_order', active_order) result = bitrix24.get_deal_state({'id': active_order.get('deal_id')}) print('______________________________') print('result', result) try: print('status', active_order.get('status')) print('STAGE_ID', result.get('result').get('STAGE_ID')) print( result.get('result').get('STAGE_ID') != active_order.get( 'status')) if result.get('result').get('STAGE_ID') != active_order.get( 'status'): where = 'order_number = %s' % active_order.get('order_number') print('where', where) connect_mysql.update( 'basket', where, **{'status': result.get('result').get('STAGE_ID')}) except Exception as e: where = 'telegram = %s' % active_order.get('telegram') connect_mysql.update('basket', where, **{'status': 'WON'}) return
def update_menu(telegram, message_id, greetings, index): check_connect() where = 'telegram = %s' % telegram connect_mysql.update( 'menu', where, **{ 'message_id': message_id, 'text': greetings, 'index': index })
def for_street_menu(bot, telegram, street, where, index): check_connect() print('street %s ' % street) if street == []: message_id = bot.send_message(telegram, LOCATION, reply_markup=button.inline_location_menu(where), parse_mode='HTML') else: message_id = bot.send_message(telegram, LOCATION, reply_markup= button.inline_location_menu2(street.get('street'), where), parse_mode='HTML') where = 'telegram = %s' % telegram connect_mysql.update('menu', where, **{'message_id': message_id.message_id, 'text': LOCATION, 'index': index})
def send_photo(bot, chat_id, photo, text, index): check_connect() message_id = bot.send_photo(chat_id, photo, text, reply_markup=menu[index].get('button')) where = 'telegram = %s' % chat_id connect_mysql.update( 'menu', where, **{ 'message_id': message_id.message_id, 'text': text, 'index': index })
def add_contactID_to_db(telegram, contact_id): check_connect() where = 'telegram = %s' % telegram connect_mysql.update('users', where, **{'contact_id': contact_id})