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