Пример #1
0
    def linkchanger(call):
        bot.answer_callback_query(call.id)
        course_to_change = call.data[5:]
        markup_yes_no = InlineKeyboardMarkup()
        markup_yes_no.row_width = 2
        markup_yes_no.add(InlineKeyboardButton("Add link", callback_data="addlink_"+course_to_change),
                          InlineKeyboardButton('Remove Link', callback_data="remlink_"+course_to_change))
        bot.send_message(call.message.chat.id, "please choose for "+course_to_change, reply_markup=markup_yes_no)

        @bot.callback_query_handler(func=lambda call: call.data.startswith("addlink_") or call.data.startswith("remlink_"))
        def tatticode(call):
            bot.answer_callback_query(call.id)
            course_name = call.data[8:]
            if call.data[0] == "a":
                msg = bot.send_message(call.message.chat.id, "please add a name for link in "+course_name)
                bot.register_next_step_handler(msg, get_name, course_name)
            elif call.data[0] == "r":
                print("remo")
                local_links = links[course_name]
                markup = InlineKeyboardMarkup()
                markup.row_width = len(local_links.keys())
                for text, url in local_links.items():
                    markup.add(InlineKeyboardButton(text, callback_data="linkrem_"+text))
                bot.send_message(call.message.chat.id, "please select a link to delete..", reply_markup=markup)

        def get_name(msg, course_name):
            li = msg.text
            bot.send_message(msg.chat.id, "this link will be added as " + li + " for "+course_name+" \nPlease send new link now....")
            bot.register_next_step_handler(msg, get_link, course_name, li)

        def get_link(msg, course_name, lin_nm):
            li = msg.text
            bot.send_message(msg.chat.id, "this will be added as new link " + lin_nm + " for "+course_name)
            links[course_name][lin_nm] = li
Пример #2
0
def callback_query(call):
    bot.answer_callback_query(call.id)
    bot.delete_message(call.message.chat.id, call.message.id)
    if is_reg(call.message):
        analytics_manager(call.data, users_dict[call.message.chat.id])
    else:
        bot.send_message(call.message.chat.id, "Please /start again")
Пример #3
0
def callback_query(call):
    bot.answer_callback_query(call.id)
    if is_reg(call.message):
        bot.delete_message(call.message.chat.id, call.message.id)
        bot.send_message(call.message.chat.id, "Please click /hi again")
    else:
        bot.send_message(call.message.chat.id, "Please /start again")
Пример #4
0
def callback_query(call):
    bot.answer_callback_query(call.id)
    if is_reg(call.message):
        session = call.data[9:]
        get_marks(call.message, users_dict[call.message.chat.id], session)
    else:
        bot.send_message(call.message.chat.id, "Please /start again")
Пример #5
0
def classlinks_callback_handler(call):
    bot.answer_callback_query(call.id)
    if call.message.chat.id in users_dict:
        user = users_dict[call.message.chat.id]
        user.request_no = 0
        get_classlinks(call.message)
    else:
        bot.send_message(call.message.chat.id, "Please /start again")
Пример #6
0
def login_callback(call):
    if not is_reg(call.message):
        bot.answer_callback_query(call.id)
        bot.send_message(call.message.chat.id,
                         "Please enter you Roll number like mitXXXXXXXXX")
        bot.register_next_step_handler(call.message, get_username)
    else:
        bot.answer_callback_query(call.id)
        bot.send_message(call.message.chat.id,
                         "You are already logged in just click /start")
Пример #7
0
def poll_callback_handler(call):
    bot.answer_callback_query(call.id)
    bot.send_message(call.message.chat.id, "Remember few points")
    bot.send_message(call.message.chat.id,
                     "1. User can create only one poll at a time")
    bot.send_message(call.message.chat.id,
                     "2. For any poll only first reponse will be recorded")
    bot.send_message(call.message.chat.id,
                     "3. Poll cannot have multiple responses ")
    bot.send_message(call.message.chat.id,
                     "Enter briefy what the poll is about")
    bot.register_next_step_handler(call.message, create_poll)
