# Path: conf.py
# CONF_FILE = os.path.join(urk.userpath,'urk.conf')
# def pprint(obj, depth=-2):
# def save(*args):


import events
import irc
from conf import conf

def preRaw(e):
    if e.msg[1] in ('PRIVMSG','NOTICE'):
        address = e.network.norm_case('%s!%s' % (e.source, e.address))
        for mask in conf.get('ignore_masks',()):
            if irc.match_glob(address, e.network.norm_case(mask)):
                events.halt()

def onCommandIgnore(e):
    if 'ignore_masks' not in conf:
        conf['ignore_masks'] = []
    if 'l' in e.switches:
        for i in conf['ignore_masks']:
            e.window.write('* %s' % i)
    elif 'c' in e.switches:
        del conf['ignore_masks']
        e.window.write('* Cleared the ignore list.')  
    elif e.args:
        if '!' in e.args[0] or '*' in e.args[0] or '?' in e.args[0]:
            mask = e.args[0]
        else:
            mask = '%s!*' % e.args[0]
        if 'r' in e.switches:
            if mask in conf['ignore_masks']:
                conf['ignore_masks'].remove(mask)

# Path: conf.py
# CONF_FILE = os.path.join(urk.userpath,'urk.conf')
# def pprint(obj, depth=-2):
# def save(*args):


# Path: scripts/ignore.py
import events
import irc
from conf import conf


def preRaw(e):
    if e.msg[1] in ('PRIVMSG','NOTICE'):
        address = e.network.norm_case('%s!%s' % (e.source, e.address))
        for mask in conf.get('ignore_masks',()):
            if irc.match_glob(address, e.network.norm_case(mask)):
                events.halt()

def onCommandIgnore(e):
    if 'ignore_masks' not in conf:
        conf['ignore_masks'] = []
    if 'l' in e.switches:
        for i in conf['ignore_masks']:
            e.window.write('* %s' % i)
    elif 'c' in e.switches:
        del conf['ignore_masks']
        e.window.write('* Cleared the ignore list.')  
    elif e.args:
        if '!' in e.args[0] or '*' in e.args[0] or '?' in e.args[0]:
            mask = e.args[0]
        else:
            mask = '%s!*' % e.args[0]
        if 'r' in e.switches:
            if mask in conf['ignore_masks']:
                conf['ignore_masks'].remove(mask)

                e.window.write('* Removed %s from the ignore list' % e.args[0])