Example #1
0
def front_page(user, message):
    bot.send_message(message.chat.id, "Hiii " + user.name + " ... ")
    markup = InlineKeyboardMarkup()
    markup.row_width = 1
    #
    markup.add(
        InlineKeyboardButton("Aviral marks " + emojis.get_emoji("bar_chart"),
                             callback_data="aviral")
    )  # InlineKeyboardButton("New announcements", callback_data="announcement")
    markup.add(
        InlineKeyboardButton("OPT IN/OUT for Marks Analytics",
                             callback_data="enable_analytics"))
    markup.add(
        InlineKeyboardButton("Online Class links", callback_data="classlinks"))
    markup.add(
        InlineKeyboardButton("Logout", callback_data="logout")
    )  # InlineKeyboardButton("Create Poll", callback_data="create_poll"),
    markup.row_width = 2
    markup.add(InlineKeyboardButton("About", callback_data="about"),
               InlineKeyboardButton("FAQ", callback_data="faq"))
    if user.is_admin:
        bot.send_message(message.chat.id, "Awesome you are an admin!!!")
        markup.add(
            InlineKeyboardButton("Admin Panel", callback_data="admin_panel"))
    bot.send_message(message.chat.id,
                     "Here are some things you can do",
                     reply_markup=markup)
Example #2
0
def enable_analytics(message, user):
    if user.flags['analytics_enabled']:
        yes_msg = "You have analytics enabled.\n\n Analytics do not share anything and does not even have any open api " \
                  "to access any records, as aviral dont provide any analytics so we have" \
                  + "to maintain our own little DB to give you analytics. It is not shared and all the code is hosted " \
                    "on " \
                    "github so you can ensure that there is no API support for any privacy" \
                  + " invading calls."
        msg = bot.send_message(message.chat.id, yes_msg)
        # time.sleep(10)
        # bot.delete_message(message.chat.id, msg.id)
        yes_msg = "But still if you dont want to contribute to rank analytics then it okay too. You can opt out from " \
                  "here. You can still use ZeNo as before but without analytics. \n\n"
        yes_msg += "Here are some things to keep in mind when opting out.\n" \
                   + "1. You wont be able to see your ranks also.\n" \
                   + "2. Your old data will take time to flush out from system but your new marks will not be stored " \
                     "from immediate effect.\n" \
                   + "3. As of now you can't opt in one you opt out.\n\n\n\n Please wait......"
        msg1 = bot.send_message(message.chat.id, yes_msg)
        time.sleep(10)
        bot.delete_message(message.chat.id, msg.id)
        bot.delete_message(message.chat.id, msg1.id)
        markup = InlineKeyboardMarkup()
        markup.row_width = 2
        markup.add(InlineKeyboardButton("Disable Analytics for me", callback_data="enable_analytics_no"),
                   InlineKeyboardButton("Cancel", callback_data="cancel"))
        bot.send_message(message.chat.id, "Do you want to opt out?", reply_markup=markup)
    else:
        markup = InlineKeyboardMarkup()
        markup.row_width = 2
        markup.add(InlineKeyboardButton("Enable Analytics for me", callback_data="enable_analytics_yes"),
                   InlineKeyboardButton("Cancel", callback_data="cancel"))
        bot.send_message(message.chat.id, "Do you want to opt in?", reply_markup=markup)
Example #3
0
def gen_markup_login():
    markup = InlineKeyboardMarkup()
    markup.row_width = 1
    markup.add(InlineKeyboardButton("Login Now", callback_data="main_login"),
               InlineKeyboardButton("No Thanks", callback_data="cancel"))
    markup.row_width = 2
    markup.add(InlineKeyboardButton("About", callback_data="about"),
               InlineKeyboardButton("FAQ", callback_data="faq"))
    return markup
