Ejemplo n.º 1
0
def create_poll(message):
    new_poll = PollData()
    poll_dict[message.chat.id] = new_poll
    about_poll = message.text
    poll = poll_dict[message.chat.id]
    poll.about_poll = about_poll
    bot.reply_to(message, "Give your question for poll!")
    bot.register_next_step_handler(message, get_poll_question)
Ejemplo n.º 2
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")
Ejemplo n.º 3
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)
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
def get_number_of_options(message):
    try:
        number_of_options = int(message.text)
        poll = poll_dict[message.chat.id]
        poll.no_of_options = number_of_options
        poll.current_option_no = 1
        response = {}
        for i in range(1, poll.no_of_options + 1):
            response["Option " + str(i)] = 0
        poll.response = response
        bot.reply_to(message, "Give option " + str(poll.current_option_no))
        bot.register_next_step_handler(message, get_options)
    except ValueError:
        bot.reply_to(message, "Give a valid input")
        bot.register_next_step_handler(message, get_number_of_options)
Ejemplo n.º 6
0
def get_options(message):
    current_option = message.text
    poll = poll_dict[message.chat.id]
    options = poll.options
    if not options:
        poll.options = {
            "Option " + str(poll.current_option_no): current_option
        }
    else:
        options["Option " + str(poll.current_option_no)] = current_option
        poll.options = options
    poll.current_option_no += 1
    if poll.current_option_no <= poll.no_of_options:
        bot.reply_to(message, "Give option " + str(poll.current_option_no))
        bot.register_next_step_handler(message, get_options)
    else:
        bot.send_message(message.chat.id, "Poll has been created")
Ejemplo n.º 7
0
def get_username(message):
    username = message.text.lower()
    bot.reply_to(message, "please enter you login pass")
    bot.register_next_step_handler(message, get_password, username)
Ejemplo n.º 8
0
 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)
Ejemplo n.º 9
0
def get_poll_question(message):
    question = message.text
    poll = poll_dict[message.chat.id]
    poll.question = question
    bot.reply_to(message, "How many options you want?")
    bot.register_next_step_handler(message, get_number_of_options)