mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 01:09:22 +01:00
core: reuse existing service client UIDs for all service bots
This prevents nick collision wars caused by spawn_service when an ENDBURST hook for the uplink is received multiple times.
This commit is contained in:
parent
21b8b51cba
commit
cad55097f1
10
classes.py
10
classes.py
@ -468,16 +468,13 @@ class PyLinkNetworkCore(structures.DeprecatedAttributesObject, structures.CamelC
|
|||||||
if not userobj:
|
if not userobj:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Look for the "service" attribute in the User object, if one exists.
|
# Look for the "service" attribute in the User object,sname = userobj.service
|
||||||
try:
|
|
||||||
sname = userobj.service
|
|
||||||
# Warn if the service name we fetched isn't a registered service.
|
# Warn if the service name we fetched isn't a registered service.
|
||||||
|
sname = userobj.service
|
||||||
if sname not in world.services.keys():
|
if sname not in world.services.keys():
|
||||||
log.warning("(%s) User %s / %s had a service bot record to a service that doesn't "
|
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)
|
"exist (%s)!", self.name, uid, userobj.nick, sname)
|
||||||
return world.services.get(sname)
|
return world.services.get(sname)
|
||||||
except AttributeError:
|
|
||||||
return False
|
|
||||||
|
|
||||||
structures._BLACKLISTED_COPY_TYPES.append(PyLinkNetworkCore)
|
structures._BLACKLISTED_COPY_TYPES.append(PyLinkNetworkCore)
|
||||||
|
|
||||||
@ -1596,6 +1593,9 @@ class User():
|
|||||||
# Cloaked host for IRCds that use it
|
# Cloaked host for IRCds that use it
|
||||||
self.cloaked_host = None
|
self.cloaked_host = None
|
||||||
|
|
||||||
|
# Stores service bot name if applicable
|
||||||
|
self.service = None
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return 'User(%s/%s)' % (self.uid, self.nick)
|
return 'User(%s/%s)' % (self.uid, self.nick)
|
||||||
IrcUser = User
|
IrcUser = User
|
||||||
|
@ -22,10 +22,11 @@ def spawn_service(irc, source, command, args):
|
|||||||
# Get the ServiceBot object.
|
# Get the ServiceBot object.
|
||||||
sbot = world.services[name]
|
sbot = world.services[name]
|
||||||
|
|
||||||
if name == 'pylink' and irc.pseudoclient:
|
old_userobj = irc.users.get(sbot.uids.get(irc.name))
|
||||||
# irc.pseudoclient already exists, for protocols like clientbot
|
if old_userobj and old_userobj.service:
|
||||||
log.debug('(%s) spawn_service: Using existing nick %r for service %r', irc.name, irc.pseudoclient.nick, name)
|
# A client already exists, so reuse it.
|
||||||
userobj = irc.pseudoclient
|
log.debug('(%s) spawn_service: Using existing nick %r for service %r', irc.name, old_userobj.nick, name)
|
||||||
|
userobj = old_userobj
|
||||||
userobj.opertype = "PyLink Service"
|
userobj.opertype = "PyLink Service"
|
||||||
userobj.manipulatable = sbot.manipulatable
|
userobj.manipulatable = sbot.manipulatable
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user