Python telegram.InlineKeyboardMarkup() Examples

The following are 30 code examples of telegram.InlineKeyboardMarkup(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module telegram , or try the search function .
Example #1
Source File: ranklist.py    From superCodingBot with MIT License 9 votes vote down vote up
def polo(self, bot, update, user_data):
        msg = update.message.text.upper()
        conn = sqlite3.connect(self.mount_point + 'coders1.db')
        c = conn.cursor()
        c.execute("SELECT name FROM handles WHERE name=(?)", (msg,))
        if c.fetchone():
            keyboard = [[InlineKeyboardButton("Hackerearth", callback_data='HElist8'),
                         InlineKeyboardButton("Hackerrank", callback_data='HRlist8')],
                        [InlineKeyboardButton("Codechef", callback_data='CClist8'),
                         InlineKeyboardButton("Spoj", callback_data='SPlist8')],
                        [InlineKeyboardButton("Codeforces", callback_data='CFlist8'),
                         InlineKeyboardButton("ALL", callback_data='ALLlist8')]]
            reply_markup = InlineKeyboardMarkup(keyboard)
            update.message.reply_text('please select the judge or select all for showing all',
                                      reply_markup=reply_markup)
            user_data['name1'] = msg
            conn.close()
            return XOLO
        else:
            conn.close()
            update.message.reply_text("Sorry this name is not registered with me.")
            return ConversationHandler.END

    # FUNCTION TO SHOW THE KIND OF RANKLIST USER WANTS 
Example #2
Source File: contest_utility.py    From superCodingBot with MIT License 7 votes vote down vote up
def upcoming_sender(self, update, contest_list):
        i = 0
        s = ""
        keyboard = []
        keyboard1 = []
        for er in contest_list:
            i = i + 1
            # LIMITING NO OF EVENTS TO 20
            if i == 16:
                break
            parsed_contest = self.contest_parser(er)
            s = s + str(i) + ". " + parsed_contest["title"] + "\n" + "Start:\n" + \
                parsed_contest["start"].replace("T", " ")\
                + " GMT\n" + str(parsed_contest["start1"]).replace("T", " ") + " IST\n" + \
                "Duration: " + str(parsed_contest["duration"]) + "\n" + \
                parsed_contest["host"] + "\n" + parsed_contest["contest"] + "\n\n"
            keyboard1.append(InlineKeyboardButton(str(i), callback_data=str(i)))
            if i % 5 == 0:
                keyboard.append(keyboard1)
                keyboard1 = []
        keyboard.append(keyboard1)
        reply_markup = InlineKeyboardMarkup(keyboard)
        update.message.reply_text(s + "Select competition number to get notification" + "\n\n",
                                  reply_markup=reply_markup) 
Example #3
Source File: favorites.py    From BotListBot with MIT License 7 votes vote down vote up
def remove_favorite_menu(bot, update):
    uid = util.uid_from_update(update)
    user = User.from_update(update)
    favorites = Favorite.select_all(user)

    fav_remove_buttons = [InlineKeyboardButton(
        '✖️ {}'.format(str(f.bot.username)),
        callback_data=util.callback_for_action(CallbackActions.REMOVE_FAVORITE, {'id': f.id}))
                          for f in favorites]
    buttons = util.build_menu(fav_remove_buttons, 2, header_buttons=[
        InlineKeyboardButton(captions.DONE,
                             callback_data=util.callback_for_action(CallbackActions.SEND_FAVORITES_LIST))
    ])
    reply_markup = InlineKeyboardMarkup(buttons)
    bot.formatter.send_or_edit(uid, util.action_hint("Select favorites to remove"),
                                 to_edit=util.mid_from_update(update),
                                 reply_markup=reply_markup) 
Example #4
Source File: keyboards.py    From AmbroBot with GNU General Public License v3.0 7 votes vote down vote up
def time_options_keyboard():
    buttons = [
        [
            Button('5 Mins', callback_data=remind_time(5 * MINUTE)),
            Button('10 Mins', callback_data=remind_time(10 * MINUTE)),
            Button('20 Mins', callback_data=remind_time(20 * MINUTE)),
            Button('30 Mins', callback_data=remind_time(30 * MINUTE)),
        ],
        [
            Button('1 Hour', callback_data=remind_time(HOUR)),
            Button('2 Hours', callback_data=remind_time(2 * HOUR)),
            Button('4 Hours', callback_data=remind_time(4 * HOUR)),
            Button('8 Hours', callback_data=remind_time(8 * HOUR)),
        ],
        [
            Button('12 hours', callback_data=remind_time(12 * HOUR)),
            Button('24 hours', callback_data=remind_time(24 * HOUR)),
            Button('48 hours', callback_data=remind_time(48 * HOUR)),
        ],
    ]

    return InlineKeyboardMarkup(buttons) 
Example #5
Source File: stickers.py    From SkittBot with GNU General Public License v3.0 7 votes vote down vote up
def makepack_internal(msg, user, png_sticker, emoji, bot, packname, packnum):
    name = user.first_name
    name = name[:50]
    try:
        extra_version = ""
        if packnum > 0:
            extra_version = " " + str(packnum)
        success = bot.create_new_sticker_set(user.id, packname, f"{name}s kang pack" + extra_version,
                                             png_sticker=png_sticker,
                                             emojis=emoji)
    except TelegramError as e:
        print(e)
        if e.message == "Sticker set name is already occupied":
            msg.reply_text("Your pack can be found [here](t.me/addstickers/%s)" % packname,
                           parse_mode=ParseMode.MARKDOWN)
        elif e.message == "Peer_id_invalid":
            msg.reply_text("Contact me in PM first.", reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(
                text="Start", url=f"t.me/{bot.username}")]]))
        elif e.message == "Internal Server Error: created sticker set not found (500)":
                msg.reply_text("Sticker pack successfully created. Get it [here](t.me/addstickers/%s)" % packname,
                       parse_mode=ParseMode.MARKDOWN)
        return

    if success:
        msg.reply_text("Sticker pack successfully created. Get it [here](t.me/addstickers/%s)" % packname,
                       parse_mode=ParseMode.MARKDOWN)
    else:
        msg.reply_text("Failed to create sticker pack. Possibly due to blek mejik.") 
