mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 01:09:22 +01:00
Irc, services_support: store service name in IrcUser objects (#355)
This commit is contained in:
parent
0815df1bca
commit
08fa64c3cc
18
classes.py
18
classes.py
@ -907,12 +907,20 @@ class Irc():
|
||||
Checks whether the given UID is a registered service bot. If True,
|
||||
returns the cooresponding ServiceBot object.
|
||||
"""
|
||||
if not uid:
|
||||
userobj = self.users.get(uid)
|
||||
if not userobj:
|
||||
return False
|
||||
|
||||
# Look for the "service" attribute in the IrcUser object, if one exists.
|
||||
try:
|
||||
sname = userobj.service
|
||||
# Warn if the service name we fetched isn't a registered service.
|
||||
if sname not in world.services.keys():
|
||||
log.warning("(%s) User %s / %s had a service bot record to a service that doesn't "
|
||||
"exist (%s)!", self.name, uid, userobj.nick, sname)
|
||||
return world.services.get(sname)
|
||||
except AttributeError:
|
||||
return False
|
||||
for sbot in world.services.values():
|
||||
if uid == sbot.uids.get(self.name):
|
||||
return sbot
|
||||
return False
|
||||
|
||||
def getHostmask(self, user, realhost=False, ip=False):
|
||||
"""
|
||||
|
@ -51,6 +51,9 @@ def spawn_service(irc, source, command, args):
|
||||
userobj = irc.proto.spawnClient(nick, ident, host, modes=modes, opertype="PyLink Service",
|
||||
manipulatable=sbot.manipulatable)
|
||||
|
||||
# Store the service name in the IrcUser object for easier access.
|
||||
userobj.service = name
|
||||
|
||||
sbot.uids[irc.name] = u = userobj.uid
|
||||
|
||||
# Special case: if this is the main PyLink client being spawned,
|
||||
|
Loading…
Reference in New Issue
Block a user