triggerreact.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:Tobo-Cogs 作者: Tobotimus 项目源码 文件源码
def trigger_set_text(self, ctx: commands.Context, *,
                               text: str):
        """Trigger if a message contains a word or phrase.

        This text is not case sensitive and strips the message of leading
         or trailing whitespace.
        """
        text = text.strip().lower()
        emojis = await self._get_trigger_emojis(ctx)
        if emojis:
            self.triggers["text_triggers"][text] = emojis
            _save(self.triggers)
            emojis_str = " ".join(str(self._lookup_emoji(emoji)) for emoji in emojis)
            await self.bot.say("Done - I will now react to messages containing `{text}` with"
                               " {emojis}.".format(text=text,
                                                   emojis=emojis_str))
        elif text in self.triggers['text_triggers']:
            del self.triggers['text_triggers'][text]
            _save(self.triggers)
            await self.bot.say("Done - I will no longer react to messages containing `{text}`."
                               "".format(text=text))
        else:
            await self.bot.say("Done - no triggers were changed.")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号