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.")
评论列表
文章目录