3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-27 21:19:31 +01:00

Irc: s/isServiceBot/getServiceBot/g (#355)

This function is renamed to better reflect its return value (ServiceBot object instead of boolean True).
This commit is contained in:
James Lu 2016-11-09 19:09:59 -08:00
parent 08fa64c3cc
commit 377df413ed
5 changed files with 10 additions and 10 deletions

View File

@ -902,7 +902,7 @@ class Irc():
""" """
return self.isInternalClient(uid) and self.users[uid].manipulatable return self.isInternalClient(uid) and self.users[uid].manipulatable
def isServiceBot(self, uid): def getServiceBot(self, uid):
""" """
Checks whether the given UID is a registered service bot. If True, Checks whether the given UID is a registered service bot. If True,
returns the cooresponding ServiceBot object. returns the cooresponding ServiceBot object.

View File

@ -94,7 +94,7 @@ utils.add_hook(handle_endburst, 'ENDBURST')
def handle_kill(irc, source, command, args): def handle_kill(irc, source, command, args):
"""Handle KILLs to PyLink service bots, respawning them as needed.""" """Handle KILLs to PyLink service bots, respawning them as needed."""
target = args['target'] target = args['target']
sbot = irc.isServiceBot(target) sbot = irc.getServiceBot(target)
if sbot: if sbot:
spawn_service(irc, source, command, {'name': sbot.name}) spawn_service(irc, source, command, {'name': sbot.name})
return return
@ -104,7 +104,7 @@ def handle_kick(irc, source, command, args):
"""Handle KICKs to the PyLink service bots, rejoining channels as needed.""" """Handle KICKs to the PyLink service bots, rejoining channels as needed."""
kicked = args['target'] kicked = args['target']
channel = args['channel'] channel = args['channel']
sbot = irc.isServiceBot(kicked) sbot = irc.getServiceBot(kicked)
if sbot: if sbot:
sbot.join(irc, channel) sbot.join(irc, channel)
utils.add_hook(handle_kick, 'KICK') utils.add_hook(handle_kick, 'KICK')
@ -114,7 +114,7 @@ def handle_commands(irc, source, command, args):
target = args['target'] target = args['target']
text = args['text'] text = args['text']
sbot = irc.isServiceBot(target) sbot = irc.getServiceBot(target)
if sbot: if sbot:
sbot.call_cmd(irc, source, text) sbot.call_cmd(irc, source, text)

View File

@ -74,7 +74,7 @@ def joinclient(irc, source, args):
irc.reply("Error: No valid channels given.") irc.reply("Error: No valid channels given.")
return return
if not (irc.isManipulatableClient(u) or irc.isServiceBot(u)): if not (irc.isManipulatableClient(u) or irc.getServiceBot(u)):
irc.reply("Error: Cannot force join a protected PyLink services client.") irc.reply("Error: Cannot force join a protected PyLink services client.")
return return
@ -116,7 +116,7 @@ def nick(irc, source, args):
irc.reply('Error: Invalid nickname %r.' % newnick) irc.reply('Error: Invalid nickname %r.' % newnick)
return return
elif not (irc.isManipulatableClient(u) or irc.isServiceBot(u)): elif not (irc.isManipulatableClient(u) or irc.getServiceBot(u)):
irc.reply("Error: Cannot force nick changes for a protected PyLink services client.") irc.reply("Error: Cannot force nick changes for a protected PyLink services client.")
return return
@ -158,7 +158,7 @@ def part(irc, source, args):
irc.reply("Error: No valid channels given.") irc.reply("Error: No valid channels given.")
return return
if not (irc.isManipulatableClient(u) or irc.isServiceBot(u)): if not (irc.isManipulatableClient(u) or irc.getServiceBot(u)):
irc.reply("Error: Cannot force part a protected PyLink services client.") irc.reply("Error: Cannot force part a protected PyLink services client.")
return return

View File

@ -393,7 +393,7 @@ def getRemoteUser(irc, remoteirc, user, spawnIfMissing=True, times_tagged=0):
irc.connected.wait(5) irc.connected.wait(5)
# Don't spawn clones for registered service bots. # Don't spawn clones for registered service bots.
sbot = irc.isServiceBot(user) sbot = irc.getServiceBot(user)
if sbot: if sbot:
return sbot.uids.get(remoteirc.name) return sbot.uids.get(remoteirc.name)
@ -1196,7 +1196,7 @@ def handle_kick(irc, source, command, args):
return return
# Don't relay kicks to protected service bots. # Don't relay kicks to protected service bots.
if relay is None or irc.isServiceBot(target): if relay is None or irc.getServiceBot(target):
return return
origuser = getOrigUser(irc, target) origuser = getOrigUser(irc, target)

View File

@ -89,7 +89,7 @@ def cb_relay_core(irc, source, command, args):
text_template = string.Template(text_template) text_template = string.Template(text_template)
if text_template: if text_template:
if irc.isServiceBot(source): if irc.getServiceBot(source):
# HACK: service bots are global and lack the relay state we look for. # HACK: service bots are global and lack the relay state we look for.
# just pretend the message comes from the current network. # just pretend the message comes from the current network.
log.debug('(%s) relay_cb_core: Overriding network origin to local (source=%s)', irc.name, source) log.debug('(%s) relay_cb_core: Overriding network origin to local (source=%s)', irc.name, source)