コード例 #1
0
def compete_conf(bot, updater):
    time.sleep(random.uniform(0, 0.7))
    btnlist = [
        telegram.InlineKeyboardButton('Желаю.', callback_data='want'),
        telegram.InlineKeyboardButton('Не желаю.', callback_data='not want')
    ]
    markup = telegram.InlineKeyboardMarkup(wr.build_menu(btnlist, n_cols=2))
    bot.send_message(chat_id=updater.callback_query.message.chat.id,
                     text='Хотите ли вы учавствовать с соревновательном режиме, где ваши результаты будут учтены в общем рейтинге?',reply_markup=markup)
コード例 #2
0
def send_welcome(bot, updater):
    time.sleep(random.uniform(0, 0.7))
    if pidr_cd(bot, updater)[0]:
        btnlist = [
            telegram.InlineKeyboardButton('Контест!', callback_data='contest'),
            telegram.InlineKeyboardButton('Дорешка!', callback_data='problems'),
            telegram.InlineKeyboardButton('Правила.', callback_data='rules')
        ]
        markup = telegram.InlineKeyboardMarkup(wr.build_menu(btnlist, n_cols=2))
        bot.send_message(chat_id=updater.callback_query.message.chat.id, text="Привет. Ты попал на Карусель! И она сегодня!\nЧто хочешь выбрать?",
                         reply_markup=markup)
    else:
        btnlist=[
            telegram.InlineKeyboardButton('Задачи предыдущего тура. ', callback_data='problems'),
            telegram.InlineKeyboardButton('Правила.', callback_data='rules')
        ]
        markup = telegram.InlineKeyboardMarkup(wr.build_menu(btnlist, n_cols=2))
        bot.send_message(chat_id=updater.callback_query.message.chat.id, text="Привет. Ты попал на Карусель! Но она не сегодня(\nЧто хочешь выбрать?", reply_markup=markup)
コード例 #3
0
def send_res(bot, updater):
    #GD.find_file('res.json').GetContentFile('res.json')
    doc = open('results.json', 'rb')
    btnlist = [
        telegram.InlineKeyboardButton('Да.', callback_data='yes')
    ]
    markup = telegram.InlineKeyboardMarkup(wr.build_menu(btnlist, n_cols=1))
    bot.send_document(chat_id=updater.message.chat.id, document=doc)
    bot.send_message(
        chat_id=updater.message.chat.id,
        text='Отправить тебе xlxs?',
        reply_markup=markup)
コード例 #4
0
def show_menu(bot, updater):
    time.sleep(random.uniform(0, 0.7))
    if 'callback_query' in str(updater):
        id = updater.callback_query.message.chat.id
    else:
        id = updater.message.chat.id
    btnlist = [
        telegram.InlineKeyboardButton('Показать задачки.', callback_data='problems'),
        telegram.InlineKeyboardButton('Правила.', callback_data='rules'),
        telegram.InlineKeyboardButton('Другое.', callback_data='others')

    ]
    btn = telegram.InlineKeyboardButton('Начать Контест!', callback_data='contest')
    markup = telegram.InlineKeyboardMarkup(wr.build_menu(btnlist, n_cols=2, footer_buttons=[btn]))
    bot.send_message(chat_id=id, text='Меню:', reply_markup=markup)
コード例 #5
0
def confirmation(bot, updater):
    time.sleep(random.uniform(0, 0.7))
    players = wr.read_results()
    if str(updater.message.chat.id) in players:
        bot.send_message(chat_id=updater.message.chat.id,
                         text='Йо, ты уже в системе. Просто используй команды.')
        show_menu(bot, updater)
    else:
        btnlist = [
            telegram.InlineKeyboardButton('Согласен.', callback_data='agree'),
            telegram.InlineKeyboardButton('Не согласен.', callback_data='disagree'),
        ]
        markup = telegram.InlineKeyboardMarkup(wr.build_menu(btnlist, n_cols=2))
        bot.send_message(chat_id=updater.message.chat.id,
                         text='Для начала необходимо согласиться с Согласием на обработку персональный данных.')
        bot.send_message(chat_id=updater.message.chat.id,
                         text='Я даю своё согласие на обработку и публикацию моих персональных данных, таких как: результат участия в Экономической Карусели и никнейм в телеграмм.',
                         reply_markup=markup)
