Ejemplo n.º 1
0
async def g_gadmins(client, data):
    """
    .gadmins <list/add/del> [user/mask] -- Lists, adds or deletes users or
    masks from gadmins.
    """
    gadmins = client.bot.config['servers'][data.server]['admins']
    message = data.split_message
    if message[0] == 'list':
        asyncio.create_task(
            client.notice(data.nickname, 'gadmins are: ' + ', '.join(gadmins)))
        return
    conn = client.bot.dbs[data.server]
    masks = await user.parse_masks(client, conn, ' '.join(message[1:]))

    for mask in masks:
        if message[0] == 'del':
            asyncio.create_task(
                botu.del_from_conf(client, data, mask, gadmins,
                                   f'Removing {mask} from gadmins.',
                                   f'{mask} is not a gadmin.'))
        elif message[0] == 'add':
            asyncio.create_task(
                botu.add_to_conf(client, data, mask, gadmins,
                                 f'Adding {mask} to gadmins..',
                                 f'{mask} is already a gadmin.'))
Ejemplo n.º 2
0
async def whois(client, data):
    """
    Is for listening to whois to deal with invites.

    If the whois was the result of the invite event, check the user is op,
    owner, or hop in the channel then join.
    """
    message = data.split_message
    global last_invite
    if last_invite:
        invite = last_invite.split()
        nick = invite[0]
        data.nickname = nick
        channel = invite[1]
        channel = channel.lower()
        if message[1] == invite[0]:
            privilages = [
                f'~{channel}', f'&{channel}', f'@{channel}', f'%{channel}']
            if len([priv for priv in privilages if priv in message]) > 0:
                channels = client.bot.config['servers'][data
                                                        .server]['channels']
                if channel not in channels:
                    channels.append(channel)
                
                asyncio.create_task(
                    botu.add_to_conf(client, data, channel, channels,
                                     f'Joining {channel}.',
                                     f'{channel} is already in the config, joining regardless.'))
                asyncio.create_task(client.rawmsg('JOIN', channel))
Ejemplo n.º 3
0
async def g_genable_gdisable(client, data):
    """
    .genable/.gdisable <list/commands/events/sieves> -- Lists, enables or
    disables commands, events and sieves.
    """
    event_vals = list(client.bot.plugs['event'].values())
    events = [func[0].__name__ for func in (event for event in event_vals)]
    commands = list(client.bot.plugs['command'])
    sieves = list(client.bot.plugs['sieve'])
    init = list(client.bot.plugs['init'])

    nodisable = client.bot.config['servers'][data.server]['no_disable']
    gdisabled = client.bot.config['servers'][data.server]['disabled']

    message = data.split_message

    if message[0] == 'list':
        asyncio.create_task(
            botu.cmd_event_sieve_init_lists(client, data, gdisabled, nodisable,
                                            sieves, events, commands, init))
        return

    for plugin in message:
        plugin = plugin.lower().strip()
        if await botu.is_cmd_event_sieve_init(plugin, data, sieves, events,
                                              commands, init):
            asyncio.create_task(
                client.notice(data.nickname,
                              f'{plugin} is not a sieve, command or event.'))
        elif data.command == 'genable':
            asyncio.create_task(
                botu.remove_from_conf(client, data, plugin, gdisabled,
                                      f'Genabling {plugin}.',
                                      f'{plugin} is not gdisabled.'))
        elif data.command == 'gdisable':
            if plugin in nodisable:
                asyncio.create_task(
                    client.notice(data.nickname,
                                  f'You cannot gdisable {plugin}.'))
            else:
                asyncio.create_task(
                    botu.add_to_conf(client, data, plugin, gdisabled,
                                     f'Gdisabling {plugin}.',
                                     f'{plugin} is already gdisabled.'))