3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-30 23:09:23 +01:00

Merge branch 'devel' into wip/unrealircd

This commit is contained in:
James Lu 2015-09-05 11:24:45 -07:00
commit a96826273f
3 changed files with 17 additions and 5 deletions

View File

@ -425,10 +425,11 @@ def handle_events(irc, data):
if parsed_args is not None: if parsed_args is not None:
return [numeric, command, parsed_args] 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 # -> :0AL SERVER test.server * 1 0AM :some silly pseudoserver
uplink = uplink or irc.sid uplink = uplink or irc.sid
name = name.lower() name = name.lower()
desc = desc or irc.serverdata.get('serverdesc') or irc.botdata['serverdesc']
if sid is None: # No sid given; generate one! if sid is None: # No sid given; generate one!
irc.sidgen = utils.TS6SIDGenerator(irc.serverdata["sidrange"]) irc.sidgen = utils.TS6SIDGenerator(irc.serverdata["sidrange"])
sid = irc.sidgen.next_sid() sid = irc.sidgen.next_sid()
@ -447,6 +448,11 @@ def spawnServer(irc, name, sid=None, uplink=None, desc='PyLink Server'):
_send(irc, sid, 'ENDBURST') _send(irc, sid, 'ENDBURST')
return sid 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): def handle_ftopic(irc, numeric, command, args):
# <- :70M FTOPIC #channel 1434510754 GLo|o|!GLolol@escape.the.dreamland.ca :Some channel topic # <- :70M FTOPIC #channel 1434510754 GLo|o|!GLolol@escape.the.dreamland.ca :Some channel topic
channel = utils.toLower(irc, args[0]) channel = utils.toLower(irc, args[0])

View File

@ -575,27 +575,33 @@ def handle_events(irc, data):
if parsed_args is not None: if parsed_args is not None:
return [numeric, command, parsed_args] 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 0XY :some silly pseudoserver # -> :0AL SID test.server 1 0XY :some silly pseudoserver
uplink = uplink or irc.sid uplink = uplink or irc.sid
name = name.lower() name = name.lower()
desc = desc or irc.serverdata.get('serverdesc') or irc.botdata['serverdesc']
if sid is None: # No sid given; generate one! if sid is None: # No sid given; generate one!
irc.sidgen = utils.TS6SIDGenerator(irc.serverdata["sidrange"]) irc.sidgen = utils.TS6SIDGenerator(irc.serverdata["sidrange"])
sid = irc.sidgen.next_sid() sid = irc.sidgen.next_sid()
assert len(sid) == 3, "Incorrect SID length" assert len(sid) == 3, "Incorrect SID length"
if sid in irc.servers: if sid in irc.servers:
raise ValueError('A server with SID %r already exists!' % sid) 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: if name == server.name:
raise ValueError('A server named %r already exists!' % name) raise ValueError('A server named %r already exists!' % name)
if not utils.isInternalServer(irc, uplink): if not utils.isInternalServer(irc, uplink):
raise ValueError('Server %r is not a PyLink internal PseudoServer!' % uplink) raise ValueError('Server %r is not a PyLink internal PseudoServer!' % uplink)
if not utils.isServerName(name): if not utils.isServerName(name):
raise ValueError('Invalid server name %r' % 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) irc.servers[sid] = IrcServer(uplink, name, internal=True)
return sid 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): def handle_tb(irc, numeric, command, args):
# <- :42X TB 1434510754 #channel GLo|o|!GLolol@escape.the.dreamland.ca :Some channel topic # <- :42X TB 1434510754 #channel GLo|o|!GLolol@escape.the.dreamland.ca :Some channel topic
channel = args[1].lower() channel = args[1].lower()

View File