Exemplo n.º 1
0
def onClose(e):
    nwindows = list(windows.get_with(core.manager, network=e.window.network))

    if isinstance(e.window, windows.ChannelWindow):
        cwindows = list(
            windows.get_with(core.manager,
                             network=e.window.network,
                             wclass=windows.ChannelWindow))

        #if we only have one window for the network, don't bother to part as
        # we'll soon be quitting anyway
        if len(nwindows) != 1 and irc_script.ischan(e.window.network,
                                                    e.window.id):
            e.window.network.part(e.window.id)

    if len(nwindows) == 1:
        core.events.trigger("CloseNetwork",
                            window=e.window,
                            network=e.window.network)

    elif isinstance(e.window, windows.StatusWindow) and conf.get('status'):
        core.events.trigger("CloseNetwork",
                            window=e.window,
                            network=e.window.network)
        for window in nwindows:
            if window != e.window:
                window.close()

    if len(core.manager) == 1:
        windows.new(windows.StatusWindow, irc.Network(), "status", core)
Exemplo n.º 2
0
def onClose(e):
    nwindows = list(windows.get_with(network=e.window.network))
    
    if isinstance(e.window, windows.ChannelWindow): 
        cwindows = list(windows.get_with(
                            network=e.window.network,
                            wclass=windows.ChannelWindow
                            ))
        
        #if we only have one window for the network, don't bother to part as
        # we'll soon be quitting anyway
        if len(nwindows) != 1 and irc_script.ischan(e.window.network, e.window.id):
            e.window.network.part(e.window.id) 
    
    if len(nwindows) == 1:
        events.trigger("CloseNetwork", window=e.window, network=e.window.network)
    
    elif isinstance(e.window, windows.StatusWindow) and conf.get('status'):
        events.trigger("CloseNetwork", window=e.window, network=e.window.network)
        for window in nwindows:
            if window != e.window:
                window.close()
        
    if len(windows.manager) == 1:
        windows.new(windows.StatusWindow, irc.Network(), "status")
Exemplo n.º 3
0
def channel_completer(window, left, right, text):
    if isinstance(window, windows.ChannelWindow):
        yield window.id

    for w in windows.get_with(wclass=windows.ChannelWindow,
                              network=window.network):
        if w is not window:
            yield w.id

    for w in windows.get_with(wclass=windows.ChannelWindow):
        if w.network is not window.network:
            yield w.id
Exemplo n.º 4
0
def channel_completer(window, left, right, text):
    if isinstance(window, windows.ChannelWindow):
        yield window.id

    for w in windows.get_with(
            wclass=windows.ChannelWindow,
            network=window.network):
        if w is not window:
            yield w.id

    for w in windows.get_with(wclass=windows.ChannelWindow):
        if w.network is not window.network:
            yield w.id
Exemplo n.º 5
0
def setupNick(e):
    if e.source == e.network.me:
        for w in windows.get_with(core.manager, network=e.network):
            try:
                w.nick_label.update(e.target)
            except AttributeError:
                pass
Exemplo n.º 6
0
def setdownPart(e):
    if e.source == e.network.me:
        window = windows.get(windows.ChannelWindow, e.network, e.target)        
        
        if window:
            cwindows = list(windows.get_with(
                                network=window.network,
                                wclass=windows.ChannelWindow
                                ))
                            
            if len(cwindows) == 1 and not list(windows.get_with(network=window.network, wclass=windows.StatusWindow)):
                window.mutate(windows.StatusWindow, e.network, 'status')
                if e.requested:
                    window.activate()
            elif e.requested:
                window.close()
Exemplo n.º 7
0
def setupNick(e):
    if e.source == e.network.me:
        for w in windows.get_with(network=e.network):
            try:
                w.nick_label.update(e.target)
            except AttributeError:
                pass    
Exemplo n.º 8
0
def setdownPart(e):
    if e.source == e.network.me:
        window = windows.get(windows.ChannelWindow, e.network, e.target, core)

        if window:
            cwindows = list(
                windows.get_with(network=window.network,
                                 wclass=windows.ChannelWindow))

            if len(cwindows) == 1 and not list(
                    windows.get_with(network=window.network,
                                     wclass=windows.StatusWindow)):
                window.mutate(windows.StatusWindow, e.network, 'status')
                if e.requested:
                    window.activate()
            elif e.requested:
                window.close()
