mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-27 21:19:31 +01:00
core, protocols: add server argument to IrcUser (#355)
This commit is contained in:
parent
b0bd5d47ae
commit
c57fabc9ef
@ -1042,7 +1042,7 @@ class Irc():
|
|||||||
|
|
||||||
class IrcUser():
|
class IrcUser():
|
||||||
"""PyLink IRC user class."""
|
"""PyLink IRC user class."""
|
||||||
def __init__(self, nick, ts, uid, ident='null', host='null',
|
def __init__(self, nick, ts, uid, server, ident='null', host='null',
|
||||||
realname='PyLink dummy client', realhost='null',
|
realname='PyLink dummy client', realhost='null',
|
||||||
ip='0.0.0.0', manipulatable=False, opertype='IRC Operator'):
|
ip='0.0.0.0', manipulatable=False, opertype='IRC Operator'):
|
||||||
self.nick = nick
|
self.nick = nick
|
||||||
@ -1054,6 +1054,7 @@ class IrcUser():
|
|||||||
self.ip = ip
|
self.ip = ip
|
||||||
self.realname = realname
|
self.realname = realname
|
||||||
self.modes = set() # Tracks user modes
|
self.modes = set() # Tracks user modes
|
||||||
|
self.server = server
|
||||||
|
|
||||||
# Tracks PyLink identification status
|
# Tracks PyLink identification status
|
||||||
self.account = ''
|
self.account = ''
|
||||||
|
@ -89,7 +89,7 @@ class ClientbotWrapperProtocol(Protocol):
|
|||||||
ts = ts or int(time.time())
|
ts = ts or int(time.time())
|
||||||
|
|
||||||
log.debug('(%s) spawnClient stub called, saving nick %s as PUID %s', self.irc.name, nick, uid)
|
log.debug('(%s) spawnClient stub called, saving nick %s as PUID %s', self.irc.name, nick, uid)
|
||||||
u = self.irc.users[uid] = IrcUser(nick, ts, uid, ident=ident, host=host, realname=realname,
|
u = self.irc.users[uid] = IrcUser(nick, ts, uid, server, ident=ident, host=host, realname=realname,
|
||||||
manipulatable=manipulatable, realhost=realhost, ip=ip)
|
manipulatable=manipulatable, realhost=realhost, ip=ip)
|
||||||
self.irc.servers[server].users.add(uid)
|
self.irc.servers[server].users.add(uid)
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ class HybridProtocol(TS6Protocol):
|
|||||||
realname = realname or self.irc.botdata['realname']
|
realname = realname or self.irc.botdata['realname']
|
||||||
realhost = realhost or host
|
realhost = realhost or host
|
||||||
raw_modes = self.irc.joinModes(modes)
|
raw_modes = self.irc.joinModes(modes)
|
||||||
u = self.irc.users[uid] = IrcUser(nick, ts, uid, ident=ident, host=host, realname=realname,
|
u = self.irc.users[uid] = IrcUser(nick, ts, uid, server, ident=ident, host=host, realname=realname,
|
||||||
realhost=realhost, ip=ip, manipulatable=manipulatable)
|
realhost=realhost, ip=ip, manipulatable=manipulatable)
|
||||||
self.irc.applyModes(uid, modes)
|
self.irc.applyModes(uid, modes)
|
||||||
self.irc.servers[server].users.add(uid)
|
self.irc.servers[server].users.add(uid)
|
||||||
@ -175,7 +175,7 @@ class HybridProtocol(TS6Protocol):
|
|||||||
'host=%s realname=%s ip=%s', self.irc.name, nick, ts, uid,
|
'host=%s realname=%s ip=%s', self.irc.name, nick, ts, uid,
|
||||||
ident, host, realname, ip)
|
ident, host, realname, ip)
|
||||||
|
|
||||||
self.irc.users[uid] = IrcUser(nick, ts, uid, ident, host, realname, host, ip)
|
self.irc.users[uid] = IrcUser(nick, ts, uid, numeric, ident, host, realname, host, ip)
|
||||||
|
|
||||||
parsedmodes = self.irc.parseModes(uid, [modes])
|
parsedmodes = self.irc.parseModes(uid, [modes])
|
||||||
log.debug('(%s) handle_uid: Applying modes %s for %s', self.irc.name, parsedmodes, uid)
|
log.debug('(%s) handle_uid: Applying modes %s for %s', self.irc.name, parsedmodes, uid)
|
||||||
|
@ -50,7 +50,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
|||||||
realname = realname or self.irc.botdata['realname']
|
realname = realname or self.irc.botdata['realname']
|
||||||
realhost = realhost or host
|
realhost = realhost or host
|
||||||
raw_modes = self.irc.joinModes(modes)
|
raw_modes = self.irc.joinModes(modes)
|
||||||
u = self.irc.users[uid] = IrcUser(nick, ts, uid, ident=ident, host=host, realname=realname,
|
u = self.irc.users[uid] = IrcUser(nick, ts, uid, server, ident=ident, host=host, realname=realname,
|
||||||
realhost=realhost, ip=ip, manipulatable=manipulatable, opertype=opertype)
|
realhost=realhost, ip=ip, manipulatable=manipulatable, opertype=opertype)
|
||||||
|
|
||||||
self.irc.applyModes(uid, modes)
|
self.irc.applyModes(uid, modes)
|
||||||
@ -560,7 +560,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
|||||||
# :70M UID 70MAAAAAB 1429934638 GL 0::1 hidden-7j810p.9mdf.lrek.0000.0000.IP gl 0::1 1429934638 +Wioswx +ACGKNOQXacfgklnoqvx :realname
|
# :70M UID 70MAAAAAB 1429934638 GL 0::1 hidden-7j810p.9mdf.lrek.0000.0000.IP gl 0::1 1429934638 +Wioswx +ACGKNOQXacfgklnoqvx :realname
|
||||||
uid, ts, nick, realhost, host, ident, ip = args[0:7]
|
uid, ts, nick, realhost, host, ident, ip = args[0:7]
|
||||||
realname = args[-1]
|
realname = args[-1]
|
||||||
self.irc.users[uid] = userobj = IrcUser(nick, ts, uid, ident, host, realname, realhost, ip)
|
self.irc.users[uid] = userobj = IrcUser(nick, ts, uid, numeric, ident, host, realname, realhost, ip)
|
||||||
|
|
||||||
parsedmodes = self.irc.parseModes(uid, [args[8], args[9]])
|
parsedmodes = self.irc.parseModes(uid, [args[8], args[9]])
|
||||||
self.irc.applyModes(uid, parsedmodes)
|
self.irc.applyModes(uid, parsedmodes)
|
||||||
|
@ -277,7 +277,7 @@ class P10Protocol(IRCS2SProtocol):
|
|||||||
raw_modes = self.irc.joinModes(modes)
|
raw_modes = self.irc.joinModes(modes)
|
||||||
|
|
||||||
# Initialize an IrcUser instance
|
# Initialize an IrcUser instance
|
||||||
u = self.irc.users[uid] = IrcUser(nick, ts, uid, ident=ident, host=host, realname=realname,
|
u = self.irc.users[uid] = IrcUser(nick, ts, uid, server, ident=ident, host=host, realname=realname,
|
||||||
realhost=realhost, ip=ip, manipulatable=manipulatable,
|
realhost=realhost, ip=ip, manipulatable=manipulatable,
|
||||||
opertype=opertype)
|
opertype=opertype)
|
||||||
|
|
||||||
@ -838,7 +838,7 @@ class P10Protocol(IRCS2SProtocol):
|
|||||||
'host=%s realname=%s realhost=%s ip=%s', self.irc.name, nick, ts, uid,
|
'host=%s realname=%s realhost=%s ip=%s', self.irc.name, nick, ts, uid,
|
||||||
ident, host, realname, realhost, ip)
|
ident, host, realname, realhost, ip)
|
||||||
|
|
||||||
uobj = self.irc.users[uid] = IrcUser(nick, ts, uid, ident, host, realname, realhost, ip)
|
uobj = self.irc.users[uid] = IrcUser(nick, ts, uid, source, ident, host, realname, realhost, ip)
|
||||||
self.irc.servers[source].users.add(uid)
|
self.irc.servers[source].users.add(uid)
|
||||||
|
|
||||||
# https://github.com/evilnet/nefarious2/blob/master/doc/p10.txt#L708
|
# https://github.com/evilnet/nefarious2/blob/master/doc/p10.txt#L708
|
||||||
|
@ -64,7 +64,7 @@ class RatboxProtocol(TS6Protocol):
|
|||||||
orig_realhost = realhost
|
orig_realhost = realhost
|
||||||
realhost = realhost or host
|
realhost = realhost or host
|
||||||
|
|
||||||
u = self.irc.users[uid] = IrcUser(nick, ts, uid, ident=ident, host=host, realname=realname,
|
u = self.irc.users[uid] = IrcUser(nick, ts, uid, server, ident=ident, host=host, realname=realname,
|
||||||
realhost=realhost, ip=ip, manipulatable=manipulatable)
|
realhost=realhost, ip=ip, manipulatable=manipulatable)
|
||||||
self.irc.applyModes(uid, modes)
|
self.irc.applyModes(uid, modes)
|
||||||
self.irc.servers[server].users.add(uid)
|
self.irc.servers[server].users.add(uid)
|
||||||
|
@ -47,7 +47,7 @@ class TS6Protocol(TS6BaseProtocol):
|
|||||||
realname = realname or self.irc.botdata['realname']
|
realname = realname or self.irc.botdata['realname']
|
||||||
realhost = realhost or host
|
realhost = realhost or host
|
||||||
raw_modes = self.irc.joinModes(modes)
|
raw_modes = self.irc.joinModes(modes)
|
||||||
u = self.irc.users[uid] = IrcUser(nick, ts, uid, ident=ident, host=host, realname=realname,
|
u = self.irc.users[uid] = IrcUser(nick, ts, uid, server, ident=ident, host=host, realname=realname,
|
||||||
realhost=realhost, ip=ip, manipulatable=manipulatable, opertype=opertype)
|
realhost=realhost, ip=ip, manipulatable=manipulatable, opertype=opertype)
|
||||||
|
|
||||||
self.irc.applyModes(uid, modes)
|
self.irc.applyModes(uid, modes)
|
||||||
@ -511,7 +511,7 @@ class TS6Protocol(TS6BaseProtocol):
|
|||||||
if ip == '0': # IP was invalid; something used for services.
|
if ip == '0': # IP was invalid; something used for services.
|
||||||
ip = '0.0.0.0'
|
ip = '0.0.0.0'
|
||||||
|
|
||||||
self.irc.users[uid] = IrcUser(nick, ts, uid, ident, host, realname, realhost, ip)
|
self.irc.users[uid] = IrcUser(nick, ts, uid, numeric, ident, host, realname, realhost, ip)
|
||||||
|
|
||||||
parsedmodes = self.irc.parseModes(uid, [modes])
|
parsedmodes = self.irc.parseModes(uid, [modes])
|
||||||
log.debug('Applying modes %s for %s', parsedmodes, uid)
|
log.debug('Applying modes %s for %s', parsedmodes, uid)
|
||||||
|
@ -73,7 +73,7 @@ class UnrealProtocol(TS6BaseProtocol):
|
|||||||
modes |= {('+x', None), ('+t', None)}
|
modes |= {('+x', None), ('+t', None)}
|
||||||
|
|
||||||
raw_modes = self.irc.joinModes(modes)
|
raw_modes = self.irc.joinModes(modes)
|
||||||
u = self.irc.users[uid] = IrcUser(nick, ts, uid, ident=ident, host=host, realname=realname,
|
u = self.irc.users[uid] = IrcUser(nick, ts, uid, server, ident=ident, host=host, realname=realname,
|
||||||
realhost=realhost, ip=ip, manipulatable=manipulatable, opertype=opertype)
|
realhost=realhost, ip=ip, manipulatable=manipulatable, opertype=opertype)
|
||||||
self.irc.applyModes(uid, modes)
|
self.irc.applyModes(uid, modes)
|
||||||
self.irc.servers[server].users.add(uid)
|
self.irc.servers[server].users.add(uid)
|
||||||
@ -363,7 +363,7 @@ class UnrealProtocol(TS6BaseProtocol):
|
|||||||
|
|
||||||
realname = args[-1]
|
realname = args[-1]
|
||||||
|
|
||||||
self.irc.users[uid] = IrcUser(nick, ts, uid, ident, host, realname, realhost, ip)
|
self.irc.users[uid] = IrcUser(nick, ts, uid, numeric, ident, host, realname, realhost, ip)
|
||||||
self.irc.servers[numeric].users.add(uid)
|
self.irc.servers[numeric].users.add(uid)
|
||||||
|
|
||||||
# Handle user modes
|
# Handle user modes
|
||||||
|
Loading…
Reference in New Issue
Block a user