api.py 文件源码

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

项目:PyMiki 作者: TheGrammarJew 项目源码 文件源码
def on_message(self, message):
        channel = message.channel
        author = message.author

        if channel.id != DISCORD_PY_ID:
            return

        if author.status is discord.Status.offline:
            fmt = f'{author} (ID: {author.id}) has been automatically blocked for 5 minutes for being invisible'
            await channel.set_permissions(author, read_messages=False, reason='invisible block')
            await channel.send(fmt)

            try:
                msg = f'Heya. You have been automatically blocked from <#{DISCORD_PY_ID}> for 5 minutes for being ' \
                       'invisible.\nTry chatting again in 5 minutes when you change your status. If you\'re curious ' \
                       'why invisible users are blocked, it is because they tend to break the client and cause them to ' \
                       'be hard to mention. Since we want to help you usually, we expect mentions to work without ' \
                       'headaches.\n\nSorry for the trouble.'
                await author.send(msg)
            except discord.HTTPException:
                pass

            await asyncio.sleep(300)
            await channel.set_permissions(author, overwrite=None, reason='invisible unblock')
            return

        m = self.issue.search(message.content)
        if m is not None:
            url = 'https://github.com/Rapptz/discord.py/issues/'
            await channel.send(url + m.group('number'))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号