Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def thank_you_markup(count=0):
assert isinstance(count, int)
count_caption = "" if count == 0 else mdformat.number_as_emoji(count)
button = InlineKeyboardButton(
"{} {}".format(messages.rand_thank_you_slang(), count_caption),
callback_data=util.callback_for_action(
const.CallbackActions.COUNT_THANK_YOU, {"count": count + 1}
),
)
return InlineKeyboardMarkup([[button]])
n_suggestions = len(Suggestion.select_all())
n_pending = len(Bot.select_pending_update())
second_row = list()
if n_unapproved > 0:
second_row.append(
KeyboardButton(
captions.APPROVE_BOTS
+ " {}🆕".format(mdformat.number_as_emoji(n_unapproved))
)
)
if n_suggestions > 0:
second_row.append(
KeyboardButton(
captions.APPROVE_SUGGESTIONS
+ " {}⁉️".format(mdformat.number_as_emoji(n_suggestions))
)
)
buttons = [
[KeyboardButton(captions.EXIT), KeyboardButton(captions.REFRESH)],
[
KeyboardButton(captions.FIND_OFFLINE),
KeyboardButton(captions.SEND_CONFIG_FILES),
],
]
update_row = list()
if n_pending > 0:
update_row.append(
KeyboardButton(
captions.PENDING_UPDATE
buttons = [
[KeyboardButton(captions.EXIT), KeyboardButton(captions.REFRESH)],
[
KeyboardButton(captions.FIND_OFFLINE),
KeyboardButton(captions.SEND_CONFIG_FILES),
],
]
update_row = list()
if n_pending > 0:
update_row.append(
KeyboardButton(
captions.PENDING_UPDATE
+ " {}{}".format(
mdformat.number_as_emoji(n_pending),
captions.SUGGESTION_PENDING_EMOJI,
)
)
)
if send_botlist_button:
update_row.append(KeyboardButton(captions.SEND_BOTLIST))
if logs_button:
update_row.append(KeyboardButton(captions.SEND_ACTIVITY_LOGS))
if len(update_row) > 0:
buttons.insert(1, update_row)
if len(second_row) > 0:
buttons.insert(1, second_row)
return buttons
def _admin_buttons(send_botlist_button=False, logs_button=False):
n_unapproved = len(Bot.select().where(Bot.approved == False, Bot.disabled == False))
n_suggestions = len(Suggestion.select_all())
n_pending = len(Bot.select_pending_update())
second_row = list()
if n_unapproved > 0:
second_row.append(
KeyboardButton(
captions.APPROVE_BOTS
+ " {}🆕".format(mdformat.number_as_emoji(n_unapproved))
)
)
if n_suggestions > 0:
second_row.append(
KeyboardButton(
captions.APPROVE_SUGGESTIONS
+ " {}⁉️".format(mdformat.number_as_emoji(n_suggestions))
)
)
buttons = [
[KeyboardButton(captions.EXIT), KeyboardButton(captions.REFRESH)],
[
KeyboardButton(captions.FIND_OFFLINE),
KeyboardButton(captions.SEND_CONFIG_FILES),
],