當前位置: 首頁>>代碼示例>>Python>>正文


Python ChatAction.TYPING屬性代碼示例

本文整理匯總了Python中telegram.ChatAction.TYPING屬性的典型用法代碼示例。如果您正苦於以下問題:Python ChatAction.TYPING屬性的具體用法?Python ChatAction.TYPING怎麽用?Python ChatAction.TYPING使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在telegram.ChatAction的用法示例。


在下文中一共展示了ChatAction.TYPING屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: send_typing

# 需要導入模塊: from telegram import ChatAction [as 別名]
# 或者: from telegram.ChatAction import TYPING [as 別名]
def send_typing(cls, func):
        def _send_typing_action(self, bot, update, **kwargs):
            if update.message:
                user_id = update.message.chat_id
            elif update.callback_query:
                user_id = update.callback_query.message.chat_id
            else:
                return func(self, bot, update, **kwargs)

            try:
                bot.send_chat_action(
                    chat_id=user_id,
                    action=ChatAction.TYPING)
            except Exception as ex:
                logging.error(f"{ex} - {update}")

            return func(self, bot, update, **kwargs)
        return _send_typing_action 
開發者ID:Endogen,項目名稱:OpenCryptoBot,代碼行數:20,代碼來源:plugin.py

示例2: github

# 需要導入模塊: from telegram import ChatAction [as 別名]
# 或者: from telegram.ChatAction import TYPING [as 別名]
def github(update: Update, context: CallbackContext):
    message = update.message or update.edited_message
    last = 0
    thing_matches = []
    things = {}

    # Due to bug in ptb we need to convert entities of type URL to TEXT_LINK for them to be converted to html
    for entity in message.entities:
        if entity.type == MessageEntity.URL:
            entity.type = MessageEntity.TEXT_LINK
            entity.url = message.parse_entity(entity)

    for match in GITHUB_PATTERN.finditer(get_text_not_in_entities(message.text_html)):
        logging.debug(match.groupdict())
        owner, repo, number, sha = [match.groupdict()[x] for x in ('owner', 'repo', 'number', 'sha')]
        if number or sha:
            thing_matches.append((owner, repo, number, sha))

    for thing_match in thing_matches:
        last = keep_typing(last, update.effective_chat, ChatAction.TYPING)
        owner, repo, number, sha = thing_match
        if number:
            issue = github_issues.get_issue(int(number), owner, repo)
            things[issue.url] = github_issues.pretty_format_issue(issue)
        elif sha:
            commit = github_issues.get_commit(sha, owner, repo)
            things[commit.url] = github_issues.pretty_format_commit(commit)

    if things:
        reply_or_edit(update, context, '\n'.join([f'<a href="{url}">{name}</a>' for url, name in things.items()])) 
開發者ID:python-telegram-bot,項目名稱:rules-bot,代碼行數:32,代碼來源:rules_bot.py

示例3: wait

# 需要導入模塊: from telegram import ChatAction [as 別名]
# 或者: from telegram.ChatAction import TYPING [as 別名]
def wait(bot, update, t=1.5):
    chat_id = uid_from_update(update)
    bot.sendChatAction(chat_id, ChatAction.TYPING)
    time.sleep(t) 
開發者ID:JosXa,項目名稱:BotListBot,代碼行數:6,代碼來源:util.py

示例4: start

