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


Python ParseMode.HTML属性代码示例

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


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

示例1: reply_or_edit

# 需要导入模块: from telegram import ParseMode [as 别名]
# 或者: from telegram.ParseMode import HTML [as 别名]
def reply_or_edit(update, context, text):
    chat_data = context.chat_data
    if update.edited_message:
        chat_data[update.edited_message.message_id].edit_text(text,
                                                              parse_mode=ParseMode.HTML,
                                                              disable_web_page_preview=True)
    else:
        issued_reply = get_reply_id(update)
        if issued_reply:
            chat_data[update.message.message_id] = context.bot.sendMessage(update.message.chat_id, text,
                                                                           reply_to_message_id=issued_reply,
                                                                           parse_mode=ParseMode.HTML,
                                                                           disable_web_page_preview=True)
        else:
            chat_data[update.message.message_id] = update.message.reply_text(text,
                                                                             parse_mode=ParseMode.HTML,
                                                                             disable_web_page_preview=True) 
开发者ID:python-telegram-bot,项目名称:rules-bot,代码行数:19,代码来源:util.py

示例2: blacklist

# 需要导入模块: from telegram import ParseMode [as 别名]
# 或者: from telegram.ParseMode import HTML [as 别名]
def blacklist(bot: Bot, update: Update, args: List[str]):
    msg = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]

    all_blacklisted = sql.get_chat_blacklist(chat.id)

    filter_list = BASE_BLACKLIST_STRING

    if len(args) > 0 and args[0].lower() == 'copy':
        for trigger in all_blacklisted:
            filter_list += "<code>{}</code>\n".format(html.escape(trigger))
    else:
        for trigger in all_blacklisted:
            filter_list += " - <code>{}</code>\n".format(html.escape(trigger))

    split_text = split_message(filter_list)
    for text in split_text:
        if text == BASE_BLACKLIST_STRING:
            msg.reply_text("There are no blacklisted messages here!")
            return
        msg.reply_text(text, parse_mode=ParseMode.HTML) 
开发者ID:skittles9823,项目名称:SkittBot,代码行数:23,代码来源:blacklist.py

示例3: add_blacklist

# 需要导入模块: from telegram import ParseMode [as 别名]
# 或者: from telegram.ParseMode import HTML [as 别名]
def add_blacklist(bot: Bot, update: Update):
    msg = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    words = msg.text.split(None, 1)
    if len(words) > 1:
        text = words[1]
        to_blacklist = list(set(trigger.strip() for trigger in text.split("\n") if trigger.strip()))
        for trigger in to_blacklist:
            sql.add_to_blacklist(chat.id, trigger.lower())

        if len(to_blacklist) == 1:
            msg.reply_text("Added <code>{}</code> to the blacklist!".format(html.escape(to_blacklist[0])),
                           parse_mode=ParseMode.HTML)

        else:
            msg.reply_text(
                "Added <code>{}</code> triggers to the blacklist.".format(len(to_blacklist)), parse_mode=ParseMode.HTML)

    else:
        msg.reply_text("Tell me which words you would like to add to the blacklist.") 
开发者ID:skittles9823,项目名称:SkittBot,代码行数:22,代码来源:blacklist.py

示例4: list_urls

# 需要导入模块: from telegram import ParseMode [as 别名]
# 或者: from telegram.ParseMode import HTML [as 别名]
def list_urls(bot, update):
    tg_chat_id = str(update.effective_chat.id)

    user_data = sql.get_urls(tg_chat_id)

    # this loops gets every link from the DB based on the filter above and appends it to the list
    links_list = [row.feed_link for row in user_data]

    final_content = "\n\n".join(links_list)

    # check if the length of the message is too long to be posted in 1 chat bubble
    if len(final_content) == 0:
        bot.send_message(chat_id=tg_chat_id, text="This chat is not subscribed to any links")
    elif len(final_content) <= constants.MAX_MESSAGE_LENGTH:
        bot.send_message(chat_id=tg_chat_id, text="This chat is subscribed to the following links:\n" + final_content)
    else:
        bot.send_message(chat_id=tg_chat_id, parse_mode=ParseMode.HTML,
                         text="<b>Warning:</b> The message is too long to be sent") 