Exemplo n.º 9
0
def onDisconnect(e):
    to_write = '%s* Disconnected' % prefix(e)
    if e.error:
        to_write += ' (%s)' % e.error

    for window in windows.get_with(core.manager, network=e.network):
        if isinstance(window, windows.StatusWindow):
            window.write(to_write, widgets.TEXT)
        else:
            window.write(to_write, widgets.EVENT)
Exemplo n.º 10
0
def onDisconnect(e):
    if e.error:
        to_write = '* Disconnected (%s)' % e.error
    else:
        to_write = '* Disconnected'

    for window in windows.get_with(network=e.network):
        f = log_file(e.network, window.id)
        
        f.write(to_write)
Exemplo n.º 11
0
def onQuit(e):
    reps = {
        'nick':e.source,
        'address':e.address,
        'text':e.text,
        'timestamp':time.strftime(theme.get('TimeStamp',default.get('TimeStamp'))),
        'pre':theme.get('Prefix',default.get('Prefix'))
    }
    for window in windows.get_with(network=e.network):
        if chaninfo.ison(e.network, window.id, e.source):
            output('Quit',None,window,reps,widgets.EVENT)
Exemplo n.º 12
0
def onDisconnect(e):
    reps = {
        'timestamp':time.strftime(theme.get('TimeStamp',default.get('TimeStamp'))),
        'pre':theme.get('Prefix',default.get('Prefix'))
    }
    if hasattr(e,'error'):
        reps['text'] = e.error
    for window in windows.get_with(network=e.network):
        if isinstance(window, windows.StatusWindow):
            output('Disconnect',None,window,reps,widgets.TEXT)
        else:
            output('Disconnect',None,window,reps,widgets.EVENT)
Exemplo n.º 13
0
def onNick(e):
    color = getsourcecolor(e)
    if e.source == e.network.me:
        to_write = "%s%sYou are now known as %s" % (prefix(e), color, e.target)
    else:
        to_write = "%s%s%s is now known as %s" % (prefix(e), color, e.source, e.target)
    
    if e.source == e.network.me:
        for window in windows.get_with(network=e.network):
            window.write(to_write)
    else:
        for channame in chaninfo.channels(e.network):
            if chaninfo.ison(e.network,channame,e.source):
                window = windows.get(windows.ChannelWindow, e.network, channame)
                if window:
                    window.write(to_write)
Exemplo n.º 14
0
def onNick(e):
    color = getsourcecolor(e)
    if e.source == e.network.me:
        to_write = "%s%sYou are now known as %s" % (prefix(e), color, e.target)
    else:
        to_write = "%s%s%s is now known as %s" % (prefix(e), color, e.source,
                                                  e.target)

    if e.source == e.network.me:
        for window in windows.get_with(core.manager, network=e.network):
            window.write(to_write)
    else:
        for channame in chaninfo.channels(e.network):
            if chaninfo.ison(e.network, channame, e.source):
                window = windows.get(windows.ChannelWindow, e.network,
                                     channame)
                if window:
                    window.write(to_write)
Exemplo n.º 15
0
def onNick(e):
    if e.source == e.network.me:
        to_write = 'You are now known as %s' % e.target
    
        for window in windows.get_with(network=e.network):
            f = log_file(e.network, window.id)
            
            f.write(to_write)
    else:
        to_write = '%s is now known as %s' % (e.source, e.target)
    
        for channame in chaninfo.channels(e.network):
            if chaninfo.ison(e.network,channame,e.source):
                window = windows.get(windows.ChannelWindow, e.network, channame)
                if window:
                    f = log_file(e.network, window.id)
                    
                    f.write(to_write)
Exemplo n.º 16
0
def color_nicklists(network):
    for window in windows.get_with(network=network):
        if type(window).__name__ == 'ChannelWindow':
            color_nicklist(network,window)