def get_response(message, send_typing=True):
"""Gets a response. Split up so messages can be edited."""
# Check if the message is a valid command and the server or channel is not muted
if (message.content and message.content[0] in configmanager.config['command_invokers'] and message.author.id != client.user.id): # Valid invoker from not the bot
is_private = (type(message.channel) is discord.PrivateChannel)
if parser.is_command(message.content.partition(' ')[0][1:].lower(), private=is_private): # Valid command
if is_private or (not is_private and # Private - skip checks. Not private - do server checks.
not servermanager.is_banned(server_id=message.server.id, user_id=message.author.id) and # Author is not banned
(not servermanager.is_muted(server_id=message.server.id, channel_id=message.channel.id) or # Server or channel is not muted or
(servermanager.is_admin(message.server.id, message.author.id) and message.content[1:].startswith('admin')))): # Admin is unmuting bot
try:
global last_responses_dictionary
if send_typing:
await client.send_typing(message.channel)
return await parser.parse(
message.content,
message.server.id if not is_private else '0',
message.channel.id if not is_private else '0',
message.author.id if not is_private else '0',
message.author.voice_channel.id if (not is_private and message.author.voice_channel) else 0, # Previously type None
is_private)
except bot_exception as e: # Something bad happened
return [str(e), False]
return ['', False]
评论列表
文章目录