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

core, protocols: add server argument to IrcUser (#355)

This commit is contained in:
James Lu 2016-11-09 18:40:16 -08:00
parent b0bd5d47ae
commit c57fabc9ef
8 changed files with 14 additions and 13 deletions

View File

@ -1042,7 +1042,7 @@ class Irc():
class IrcUser():
"""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',
ip='0.0.0.0', manipulatable=False, opertype='IRC Operator'):
self.nick = nick
@ -1054,6 +1054,7 @@ class IrcUser():
self.ip = ip
self.realname = realname
self.modes = set() # Tracks user modes
self.server = server
# Tracks PyLink identification status
self.account = ''

View File

@ -89,7 +89,7 @@ class ClientbotWrapperProtocol(Protocol):
ts = ts or int(time.time())
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)
self.irc.servers[server].users.add(uid)

View File

@ -104,7 +104,7 @@ class HybridProtocol(TS6Protocol):
realname = realname or self.irc.botdata['realname']
realhost = realhost or host
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)
self.irc.applyModes(uid, modes)
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,
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])
log.debug('(%s) handle_uid: Applying modes %s for %s', self.irc.name, parsedmodes, uid)

View File

@ -50,7 +50,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
realname = realname or self.irc.botdata['realname']
realhost = realhost or host
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)
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
uid, ts, nick, realhost, host, ident, ip = args[0:7]
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]])
self.irc.applyModes(uid, parsedmodes)

View File

@ -277,7 +277,7 @@ class P10Protocol(IRCS2SProtocol):
raw_modes = self.irc.joinModes(modes)
# 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,
opertype=opertype)
@ -838,7 +838,7 @@ class P10Protocol(IRCS2SProtocol):
'host=%s realname=%s realhost=%s ip=%s', self.irc.name, nick, ts, uid,
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)
# https://github.com/evilnet/nefarious2/blob/master/doc/p10.txt#L708

View File

@ -64,7 +64,7 @@ class RatboxProtocol(TS6Protocol):
orig_realhost = realhost
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)
self.irc.applyModes(uid, modes)
self.irc.servers[server].users.add(uid)

View File

@ -47,7 +47,7 @@ class TS6Protocol(TS6BaseProtocol):
realname = realname or self.irc.botdata['realname']
realhost = realhost or host
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)
self.irc.applyModes(uid, modes)
@ -511,7 +511,7 @@ class TS6Protocol(TS6BaseProtocol):
if ip == '0': # IP was invalid; something used for services.
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])
log.debug('Applying modes %s for %s', parsedmodes, uid)

View File

@ -73,7 +73,7 @@ class UnrealProtocol(TS6BaseProtocol):
modes |= {('+x', None), ('+t', None)}
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)
self.irc.applyModes(uid, modes)
self.irc.servers[server].users.add(uid)
@ -363,7 +363,7 @@ class UnrealProtocol(TS6BaseProtocol):
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)
# Handle user modes