Example #4
0
def handle_message(hnm):
    print(hnm)
    if hnm.message_type == 'UPDATE_COUNTRY':
        bot.send_message(hnm.chat_id,
                         hnm.content[0],
                         reply_markup=gen_markup(hnm.chat_id, hnm.content[1],
                                                 [(ii['name'], ii['code'])
                                                  for ii in hnm.content[2]]))
    elif hnm.message_type == 'CATEGORIES_CHOOSE':
        markup = InlineKeyboardMarkup()
        markup.row_width = 2
        for i in range(0, len(hnm.content[2]), 2):
            if i + 1 == len(hnm.content[2]):
                cat = hnm.content[2][i]
                markup.add(
                    InlineKeyboardButton(
                        cat[0],
                        callback_data=
                        f"CATEGORIES_CHOOSE:{cat[1]}:{hnm.chat_id}"))
            else:
                cat = hnm.content[2][i]
                cat1 = hnm.content[2][i + 1]
                markup.add(
                    InlineKeyboardButton(
                        cat[0],
                        callback_data=
                        f"CATEGORIES_CHOOSE:{cat[1]}:{hnm.chat_id}"),
                    InlineKeyboardButton(
                        cat1[0],
                        callback_data=
                        f"CATEGORIES_CHOOSE:{cat1[1]}:{hnm.chat_id}"))
        bot.send_message(hnm.chat_id, hnm.content[0], reply_markup=markup)
    elif hnm.message_type in [
            'LOADING', 'ITEM_END', 'INFO', 'UPDATE', 'ERROR'
    ]:
        bot.send_message(hnm.chat_id, hnm.content)
    elif hnm.message_type == 'ITEM':
        markup = InlineKeyboardMarkup()
        markup.row_width = 1
        markup.add(
            InlineKeyboardButton(
                hnm.content[2],
                callback_data=f'ITEM:{hnm.content[1]}:{hnm.chat_id}'))
        bot.send_message(
            hnm.chat_id,
            f"{hnm.content[0]['title']}\n{hnm.content[0]['link']}",
            reply_markup=markup)
    elif hnm.message_type == 'SET_LANGUAGE':
        markup = InlineKeyboardMarkup()
        for lang in hnm.content[1]:
            markup.add(
                InlineKeyboardButton(
                    lang[0].name,
                    callback_data=f'SET_LANGUAGE:{lang[1]}:{hnm.chat_id}'))
        bot.send_message(hnm.chat_id, hnm.content[0], reply_markup=markup)
Example #5
0
def set_markup():
    markup = InlineKeyboardMarkup()
    markup.row_width = 3
    markup = InlineKeyboardMarkup()
    markup.row_width = 3
    top_sponser=InlineKeyboardButton('⬆️ Set Top Text',callback_data='top_sponser')
    bottom_sponser=InlineKeyboardButton('⬇️ Set Bottom Text',callback_data='bottom_sponser')
    emoji=InlineKeyboardButton('☑️ Set Emoji',callback_data='emoji')
    markup.add(emoji)
    markup.add(top_sponser,bottom_sponser) 
    return markup
Example #6
0
def main_menu_markup():
    markup = InlineKeyboardMarkup()
    markup.row_width = 1
    markup.add(
        InlineKeyboardButton("Faze Uma Nova Postagem",
                             callback_data="create_post"))
    return markup
def readines_change_markup():
    markup = InlineKeyboardMarkup()
    markup.row_width = 2
    markup.add(InlineKeyboardButton("Да", callback_data="change_order"),
                               InlineKeyboardButton("Нет", callback_data="no_change_order")
)
    return markup
Example #8
0
def gen_mark(mode="", father=None, admin=True):
    mark = InlineKeyboardMarkup()
    mark.row_width = 2  #len(buttons)
    butt = []
    data = DB()

    if mode:
        butt = data.get_children_category_id(ObjectId(mode))
        print(data.get_children_category_id(ObjectId(mode)))
    else:
        butt = data.get_root_categories_id()

#    if not(father is None) :

    if (father or not (current_id is None)):
        mark.row(InlineKeyboardButton("Назад", callback_data=father))

    for b in butt:
        mark.row(
            InlineKeyboardButton(data.get_category_name(b), callback_data=b))

    #Есть админка
    if (admin):
        mark.row(InlineKeyboardButton("Изменить", callback_data="Edit"))
    return mark
def keyboardReturnCustom(prefix, node_code):
    markup = InlineKeyboardMarkup()
    markup.row_width = 1
    markup.add(
        InlineKeyboardButton("« Return", callback_data=prefix + node_code))

    return markup
Example #10
0
def keyboardReturnMyNodes():
    markup = InlineKeyboardMarkup()
    markup.row_width = 1
    markup.add(
        InlineKeyboardButton("« Back to Nodes List", callback_data="myNodes"))

    return markup
Example #11
0
def menu_qty_markup():
    markup = InlineKeyboardMarkup()
    markup.row_width = 3
    for i in range(1, 10):
        markup.add(
            InlineKeyboardButton(text=i, callback_data='qty_{0}'.format(i)))
    return markup
