mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-23 19:19:31 +01:00
core: Store opertype info in all IrcUser objects
This allows plugins to define custom opertypes for their clients, and still have them show in WHOIS queries.
This commit is contained in:
parent
bdbc1020f2
commit
44083ccd5e
@ -521,7 +521,7 @@ class IrcUser():
|
||||
"""PyLink IRC user class."""
|
||||
def __init__(self, nick, ts, uid, ident='null', host='null',
|
||||
realname='PyLink dummy client', realhost='null',
|
||||
ip='0.0.0.0', manipulatable=False):
|
||||
ip='0.0.0.0', manipulatable=False, opertype='IRC Operator'):
|
||||
self.nick = nick
|
||||
self.ts = ts
|
||||
self.uid = uid
|
||||
@ -535,6 +535,9 @@ class IrcUser():
|
||||
# Tracks PyLink identification status
|
||||
self.identified = ''
|
||||
|
||||
# Tracks oper type (for display only)
|
||||
self.opertype = opertype
|
||||
|
||||
# Tracks services identification status
|
||||
self.services_account = ''
|
||||
|
||||
|
@ -35,7 +35,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
||||
### Outgoing commands
|
||||
|
||||
def spawnClient(self, nick, ident='null', host='null', realhost=None, modes=set(),
|
||||
server=None, ip='0.0.0.0', realname=None, ts=None, opertype=None,
|
||||
server=None, ip='0.0.0.0', realname=None, ts=None, opertype='IRC Operator',
|
||||
manipulatable=False):
|
||||
"""Spawns a client with nick <nick> on the given IRC connection.
|
||||
|
||||
@ -52,7 +52,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
||||
realhost = realhost or host
|
||||
raw_modes = utils.joinModes(modes)
|
||||
u = self.irc.users[uid] = IrcUser(nick, ts, uid, ident=ident, host=host, realname=realname,
|
||||
realhost=realhost, ip=ip, manipulatable=manipulatable)
|
||||
realhost=realhost, ip=ip, manipulatable=manipulatable, opertype=opertype)
|
||||
utils.applyModes(self.irc, uid, modes)
|
||||
self.irc.servers[server].users.add(uid)
|
||||
self._send(server, "UID {uid} {ts} {nick} {realhost} {host} {ident} {ip}"
|
||||
@ -61,7 +61,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
||||
modes=raw_modes, ip=ip, realname=realname,
|
||||
realhost=realhost))
|
||||
if ('o', None) in modes or ('+o', None) in modes:
|
||||
self._operUp(uid, opertype=opertype or 'IRC Operator')
|
||||
self._operUp(uid, opertype)
|
||||
return u
|
||||
|
||||
def join(self, client, channel):
|
||||
|
@ -31,7 +31,7 @@ class TS6Protocol(TS6BaseProtocol):
|
||||
### OUTGOING COMMANDS
|
||||
|
||||
def spawnClient(self, nick, ident='null', host='null', realhost=None, modes=set(),
|
||||
server=None, ip='0.0.0.0', realname=None, ts=None, opertype=None,
|
||||
server=None, ip='0.0.0.0', realname=None, ts=None, opertype='IRC Operator',
|
||||
manipulatable=False):
|
||||
"""Spawns a client with nick <nick> on the given IRC connection.
|
||||
|
||||
@ -51,7 +51,7 @@ class TS6Protocol(TS6BaseProtocol):
|
||||
realhost = realhost or host
|
||||
raw_modes = utils.joinModes(modes)
|
||||
u = self.irc.users[uid] = IrcUser(nick, ts, uid, ident=ident, host=host, realname=realname,
|
||||
realhost=realhost, ip=ip, manipulatable=manipulatable)
|
||||
realhost=realhost, ip=ip, manipulatable=manipulatable, opertype=opertype)
|
||||
utils.applyModes(self.irc, uid, modes)
|
||||
self.irc.servers[server].users.add(uid)
|
||||
self._send(server, "EUID {nick} 1 {ts} {modes} {ident} {host} {ip} {uid} "
|
||||
|
@ -51,7 +51,7 @@ class UnrealProtocol(TS6BaseProtocol):
|
||||
|
||||
### OUTGOING COMMAND FUNCTIONS
|
||||
def spawnClient(self, nick, ident='null', host='null', realhost=None, modes=set(),
|
||||
server=None, ip='0.0.0.0', realname=None, ts=None, opertype=None,
|
||||
server=None, ip='0.0.0.0', realname=None, ts=None, opertype='IRC Operator',
|
||||
manipulatable=False):
|
||||
"""Spawns a client with nick <nick> on the given IRC connection.
|
||||
|
||||
@ -60,15 +60,15 @@ class UnrealProtocol(TS6BaseProtocol):
|
||||
server = server or self.irc.sid
|
||||
if not self.irc.isInternalServer(server):
|
||||
raise ValueError('Server %r is not a PyLink server!' % server)
|
||||
# Unreal 3.4 uses TS6-style UIDs. They don't start from AAAAAA like other IRCd's
|
||||
# do, but we can do that fine...
|
||||
# Unreal 4.0 uses TS6-style UIDs. They don't start from AAAAAA like other IRCd's
|
||||
# do, but that doesn't matter to us...
|
||||
uid = self.uidgen.setdefault(server, utils.TS6UIDGenerator(server)).next_uid()
|
||||
ts = ts or int(time.time())
|
||||
realname = realname or self.irc.botdata['realname']
|
||||
realhost = realhost or host
|
||||
raw_modes = utils.joinModes(modes)
|
||||
u = self.irc.users[uid] = IrcUser(nick, ts, uid, ident=ident, host=host, realname=realname,
|
||||
realhost=realhost, ip=ip, manipulatable=manipulatable)
|
||||
realhost=realhost, ip=ip, manipulatable=manipulatable, opertype=opertype)
|
||||
utils.applyModes(self.irc, uid, modes)
|
||||
self.irc.servers[server].users.add(uid)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user