示例#1
0
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)
示例#2
0
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)
示例#3
0
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)
示例#4
0
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)
示例#5
0
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)
示例#6
0
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)
示例#7
0
def random(message):
    if is_admin(message):
        db = Db(db_dir)
        db.delete_today()
示例#8
0
def die(message):
    if is_admin(message):
        bot.stop_polling()
示例#9
0
def random(message):
    if is_admin(message):
        db = Db(db_dir)
        db.delete_today()
示例#10
0
def die(message):
    if is_admin(message):
        bot.stop_polling()