开发者ID:skittles9823,项目名称:SkittBot,代码行数:20,代码来源:rss.py

示例5: list_warn_filters

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

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

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

    if not filter_list == CURRENT_WARNING_FILTER_STRING:
        update.effective_message.reply_text(filter_list, parse_mode=ParseMode.HTML) 
开发者ID:skittles9823,项目名称:SkittBot,代码行数:21,代码来源:warns.py

示例6: gfg3

# 需要导入模块: from telegram import ParseMode [as 别名]
# 或者: from telegram.ParseMode import HTML [as 别名]
def gfg3(bot, update, user_data):
        query = update.callback_query
        try:
            val = query.data
            val = str(val).replace("gfg3", "")
            with open("geeks_for_geeks/"+user_data['gfg'], encoding='utf-8') as data_file:
                data = json.load(data_file)
            se = data["Advanced Data Structures"][val]
            s = ""
            for i in se:
                s = s + '<a href="' + se[i] + '">' + i + '</a>\n\n'
            bot.edit_message_text(text=val + "\n\n" + s, chat_id=query.message.chat_id,
                                  message_id=query.message.message_id, parse_mode=ParseMode.HTML)
        except:
            return ConversationHandler.END
        user_data.clear()
        return ConversationHandler.END 
开发者ID:Gotham13121997,项目名称:superCodingBot,代码行数:19,代码来源:geeks_for_geeks.py

示例7: fed_chat

# 需要导入模块: from telegram import ParseMode [as 别名]
# 或者: from telegram.ParseMode import HTML [as 别名]
def fed_chat(update, context):
	chat = update.effective_chat  # type: Optional[Chat]
	user = update.effective_user  # type: Optional[User]
	fed_id = sql.get_fed_id(chat.id)

	user_id = update.effective_message.from_user.id
	if not is_user_admin(update.effective_chat, user_id):
		send_message(update.effective_message, tl(update.effective_message, "Anda harus menjadi admin untuk menjalankan perintah ini"))
		return

	if not fed_id:
		send_message(update.effective_message, tl(update.effective_message, "Grup ini tidak dalam federasi apa pun!"))
		return

	user = update.effective_user  # type: Optional[Chat]
	chat = update.effective_chat  # type: Optional[Chat]
	info = sql.get_fed_info(fed_id)

	text = tl(update.effective_message, "Obrolan ini adalah bagian dari federasi berikut:")
	text += "\n{} (ID: <code>{}</code>)".format(info['fname'], fed_id)

	send_message(update.effective_message, text, parse_mode=ParseMode.HTML) 
开发者ID:AyraHikari,项目名称:EmiliaHikari,代码行数:24,代码来源:feds.py

示例8: update_feed

# 需要导入模块: from telegram import ParseMode [as 别名]
# 或者: from telegram.ParseMode import HTML [as 别名]
def update_feed(self, url):
        telegram_users = self.db.get_users_for_url(url=url[0])

        for user in telegram_users:
            if user[6]:  # is_active
                try:
                    for post in FeedHandler.parse_feed(url[0]):
                        self.send_newest_messages(
                            url=url, post=post, user=user)
                except:
                    traceback.print_exc()
                    message = "Something went wrong when I tried to parse the URL: \n\n " + \
                        url[0] + "\n\nCould you please check that for me? Remove the url from your subscriptions using the /remove command, it seems like it does not work anymore!"
                    self.bot.send_message(
                        chat_id=user[0], text=message, parse_mode=ParseMode.HTML)

        self.db.update_url(url=url[0], last_updated=str(
            DateHandler.get_datetime_now())) 
开发者ID:cbrgm,项目名称:telegram-robot-rss,代码行数:20,代码来源:processing.py

示例9: source

