Esempio n. 1
0
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)
Esempio n. 2
0
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,
    )
Esempio n. 3
0
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
Esempio n. 4
0
def prepare_transmission(bot, update, chat_data):
    chat_id = util.uid_from_update(update)
    pending_update(bot, 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)
Esempio n. 5
0
 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))
Esempio n. 6
0
▫️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 will be able to see it shortly 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, #chatfuelbot)
▫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"