How to use the mdformat.failure function in mdformat

To help you get started, we’ve selected a few mdformat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JosXa / BotListBot / botlistbot / components / admin.py View on Github external
def ban_handler(bot, update, args, chat_data, ban_state: bool):
    if args:
        query = " ".join(args) if isinstance(args, list) else args

        entity_to_ban = lookup_entity(query, exact=True)

        if isinstance(entity_to_ban, User):
            ban_user(bot, update, entity_to_ban, ban_state)
        elif isinstance(entity_to_ban, Bot):
            ban_bot(bot, update, chat_data, entity_to_ban, ban_state)
        else:
            update.message.reply_text(mdformat.failure("Can only ban users and bots."))
    else:
        # no search term
        update.message.reply_text(
            messages.BAN_MESSAGE if ban_state else messages.UNBAN_MESSAGE,
            reply_markup=ForceReply(selective=True),
        )
    return ConversationHandler.END
github JosXa / BotListBot / botlistbot / lib / markdownformatter.py View on Github external
def send_failure(self, chat_id, text: str, **kwargs):
        text = str.strip(text)
        if text[-1] != '.':
            text += '.'
        return self.bot.sendMessage(
            chat_id,
            failure(text),
            **self._set_defaults(kwargs))
github JosXa / BotListBot / botlistbot / components / admin.py View on Github external
),
                )
            msg += "\nUser {} was notified.".format(str(to_reject.submitted_by))
            notification_successful = True
        except TelegramError:
            msg += "\nUser {} could NOT be contacted/notified in private.".format(
                str(to_reject.submitted_by)
            )
            notification_successful = False

    text = util.success("{} rejected.".format(to_reject.username))
    if notification_successful is True:
        text += " User {} was notified.".format(to_reject.submitted_by.plaintext)
    elif notification_successful is False:
        try:
            text += " " + mdformat.failure(
                "Could not contact {}.".format(to_reject.submitted_by.plaintext)
            )
        except:
            pass
    else:
        text += " No notification sent."
    return msg
github JosXa / BotListBot / botlistbot / components / admin.py View on Github external
)
    try:
        util.send_md_message(
            bot,
            moderator.chat_id,
            text,
            reply_markup=reply_markup,
            disable_web_page_preview=True,
        )
        answer_text = mdformat.success(
            "I will ask {} to have a look at this submission.".format(
                moderator.plaintext
            )
        )
    except Exception as e:
        answer_text = mdformat.failure(f"Could not contact {moderator.plaintext}: {e}")

    if update.callback_query:
        update.callback_query.answer(text=answer_text)

    Statistic.of(
        update,
        "share",
        "submission {} with {}".format(bot_in_question.username, moderator.plaintext),
    )

mdformat

CommonMark compliant Markdown formatter

MIT
Latest version published 8 months ago

Package Health Score

71 / 100
Full package analysis

Similar packages