# 需要导入模块: from telegram import ParseMode [as 别名]
# 或者: from telegram.ParseMode import HTML [as 别名]
def source(bot, update):
    """Handler for the /help command"""
    source_text = _("This bot is Free Software and licensed under the AGPL. "
      "The code is available here: \n"
      "https://github.com/jh0ker/mau_mau_bot")
    attributions = _("Attributions:\n"
      'Draw icon by '
      '<a href="http://www.faithtoken.com/">Faithtoken</a>\n'
      'Pass icon by '
      '<a href="http://delapouite.com/">Delapouite</a>\n'
      "Originals available on http://game-icons.net\n"
      "Icons edited by ɳick")

    send_async(bot, update.message.chat_id, text=source_text + '\n' +
                                                 attributions,
               parse_mode=ParseMode.HTML, disable_web_page_preview=True) 
开发者ID:jh0ker,项目名称:mau_mau_bot,代码行数:18,代码来源:simple_commands.py

示例10: disable_web_page_preview

# 需要导入模块: from telegram import ParseMode [as 别名]
# 或者: from telegram.ParseMode import HTML [as 别名]
def disable_web_page_preview(update, context):
    if not update.message.reply_to_message:
        text = ("This command permits to remove the web page preview from a message with "
                "a link.\n\nUse it replying to the message the bot already echoed and you "
                "want to disable the preview with this command.")
        update.message.reply_text(text=text)
        return

    if not update.message.reply_to_message.text:
        text = "This message does not have a web page preview"
        update.message.reply_to_message.reply_text(text=text, quote=True)
        return

    entities_list = [MessageEntity.URL, MessageEntity.TEXT_LINK]
    entities = update.message.reply_to_message.parse_entities(entities_list)
    if len(entities) == 0:
        text = "This message does not have a web page preview"
        update.message.reply_to_message.reply_text(text=text, quote=True)
        return

    text = update.message.reply_to_message.text_html
    update.message.reply_to_message.reply_text(
            text=text, 
            disable_web_page_preview=True, 
            parse_mode=ParseMode.HTML) 
开发者ID:91DarioDev,项目名称:forwardscoverbot,代码行数:27,代码来源:commands.py

示例11: add_blacklist

# 需要导入模块: from telegram import ParseMode [as 别名]
# 或者: from telegram.ParseMode import HTML [as 别名]
def add_blacklist(bot: Bot, update: Update):
    msg = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    words = msg.text.split(None, 1)
    if len(words) > 1:
        text = words[1]
        to_blacklist = list(set(trigger.strip() for trigger in text.split("\n") if trigger.strip()))
        for trigger in to_blacklist:
            sql.add_to_blacklist(chat.id, trigger.lower())

        if len(to_blacklist) == 1:
            msg.reply_text("Added <code>{}</code> to the blacklist!".format(html.escape(to_blacklist[0])),
                           parse_mode=ParseMode.HTML)

        else:
            msg.reply_text(
                "Added <code>{}</code> triggers to the blacklist.".format(len(to_blacklist)), parse_mode=ParseMode.HTML)

    else:
        msg.reply_text("Tell me which words you would like to remove from the blacklist.") 
开发者ID:TGExplore,项目名称:Marie-2.0-English,代码行数:22,代码来源:blacklist.py

示例12: button

# 需要导入模块: from telegram import ParseMode [as 别名]
# 或者: from telegram.ParseMode import HTML [as 别名]
def button(bot: Bot, update: Update) -> str:
    query = update.callback_query  # type: Optional[CallbackQuery]
    user = update.effective_user  # type: Optional[User]
    match = re.match(r"rm_warn\((.+?)\)", query.data)
    if match:
        user_id = match.group(1)
        chat = update.effective_chat  # type: Optional[Chat]
        res = sql.remove_warn(user_id, chat.id)
        if res:
            update.effective_message.edit_text(
                "Warn removed by {}.".format(mention_html(user.id, user.first_name)),
                parse_mode=ParseMode.HTML)
            user_member = chat.get_member(user_id)
            return "<b>{}:</b>" \
                   "\n#UNWARN" \
                   "\n<b>Admin:</b> {}" \
                   "\n<b>User:</b> {}".format(html.escape(chat.title),
                                              mention_html(user.id, user.first_name),
                                              mention_html(user_member.user.id, user_member.user.first_name))
        else:
            update.effective_message.edit_text(
                "User has already has no warns.".format(mention_html(user.id, user.first_name)),
                parse_mode=ParseMode.HTML)

    return "" 
