From f6a4503372f2c995a632a5e07edc1cdebfbec473 Mon Sep 17 00:00:00 2001 From: James Lu Date: Fri, 4 Sep 2015 18:16:26 -0700 Subject: [PATCH 1/4] Use a more unique main executable name... --- main.py => pylink | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename main.py => pylink (100%) diff --git a/main.py b/pylink similarity index 100% rename from main.py rename to pylink From 8f70582d1b6227b682ffae92ce5620842e130896 Mon Sep 17 00:00:00 2001 From: James Lu Date: Fri, 4 Sep 2015 18:46:21 -0700 Subject: [PATCH 2/4] ts6: fixes to spawnServer 1) Use SID, not SERVER - This allows us to actually spawn clients on these servers... 2) Fix check for existing server names (drop the .keys() loop, it raises TypeError and isn't needed) --- protocols/ts6.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/protocols/ts6.py b/protocols/ts6.py index e41d27d..c7b233d 100644 --- a/protocols/ts6.py +++ b/protocols/ts6.py @@ -601,7 +601,7 @@ def handle_events(irc, data): 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 + # -> :0AL SID test.server 1 0XY :some silly pseudoserver uplink = uplink or irc.sid name = name.lower() if sid is None: # No sid given; generate one! @@ -610,14 +610,14 @@ def spawnServer(irc, name, sid=None, uplink=None, desc='PyLink Server'): 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 From 759f6c449222fd89d456386651ca72d6640f1419 Mon Sep 17 00:00:00 2001 From: James Lu Date: Fri, 4 Sep 2015 18:55:39 -0700 Subject: [PATCH 3/4] protocols/: add outgoing squitServer() --- protocols/inspircd.py | 5 +++++ protocols/ts6.py | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/protocols/inspircd.py b/protocols/inspircd.py index 0bb6490..2cb2ab8 100644 --- a/protocols/inspircd.py +++ b/protocols/inspircd.py @@ -447,6 +447,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 5c68a6d..1a3954e 100644 --- a/protocols/ts6.py +++ b/protocols/ts6.py @@ -596,6 +596,11 @@ def spawnServer(irc, name, sid=None, uplink=None, desc='PyLink Server'): 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() From 72cfe04904526b053d114a874b393d9e603afe8e Mon Sep 17 00:00:00 2001 From: James Lu Date: Fri, 4 Sep 2015 18:59:57 -0700 Subject: [PATCH 4/4] protocols: respect serverdesc config options in spawnServer --- protocols/inspircd.py | 3 ++- protocols/ts6.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/protocols/inspircd.py b/protocols/inspircd.py index 2cb2ab8..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() diff --git a/protocols/ts6.py b/protocols/ts6.py index 1a3954e..7dd49d4 100644 --- a/protocols/ts6.py +++ b/protocols/ts6.py @@ -575,10 +575,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 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()