antispam.py 文件源码

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

项目:Red_Star 作者: medeor413 项目源码 文件源码
def _getmoji(self, msg):
        args = msg.content.split()
        if len(args) > 1:
            if len(args[1]) == 1:
                try:
                    await msg.add_reaction(args[1])
                except HTTPException:
                    raise CommandSyntaxError(f"Non-emoji character set as spam reaction on server.")
                else:
                    self.plugin_config[str(msg.guild.id)]["spam_reaction"] = args[1]
                    await respond(msg, f"**AFFIRMATIVE. ANALYSIS: New spam reaction emoji: {args[1]}.**")
                    await msg.remove_reaction(args[1], msg.guild.me)
            elif re.fullmatch("<:\w{1,32}:\d{1,20}>", args[1]):
                t_emoji = re.search("\d{1,20}", args[1])[0]
                if self.client.get_emoji(int(t_emoji)):
                    self.plugin_config[str(msg.guild.id)]["spam_reaction"] = t_emoji.rjust(18, "0")
                    await respond(msg, f"**AFFIRMATIVE. ANALYSIS: New spam reaction emoji: {args[1]}.**")
            else:
                raise CommandSyntaxError("Expected a single emoji as argument.")
        else:
            self.plugin_config[str(msg.guild.id)]["spam_reaction"] = False
            await respond(msg, f"**AFFIRMATIVE. Spam reaction disabled.**")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号