开发者ID:TGExplore,项目名称:Marie-2.0-English,代码行数:27,代码来源:warns.py

示例13: rules

# 需要导入模块: from telegram import ParseMode [as 别名]
# 或者: from telegram.ParseMode import HTML [as 别名]
def rules(update: Update, context: CallbackContext):
    """Load and send the appropriate rules based on which group we're in"""
    if update.message.chat.username == ONTOPIC_USERNAME:
        update.message.reply_text(ONTOPIC_RULES, parse_mode=ParseMode.HTML,
                                  disable_web_page_preview=True, quote=False)
        update.message.delete()
    elif update.message.chat.username == OFFTOPIC_USERNAME:
        update.message.reply_text(OFFTOPIC_RULES, parse_mode=ParseMode.HTML,
                                  disable_web_page_preview=True, quote=False)
        update.message.delete()
    else:
        update.message.reply_text("Hmm. You're not in a python-telegram-bot group, "
                                  "and I don't know the rules around here.") 
开发者ID:python-telegram-bot,项目名称:rules-bot,代码行数:15,代码来源:rules_bot.py

示例14: send_log

# 需要导入模块: from telegram import ParseMode [as 别名]
# 或者: from telegram.ParseMode import HTML [as 别名]
def send_log(bot: Bot, log_chat_id: str, orig_chat_id: str, result: str):
        try:
            bot.send_message(log_chat_id, result, parse_mode=ParseMode.HTML)
        except BadRequest as excp:
            if excp.message == "Chat not found":
                bot.send_message(orig_chat_id, "This log channel has been deleted - unsetting.")
                sql.stop_chat_logging(orig_chat_id)
            else:
                LOGGER.warning(excp.message)
                LOGGER.warning(result)
                LOGGER.exception("Could not parse")

                bot.send_message(log_chat_id, result + "\n\nFormatting has been disabled due to an unexpected error.") 
开发者ID:skittles9823,项目名称:SkittBot,代码行数:15,代码来源:log_channel.py

示例15: unblacklist

# 需要导入模块: from telegram import ParseMode [as 别名]
# 或者: from telegram.ParseMode import HTML [as 别名]
def unblacklist(bot: Bot, update: Update):
    msg = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    words = msg.text.split(None, 1)
    if len(words) > 1:
        text = words[1]
        to_unblacklist = list(set(trigger.strip() for trigger in text.split("\n") if trigger.strip()))
        successful = 0
        for trigger in to_unblacklist:
            success = sql.rm_from_blacklist(chat.id, trigger.lower())
            if success:
                successful += 1

        if len(to_unblacklist) == 1:
            if successful:
                msg.reply_text("Removed <code>{}</code> from the blacklist!".format(html.escape(to_unblacklist[0])),
                               parse_mode=ParseMode.HTML)
            else:
                msg.reply_text("This isn't a blacklisted trigger...!")

        elif successful == len(to_unblacklist):
            msg.reply_text(
                "Removed <code>{}</code> triggers from the blacklist.".format(
                    successful), parse_mode=ParseMode.HTML)

        elif not successful:
            msg.reply_text(
                "None of these triggers exist, so they weren't removed.".format(
                    successful, len(to_unblacklist) - successful), parse_mode=ParseMode.HTML)

        else:
            msg.reply_text(
                "Removed <code>{}</code> triggers from the blacklist. {} did not exist, "
                "so were not removed.".format(successful, len(to_unblacklist) - successful),
                parse_mode=ParseMode.HTML)
    else:
        msg.reply_text("Tell me which words you would like to remove from the blacklist.") 
开发者ID:skittles9823,项目名称:SkittBot,代码行数:39,代码来源:blacklist.py


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