# 需要導入模塊: from telegram import ChatAction [as 別名]
# 或者: from telegram.ChatAction import TYPING [as 別名]
def start(bot, update):
    bot.sendChatAction(chat_id=update.message.chat_id,
                       action=ChatAction.TYPING)
    bot.sendMessage(chat_id=update.message.chat_id, text="Hi. I'm sudobot.")
    if update.message.from_user.id != int(config['ADMIN']['id']):
        bot.sendChatAction(chat_id=update.message.chat_id,
                           action=ChatAction.TYPING)
        time.sleep(1)
        bot.sendMessage(chat_id=update.message.chat_id,
                        text="It seems like you aren't allowed to use me. :(")
        bot.sendChatAction(chat_id=update.message.chat_id,
                           action=ChatAction.TYPING)
        time.sleep(1.5)
        bot.sendMessage(chat_id=update.message.chat_id,
                        text="But sudobot is open source software, which means you can have your own! See my [GitHub repo](https://github.com/bvanrijn/sudobot) for details.", parse_mode="Markdown")
    else:
        bot.sendChatAction(chat_id=update.message.chat_id,
                           action=ChatAction.TYPING)
        time.sleep(1)
        bot.sendMessage(chat_id=update.message.chat_id,
                        text="You can use me to run commands on your computer or server.")
        bot.sendChatAction(chat_id=update.message.chat_id,
                           action=ChatAction.TYPING)
        time.sleep(1.5)
        bot.sendMessage(chat_id=update.message.chat_id,
                        text="Note that interactive commands or commands that generate a lot of output won't work.")
        bot.sendChatAction(chat_id=update.message.chat_id,
                           action=ChatAction.TYPING)
        time.sleep(1)
        bot.sendMessage(chat_id=update.message.chat_id, text="Have fun!")
        bot.sendChatAction(chat_id=update.message.chat_id,
                           action=ChatAction.TYPING)
        time.sleep(1.5)
        bot.sendMessage(chat_id=update.message.chat_id,
                        text="Oh, before I forget: sudobot is open source software. See my [GitHub repo](https://github.com/bvanrijn/sudobot).", parse_mode="Markdown") 
開發者ID:bvanrijn,項目名稱:sudobot,代碼行數:37,代碼來源:bot.py

示例5: execute

# 需要導入模塊: from telegram import ChatAction [as 別名]
# 或者: from telegram.ChatAction import TYPING [as 別名]
def execute(bot, update, direct=True):

    try:
        user_id = update.message.from_user.id
        command = update.message.text
        inline = False
    except AttributeError:
        # Using inline
        user_id = update.inline_query.from_user.id
        command = update.inline_query.query
        inline = True

    if user_id == int(config['ADMIN']['id']):
        if not inline:
            bot.sendChatAction(chat_id=update.message.chat_id,
                               action=ChatAction.TYPING)
        output = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
        output = output.stdout.read().decode('utf-8')
        output = '`{0}`'.format(output)

        if not inline:
            bot.sendMessage(chat_id=update.message.chat_id,
                        text=output, parse_mode="Markdown")
            return False

        if inline:
            return output 
開發者ID:bvanrijn,項目名稱:sudobot,代碼行數:29,代碼來源:bot.py

示例6: send_typing_action

# 需要導入模塊: from telegram import ChatAction [as 別名]
# 或者: from telegram.ChatAction import TYPING [as 別名]
def send_typing_action(bot, update):
    """Send 'typing...' message to chat as long as it is not a reply message."""
    if not update.message.reply_to_message:
        frontend_logger.debug("Send typing")
        bot.sendChatAction(chat_id=update.message.chat_id, action=ChatAction.TYPING) 
開發者ID:ekeih,項目名稱:OmNomNom,代碼行數:7,代碼來源:frontend.py

示例7: bot_send_message

# 需要導入模塊: from telegram import ChatAction [as 別名]
# 或者: from telegram.ChatAction import TYPING [as 別名]
def bot_send_message(bot, update, text):
    bot.sendChatAction(update.message.chat_id, action=ChatAction.TYPING)
    sleep(random.random() * 2 + 1.)
    bot.sendMessage(update.message.chat_id, text=text) 
開發者ID:deepmipt,項目名稱:ConvAI-baseline,代碼行數:6,代碼來源:bot.py

示例8: typing_illusion

# 需要導入模塊: from telegram import ChatAction [as 別名]
# 或者: from telegram.ChatAction import TYPING [as 別名]
def typing_illusion(bot, chat_id):
	try:
		bot.sendChatAction(chat_id=chat_id, action=ChatAction.TYPING) # typing illusion
	except:
		sleep(1)
		bot.sendChatAction(chat_id=chat_id, action=ChatAction.TYPING) # typing illusion 
開發者ID:SergiySW,項目名稱:NanoWalletBot,代碼行數:8,代碼來源:raiwalletbot.py


注:本文中的telegram.ChatAction.TYPING屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。