Example #12
0
 def photo(message):
     try:
         bot.send_message(
             message.chat.id,
             "Are you trying to add an ingredient, lest see if our system can figure out "
             "what it is")
         file_id = message.photo[0].file_id
         file_info = bot.get_file(file_id)
         downloaded_file = bot.download_file(file_info.file_path)
         text = emoji.emojize("Humm..., let me think :thinking_face:")
         bot.send_message(message.chat.id, text)
         ingredient = predict_photo(downloaded_file)
         vowels = ('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U')
         if ingredient.startswith(vowels):
             item = 'It might be an ' + ingredient
         else:
             item = 'It might be a ' + ingredient
         bot.reply_to(message, item)
         markup = InlineKeyboardMarkup()
         markup.row_width = 2
         markup.add(
             InlineKeyboardButton("Yes",
                                  callback_data="yes_add_ingredient"),
             InlineKeyboardButton("No", callback_data="no_add_ingredient"))
         bot.send_message(message.chat.id,
                          "Am i right bro?",
                          reply_markup=markup)
         posible_ingredient = {"name": ingredient, "amount": 0, "unit": ""}
         mongo.possible_ingredient(message.chat.id, posible_ingredient)
     except:
         mongo.update_user_status(message.chat.id, 0)
         bot.send_message(message.chat.id, "Could you repeat")
Example #13
0
def send_welcome(message):
    try:
        bot.send_message(message.chat.id, "Hello User!")

        markup = InlineKeyboardMarkup()
        markup.row_width = 3
        markup.add(
            InlineKeyboardButton("FASS", callback_data="cb_fass"),
            InlineKeyboardButton("BIZ", callback_data="cb_biz"),
            InlineKeyboardButton("COM", callback_data="cb_com"),
            InlineKeyboardButton("UTown", callback_data="cb_utown"),
            InlineKeyboardButton("Engineering", callback_data="cb_engine"),
            InlineKeyboardButton("Science", callback_data="cb_science"),
            InlineKeyboardButton("SDE", callback_data="cb_sde"),
            InlineKeyboardButton("Yale", callback_data="cb_yale"),
            InlineKeyboardButton("YST", callback_data="cb_yst"))
        bot.send_message(
            message.chat.id,
            "Select the *location* of the room that you would like to book",
            reply_markup=markup,
            parse_mode='MarkdownV2')
        return markup

    except Exception as e:
        bot.reply_to(message, "There was a problem. Please try again.")
        print(e)
Example #14
0
def keyboardReturnMyAddrs(infoUserCall):
    markup = InlineKeyboardMarkup()
    markup.row_width = 1
    markup.add(
        InlineKeyboardButton(translations[infoUserCall['languageApp']]['return'], callback_data="myAddrs"))

    return markup
Example #15
0
def keyboardStats1(infoUserDB):
    markup = InlineKeyboardMarkup()
    markup.row_width = 2
    markup.add(InlineKeyboardButton(translations[infoUserDB['languageApp']]['statsp2m'], callback_data="statsp2m"),
               InlineKeyboardButton(translations[infoUserDB['languageApp']]['statsaddr'], callback_data="statsaddr"))

    return markup
Example #16
0
def contact_admin_markup():
    markup = InlineKeyboardMarkup()
    markup.row_width = 1
    admin = InlineKeyboardButton('👨🏻‍💼 Contact Admin',
                                 url='https://t.me/PinkPromotionAdmin')
    markup.add(admin)
    return markup
 def response(statement, bot, mongo):
     try:
         response = api.parse_ingredients(statement.text)
         if response.status_code == 200:
             ingredient = json.loads(response.text)
             bot.send_message(statement.id, printIngridient(ingredient[0]))
             markup = InlineKeyboardMarkup()
             markup.row_width = 2
             markup.add(
                 InlineKeyboardButton("Yes",
                                      callback_data="yes_add_ingredient"),
                 InlineKeyboardButton("No",
                                      callback_data="no_add_ingredient"))
             bot.send_message(statement.id,
                              "Is this the item that you wanted to add?",
                              reply_markup=markup)
             mongo.possible_ingredient(statement.id, ingredient[0])
             mongo.update_user_status(statement.id, 23)
         else:
             bot.send_message(statement.id,
                              "This not seem like an ingredient")
             bot.send_message(statement.id, "Could you repeat?")
     except:
         bot.send_message(statement.id, "This not seem like an ingredient")
         bot.send_message(statement.id, "Could you repeat?")
