mirror of
https://github.com/jlu5/PyLink.git
synced 2025-01-25 19:54:25 +01:00
core: convert IrcUser calls to User
This commit is contained in:
parent
b81a03fda9
commit
a204d2b2db
@ -58,7 +58,7 @@ def spawn_service(irc, source, command, args):
|
|||||||
userobj = irc.spawn_client(nick, ident, host, modes=modes, opertype="PyLink Service",
|
userobj = irc.spawn_client(nick, ident, host, modes=modes, opertype="PyLink Service",
|
||||||
manipulatable=sbot.manipulatable)
|
manipulatable=sbot.manipulatable)
|
||||||
|
|
||||||
# Store the service name in the IrcUser object for easier access.
|
# Store the service name in the User object for easier access.
|
||||||
userobj.service = name
|
userobj.service = name
|
||||||
|
|
||||||
sbot.uids[irc.name] = u = userobj.uid
|
sbot.uids[irc.name] = u = userobj.uid
|
||||||
|
@ -18,7 +18,7 @@ def hook_privmsg(irc, source, command, args):
|
|||||||
channel = args['target']
|
channel = args['target']
|
||||||
text = args['text']
|
text = args['text']
|
||||||
|
|
||||||
# irc.pseudoclient stores the IrcUser object of the main PyLink client.
|
# irc.pseudoclient stores the User object of the main PyLink client.
|
||||||
# (i.e. the user defined in the bot: section of the config)
|
# (i.e. the user defined in the bot: section of the config)
|
||||||
if utils.isChannel(channel) and irc.pseudoclient.nick in text:
|
if utils.isChannel(channel) and irc.pseudoclient.nick in text:
|
||||||
irc.msg(channel, 'hi there!')
|
irc.msg(channel, 'hi there!')
|
||||||
|
@ -4,7 +4,7 @@ import base64
|
|||||||
|
|
||||||
from pylinkirc import utils, conf
|
from pylinkirc import utils, conf
|
||||||
from pylinkirc.log import log
|
from pylinkirc.log import log
|
||||||
from pylinkirc.classes import Protocol, IrcUser, IrcServer, ProtocolError
|
from pylinkirc.classes import Protocol, User, IrcServer, ProtocolError
|
||||||
|
|
||||||
FALLBACK_REALNAME = 'PyLink Relay Mirror Client'
|
FALLBACK_REALNAME = 'PyLink Relay Mirror Client'
|
||||||
COMMON_PREFIXMODES = [('h', 'halfop'), ('a', 'admin'), ('q', 'owner'), ('y', 'owner')]
|
COMMON_PREFIXMODES = [('h', 'halfop'), ('a', 'admin'), ('q', 'owner'), ('y', 'owner')]
|
||||||
@ -109,7 +109,7 @@ class ClientbotWrapperProtocol(IRCCommonProtocol):
|
|||||||
ts = ts or int(time.time())
|
ts = ts or int(time.time())
|
||||||
|
|
||||||
log.debug('(%s) spawn_client stub called, saving nick %s as PUID %s', self.name, nick, uid)
|
log.debug('(%s) spawn_client stub called, saving nick %s as PUID %s', self.name, nick, uid)
|
||||||
u = self.users[uid] = IrcUser(nick, ts, uid, server, ident=ident, host=host, realname=realname,
|
u = self.users[uid] = User(nick, ts, uid, server, ident=ident, host=host, realname=realname,
|
||||||
manipulatable=manipulatable, realhost=realhost, ip=ip)
|
manipulatable=manipulatable, realhost=realhost, ip=ip)
|
||||||
self.servers[server].users.add(uid)
|
self.servers[server].users.add(uid)
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ class HybridProtocol(TS6Protocol):
|
|||||||
realname = realname or conf.conf['bot']['realname']
|
realname = realname or conf.conf['bot']['realname']
|
||||||
realhost = realhost or host
|
realhost = realhost or host
|
||||||
raw_modes = self.join_modes(modes)
|
raw_modes = self.join_modes(modes)
|
||||||
u = self.users[uid] = IrcUser(nick, ts, uid, server, ident=ident, host=host, realname=realname,
|
u = self.users[uid] = User(nick, ts, uid, server, ident=ident, host=host, realname=realname,
|
||||||
realhost=realhost, ip=ip, manipulatable=manipulatable)
|
realhost=realhost, ip=ip, manipulatable=manipulatable)
|
||||||
self.apply_modes(uid, modes)
|
self.apply_modes(uid, modes)
|
||||||
self.servers[server].users.add(uid)
|
self.servers[server].users.add(uid)
|
||||||
@ -177,7 +177,7 @@ class HybridProtocol(TS6Protocol):
|
|||||||
'host=%s realname=%s ip=%s', self.name, nick, ts, uid,
|
'host=%s realname=%s ip=%s', self.name, nick, ts, uid,
|
||||||
ident, host, realname, ip)
|
ident, host, realname, ip)
|
||||||
|
|
||||||
self.users[uid] = IrcUser(nick, ts, uid, numeric, ident, host, realname, host, ip)
|
self.users[uid] = User(nick, ts, uid, numeric, ident, host, realname, host, ip)
|
||||||
|
|
||||||
parsedmodes = self.parse_modes(uid, [modes])
|
parsedmodes = self.parse_modes(uid, [modes])
|
||||||
log.debug('(%s) handle_uid: Applying modes %s for %s', self.name, parsedmodes, uid)
|
log.debug('(%s) handle_uid: Applying modes %s for %s', self.name, parsedmodes, uid)
|
||||||
|
@ -53,7 +53,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
|||||||
realname = realname or conf.conf['bot']['realname']
|
realname = realname or conf.conf['bot']['realname']
|
||||||
realhost = realhost or host
|
realhost = realhost or host
|
||||||
raw_modes = self.join_modes(modes)
|
raw_modes = self.join_modes(modes)
|
||||||
u = self.users[uid] = IrcUser(nick, ts, uid, server, ident=ident, host=host, realname=realname,
|
u = self.users[uid] = User(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.apply_modes(uid, modes)
|
self.apply_modes(uid, modes)
|
||||||
@ -163,7 +163,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
|||||||
recognize ANY non-burst oper ups.
|
recognize ANY non-burst oper ups.
|
||||||
|
|
||||||
Plugins don't have to call this function themselves, but they can
|
Plugins don't have to call this function themselves, but they can
|
||||||
set the opertype attribute of an IrcUser object (in self.users),
|
set the opertype attribute of an User object (in self.users),
|
||||||
and the change will be reflected here."""
|
and the change will be reflected here."""
|
||||||
userobj = self.users[target]
|
userobj = self.users[target]
|
||||||
try:
|
try:
|
||||||
@ -577,7 +577,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
|||||||
uid, ts, nick, realhost, host, ident, ip = args[0:7]
|
uid, ts, nick, realhost, host, ident, ip = args[0:7]
|
||||||
self.check_nick_collision(nick)
|
self.check_nick_collision(nick)
|
||||||
realname = args[-1]
|
realname = args[-1]
|
||||||
self.users[uid] = userobj = IrcUser(nick, ts, uid, numeric, ident, host, realname, realhost, ip)
|
self.users[uid] = userobj = User(nick, ts, uid, numeric, ident, host, realname, realhost, ip)
|
||||||
|
|
||||||
parsedmodes = self.parse_modes(uid, [args[8], args[9]])
|
parsedmodes = self.parse_modes(uid, [args[8], args[9]])
|
||||||
self.apply_modes(uid, parsedmodes)
|
self.apply_modes(uid, parsedmodes)
|
||||||
|
@ -275,10 +275,9 @@ class P10Protocol(IRCS2SProtocol):
|
|||||||
realhost = realhost or host
|
realhost = realhost or host
|
||||||
raw_modes = self.join_modes(modes)
|
raw_modes = self.join_modes(modes)
|
||||||
|
|
||||||
# Initialize an IrcUser instance
|
# Initialize an User instance
|
||||||
u = self.users[uid] = IrcUser(nick, ts, uid, server, ident=ident, host=host, realname=realname,
|
u = self.users[uid] = User(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)
|
|
||||||
|
|
||||||
# Fill in modes and add it to our users index
|
# Fill in modes and add it to our users index
|
||||||
self.apply_modes(uid, modes)
|
self.apply_modes(uid, modes)
|
||||||
@ -856,7 +855,7 @@ class P10Protocol(IRCS2SProtocol):
|
|||||||
'host=%s realname=%s realhost=%s ip=%s', self.name, nick, ts, uid,
|
'host=%s realname=%s realhost=%s ip=%s', self.name, nick, ts, uid,
|
||||||
ident, host, realname, realhost, ip)
|
ident, host, realname, realhost, ip)
|
||||||
|
|
||||||
uobj = self.users[uid] = IrcUser(nick, ts, uid, source, ident, host, realname, realhost, ip)
|
uobj = self.users[uid] = User(nick, ts, uid, source, ident, host, realname, realhost, ip)
|
||||||
self.servers[source].users.add(uid)
|
self.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
|
||||||
|
@ -66,7 +66,7 @@ class RatboxProtocol(TS6Protocol):
|
|||||||
orig_realhost = realhost
|
orig_realhost = realhost
|
||||||
realhost = realhost or host
|
realhost = realhost or host
|
||||||
|
|
||||||
u = self.users[uid] = IrcUser(nick, ts, uid, server, ident=ident, host=host, realname=realname,
|
u = self.users[uid] = User(nick, ts, uid, server, ident=ident, host=host, realname=realname,
|
||||||
realhost=realhost, ip=ip, manipulatable=manipulatable)
|
realhost=realhost, ip=ip, manipulatable=manipulatable)
|
||||||
self.apply_modes(uid, modes)
|
self.apply_modes(uid, modes)
|
||||||
self.servers[server].users.add(uid)
|
self.servers[server].users.add(uid)
|
||||||
|
@ -50,7 +50,7 @@ class TS6Protocol(TS6BaseProtocol):
|
|||||||
realname = realname or conf.conf['bot']['realname']
|
realname = realname or conf.conf['bot']['realname']
|
||||||
realhost = realhost or host
|
realhost = realhost or host
|
||||||
raw_modes = self.join_modes(modes)
|
raw_modes = self.join_modes(modes)
|
||||||
u = self.users[uid] = IrcUser(nick, ts, uid, server, ident=ident, host=host, realname=realname,
|
u = self.users[uid] = User(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.apply_modes(uid, modes)
|
self.apply_modes(uid, modes)
|
||||||
@ -512,7 +512,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.users[uid] = IrcUser(nick, ts, uid, numeric, ident, host, realname, realhost, ip)
|
self.users[uid] = User(nick, ts, uid, numeric, ident, host, realname, realhost, ip)
|
||||||
|
|
||||||
parsedmodes = self.parse_modes(uid, [modes])
|
parsedmodes = self.parse_modes(uid, [modes])
|
||||||
log.debug('Applying modes %s for %s', parsedmodes, uid)
|
log.debug('Applying modes %s for %s', parsedmodes, uid)
|
||||||
|
@ -82,7 +82,7 @@ class UnrealProtocol(TS6BaseProtocol):
|
|||||||
modes |= {('+x', None), ('+t', None)}
|
modes |= {('+x', None), ('+t', None)}
|
||||||
|
|
||||||
raw_modes = self.join_modes(modes)
|
raw_modes = self.join_modes(modes)
|
||||||
u = self.users[uid] = IrcUser(nick, ts, uid, server, ident=ident, host=host, realname=realname,
|
u = self.users[uid] = User(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.apply_modes(uid, modes)
|
self.apply_modes(uid, modes)
|
||||||
self.servers[server].users.add(uid)
|
self.servers[server].users.add(uid)
|
||||||
@ -418,7 +418,7 @@ class UnrealProtocol(TS6BaseProtocol):
|
|||||||
|
|
||||||
realname = args[-1]
|
realname = args[-1]
|
||||||
|
|
||||||
self.users[uid] = IrcUser(nick, ts, uid, numeric, ident, host, realname, realhost, ip)
|
self.users[uid] = User(nick, ts, uid, numeric, ident, host, realname, realhost, ip)
|
||||||
self.servers[numeric].users.add(uid)
|
self.servers[numeric].users.add(uid)
|
||||||
|
|
||||||
# Handle user modes
|
# Handle user modes
|
||||||
|
Loading…
Reference in New Issue
Block a user