mirror of
https://github.com/jlu5/PyLink.git
synced 2025-02-17 14:01:03 +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."""
|
"""PyLink IRC user class."""
|
||||||
def __init__(self, nick, ts, uid, ident='null', host='null',
|
def __init__(self, nick, ts, uid, ident='null', host='null',
|
||||||
realname='PyLink dummy client', realhost='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.nick = nick
|
||||||
self.ts = ts
|
self.ts = ts
|
||||||
self.uid = uid
|
self.uid = uid
|
||||||
@ -535,6 +535,9 @@ class IrcUser():
|
|||||||
# Tracks PyLink identification status
|
# Tracks PyLink identification status
|
||||||
self.identified = ''
|
self.identified = ''
|
||||||
|
|
||||||
|
# Tracks oper type (for display only)
|
||||||
|
self.opertype = opertype
|
||||||
|
|
||||||
# Tracks services identification status
|
# Tracks services identification status
|
||||||
self.services_account = ''
|
self.services_account = ''
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
|||||||
### Outgoing commands
|
### Outgoing commands
|
||||||
|
|
||||||
def spawnClient(self, nick, ident='null', host='null', realhost=None, modes=set(),
|
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):
|
manipulatable=False):
|
||||||
"""Spawns a client with nick <nick> on the given IRC connection.
|
"""Spawns a client with nick <nick> on the given IRC connection.
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
|||||||
realhost = realhost or host
|
realhost = realhost or host
|
||||||
raw_modes = utils.joinModes(modes)
|
raw_modes = utils.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, 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)
|
utils.applyModes(self.irc, uid, modes)
|
||||||
self.irc.servers[server].users.add(uid)
|
self.irc.servers[server].users.add(uid)
|
||||||
self._send(server, "UID {uid} {ts} {nick} {realhost} {host} {ident} {ip}"
|
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,
|
modes=raw_modes, ip=ip, realname=realname,
|
||||||
realhost=realhost))
|
realhost=realhost))
|
||||||
if ('o', None) in modes or ('+o', None) in modes:
|
if ('o', None) in modes or ('+o', None) in modes:
|
||||||
self._operUp(uid, opertype=opertype or 'IRC Operator')
|
self._operUp(uid, opertype)
|
||||||
return u
|
return u
|
||||||
|
|
||||||
def join(self, client, channel):
|
def join(self, client, channel):
|
||||||
|
@ -31,7 +31,7 @@ class TS6Protocol(TS6BaseProtocol):
|
|||||||
### OUTGOING COMMANDS
|
### OUTGOING COMMANDS
|
||||||
|
|
||||||
def spawnClient(self, nick, ident='null', host='null', realhost=None, modes=set(),
|
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):
|
manipulatable=False):
|
||||||
"""Spawns a client with nick <nick> on the given IRC connection.
|
"""Spawns a client with nick <nick> on the given IRC connection.
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ class TS6Protocol(TS6BaseProtocol):
|
|||||||
realhost = realhost or host
|
realhost = realhost or host
|
||||||
raw_modes = utils.joinModes(modes)
|
raw_modes = utils.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, 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)
|
utils.applyModes(self.irc, uid, modes)
|
||||||
self.irc.servers[server].users.add(uid)
|
self.irc.servers[server].users.add(uid)
|
||||||
self._send(server, "EUID {nick} 1 {ts} {modes} {ident} {host} {ip} {uid} "
|
self._send(server, "EUID {nick} 1 {ts} {modes} {ident} {host} {ip} {uid} "
|
||||||
|
@ -51,7 +51,7 @@ class UnrealProtocol(TS6BaseProtocol):
|
|||||||
|
|
||||||
### OUTGOING COMMAND FUNCTIONS
|
### OUTGOING COMMAND FUNCTIONS
|
||||||
def spawnClient(self, nick, ident='null', host='null', realhost=None, modes=set(),
|
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):
|
manipulatable=False):
|
||||||
"""Spawns a client with nick <nick> on the given IRC connection.
|
"""Spawns a client with nick <nick> on the given IRC connection.
|
||||||
|
|
||||||
@ -60,15 +60,15 @@ class UnrealProtocol(TS6BaseProtocol):
|
|||||||
server = server or self.irc.sid
|
server = server or self.irc.sid
|
||||||
if not self.irc.isInternalServer(server):
|
if not self.irc.isInternalServer(server):
|
||||||
raise ValueError('Server %r is not a PyLink server!' % 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
|
# Unreal 4.0 uses TS6-style UIDs. They don't start from AAAAAA like other IRCd's
|
||||||
# do, but we can do that fine...
|
# do, but that doesn't matter to us...
|
||||||
uid = self.uidgen.setdefault(server, utils.TS6UIDGenerator(server)).next_uid()
|
uid = self.uidgen.setdefault(server, utils.TS6UIDGenerator(server)).next_uid()
|
||||||
ts = ts or int(time.time())
|
ts = ts or int(time.time())
|
||||||
realname = realname or self.irc.botdata['realname']
|
realname = realname or self.irc.botdata['realname']
|
||||||
realhost = realhost or host
|
realhost = realhost or host
|
||||||
raw_modes = utils.joinModes(modes)
|
raw_modes = utils.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, 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)
|
utils.applyModes(self.irc, uid, modes)
|
||||||
self.irc.servers[server].users.add(uid)
|
self.irc.servers[server].users.add(uid)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user