コード例 #6
0
def query_h(bot, updater, job_queue):
    time.sleep(random.uniform(0, 0.7))
    call = updater.callback_query
    if call.message:
        if call.data == "contest":
            players = wr.read_results()
            id = call.from_user.id
            try:
                if not pidr_cd(bot, updater)[0]:
                    bot.send_message(chat_id=id, text='Контест не сегодня!')
                elif players[str(id)][2][len(players[str(id)][2]) - 1][3] == 'not contestFalse' and pidr_cd(bot, updater)[0]:
                    bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text=call.message.text)
                    start_carousel(bot, updater, 1, job_queue)
                else:
                    bot.send_message(chat_id=id, text='Ты уже писал контест!')
            except KeyError:
                bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,
                                      text=call.message.text)
                start_carousel(bot, updater, 1, job_queue)

    if call.data == 'agree':
        bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text=call.message.text)
        send_welcome(bot, updater)
    if call.data == 'disagree':
        bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text=call.message.text)
        bot.send_message(chat_id=call.message.chat.id, text='Если всё же передумаешь, то нажми старт ещё раз.')

    if call.data == 'want':
        bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text=call.message.text)
        start_carousel(bot, updater, 1, job_queue)
    if call.data == 'not want':
        bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text=call.message.text)
        start_carousel(bot, updater, 0, job_queue)

    if call.data == 'rules':
        if updater.callback_query.message.text != 'Меню:':
            bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text=call.message.text)
        print_rules(bot, updater)

    if call.data == 'problems':
        if call.message.text != 'Меню:':
            bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text=call.message.text )
        select_problems(bot, updater)

    if call.data[:3] == 'pr_':
        print_problem(bot, updater, int(call.data[3:]))

    if call.data == 'result':
        result(bot, updater)
    if call.data == 'allresults':
        allresults(bot, updater)

    if call.data == 'others':
        btnlist = [
        telegram.InlineKeyboardButton('Поддержать проект!', callback_data='donate'),
        telegram.InlineKeyboardButton('Отправить отзыв.', callback_data='feedback'),
            telegram.InlineKeyboardButton('Последний результат.', callback_data='result'),
            telegram.InlineKeyboardButton('Все результаты.', callback_data='allresults'),
            telegram.InlineKeyboardButton('Основное меню.', callback_data='menu')
        ]
        markup = telegram.InlineKeyboardMarkup(wr.build_menu(btnlist, n_cols=2))
        bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text=call.message.text, reply_markup=markup)

    if call.data == 'menu':
        btnlist = [
            telegram.InlineKeyboardButton('Показать задачки.', callback_data='problems'),
            telegram.InlineKeyboardButton('Правила.', callback_data='rules'),
            telegram.InlineKeyboardButton('Другое.', callback_data='others')
        ]
        btn = telegram.InlineKeyboardButton('Начать Контест!', callback_data='contest')
        markup = telegram.InlineKeyboardMarkup(wr.build_menu(btnlist, n_cols=2, footer_buttons=[btn]))
        bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text=call.message.text, reply_markup=markup)


    if call.data == 'donate':
        donate(bot, updater)

    if call.data == 'feedback':
        feedback(bot, updater)

    if call.data == 'yes':
        send_xlxs(bot, updater)

    return
コード例 #7
0
def select_problems(bot, updater):
    time.sleep(random.uniform(0, 0.7))
    if 'callback_query' in str(updater):
        message = updater.callback_query.message
    else:
        message = updater.message
    players = wr.read_results()
    today = pidr_cd(bot, updater)[1]
    state = pidr_cd(bot, updater)[0]
    name = str(message.chat.username) + '  ' + str(message.chat.first_name) + '  ' + str(message.chat.last_name)
    contest = players[str(message.chat.id)][2][len(players[str(message.chat.id)][2])-1][3]
    if str(message.chat.id) not in players:
        players[str(message.chat.id)] = [message.chat.id,
                                         '@' + name,
                                         [[today.strftime("%Y-%m-%d %H:%M:%S.%f"),
                                           {'1': [0],
                                            '2': [0],
                                            '3': [0],
                                            '4': [0],
                                            '5': [0],
                                            '6': [0],
                                            '7': [0],
                                            '8': [0],
                                            '9': [0],
                                            '10': [0],
                                            '11': [0],
                                            '12': [0]},
                                           2,
                                           'not contest{}'.format(state)]]]
        wr.write_results(players)
    elif contest[:11] != 'not contest':
        players[str(message.chat.id)][2].append([today.strftime("%Y-%m-%d %H:%M:%S.%f"),
                                           {'1': [0],
                                            '2': [0],
                                            '3': [0],
                                            '4': [0],
                                            '5': [0],
                                            '6': [0],
                                            '7': [0],
                                            '8': [0],
                                            '9': [0],
                                            '10': [0],
                                            '11': [0],
                                            '12': [0]},
                                           2,
                                           'not contest{}'.format(state)])
        wr.write_results(players)
    if contest[:11] == 'not contest':
        btnlist = []
        for i in range(1, 8, 6):
            btnlist.append(telegram.InlineKeyboardButton(
                str(i), callback_data='pr_{}'.format(i)))
            btnlist.append(telegram.InlineKeyboardButton(
                str(i + 1), callback_data='pr_{}'.format(i + 1)))
            btnlist.append(telegram.InlineKeyboardButton(
                str(i + 2), callback_data='pr_{}'.format(i + 2)))
            btnlist.append(telegram.InlineKeyboardButton(
                str(i + 3), callback_data='pr_{}'.format(i + 3)))
            btnlist.append(telegram.InlineKeyboardButton(
                str(i + 4), callback_data='pr_{}'.format(i + 4)))
            btnlist.append(telegram.InlineKeyboardButton(
                str(i + 5), callback_data='pr_{}'.format(i + 5)))
            markup = telegram.InlineKeyboardMarkup(wr.build_menu(btnlist, n_cols=6))
        bot.send_message(
            chat_id=message.chat.id,
            text='Выбери задачу из списка!',
            reply_markup=markup)
    else:
        bot.send_message(chat_id=message.chat.id, text='Ты уже начал контест!')