mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 01:09:22 +01:00
parent
8b93b78d13
commit
dafeff6324
@ -36,6 +36,7 @@ class IrcServer():
|
|||||||
class IrcChannel():
|
class IrcChannel():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.users = set()
|
self.users = set()
|
||||||
|
self.modes = set()
|
||||||
'''
|
'''
|
||||||
self.ops = []
|
self.ops = []
|
||||||
self.halfops = []
|
self.halfops = []
|
||||||
|
@ -12,7 +12,7 @@ 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'}
|
'RSQUIT': 'SQUIT', 'FMODE': 'MODE'}
|
||||||
|
|
||||||
def _sendFromServer(irc, sid, msg):
|
def _sendFromServer(irc, sid, msg):
|
||||||
irc.send(':%s %s' % (sid, msg))
|
irc.send(':%s %s' % (sid, msg))
|
||||||
@ -207,14 +207,18 @@ def handle_fjoin(irc, servernumeric, command, args):
|
|||||||
channel = args[0].lower()
|
channel = args[0].lower()
|
||||||
# InspIRCd sends each user's channel data in the form of 'modeprefix(es),UID'
|
# InspIRCd sends each user's channel data in the form of 'modeprefix(es),UID'
|
||||||
userlist = args[-1].split()
|
userlist = args[-1].split()
|
||||||
|
ts = args[1]
|
||||||
|
modestring = args[2:-1] or args[2]
|
||||||
|
irc.channels[channel].modes = utils.applyModes(irc.channels[channel].modes, utils.parseModes(irc, modestring))
|
||||||
namelist = []
|
namelist = []
|
||||||
for user in userlist:
|
for user in userlist:
|
||||||
modeprefix, user = user.split(',', 1)
|
modeprefix, user = user.split(',', 1)
|
||||||
namelist.append(user)
|
namelist.append(user)
|
||||||
|
'''
|
||||||
for mode in modeprefix:
|
for mode in modeprefix:
|
||||||
# Note that a user can have more than one mode prefix (e.g. they have both +o and +v),
|
# Note that a user can have more than one mode prefix (e.g. they have both +o and +v),
|
||||||
# so they would be added to both lists.
|
# so they would be added to both lists.
|
||||||
'''
|
|
||||||
# left to right: m_ojoin, m_operprefix, owner (~/+q), admin (&/+a), and op (!/+o)
|
# left to right: m_ojoin, m_operprefix, owner (~/+q), admin (&/+a), and op (!/+o)
|
||||||
if mode in 'Yyqao':
|
if mode in 'Yyqao':
|
||||||
irc.channels[channel].ops.append(user)
|
irc.channels[channel].ops.append(user)
|
||||||
@ -276,13 +280,13 @@ def handle_save(irc, numeric, command, args):
|
|||||||
irc.users[user].nick = user
|
irc.users[user].nick = user
|
||||||
return {'target': user, 'ts': args[1]}
|
return {'target': user, 'ts': args[1]}
|
||||||
|
|
||||||
'''
|
|
||||||
def handle_fmode(irc, numeric, command, args):
|
def handle_fmode(irc, numeric, command, args):
|
||||||
# <- :70MAAAAAA FMODE #chat 1433653462 +hhT 70MAAAAAA 70MAAAAAD
|
# <- :70MAAAAAA FMODE #chat 1433653462 +hhT 70MAAAAAA 70MAAAAAD
|
||||||
# Oh god, how are we going to handle this?!
|
channel = args[0].lower()
|
||||||
channel = args[0]
|
modes = args[2:]
|
||||||
modestrings = args[3:]
|
changedmodes = utils.parseModes(irc, modes)
|
||||||
'''
|
irc.channels[channel].modes = utils.applyModes(irc.channels[channel].modes, changedmodes)
|
||||||
|
return {'target': channel, 'modes': changedmodes}
|
||||||
|
|
||||||
def handle_mode(irc, numeric, command, args):
|
def handle_mode(irc, numeric, command, args):
|
||||||
# In InspIRCd, MODE is used for setting user modes and
|
# In InspIRCd, MODE is used for setting user modes and
|
||||||
|
4
utils.py
4
utils.py
@ -117,7 +117,8 @@ def parseModes(irc, args, usermodes=False):
|
|||||||
elif mode in irc.prefixmodes and not usermodes:
|
elif mode in irc.prefixmodes and not usermodes:
|
||||||
# We're setting a prefix mode on someone (e.g. +o user1)
|
# We're setting a prefix mode on someone (e.g. +o user1)
|
||||||
print('%s: prefixmode.' % mode)
|
print('%s: prefixmode.' % mode)
|
||||||
arg = args.pop(0)
|
# TODO: handle this properly (issue #16).
|
||||||
|
continue
|
||||||
elif prefix == '+' and mode in supported_modes['*C']:
|
elif prefix == '+' and mode in supported_modes['*C']:
|
||||||
# Only has parameter when setting.
|
# Only has parameter when setting.
|
||||||
print('%s: Only has parameter when setting.' % mode)
|
print('%s: Only has parameter when setting.' % mode)
|
||||||
@ -136,6 +137,7 @@ def applyModes(modelist, changedmodes):
|
|||||||
print('Adding mode %r' % str(mode))
|
print('Adding mode %r' % str(mode))
|
||||||
else:
|
else:
|
||||||
# We're removing a mode
|
# We're removing a mode
|
||||||
|
mode[0] = mode[0].replace('-', '+')
|
||||||
modelist.discard(mode)
|
modelist.discard(mode)
|
||||||
print('Removing mode %r' % str(mode))
|
print('Removing mode %r' % str(mode))
|
||||||
print('Final modelist: %s' % modelist)
|
print('Final modelist: %s' % modelist)
|
||||||
|
Loading…
Reference in New Issue
Block a user