def recommend_moderator(bot, update, bot_in_question, page): uid = update.effective_user.id mid = util.mid_from_update(update) moderators = User.select().where((User.chat_id << settings.MODERATORS) & (User.chat_id != uid)) buttons = [ InlineKeyboardButton(u.first_name, callback_data=util.callback_for_action( CallbackActions.SELECT_MODERATOR, { 'bot_id': bot_in_question.id, 'uid': u.id, 'page': page })) for u in moderators ] buttons.insert( 0, InlineKeyboardButton(captions.BACK, callback_data=util.callback_for_action( CallbackActions.SWITCH_APPROVALS_PAGE, {'page': page}))) reply_markup = InlineKeyboardMarkup(util.build_menu(buttons, 1)) text = mdformat.action_hint( "Select a moderator you think is better suited to evaluate the submission of {}." .format(str(bot_in_question))) bot.formatter.send_or_edit(uid, text, to_edit=mid, reply_markup=reply_markup)
def prepare_transmission(bot, update, chat_data): chat_id = util.uid_from_update(update) text = mdformat.action_hint("Notify subscribers about this update?") reply_markup = InlineKeyboardMarkup( [[ InlineKeyboardButton("☑ Notifications", callback_data=util.callback_for_action( CallbackActions.SEND_BOTLIST, {'silent': False})), InlineKeyboardButton("Silent", callback_data=util.callback_for_action( CallbackActions.SEND_BOTLIST, {'silent': True})) ], [ InlineKeyboardButton("Re-send all Messages", callback_data=util.callback_for_action( CallbackActions.SEND_BOTLIST, { 'silent': True, 're': True })) ]]) # # TODO # text = "Temporarily disabled" # reply_markup = None util.send_md_message(bot, chat_id, text, reply_markup=reply_markup)
def set_text_property(bot, update, chat_data, property_name, to_edit=None): uid = util.uid_from_update(update) user = User.from_update(update) if check_suggestion_limit(bot, update, user): return if to_edit: text = (util.escape_markdown(getattr(to_edit, property_name)) + "\n\n" if getattr(to_edit, property_name) else '') text += mdformat.action_hint( messages.SET_BOTPROPERTY.format( property_name, util.escape_markdown(to_edit.username), CLEAR_QUERY)) if property_name == 'description': text += ', markdown enabled.' update.effective_message.reply_text( text, reply_markup=ForceReply(selective=True), parse_mode=ParseMode.MARKDOWN) chat_data['edit_bot'] = to_edit elif update.message: value = None text = update.message.text to_edit = chat_data.get('edit_bot', None) def too_long(n): bot.formatter.send_failure( uid, "Your {} text is too long, it must be shorter " "than {} characters. Please try again.".format( property_name, n)) util.wait(bot, update) return admin.edit_bot(bot, update, chat_data, to_edit) # Validation if property_name == 'description' and len(text) > 300: return too_long(300) if property_name == 'username': value = helpers.validate_username(text) if value: to_edit = chat_data.get('edit_bot', None) else: bot.formatter.send_failure( uid, "The username you entered is not valid. Please try again..." ) return admin.edit_bot(bot, update, chat_data, to_edit) if not value: value = text if to_edit: if _is_clear_query(text): Suggestion.add_or_update(user, property_name, to_edit, None) else: Suggestion.add_or_update(user, property_name, to_edit, value) admin.edit_bot(bot, update, chat_data, to_edit) else: bot.formatter.send_failure(uid, "An unexpected error occured.")
def main_menu(bot, update): chat_id = update.effective_chat.id is_admin = chat_id in settings.MODERATORS reply_markup = ReplyKeyboardMarkup( main_menu_buttons(is_admin), resize_keyboard=True, one_time_keyboard=True) if util.is_private_message( update) else ReplyKeyboardRemove() bot.sendMessage(chat_id, mdformat.action_hint("What would you like to do?"), reply_markup=reply_markup)
def broadcast(bot, update, user_data): cid = update.effective_chat.id uid = update.effective_user.id mid = util.mid_from_update(update) user = User.from_update(update) text = '' if cid == settings.BOTLISTCHAT_ID: replied_to = update.message.reply_to_message if replied_to: user_data['broadcast'] = dict( user_data.get('broadcast', dict()), reply_to_message_id=replied_to.message_id) if replied_to.from_user.username.lower() == settings.SELF_BOT_NAME: # editing text += '*You are editing one of my messages*\n\n' user_data['broadcast']['mode'] = 'editing' else: # replying text += '*You are replying to a message of {}.*\n\n'.format( update.message.reply_to_message.from_user.first_name) user_data['broadcast']['mode'] = 'replying' # answer and clean msg = bot.send_message(cid, "k") _delete_multiple_delayed(bot, cid, delayed=[msg.message_id], immediately=[update.message.message_id]) to_text = " _to_ " text += "Send me the text to broadcast to @BotListChat.\n" text += "_You can use the following words and they will replaced:_\n\n" text += '\n'.join([ '"{}"{}{}'.format(k, to_text, v) for k, v in BROADCAST_REPLACEMENTS.items() ]) # TODO Build text mentioning replacements # text += '\n@' + str(update.effective_user.username) + to_text + user.markdown_short bot.formatter.send_or_edit(uid, mdformat.action_hint(text), mid) return BotStates.BROADCASTING
def send_action_hint(self, chat_id, text: str, **kwargs): if text[-1] == '.': text = text[0:-1] return self.bot.sendMessage(chat_id, action_hint(text), **self._set_defaults(kwargs))
▫️A better bot with the same functionality is already in the @BotList. ▫️The user interface is bad in terms of usability and/or simplicity. ▫The bot is still in an early development stage ▫️Contains ads or exclusively adult content ▫️English language not supported per default (exceptions are possible) ▫NO MANYBOTS!!! 👺 For further information, please ask in the @BotListChat.""" ACCEPTANCE_PRIVATE_MESSAGE = """Congratulations, your bot submission {} has been accepted for the @BotList. You can already see it by using the /category command, and it is going to be in the @BotList in the next two weeks.\n\nCategory: {}""" BOTLIST_UPDATE_NOTIFICATION = """⚠️@BotList *update!* There are {n_bots} new bots: {new_bots} Share your bots in @BotListChat""" SEARCH_MESSAGE = mdformat.action_hint("What would you like to search for?") SEARCH_RESULTS = """I found *{num_results} bot{plural}* in the @BotList for *{query}*:\n {bots} """ KEYWORD_BEST_PRACTICES = """The following rules for keywords apply: ▫️Keep the keywords as short as possible ▫️Use singular where applicable (#̶v̶i̶d̶e̶o̶s̶ video) ▫️Try to tag every supported platform (e.g. #vimeo, #youtube, #twitch, ...) ▫Try to tag every supported action (#search, #upload, #download, ...) ▫Try to tag every supported format (#mp3, #webm, #mp4, ...) ▫Keep it specific (only tag #share if the bot has a dedicated 'Share' button) ▫Tag bots made with _bot creators_ (e.g. #manybot) ▫Use #related if the bot is not standalone, but needs another application to work properly, e.g. an Android App ▫Always think in the perspective of a user in need of a bot. What query might he be putting in the search field? """ NEW_BOTS_INLINEQUERY = "New Bots"