Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 7
0
def random(message):
    if is_admin(message):
        db = Db(db_dir)
        db.delete_today()
Exemplo n.º 8
0
def die(message):
    if is_admin(message):
        bot.stop_polling()
Exemplo n.º 9
0
def random(message):
    if is_admin(message):
        db = Db(db_dir)
        db.delete_today()
Exemplo n.º 10
0
def die(message):
    if is_admin(message):
        bot.stop_polling()