当前位置: 首页>>代码示例>>Python>>正文


Python helpers.escape_markdown方法代码示例

本文整理汇总了Python中telegram.utils.helpers.escape_markdown方法的典型用法代码示例。如果您正苦于以下问题:Python helpers.escape_markdown方法的具体用法?Python helpers.escape_markdown怎么用?Python helpers.escape_markdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在telegram.utils.helpers的用法示例。


在下文中一共展示了helpers.escape_markdown方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: list_handlers

# 需要导入模块: from telegram.utils import helpers [as 别名]
# 或者: from telegram.utils.helpers import escape_markdown [as 别名]
def list_handlers(bot: Bot, update: Update):
    chat = update.effective_chat  # type: Optional[Chat]
    all_handlers = sql.get_chat_triggers(chat.id)

    if not all_handlers:
        update.effective_message.reply_text("No filters are active here!")
        return

    filter_list = BASIC_FILTER_STRING
    for keyword in all_handlers:
        entry = " - {}\n".format(escape_markdown(keyword))
        if len(entry) + len(filter_list) > telegram.MAX_MESSAGE_LENGTH:
            update.effective_message.reply_text(filter_list, parse_mode=telegram.ParseMode.MARKDOWN)
            filter_list = entry
        else:
            filter_list += entry

    if not filter_list == BASIC_FILTER_STRING:
        update.effective_message.reply_text(filter_list, parse_mode=telegram.ParseMode.MARKDOWN)


# NOT ASYNC BECAUSE DISPATCHER HANDLER RAISED 
开发者ID:skittles9823,项目名称:SkittBot,代码行数:24,代码来源:cust_filters.py

示例2: about_me

# 需要导入模块: from telegram.utils import helpers [as 别名]
# 或者: from telegram.utils.helpers import escape_markdown [as 别名]
def about_me(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]
    user_id = extract_user(message, args)

    if user_id:
        user = bot.get_chat(user_id)
    else:
        user = message.from_user

    info = sql.get_user_me_info(user.id)

    if info:
        update.effective_message.reply_text("*{}*:\n{}".format(user.first_name, escape_markdown(info)),
                                            parse_mode=ParseMode.MARKDOWN)
    elif message.reply_to_message:
        username = message.reply_to_message.from_user.first_name
        update.effective_message.reply_text(username + " hasn't set an info message about themselves  yet!")
    else:
        update.effective_message.reply_text("You haven't set an info message about yourself yet!") 
开发者ID:skittles9823,项目名称:SkittBot,代码行数:21,代码来源:userinfo.py

示例3: about_bio