Example #18
0
def gen_markup(eventid):
    markup = InlineKeyboardMarkup()
    markup.row_width = zabbix_keyboard_row_width
    markup.add(
        InlineKeyboardButton(zabbix_keyboard_button_message,
                             callback_data='{}'.format(
                                 json.dumps(
                                     dict(action="messages",
                                          eventid=eventid)))),
        InlineKeyboardButton(zabbix_keyboard_button_acknowledge,
                             callback_data='{}'.format(
                                 json.dumps(
                                     dict(action="acknowledge",
                                          eventid=eventid)))),
        InlineKeyboardButton(zabbix_keyboard_button_history,
                             callback_data='{}'.format(
                                 json.dumps(
                                     dict(action="history",
                                          eventid=eventid)))),
        InlineKeyboardButton(zabbix_keyboard_button_history,
                             callback_data='{}'.format(
                                 json.dumps(
                                     dict(action="last value",
                                          eventid=eventid)))),
        InlineKeyboardButton(zabbix_keyboard_button_history,
                             callback_data='{}'.format(
                                 json.dumps(
                                     dict(action="graphs", eventid=eventid)))))
    return markup
Example #19
0
def attendance_which_event(events):
    markup = InlineKeyboardMarkup()
    markup.row_width = 2
    for e in [event['ev'] for event in events]:
        markup.add(InlineKeyboardButton(e.get_inline_str(), callback_data="cb:attend_which_event:" + e.event_id))

    return markup
Example #20
0
def set_cap_markup():
    markup = InlineKeyboardMarkup()
    markup.row_width = 3
    top_sponser = InlineKeyboardButton('🔖 Set Caption',
                                       callback_data='set_caption')
    markup.add(top_sponser)
    return markup
Example #21
0
def remove_which_survey():
    markup = InlineKeyboardMarkup()
    markup.row_width = 2
    for s in get_survey():
        markup.add(InlineKeyboardButton(s.get_inline_str(), callback_data="remove_which_survey:" + s.survey_id))

    return markup
Example #22
0
def cancel_which_event():
    markup = InlineKeyboardMarkup()
    markup.row_width = 2
    for e in get_event():
        markup.add(InlineKeyboardButton(e.get_inline_str(), callback_data="cb:cancel_which_event:" + e.event_id))

    return markup
Example #23
0
def create_adapt_vote(vote_message):
    """Создаёт адапт-голосовашку"""
    keyboard = InlineKeyboardMarkup()
    url = 'https://t.me/multifandomrubot?start=new_adapt_option{}'.format(
        vote_message.message_id)
    keyboard.row_width = 1
    keyboard.add(InlineKeyboardButton("Предложить вариант", url=url))
    with open(ADAPT_VOTES_FILE, encoding='utf-8') as file:
        votes_shelve = file.read()
    if votes_shelve:
        votes_shelve = literal_eval(votes_shelve)
    else:
        votes_shelve = {}

    votes_shelve[vote_message.message_id] = {
        "text": vote_message.text,
        "votes": [],
        "keyboard": [],
        "chat": vote_message.chat.id
    }
    with open(ADAPT_VOTES_FILE, 'w', encoding='utf-8') as file:
        file.write(str(votes_shelve))
    edit_markup(vote_message.chat.id,
                vote_message.message_id,
                reply_markup=keyboard)
Example #24
0
def update_multi_vote(vote_id):
    """Обновляет мульти-голосовашку"""
    with open(MULTI_VOTES_FILE, encoding='utf-8') as file:
        votes_shelve = file.read()
    if votes_shelve:
        votes_shelve = literal_eval(votes_shelve)
    else:
        votes_shelve = {}

    votey = dict(votes_shelve[vote_id])
    keyboard = InlineKeyboardMarkup()
    url = 'https://t.me/multifandomrubot?start=new_option{}'.format(vote_id)
    keyboard.row_width = 1
    keyboard.add(InlineKeyboardButton("Предложить вариант", url=url))
    for i in votey['keyboard']:
        keyboard.add(
            InlineKeyboardButton(i,
                                 callback_data='mv_' +
                                 str(votey['keyboard'].index(i))))
    # Меняем текст голосовашки
    text = votey["text"]
    for i in votey['votes']:
        text += '\n{}: '.format(i[0]) + ', '.join(i[1].values())
    edit_text(text=text,
              chat_id=votey['chat'],
              message_id=vote_id,
              reply_markup=keyboard,
              parse_mode="HTML")