Example #6
Source File: helper_global.py    From channel-helper-bot with GNU General Public License v3.0 6 votes vote down vote up
def send_intro_template(bot, chat_id, lang, key, text_key):
    # Prepare Keyboard
    lang_list = helper_const.LANG_LIST
    width = helper_const.LANG_WIDTH
    current_lang = lang
    motd_keyboard = [[
        InlineKeyboardButton(
            lang_list[width * idx + delta] + (" (*)" if lang_list[width * idx + delta] == current_lang else ""),
            callback_data="%s|%s" % (key, lang_list[width * idx + delta])
        ) for delta in range(width)
    ] for idx in range(len(lang_list) // width)] + [[
        InlineKeyboardButton(
            lang_list[idx] + (" (*)" if lang_list[idx] == current_lang else ""),
            callback_data="%s|%s" % (key, lang_list[idx])
        )
    for idx in range(width * (len(lang_list) // width), len(lang_list))]]

    motd_markup = InlineKeyboardMarkup(motd_keyboard)
    bot.send_message(
        chat_id=chat_id, 
        text=value(text_key, "", lang=current_lang),
        reply_markup=motd_markup
    ) 
Example #7
Source File: __main__.py    From SkittBot with GNU General Public License v3.0 6 votes vote down vote up
def send_settings(chat_id, user_id, user=False):
    if user:
        if USER_SETTINGS:
            settings = "\n\n".join(
                "*{}*:\n{}".format(mod.__mod_name__, mod.__user_settings__(user_id)) for mod in USER_SETTINGS.values())
            dispatcher.bot.send_message(user_id, "These are your current settings:" + "\n\n" + settings,
                                        parse_mode=ParseMode.MARKDOWN)

        else:
            dispatcher.bot.send_message(user_id, "Seems like there aren't any user specific settings available :'(",
                                        parse_mode=ParseMode.MARKDOWN)

    else:
        if CHAT_SETTINGS:
            chat_name = dispatcher.bot.getChat(chat_id).title
            dispatcher.bot.send_message(user_id,
                                        text="Which module would you like to check {}'s settings for?".format(
                                            chat_name),
                                        reply_markup=InlineKeyboardMarkup(
                                            paginate_modules(0, CHAT_SETTINGS, "stngs", chat=chat_id)))
        else:
            dispatcher.bot.send_message(user_id, "Seems like there aren't any chat settings available :'(\nSend this "
                                                 "in a group chat you're admin in to find its current settings!",
                                        parse_mode=ParseMode.MARKDOWN) 
Example #8
Source File: competitions.py    From superCodingBot with MIT License 6 votes vote down vote up
def removeRemind(self, bot, update):
        conn = sqlite3.connect(self.mount_point + 'coders1.db')
        c = conn.cursor()
        c.execute("SELECT id FROM apscheduler_jobs WHERE id LIKE  " + "'" + str(
            update.message.chat_id) + "%' AND id LIKE " + "'%1'")
        if c.fetchone():
            c.execute("SELECT id FROM apscheduler_jobs WHERE id LIKE  " + "'" + str(
                update.message.chat_id) + "%' AND id LIKE " + "'%1'")
            a = c.fetchall()
            keyboard = []
            for i in range(0, len(a)):
                s = str(a[i]).replace("('", "").replace("',)", "").replace(
                    '("', "").replace('",)', "")
                print(s)
                keyboard.append([InlineKeyboardButton(str(self.schedule.get_job(job_id=s).args[1].split("\n")[0]),
                                                      callback_data=s[:-1] + "notiplz")])
            reply_markup = InlineKeyboardMarkup(keyboard)
            update.message.reply_text("Here are your pending reminders\nSelect the reminder you want to remove",
                                      reply_markup=reply_markup)
            c.close()
            return REMNOTI
        else:
            c.close()
            update.message.reply_text("You have no pending reminders")
            return ConversationHandler.END 
Example #9
Source File: misc.py    From BotListBot with MIT License 6 votes vote down vote up
def manage_subscription(bot, update):
    chat_id = update.effective_chat.id
    user_id = update.effective_user.id

    if util.is_group_message(update):
        admins = bot.get_chat_administrators(chat_id)
        if user_id not in admins:
            bot.formatter.send_failure(chat_id, "Sorry, but only Administrators of this group are allowed "
                                                    "to manage subscriptions.")
            return

    text = "Would you like to be notified when new bots arrive at the @BotList?"
    buttons = [[
        InlineKeyboardButton(util.success("Yes"),
                             callback_data=util.callback_for_action(CallbackActions.SET_NOTIFICATIONS,
                                                                    {'value': True})),
        InlineKeyboardButton("No", callback_data=util.callback_for_action(CallbackActions.SET_NOTIFICATIONS,
                                                                          {'value': False}))]]
    reply_markup = InlineKeyboardMarkup(buttons)
    msg = util.send_md_message(bot, chat_id, text, reply_markup=reply_markup)
    return ConversationHandler.END 
Example #10
Source File: __main__.py    From EmiliaHikari with GNU General Public License v3.0 6 votes vote down vote up
def get_help(update, context):
    chat = update.effective_chat  # type: Optional[Chat]
    args = update.effective_message.text.split(None, 1)

    # ONLY send help in PM
    if chat.type != chat.PRIVATE:

        # update.effective_message.reply_text("Contact me in PM to get the list of possible commands.",
        update.effective_message.reply_text(tl(update.effective_message, "Hubungi saya di PM untuk mendapatkan daftar perintah."),
                                            reply_markup=InlineKeyboardMarkup(
                                                [[InlineKeyboardButton(text=tl(update.effective_message, "Tolong"),
                                                                       url="t.me/{}?start=help".format(
                                                                           context.bot.username))]]))
        return

    elif len(args) >= 2 and any(args[1].lower() == x for x in HELPABLE):
        module = args[1].lower()
        text = tl(update.effective_message, "Ini adalah bantuan yang tersedia untuk modul *{}*:\n").format(HELPABLE[module].__mod_name__) \
               + tl(update.effective_message, HELPABLE[module].__help__)
        send_help(chat.id, text, InlineKeyboardMarkup([[InlineKeyboardButton(text=tl(update.effective_message, "Kembali"), callback_data="help_back")]]))

    else:
        send_help(chat.id, tl(update.effective_message, HELP_STRINGS)) 
Example #11
Source File: ranklist.py    From superCodingBot with MIT License 5 votes vote down vote up
def ranklist(bot, update):
        keyboard = [[InlineKeyboardButton("EVERY ONE", callback_data='allsel1'),
                     InlineKeyboardButton("MINE", callback_data='minesel1')],
                    [InlineKeyboardButton("GET BY NAME", callback_data='getNamesel1')]]
        reply_markup = InlineKeyboardMarkup(keyboard)
        update.message.reply_text("Please select the ranklist you want", reply_markup=reply_markup)
        return SELECTION

    # FUNCTION TO GET THE USER REQUEST AND SHOW MENU OF RANKLISTS 
Example #12
Source File: compiler.py    From superCodingBot with MIT License 5 votes vote down vote up
def lang(self, bot, update, user_data):
        query = update.callback_query
        val = query.data
        val = str(val).replace("comp1", "")
        if val == "other":
            # IF USER CHOOSES OTHER
            s1 = ""
            for language in self.compiler.supportedlanguages():
                s1 = s1 + language + ", "
            bot.edit_message_text(text="" + s1[:-2], chat_id=query.message.chat_id,
                                  message_id=query.message.message_id)
            bot.send_message(chat_id=query.message.chat_id,
                             text="Enter the name of a language from the above list",
                             reply_markup=ForceReply(True))
            return OTHER
        else:
            # ELSE ASKING WETHER HE WANTS TO SEND SOURCE CODE OR A .TXT FILE
            user_data['lang'] = val
            keyboard = [[InlineKeyboardButton("Enter Source Code", callback_data='codeso1'),
                         InlineKeyboardButton("Send a .txt file", callback_data='fileso1')]]
            reply_markup = InlineKeyboardMarkup(keyboard)
            bot.edit_message_text(text="please select", reply_markup=reply_markup, chat_id=query.message.chat_id,
                                  message_id=query.message.message_id)
            return CODE

    # FUNCTION TO GET THE SOURCE CODE OR .TXT FILE AS INPUT 
Example #13
Source File: geeks_for_geeks.py    From superCodingBot with MIT License 5 votes vote down vote up
def gfg(bot, update):
        keyboard = [[InlineKeyboardButton("ALGORITHMS", callback_data='Algorithmsgfg1'),
                     InlineKeyboardButton("DATA STRUCTURES", callback_data='DSgfg1')],
                    [InlineKeyboardButton("GATE", callback_data='GATEgfg1'),
                     InlineKeyboardButton("INTERVIEW", callback_data='Interviewgfg1')]]
        reply_markup = InlineKeyboardMarkup(keyboard)
        update.message.reply_text("please select", reply_markup=reply_markup)
        return GFG1

    # FUNCTION TO SHOW SUBMENU 1 
Example #14
Source File: update_rank_list.py    From superCodingBot with MIT License 5 votes vote down vote up
def updatesel(bot, update):
        keyboard = [[InlineKeyboardButton("Hackerearth", callback_data='HEupd5'),
                     InlineKeyboardButton("Hackerrank", callback_data='HRupd5')],
                    [InlineKeyboardButton("Codechef", callback_data='CCupd5'),
                     InlineKeyboardButton("Spoj", callback_data='SPupd5')],
                    [InlineKeyboardButton("Codeforces", callback_data='CFupd5'),
                     InlineKeyboardButton("ALL", callback_data='ALLupd5')]]
        reply_markup = InlineKeyboardMarkup(keyboard)
        update.message.reply_text("PLEASE SELECT THE JUDGE FROM WHICH YOU WANT TO UPDATE YOUR PROFILE",
                                  reply_markup=reply_markup)
        return UPDA

    # FUNCTION TO UPDATE PARTICULR ENTRY USER SELECTED 
Example #15
Source File: codechef.py    From superCodingBot with MIT License 5 votes vote down vote up
def randomcc(bot, update):
        keyboard = [[InlineKeyboardButton("Beginner", callback_data='BEGINNERcc1'),
                     InlineKeyboardButton("Easy", callback_data='EASYcc1')],
                    [InlineKeyboardButton("Medium", callback_data='MEDIUMcc1'),
                     InlineKeyboardButton("Hard", callback_data='HARDcc1')],
                    [InlineKeyboardButton("Challenge", callback_data='CHALLENGEcc1'),
                     InlineKeyboardButton("Peer", callback_data='PEERcc1')]]
        reply_markup = InlineKeyboardMarkup(keyboard)
        update.message.reply_text('Please select the type of question', reply_markup=reply_markup)
        return QSELCC

    # FUNCTION FOR SENDING THE RANDOM QUESTION TO USER ACCORDING TO HIS CHOICE 
Example #16
Source File: compiler.py    From superCodingBot with MIT License 5 votes vote down vote up
def other(bot, update, user_data):
        s = update.message.text
        user_data['lang'] = s
        keyboard = [[InlineKeyboardButton("Enter Source Code", callback_data='codeso1'),
                     InlineKeyboardButton("Send a file", callback_data='fileso1')]]
        reply_markup = InlineKeyboardMarkup(keyboard)
        update.message.reply_text("please select", reply_markup=reply_markup)
        return CODE 
Example #17
Source File: codeforces.py    From superCodingBot with MIT License 5 votes vote down vote up
def randomcf(bot, update):
        keyboard = [[InlineKeyboardButton("A", callback_data='Acf1'),
                     InlineKeyboardButton("B", callback_data='Bcf1'), InlineKeyboardButton("C", callback_data='Ccf1')],
                    [InlineKeyboardButton("D", callback_data='Dcf1'),
                     InlineKeyboardButton("E", callback_data='Ecf1'), InlineKeyboardButton("F", callback_data='Fcf1')],
                    [InlineKeyboardButton("OTHERS", callback_data='OTHERScf1')]]
        reply_markup = InlineKeyboardMarkup(keyboard)
        update.message.reply_text('Please select the type of question', reply_markup=reply_markup)
        return QSELCF

    # FUNCTION FOR SENDING THE RANDOM QUESTION TO USER ACCORDING TO HIS CHOICE 
Example #18
Source File: unregister.py    From superCodingBot with MIT License 5 votes vote down vote up
def unregister(bot, update):
        keyboard = [[InlineKeyboardButton("Hackerearth", callback_data='HErem2'),
                     InlineKeyboardButton("Hackerrank", callback_data='HRrem2')],
                    [InlineKeyboardButton("Codechef", callback_data='CCrem2'),
                     InlineKeyboardButton("Spoj", callback_data='SPrem2')],
                    [InlineKeyboardButton("Codeforces", callback_data='CFrem2'),
                     InlineKeyboardButton("ALL", callback_data='ALLrem2')]]
        reply_markup = InlineKeyboardMarkup(keyboard)
        update.message.reply_text("Select the judge you want to unregister from", reply_markup=reply_markup)
        return REMOVER

    # FUNCTION FOR REMOVING DATA FROM DATABASE ACCORDING TO USERS CHOICE 
Example #19
Source File: ques_of_the_day.py    From superCodingBot with MIT License 5 votes vote down vote up
def subscribe(bot, update):
        if update.message.chat_id < 0:
            update.message.reply_text(
                "I detected this is a group\nIf you subscribe here I will send questions to the group\nTo get questions to yourself subscribe to me in personal message")
        keyboard = [[InlineKeyboardButton("CODEFORCES", callback_data='CFsub3'),
                     InlineKeyboardButton("CODECHEF", callback_data='CCsub3')]]
        reply_markup = InlineKeyboardMarkup(keyboard)
        bot.send_message(
            text="Please select the website to which you wish to subscribe for getting question of the day",
            chat_id=update.message.chat_id, reply_markup=reply_markup)
        return SUBSEL 
Example #20
Source File: ques_of_the_day.py    From superCodingBot with MIT License 5 votes vote down vote up
def unsubsel(self, bot, update):
        names = ['', 'BEGINNER', 'EASY', 'MEDIUM', 'HARD', 'CHALLENGE', 'PEER', 'A', 'B', 'C', 'D', 'E', 'F', 'OTHERS']
        conn = sqlite3.connect(self.mount_point + 'coders1.db')
        c = conn.cursor()
        c.execute("SELECT id FROM subscribers WHERE id=(?)", (str(update.message.chat_id),))
        if not c.fetchone():
            update.message.reply_text("You are not subscribed to question of the day use /subscribe to subscribe")
            c.close()
            return ConversationHandler.END
        else:
            c.execute("SELECT * FROM subscribers WHERE id=(?)", (str(update.message.chat_id),))
            keyboard = []
            for row in c.fetchall():
                for i in range(1, len(row)):
                    if i <= 6:
                        site = "CODECHEF"
                    else:
                        site = "CODEFORCES"
                    if row[i] == 1:
                        keyboard.append(
                            [InlineKeyboardButton(site + ' ' + names[i], callback_data=names[i] + 'unsub4')])
            reply_markup = InlineKeyboardMarkup(keyboard)
            update.message.reply_text("Select the one you want to unsubscribe from", reply_markup=reply_markup)
            c.close()
            conn.close()
            return UNSUB 
Example #21
Source File: explore.py    From BotListBot with MIT License 5 votes vote down vote up
def select_category(bot, update, chat_data, callback_action=None):
    chat_id = update.effective_chat.id
    reply_markup = InlineKeyboardMarkup(_select_category_buttons(callback_action))
    reply_markup, callback = botlistchat.append_restricted_delete_button(
        update, chat_data, reply_markup
    )
    msg = bot.formatter.send_or_edit(
        chat_id,
        util.action_hint(messages.SELECT_CATEGORY),
        to_edit=util.mid_from_update(update),
        reply_markup=reply_markup,
    )
    callback(msg)
    return ConversationHandler.END 
Example #22
Source File: keyboard.py    From AmbroBot with GNU General Public License v3.0 5 votes vote down vote up
def serie_go_back_keyboard():
    return InlineKeyboardMarkup([GO_BACK_BUTTON_ROW]) 
Example #23
Source File: keyboard.py    From AmbroBot with GNU General Public License v3.0 5 votes vote down vote up
def serie_load_more_latest_episodes_keyboard():
    buttons = [
        [Button('Load more..', callback_data=LOAD_MORE_LATEST)],
        GO_BACK_BUTTON_ROW,
    ]
    return InlineKeyboardMarkup(buttons) 
Example #24
Source File: keyboard.py    From AmbroBot with GNU General Public License v3.0 5 votes vote down vote up
def serie_season_keyboard(seasons):
    COLUMNS = 2
    buttons = [
        Button(f'Season {season}', callback_data=SEASON_T.format(season))
        for season, episodes in sorted(seasons.items())
    ]
    columned_keyboard = [
        buttons[i: i + COLUMNS] for i in range(0, len(buttons), COLUMNS)
    ]
    columned_keyboard.append(GO_BACK_BUTTON_ROW)

    return InlineKeyboardMarkup(columned_keyboard) 
Example #25
Source File: keyboard.py    From AmbroBot with GNU General Public License v3.0 5 votes vote down vote up
def days_selector_keyboard():
    # Show days and recurrence. Every week, every two weeks, once?
    buttons = [
         [
             Button(dia, callback_data=DAY_T.format(dia))
             for dia in ('Lunes', 'Martes', 'Miercoles', 'Jueves', 'Viernes')
         ]
    ]
    # Add second keyboard with weekly, biweekly and monthly.
    return InlineKeyboardMarkup(buttons) 
Example #26
Source File: keyboard.py    From AmbroBot with GNU General Public License v3.0 5 votes vote down vote up
def show_matrix_markup(matrix):
    COLUMNS = len(matrix[0])
    buttons = [
        Button(f'{num}', callback_data='a')
        for row in matrix
        for num in row
    ]
    columned_keyboard = [
        buttons[i: i + COLUMNS] for i in range(0, len(buttons), COLUMNS)
    ]
    return InlineKeyboardMarkup(columned_keyboard) 
Example #27
Source File: keyboards.py    From AmbroBot with GNU General Public License v3.0 5 votes vote down vote up
def remind_again_or_done():
    buttons = [
        [
            Button('✅ Listo', callback_data=DONE),
            Button('Recordar de nuevo ⏱', callback_data=REMIND_AGAIN),
        ]
    ]
    return InlineKeyboardMarkup(buttons) 
Example #28
Source File: __main__.py    From EmiliaHikari with GNU General Public License v3.0 5 votes vote down vote up
def send_help(chat_id, text, keyboard=None):
    if not keyboard:
        keyboard = InlineKeyboardMarkup(paginate_modules(0, HELPABLE, "help"))
    dispatcher.bot.send_message(chat_id=chat_id,
                                text=text,
                                parse_mode=ParseMode.MARKDOWN,
                                reply_markup=keyboard) 
Example #29
Source File: feds.py    From EmiliaHikari with GNU General Public License v3.0 5 votes vote down vote up
def del_fed(update, context):
	chat = update.effective_chat  # type: Optional[Chat]
	user = update.effective_user  # type: Optional[User]
	args = context.args
	if chat.type != "private":
		send_message(update.effective_message, tl(update.effective_message, "Hapus federasi Anda di PM saya, bukan dalam grup."))
		return
	if args:
		is_fed_id = args[0]
		getinfo = sql.get_fed_info(is_fed_id)
		if getinfo == False:
			send_message(update.effective_message, tl(update.effective_message, "Federasi ini tidak di temukan!"))
			return
		if int(getinfo['owner']) == int(user.id) or int(user.id) == OWNER_ID:
			fed_id = is_fed_id
		else:
			send_message(update.effective_message, tl(update.effective_message, "Hanya pemilik federasi yang dapat melakukan ini!"))
			return
	else:
		send_message(update.effective_message, tl(update.effective_message, "Apa yang harus saya hapus?"))
		return

	if is_user_fed_owner(fed_id, user.id) == False:
		send_message(update.effective_message, tl(update.effective_message, "Hanya pemilik federasi yang dapat melakukan ini!"))
		return

	send_message(update.effective_message, tl(update.effective_message, "Anda yakin ingin menghapus federasi Anda? Tindakan ini tidak bisa dibatalkan, Anda akan kehilangan seluruh daftar larangan Anda, dan '{}' akan hilang secara permanen.").format(getinfo['fname']),
			reply_markup=InlineKeyboardMarkup(
						[[InlineKeyboardButton(text=tl(update.effective_message, "⚠️ Hapus Federasi ⚠️"), callback_data="rmfed_{}".format(fed_id))],
						[InlineKeyboardButton(text=tl(update.effective_message, "Batalkan"), callback_data="rmfed_cancel")]])) 
Example #30
Source File: __main__.py    From SkittBot with GNU General Public License v3.0 5 votes vote down vote up
def send_help(chat_id, text, keyboard=None):
    if not keyboard:
        keyboard = InlineKeyboardMarkup(paginate_modules(0, HELPABLE, "help"))
    dispatcher.bot.send_message(chat_id=chat_id,
                                text=text,
                                parse_mode=ParseMode.MARKDOWN,
                                reply_markup=keyboard)