def change(message): if is_admin(message): db = Db(db_dir) places = db.get_places() if places: keyboard = types.InlineKeyboardMarkup() for place in places: place_button = types.InlineKeyboardButton(text=str(place[1]), callback_data=u'{"action": "change", "id": "' + str( place[0]) + '"}') keyboard.add(place_button) bot.send_message(chat_id, "Выберите место на сегодня:", reply_markup=keyboard)
def callback(call): print(call) if is_admin(call): msg_id = call.message.message_id data = json.loads(call.data) if 'change' == data['action']: place_name = callbacks_actions.change(call.message, data['id']) bot.edit_message_text(chat_id=chat_id, message_id=msg_id, text="Вы выбрали: " + place_name) if 'delete' == data['action']: place_name = callbacks_actions.delete(call.message, data['id']) bot.edit_message_text(chat_id=chat_id, message_id=msg_id, text="Вы выбрали: " + place_name)
def change(message): if is_admin(message): db = Db(db_dir) places = db.get_places() if places: keyboard = types.InlineKeyboardMarkup() for place in places: place_button = types.InlineKeyboardButton( text=str(place[1]), callback_data=u'{"action": "change", "id": "' + str(place[0]) + '"}') keyboard.add(place_button) bot.send_message(chat_id, "Выберите место на сегодня:", reply_markup=keyboard)
def softdelete(message): if is_admin(message): db = Db(db_dir) places = db.get_all_places() if places: keyboard = types.InlineKeyboardMarkup() for place in places: if 1 == place[3]: status = '👍' else: status = '👎' place_button = types.InlineKeyboardButton(text=str(place[1]) + ' ' + status, callback_data=u'{"action": "delete", "id": "' + str( place[0]) + '"}') keyboard.add(place_button) bot.send_message(chat_id, "Выберите место чтобы удалить или добавить:", reply_markup=keyboard)
def softdelete(message): if is_admin(message): db = Db(db_dir) places = db.get_all_places() if places: keyboard = types.InlineKeyboardMarkup() for place in places: if 1 == place[3]: status = '👍' else: status = '👎' place_button = types.InlineKeyboardButton( text=str(place[1]) + ' ' + status, callback_data=u'{"action": "delete", "id": "' + str(place[0]) + '"}') keyboard.add(place_button) bot.send_message(chat_id, "Выберите место чтобы удалить или добавить:", reply_markup=keyboard)
def random(message): if is_admin(message): db = Db(db_dir) db.delete_today()
def die(message): if is_admin(message): bot.stop_polling()