Пример #8
0
def options_handler(call):
    bot.answer_callback_query(call.id)
    user = users_dict[call.message.chat.id]
    current_poll = user.current_poll
    if user.answered_poll:
        user.answered_poll.append(current_poll)
    else:
        user.answered_poll = []
        user.answered_poll.append(current_poll)
    current_poll.response[call.data] += 1
    current_poll.total_response += 1
    get_poll_result(call.message)
Пример #9
0
 def tatticode(call):
     bot.answer_callback_query(call.id)
     course_name = call.data[8:]
     if call.data[0] == "a":
         msg = bot.send_message(call.message.chat.id, "please add a name for link in "+course_name)
         bot.register_next_step_handler(msg, get_name, course_name)
     elif call.data[0] == "r":
         print("remo")
         local_links = links[course_name]
         markup = InlineKeyboardMarkup()
         markup.row_width = len(local_links.keys())
         for text, url in local_links.items():
             markup.add(InlineKeyboardButton(text, callback_data="linkrem_"+text))
         bot.send_message(call.message.chat.id, "please select a link to delete..", reply_markup=markup)
Пример #10
0
def announce_callback_handler(call):
    if call.data == "announcement":
        bot.answer_callback_query(call.id)
        if call.message.chat.id in users_dict:
            get_announcement(call.message, users_dict[call.message.chat.id])
        else:
            bot.send_message(call.message.chat.id, "Please /start again")
    elif call.data == "refresh_anc":
        bot.answer_callback_query(call.id)
        user = users_dict[call.message.chat.id]
        user.request_no = 0
        if call.message.chat.id in users_dict:
            get_announcement(call.message, users_dict[call.message.chat.id])
        else:
            bot.send_message(call.message.chat.id, "Please /start again")
Пример #11
0
def login_callback(call):
    bot.answer_callback_query(call.id)
    if not is_reg(call.message):
        bot.answer_callback_query(call.id)
        bot.send_message(
            call.message.chat.id,
            "you are not even logged in dada.\n Please click /start")
    else:
        bot.answer_callback_query(call.id)
        if call.message.chat.id in users_dict:
            logout(users_dict[call.message.chat.id])
        else:
            bot.send_message(call.message.chat.id,
                             "Sorry!! we messed up .. :(\n just click /start")
Пример #12
0
def handler_callback(call):
    bot.answer_callback_query(call.id)
    handle(call.message, call.data)
Пример #13
0
def admin_panel_callback(call):
    bot.answer_callback_query(call.id)
    admin_panel(call.message)
Пример #14
0
def broadcast_handler(call):
    bot.answer_callback_query(call.id)
    broadcast()
Пример #15
0
def classlinks_callback_handler(call):
    bot.answer_callback_query(call.id)
    res = helper.Pages.get_note(call.data)
    bot.send_message(call.message.chat.id, res)
Пример #16
0
def callback_query(call):
    bot.answer_callback_query(call.id)
    if is_reg(call.message):
        enable_analytics(call.message, users_dict[call.message.chat.id])
    else:
        bot.send_message(call.message.chat.id, "Please /start again")
Пример #17
0
def callback_query(call):
    bot.answer_callback_query(call.id)
    if is_reg(call.message):
        get_session(call.message, users_dict[call.message.chat.id])
    else:
        bot.send_message(call.message.chat.id, "Please /start again")
Пример #18
0
def active_poll_handler(call):
    bot.answer_callback_query(call.id)
    user = users_dict[call.message.chat.id]
    active_poll = user.active_poll
    user.current_poll = active_poll[call.data]
    display_poll(call.message)
Пример #19
0
def show_poll(call):
    bot.answer_callback_query(call.id)
    get_active_poll(call.message)