diff --git a/protocols/inspircd.py b/protocols/inspircd.py index 0bb6490..febdbb1 100644 --- a/protocols/inspircd.py +++ b/protocols/inspircd.py @@ -425,10 +425,11 @@ def handle_events(irc, data): if parsed_args is not None: return [numeric, command, parsed_args] -def spawnServer(irc, name, sid=None, uplink=None, desc='PyLink Server'): +def spawnServer(irc, name, sid=None, uplink=None, desc=None): # -> :0AL SERVER test.server * 1 0AM :some silly pseudoserver uplink = uplink or irc.sid name = name.lower() + desc = desc or irc.serverdata.get('serverdesc') or irc.botdata['serverdesc'] if sid is None: # No sid given; generate one! irc.sidgen = utils.TS6SIDGenerator(irc.serverdata["sidrange"]) sid = irc.sidgen.next_sid() @@ -447,6 +448,11 @@ def spawnServer(irc, name, sid=None, uplink=None, desc='PyLink Server'): _send(irc, sid, 'ENDBURST') return sid +def squitServer(irc, source, target, text='No reason given'): + # -> :9PY SQUIT 9PZ :blah, blah + _send(irc, source, 'SQUIT %s :%s' % (target, text)) + handle_squit(irc, source, 'SQUIT', [target, text]) + def handle_ftopic(irc, numeric, command, args): # <- :70M FTOPIC #channel 1434510754 GLo|o|!GLolol@escape.the.dreamland.ca :Some channel topic channel = utils.toLower(irc, args[0]) diff --git a/protocols/ts6.py b/protocols/ts6.py index 995cd69..7dd49d4 100644 --- a/protocols/ts6.py +++ b/protocols/ts6.py @@ -575,27 +575,33 @@ def handle_events(irc, data): if parsed_args is not None: return [numeric, command, parsed_args] -def spawnServer(irc, name, sid=None, uplink=None, desc='PyLink Server'): - # -> :0AL SERVER test.server 1 0XY :some silly pseudoserver +def spawnServer(irc, name, sid=None, uplink=None, desc=None): + # -> :0AL SID test.server 1 0XY :some silly pseudoserver uplink = uplink or irc.sid name = name.lower() + desc = desc or irc.serverdata.get('serverdesc') or irc.botdata['serverdesc'] if sid is None: # No sid given; generate one! irc.sidgen = utils.TS6SIDGenerator(irc.serverdata["sidrange"]) sid = irc.sidgen.next_sid() assert len(sid) == 3, "Incorrect SID length" if sid in irc.servers: raise ValueError('A server with SID %r already exists!' % sid) - for server in irc.servers.values() + irc.servers.keys(): + for server in irc.servers.values(): if name == server.name: raise ValueError('A server named %r already exists!' % name) if not utils.isInternalServer(irc, uplink): raise ValueError('Server %r is not a PyLink internal PseudoServer!' % uplink) if not utils.isServerName(name): raise ValueError('Invalid server name %r' % name) - _send(irc, uplink, 'SERVER %s 1 %s :%s' % (name, sid, desc)) + _send(irc, uplink, 'SID %s 1 %s :%s' % (name, sid, desc)) irc.servers[sid] = IrcServer(uplink, name, internal=True) return sid +def squitServer(irc, source, target, text='No reason given'): + # -> SQUIT 9PZ :blah, blah + irc.send('SQUIT %s :%s' % (target, text)) + handle_squit(irc, source, 'SQUIT', [target, text]) + def handle_tb(irc, numeric, command, args): # <- :42X TB 1434510754 #channel GLo|o|!GLolol@escape.the.dreamland.ca :Some channel topic channel = args[1].lower() diff --git a/main.py b/pylink similarity index 100% rename from main.py rename to pylink