# 需要导入模块: from telegram.utils import helpers [as 别名]
# 或者: from telegram.utils.helpers import escape_markdown [as 别名]
def about_bio(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id = extract_user(message, args)
    if user_id:
        user = bot.get_chat(user_id)
    else:
        user = message.from_user

    info = sql.get_user_bio(user.id)

    if info:
        update.effective_message.reply_text("*{}*:\n{}".format(user.first_name, escape_markdown(info)),
                                            parse_mode=ParseMode.MARKDOWN)
    elif message.reply_to_message:
        username = user.first_name
        update.effective_message.reply_text("{} hasn't had a message set about themselves yet!".format(username))
    else:
        update.effective_message.reply_text("You haven't had a bio set about yourself yet!") 
开发者ID:skittles9823,项目名称:SkittBot,代码行数:21,代码来源:userinfo.py

示例4: list_notes

# 需要导入模块: from telegram.utils import helpers [as 别名]
# 或者: from telegram.utils.helpers import escape_markdown [as 别名]
def list_notes(bot: Bot, update: Update):
    chat_id = update.effective_chat.id
    note_list = sql.get_all_chat_notes(chat_id)

    msg = "*Notes in chat:*\n"
    for note in note_list:
        note_name = escape_markdown(" - {}\n".format(note.name))
        if len(msg) + len(note_name) > MAX_MESSAGE_LENGTH:
            update.effective_message.reply_text(msg, parse_mode=ParseMode.MARKDOWN)
            msg = ""
        msg += note_name

    if msg == "*Notes in chat:*\n":
        update.effective_message.reply_text("No notes in this chat!")

    elif len(msg) != 0:
        update.effective_message.reply_text(msg, parse_mode=ParseMode.MARKDOWN) 
开发者ID:skittles9823,项目名称:SkittBot,代码行数:19,代码来源:notes.py

示例5: about_me

# 需要导入模块: from telegram.utils import helpers [as 别名]
# 或者: from telegram.utils.helpers import escape_markdown [as 别名]
def about_me(update, context):
    message = update.effective_message  # type: Optional[Message]
    args = context.args
    user_id = extract_user(message, args)

    if user_id and user_id != "error":
        user = bot.get_chat(user_id)
    else:
        user = message.from_user

    info = sql.get_user_me_info(user.id)

    if info:
        send_message(update.effective_message, "*{}*:\n{}".format(user.first_name, escape_markdown(info)),
                                            parse_mode=ParseMode.MARKDOWN)
    elif message.reply_to_message:
        username = message.reply_to_message.from_user.first_name
        send_message(update.effective_message, username + tl(update.effective_message, " belum mengatur pesan info tentang diri mereka!"))
    else:
        send_message(update.effective_message, tl(update.effective_message, "Anda belum mengatur pesan info tentang diri Anda!")) 
开发者ID:AyraHikari,项目名称:EmiliaHikari,代码行数:22,代码来源:userinfo.py

示例6: about_bio

# 需要导入模块: from telegram.utils import helpers [as 别名]
# 或者: from telegram.utils.helpers import escape_markdown [as 别名]
def about_bio(update, context):
    message = update.effective_message  # type: Optional[Message]
    args = context.args

    user_id = extract_user(message, args)
    if user_id and user_id != "error":
        user = bot.get_chat(user_id)
    else:
        user = message.from_user

    info = sql.get_user_bio(user.id)

    if info:
        send_message(update.effective_message, "*{}*:\n{}".format(user.first_name, escape_markdown(info)),
                                            parse_mode=ParseMode.MARKDOWN)
    elif message.reply_to_message:
        username = user.first_name
        send_message(update.effective_message, tl(update.effective_message, "{} belum memiliki pesan tentang dirinya sendiri!").format(username))
    else:
        send_message(update.effective_message, tl(update.effective_message, "Anda belum memiliki bio set tentang diri Anda!")) 
开发者ID:AyraHikari,项目名称:EmiliaHikari,代码行数:22,代码来源:userinfo.py

示例7: about_me

# 需要导入模块: from telegram.utils import helpers [as 别名]
# 或者: from telegram.utils.helpers import escape_markdown [as 别名]
def about_me(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]
    user_id = extract_user(message, args)

    if user_id:
        user = bot.get_chat(user_id)
    else:
        user = message.from_user

    info = sql.get_user_me_info(user.id)

    if info:
        update.effective_message.reply_text("*{}*:\n{}".format(user.first_name, escape_markdown(info)),
                                            parse_mode=ParseMode.MARKDOWN)
    elif message.reply_to_message:
        username = message.reply_to_message.from_user.first_name
        update.effective_message.reply_text(username + "Information about him is currently unavailable !")
    else:
        update.effective_message.reply_text("You have not added any information about yourself yet !") 
开发者ID:TGExplore,项目名称:Marie-2.0-English,代码行数:21,代码来源:userinfo.py

示例8: about_bio

# 需要导入模块: from telegram.utils import helpers [as 别名]
# 或者: from telegram.utils.helpers import escape_markdown [as 别名]
def about_bio(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id = extract_user(message, args)
    if user_id:
        user = bot.get_chat(user_id)
    else:
        user = message.from_user

    info = sql.get_user_bio(user.id)

    if info:
        update.effective_message.reply_text("*{}*:\n{}".format(user.first_name, escape_markdown(info)),
                                            parse_mode=ParseMode.MARKDOWN)
    elif message.reply_to_message:
        username = user.first_name
        update.effective_message.reply_text("{} No details about him have been added yet !".format(username))
    else:
        update.effective_message.reply_text(" Your information about you has been added !") 
开发者ID:TGExplore,项目名称:Marie-2.0-English,代码行数:21,代码来源:userinfo.py

示例9: fuzzy_replacements_markdown

# 需要导入模块: from telegram.utils import helpers [as 别名]
# 或者: from telegram.utils.helpers import escape_markdown [as 别名]
def fuzzy_replacements_markdown(query, threshold=95, official_api_links=True):
    """ Replaces the enclosed characters in the query string with hyperlinks to the documentations """
    symbols = re.findall(ENCLOSED_REGEX, query)

    if not symbols:
        return None, None

    replacements = list()
    for s in symbols:
        # Wiki first, cause with docs you can always prepend telegram. for better precision
        wiki = search.wiki(s.replace('_', ' '), amount=1, threshold=threshold)
        if wiki:
            name = wiki[0][0].split(ARROW_CHARACTER)[-1].strip()
            text = f'[{name}]({wiki[0][1]})'
            replacements.append((wiki[0][0], s, text))
            continue

        doc = search.docs(s, threshold=threshold)
        if doc:
            text = f'[{doc.short_name}]({doc.url})'

            if doc.tg_url and official_api_links:
                text += f' [{TELEGRAM_SUPERSCRIPT}]({doc.tg_url})'

            replacements.append((doc.short_name, s, text))
            continue

        # not found
        replacements.append((s + '❓', s, escape_markdown(s)))

    result = query
    for name, symbol, text in replacements:
        char = ENCLOSING_REPLACEMENT_CHARACTER
        result = result.replace(f'{char}{symbol}{char}', text)

    result_changed = [x[0] for x in replacements]
    return result_changed, result 
开发者ID:python-telegram-bot,项目名称:rules-bot,代码行数:39,代码来源:inlinequeries.py

示例10: start

# 需要导入模块: from telegram.utils import helpers [as 别名]
# 或者: from telegram.utils.helpers import escape_markdown [as 别名]
def start(bot: Bot, update: Update, args: List[str]):
    if update.effective_chat.type == "private":
        if len(args) >= 1:
            if args[0].lower() == "help":
                send_help(update.effective_chat.id, HELP_STRINGS)

            elif args[0].lower().startswith("stngs_"):
                match = re.match("stngs_(.*)", args[0].lower())
                chat = dispatcher.bot.getChat(match.group(1))

                if is_user_admin(chat, update.effective_user.id):
                    send_settings(match.group(1), update.effective_user.id, False)
                else:
                    send_settings(match.group(1), update.effective_user.id, True)

            elif args[0][1:].isdigit() and "rules" in IMPORTED:
                IMPORTED["rules"].send_rules(update, args[0], from_pm=True)

        else:
            first_name = update.effective_user.first_name
            update.effective_message.reply_text(
                PM_START_TEXT.format(escape_markdown(first_name), escape_markdown(bot.first_name), OWNER_ID),
                parse_mode=ParseMode.MARKDOWN)
    else:
        update.effective_message.reply_text("Heck, I'm alive :O")


# for test purposes 
开发者ID:skittles9823,项目名称:SkittBot,代码行数:30,代码来源:__main__.py

示例11: logging

# 需要导入模块: from telegram.utils import helpers [as 别名]
# 或者: from telegram.utils.helpers import escape_markdown [as 别名]
def logging(bot: Bot, update: Update):
        message = update.effective_message  # type: Optional[Message]
        chat = update.effective_chat  # type: Optional[Chat]

        log_channel = sql.get_chat_log_channel(chat.id)
        if log_channel:
            log_channel_info = bot.get_chat(log_channel)
            message.reply_text(
                "This group has all it's logs sent to: {} (`{}`)".format(escape_markdown(log_channel_info.title),
                                                                         log_channel),
                parse_mode=ParseMode.MARKDOWN)

        else:
            message.reply_text("No log channel has been set for this group!") 
开发者ID:skittles9823,项目名称:SkittBot,代码行数:16,代码来源:log_channel.py

示例12: __chat_settings__

# 需要导入模块: from telegram.utils import helpers [as 别名]
# 或者: from telegram.utils.helpers import escape_markdown [as 别名]
def __chat_settings__(chat_id, user_id):
        log_channel = sql.get_chat_log_channel(chat_id)
        if log_channel:
            log_channel_info = dispatcher.bot.get_chat(log_channel)
            return "This group has all it's logs sent to: {} (`{}`)".format(escape_markdown(log_channel_info.title),
                                                                            log_channel)
        return "No log channel is set for this group!" 
开发者ID:skittles9823,项目名称:SkittBot,代码行数:9,代码来源:log_channel.py

示例13: list_cmds

# 需要导入模块: from telegram.utils import helpers [as 别名]
# 或者: from telegram.utils.helpers import escape_markdown [as 别名]
def list_cmds(bot: Bot, update: Update):
        if DISABLE_CMDS + DISABLE_OTHER:
            result = ""
            for cmd in set(DISABLE_CMDS + DISABLE_OTHER):
                result += " - `{}`\n".format(escape_markdown(cmd))
            update.effective_message.reply_text("The following commands are toggleable:\n{}".format(result),
                                                parse_mode=ParseMode.MARKDOWN)
        else:
            update.effective_message.reply_text("No commands can be disabled.")


    # do not async 
开发者ID:skittles9823,项目名称:SkittBot,代码行数:14,代码来源:disable.py

示例14: build_curr_disabled

# 需要导入模块: from telegram.utils import helpers [as 别名]
# 或者: from telegram.utils.helpers import escape_markdown [as 别名]
def build_curr_disabled(chat_id: Union[str, int]) -> str:
        disabled = sql.get_all_disabled(chat_id)
        if not disabled:
            return "No commands are disabled!"

        result = ""
        for cmd in disabled:
            result += " - `{}`\n".format(escape_markdown(cmd))
        return "The following commands are currently restricted:\n{}".format(result) 
开发者ID:skittles9823,项目名称:SkittBot,代码行数:11,代码来源:disable.py

示例15: get_paste_content

# 需要导入模块: from telegram.utils import helpers [as 别名]
# 或者: from telegram.utils.helpers import escape_markdown [as 别名]
def get_paste_content(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message

    if len(args) >= 1:
        key = args[0]
    else:
        message.reply_text("Please supply a paste key!")
        return

    format_normal = f'{BASE_URL}/'
    format_view = f'{BASE_URL}/v/'

    if key.startswith(format_view):
        key = key[len(format_view):]
    elif key.startswith(format_normal):
        key = key[len(format_normal):]

    r = requests.get(f'{BASE_URL}/raw/{key}')

    if r.status_code != 200:
        try:
            res = r.json()
            update.effective_message.reply_text(res['message'])
        except Exception:
            if r.status_code == 404:
                update.effective_message.reply_text('Failed to reach dogbin')
            else:
                update.effective_message.reply_text('Unknown error occured')
        r.raise_for_status()

    update.effective_message.reply_text('```' + escape_markdown(r.text) + '```', parse_mode=ParseMode.MARKDOWN) 
开发者ID:skittles9823,项目名称:SkittBot,代码行数:33,代码来源:dogbin.py


注:本文中的telegram.utils.helpers.escape_markdown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。