Example #25
0
    def create_inline_keyboard_btn_hb(self, string, url):
        markup = InlineKeyboardMarkup()
        markup.row_width = 2
        markup.add(InlineKeyboardButton(text=string, callback_data='ret', url=url))
        markup.add(InlineKeyboardButton("חזרה לתפריט הראשי 🔁", callback_data="ret"))

        return markup
Example #26
0
    def create_inline_keyboard_btn(self, string, url):
        markup = InlineKeyboardMarkup()
        markup.row_width = 2
        markup.add(InlineKeyboardButton(text=string, callback_data='return', url=url))
        markup.add(InlineKeyboardButton("Return To Menu 🔁", callback_data="return"))

        return markup
def keyboardNotifications(address):
    markup = InlineKeyboardMarkup()
    markup.row_width = 2
    markup.add(InlineKeyboardButton("ON", callback_data="notON-" + address),
               InlineKeyboardButton("OFF", callback_data="notOFF-" + address))

    return markup
Example #28
0
def instruction(message):
    chat_id = message.from_user.id
    instruction = """
    Мы все привыкли пользоваться сайтом rutracker.org и скачивать оттуда много полезного и приятного. \
    К сожалению, в последние годы доступ к нему хоть и не запрещен, но ограничен. \
    Данный бот предоставляет доступ к некоторым загрузкам, основываясь на архивах 2014 года. \
    В качестве результата своей работы он возвращает пользователю magnet-ссылку, с помощью которой можно так же запустить загрузку нужного файла. \
    О том как это сделать лучше читать в интернете.\n
    Все раздачи в рутрекере делятся по категориям, которые в свою очередь делятся на подкатегории, за редким исключением. \
    Это облегчает поиск, т.к. вычеркивает из поиска те категории, в которых явно не содержится нужная информация. \
    Категорий много, поэтому они разбиты на две группы. Ознакомиться с ними можно из меню, или с помощью команд /categories58 \
    и /categories117.\n
    Уже после выбора категории результаты поиска заметно улучшатся. Но чтобы выдача идеально подходила вашим запросам \
    так же рекомендуется выбрать подкатегорию. Сделать это так же можно из меню или по команде /subcategories. Главное, чтобы \
    перед выбором подкатегории была выбрана категория. Иначе не для чего будет выводить подкатегорию.\n
    После выбора категории и подкатегории можно осуществлять поиск по ним. Из меню или по команде /targetsearch. \
    Как и на сайте rutracker.org поиск можно осуществлять адресный или глобальный поиск. Для этого есть раздел в меню и команда /globalsearch.\n
    Желаем найти все!
    """
    keyboard = InlineKeyboardMarkup()
    keyboard.row_width = 1
    keyboard.add(InlineKeyboardButton('Выбор категории 1-58', callback_data='Выбор категории 1-58'),
                 InlineKeyboardButton('Выбор категории 59-117', callback_data='Выбор категории 59-117'),
                 InlineKeyboardButton('Поиск по категориям', callback_data='Поиск по категориям'),
                 InlineKeyboardButton('Глобальный поиск', callback_data='Глобальный поиск'),
                 InlineKeyboardButton('Меню', callback_data='m'),
                 )

    bot.send_message(chat_id, instruction, reply_markup=keyboard)
    return
Example #29
0
def gen_markup():
    markup = InlineKeyboardMarkup()
    markup.row_width = 2
    markup.add(InlineKeyboardButton("USD", callback_data="USD"),
               InlineKeyboardButton("EUR", callback_data="EUR"),
               InlineKeyboardButton("other", callback_data="other"))
    return markup
Example #30
0
def gen_markup(position, n):
    if position.get('name') == '-':
        return None
    markup = InlineKeyboardMarkup()
    markup.row_width = 1
    markup.add(InlineKeyboardButton('Выдать', callback_data=str(n)))
    return markup
def gen_markup():
    markup = InlineKeyboardMarkup()
    markup.row_width = 2
    markup.add(InlineKeyboardButton("Yes", callback_data=f"cb_yes"),
                               InlineKeyboardButton("No", callback_data=f"cb_no"))
    return markup