Exemple #1
0
def get_info(server_id, user_id):
    """Builds a string listing known user information of given user."""
    user_data = servermanager.servers_data[server_id]['users'][user_id]
    config = configmanager.config
    permissions_text = ''
    if servermanager.is_owner(user_id): # Order important here
        permissions_text = "Bot owner"
    elif servermanager.is_bot(user_id):
        permissions_text = "Literally the bot"
    elif servermanager.is_admin(server_id, user_id):
        permissions_text = "Bot admin"
    elif servermanager.is_banned(server_id, user_id):
        permissions_text = "Banned from interaction"
    else:
        permissions_text = "Standard user"
    to_return = """User information for {user_data[name]}:
```
ID: {user_id}
Name: {user_data[name]}
Nickname: {user_data[nickname]}
Discriminator: {user_data[discriminator]}
Aliases: {user_data[aliases]}
Permissions: {permissions_text}
Joined: {user_data[joined]}
Last seen: {user_data[last_seen]}
Last played game: {user_data[last_game]}
Color: {user_data[color]}
Status: {user_data[status]}
Avatar: {user_data[avatar]}
```""".format(user_id=user_id, user_data=user_data, permissions_text=permissions_text)
    return to_return # Placeholder if this will be modified later
Exemple #2
0
async 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]
Exemple #3
0
async 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]