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

pr/inspircd: handlers for FTOPIC and TOPIC (ref #31); make handle_nick return 'newnick' instead of 'target' as arg

This commit is contained in:
James Lu 2015-07-06 15:33:23 -07:00
parent fe1f90bcd1
commit 8bed47e7bb
2 changed files with 22 additions and 3 deletions

View File

@ -39,6 +39,7 @@ class IrcChannel():
def __init__(self): def __init__(self):
self.users = set() self.users = set()
self.modes = set() self.modes = set()
self.topic = ''
self.prefixmodes = {'ops': set(), 'halfops': set(), 'voices': set(), self.prefixmodes = {'ops': set(), 'halfops': set(), 'voices': set(),
'owners': set(), 'admins': set()} 'owners': set(), 'admins': set()}

View File

@ -13,8 +13,8 @@ from classes import *
# Raw commands sent from servers vary from protocol to protocol. Here, we map # Raw commands sent from servers vary from protocol to protocol. Here, we map
# non-standard names to our hook handlers, so plugins get the information they need. # non-standard names to our hook handlers, so plugins get the information they need.
hook_map = {'FJOIN': 'JOIN', 'SAVE': 'NICK', hook_map = {'FJOIN': 'JOIN', 'SAVE': 'NICK', 'RSQUIT': 'SQUIT', 'FMODE': 'MODE',
'RSQUIT': 'SQUIT', 'FMODE': 'MODE'} 'FTOPIC': 'TOPIC'}
def _sendFromServer(irc, sid, msg): def _sendFromServer(irc, sid, msg):
irc.send(':%s %s' % (sid, msg)) irc.send(':%s %s' % (sid, msg))
@ -252,7 +252,7 @@ def handle_server(irc, numeric, command, args):
def handle_nick(irc, numeric, command, args): def handle_nick(irc, numeric, command, args):
# <- :70MAAAAAA NICK GL-devel 1434744242 # <- :70MAAAAAA NICK GL-devel 1434744242
n = irc.users[numeric].nick = args[0] n = irc.users[numeric].nick = args[0]
return {'target': n, 'ts': args[1]} return {'newnick': n, 'ts': args[1]}
def handle_save(irc, numeric, command, args): def handle_save(irc, numeric, command, args):
# This is used to handle nick collisions. Here, the client Derp_ already exists, # This is used to handle nick collisions. Here, the client Derp_ already exists,
@ -447,3 +447,21 @@ def spawnServer(irc, name, sid, uplink=None, desc='PyLink Server'):
_sendFromServer(irc, uplink, 'SERVER %s * 1 %s :%s' % (name, sid, desc)) _sendFromServer(irc, uplink, 'SERVER %s * 1 %s :%s' % (name, sid, desc))
_sendFromServer(irc, sid, 'ENDBURST') _sendFromServer(irc, sid, 'ENDBURST')
irc.servers[sid] = IrcServer(uplink, name, internal=True) irc.servers[sid] = IrcServer(uplink, name, internal=True)
def handle_ftopic(irc, numeric, command, args):
# <- :70M FTOPIC #channel 1434510754 GLo|o|!GLolol@escape.the.dreamland.ca :Some channel topic
channel = args[0].lower()
ts = args[1]
setter = args[2]
topic = args[-1]
irc.channels[channel].topic = topic
return {'channel': channel, 'setter': setter, 'ts': ts, 'topic': topic}
def handle_topic(irc, numeric, command, args):
# <- :70MAAAAAA TOPIC #test :test
channel = args[0].lower()
topic = args[1]
ts = int(time.time())
setter = utils.nickToUid(irc, numeric)
irc.channels[channel].topic = topic
return {'channel': channel, 'setter': setter, 'ts': ts, 'topic': topic}