예제 #1
0
파일: bot.py 프로젝트: KholkinV/tbot
def user_entering_info(message):
    db.set_state(con, states.STATE_ENTER_PARENT_CATEGORY, message.chat.id)
    categories = db.select_all_categories(con)
    inline_keyboard = types.InlineKeyboardMarkup()
    inline_keyboard.add(
        types.InlineKeyboardButton(text="Нет родительской категории",
                                   callback_data="no_category"))
    for category in categories:
        inline_keyboard.add(
            types.InlineKeyboardButton(text=category.name,
                                       callback_data=category.id))

    bot.send_message(message.chat.id,
                     "Выбери родительскую категорию",
                     reply_markup=inline_keyboard)
예제 #2
0
파일: bot.py 프로젝트: KholkinV/tbot
def admin(message):
    db.set_state(con, states.STATE_ADMIN, message.chat.id)
    inline_keyboard = types.InlineKeyboardMarkup()
    inline_keyboard.add(
        types.InlineKeyboardButton(text='Добавить категорию',
                                   callback_data='addCategory'))
    inline_keyboard.add(
        types.InlineKeyboardButton(text='Удалить категорию',
                                   callback_data='deleteCategory'))
    inline_keyboard.add(
        types.InlineKeyboardButton(text='Статистика',
                                   callback_data='show_stats'))

    bot.send_message(message.chat.id,
                     text='Администрирование',
                     reply_markup=inline_keyboard)
예제 #3
0
파일: bot.py 프로젝트: KholkinV/tbot
def start(message):
    if not (db.is_user_exists(con, message.chat.id)):
        db.add_user(con, message.chat.id, message.from_user.first_name,
                    message.from_user.last_name)

    db.set_state(con, states.STATE_CATEGORIES, message.chat.id)
    categories = db.select_categories(con)
    inline_keyboard = types.InlineKeyboardMarkup()
    for category in categories:
        inline_keyboard.add(
            types.InlineKeyboardButton(text=category.name,
                                       callback_data=category.id))

    bot.send_message(message.chat.id,
                     text=f'Привет {message.from_user.first_name}',
                     reply_markup=inline_keyboard)
예제 #4
0
파일: bot.py 프로젝트: KholkinV/tbot
def show_stats(call):
    db.set_state(con, states.STATE_SHOW_STATS, call.message.chat.id)
    visits = db.get_visits_count_by_categories(con)
    categories = db.select_categories_names_by_ids(con, tuple(visits.keys()))

    inline_keyboard = types.InlineKeyboardMarkup()
    for visit in visits.keys():
        row = categories[visit] + ' - ' + str(visits[visit])
        inline_keyboard.add(
            types.InlineKeyboardButton(text=row, callback_data=visit))
        #text += categories[visit] + ' - ' + str(visits[visit]) + '\n'

    bot.send_message(
        call.message.chat.id,
        text="Выбери категорию для просмотра пользователей посещавших её",
        reply_markup=inline_keyboard)
예제 #5
0
파일: bot.py 프로젝트: KholkinV/tbot
def user_entering_parent_category(call):
    bot.send_message(call.message.chat.id, f"Готово!, {call.data}")
    db.set_state(con, states.DEFAULT, call.message.chat.id)
예제 #6
0
파일: bot.py 프로젝트: KholkinV/tbot
def user_entering_name(message):
    bot.send_message(message.chat.id, "Введи описание категории")
    db.set_state(con, states.STATE_ENTER_CATEGORY_INFO, message.chat.id)
예제 #7
0
파일: bot.py 프로젝트: KholkinV/tbot
def add_category(call):
    db.set_state(con, states.STATE_ENTER_CATEGORY_NAME, call.message.chat.id)
    bot.send_message(call.message.chat.id, text='Введи название категории')