3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-01 01:09:22 +01:00

plugins: use irc.reply(...) instead of irc.msg(irc.called_by, ...) whereever possible

This commit is contained in:
James Lu 2015-10-23 18:29:10 -07:00
parent e942b411f1
commit 17a2dcd21f
6 changed files with 98 additions and 98 deletions

View File

@ -120,7 +120,7 @@ def identify(irc, source, args):
Logs in to PyLink using the configured administrator account."""
if utils.isChannel(irc.called_by):
irc.msg(irc.called_by, 'Error: This command must be sent in private. '
irc.reply('Error: This command must be sent in private. '
'(Would you really type a password inside a channel?)')
return
try:
@ -163,10 +163,10 @@ def load(irc, source, args):
try:
name = args[0]
except IndexError:
irc.msg(irc.called_by, "Error: Not enough arguments. Needs 1: plugin name.")
irc.reply("Error: Not enough arguments. Needs 1: plugin name.")
return
if name in world.plugins:
irc.msg(irc.called_by, "Error: %r is already loaded." % name)
irc.reply("Error: %r is already loaded." % name)
return
try:
world.plugins[name] = pl = utils.loadModuleFromFolder(name, world.plugins_folder)
@ -180,7 +180,7 @@ def load(irc, source, args):
if hasattr(pl, 'main'):
log.debug('Calling main() function of plugin %r', pl)
pl.main(irc)
irc.msg(irc.called_by, "Loaded plugin %r." % name)
irc.reply("Loaded plugin %r." % name)
utils.add_cmd(load)
def unload(irc, source, args):
@ -191,7 +191,7 @@ def unload(irc, source, args):
try:
name = args[0]
except IndexError:
irc.msg(irc.called_by, "Error: Not enough arguments. Needs 1: plugin name.")
irc.reply("Error: Not enough arguments. Needs 1: plugin name.")
return
if name in world.plugins:
pl = world.plugins[name]
@ -240,10 +240,10 @@ def unload(irc, source, args):
# Garbage collect.
gc.collect()
irc.msg(irc.called_by, "Unloaded plugin %r." % name)
irc.reply("Unloaded plugin %r." % name)
return True # We succeeded, make it clear (this status is used by reload() below)
else:
irc.msg(irc.called_by, "Unknown plugin %r." % name)
irc.reply("Unknown plugin %r." % name)
utils.add_cmd(unload)
@utils.add_cmd
@ -254,7 +254,7 @@ def reload(irc, source, args):
try:
name = args[0]
except IndexError:
irc.msg(irc.called_by, "Error: Not enough arguments. Needs 1: plugin name.")
irc.reply("Error: Not enough arguments. Needs 1: plugin name.")
return
if unload(irc, source, args):
load(irc, source, args)

View File

@ -20,7 +20,7 @@ def spawnclient(irc, source, args):
try:
nick, ident, host = args[:3]
except ValueError:
irc.msg(irc.called_by, "Error: Not enough arguments. Needs 3: nick, user, host.")
irc.reply("Error: Not enough arguments. Needs 3: nick, user, host.")
return
irc.proto.spawnClient(nick, ident, host, manipulatable=True)
@ -33,15 +33,15 @@ def quit(irc, source, args):
try:
nick = args[0]
except IndexError:
irc.msg(irc.called_by, "Error: Not enough arguments. Needs 1-2: nick, reason (optional).")
irc.reply("Error: Not enough arguments. Needs 1-2: nick, reason (optional).")
return
if irc.pseudoclient.uid == utils.nickToUid(irc, nick):
irc.msg(irc.called_by, "Error: Cannot quit the main PyLink PseudoClient!")
irc.reply("Error: Cannot quit the main PyLink PseudoClient!")
return
u = utils.nickToUid(irc, nick)
quitmsg = ' '.join(args[1:]) or 'Client Quit'
if not utils.isManipulatableClient(irc, u):
irc.msg(irc.called_by, "Error: Cannot force quit a protected PyLink services client.")
irc.reply("Error: Cannot force quit a protected PyLink services client.")
return
irc.proto.quitClient(u, quitmsg)
irc.callHooks([u, 'PYLINK_BOTSPLUGIN_QUIT', {'text': quitmsg, 'parse_as': 'QUIT'}])
@ -57,15 +57,15 @@ def joinclient(irc, source, args):
if not clist:
raise IndexError
except IndexError:
irc.msg(irc.called_by, "Error: Not enough arguments. Needs 2: nick, comma separated list of channels.")
irc.reply("Error: Not enough arguments. Needs 2: nick, comma separated list of channels.")
return
u = utils.nickToUid(irc, nick)
if not utils.isManipulatableClient(irc, u):
irc.msg(irc.called_by, "Error: Cannot force join a protected PyLink services client.")
irc.reply("Error: Cannot force join a protected PyLink services client.")
return
for channel in clist:
if not utils.isChannel(channel):
irc.msg(irc.called_by, "Error: Invalid channel name %r." % channel)
irc.reply("Error: Invalid channel name %r." % channel)
return
irc.proto.joinClient(u, channel)
irc.callHooks([u, 'PYLINK_BOTSPLUGIN_JOIN', {'channel': channel, 'users': [u],
@ -83,16 +83,16 @@ def nick(irc, source, args):
nick = args[0]
newnick = args[1]
except IndexError:
irc.msg(irc.called_by, "Error: Not enough arguments. Needs 2: nick, newnick.")
irc.reply("Error: Not enough arguments. Needs 2: nick, newnick.")
return
u = utils.nickToUid(irc, nick)
if newnick in ('0', u):
newnick = u
elif not utils.isNick(newnick):
irc.msg(irc.called_by, 'Error: Invalid nickname %r.' % newnick)
irc.reply('Error: Invalid nickname %r.' % newnick)
return
elif not utils.isManipulatableClient(irc, u):
irc.msg(irc.called_by, "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
irc.proto.nickClient(u, newnick)
irc.callHooks([u, 'PYLINK_BOTSPLUGIN_NICK', {'newnick': newnick, 'oldnick': nick, 'parse_as': 'NICK'}])
@ -108,15 +108,15 @@ def part(irc, source, args):
clist = args[1].split(',')
reason = ' '.join(args[2:])
except IndexError:
irc.msg(irc.called_by, "Error: Not enough arguments. Needs 2: nick, comma separated list of channels.")
irc.reply("Error: Not enough arguments. Needs 2: nick, comma separated list of channels.")
return
u = utils.nickToUid(irc, nick)
if not utils.isManipulatableClient(irc, u):
irc.msg(irc.called_by, "Error: Cannot force part a protected PyLink services client.")
irc.reply("Error: Cannot force part a protected PyLink services client.")
return
for channel in clist:
if not utils.isChannel(channel):
irc.msg(irc.called_by, "Error: Invalid channel name %r." % channel)
irc.reply("Error: Invalid channel name %r." % channel)
return
irc.proto.partClient(u, channel, reason)
irc.callHooks([u, 'PYLINK_BOTSPLUGIN_PART', {'channels': clist, 'text': reason, 'parse_as': 'PART'}])
@ -133,12 +133,12 @@ def kick(irc, source, args):
target = args[2]
reason = ' '.join(args[3:])
except IndexError:
irc.msg(irc.called_by, "Error: Not enough arguments. Needs 3-4: source nick, channel, target, reason (optional).")
irc.reply("Error: Not enough arguments. Needs 3-4: source nick, channel, target, reason (optional).")
return
u = utils.nickToUid(irc, nick) or nick
targetu = utils.nickToUid(irc, target)
if not utils.isChannel(channel):
irc.msg(irc.called_by, "Error: Invalid channel name %r." % channel)
irc.reply("Error: Invalid channel name %r." % channel)
return
if utils.isInternalServer(irc, u):
irc.proto.kickServer(u, channel, targetu, reason)
@ -155,20 +155,20 @@ def mode(irc, source, args):
try:
modesource, target, modes = args[0], args[1], args[2:]
except IndexError:
irc.msg(irc.called_by, 'Error: Not enough arguments. Needs 3: source nick, target, modes to set.')
irc.reply('Error: Not enough arguments. Needs 3: source nick, target, modes to set.')
return
target = utils.nickToUid(irc, target) or target
extclient = target in irc.users and not utils.isInternalClient(irc, target)
parsedmodes = utils.parseModes(irc, target, modes)
ischannel = target in irc.channels
if not (target in irc.users or ischannel):
irc.msg(irc.called_by, "Error: Invalid channel or nick %r." % target)
irc.reply("Error: Invalid channel or nick %r." % target)
return
elif not parsedmodes:
irc.msg(irc.called_by, "Error: No valid modes were given.")
irc.reply("Error: No valid modes were given.")
return
elif not (ischannel or utils.isManipulatableClient(irc, target)):
irc.msg(irc.called_by, "Error: Can only set modes on channels or non-protected PyLink clients.")
irc.reply("Error: Can only set modes on channels or non-protected PyLink clients.")
return
if utils.isInternalServer(irc, modesource):
# Setting modes from a server.
@ -189,21 +189,21 @@ def msg(irc, source, args):
try:
msgsource, target, text = args[0], args[1], ' '.join(args[2:])
except IndexError:
irc.msg(irc.called_by, 'Error: Not enough arguments. Needs 3: source nick, target, text.')
irc.reply('Error: Not enough arguments. Needs 3: source nick, target, text.')
return
sourceuid = utils.nickToUid(irc, msgsource)
if not sourceuid:
irc.msg(irc.called_by, 'Error: Unknown user %r.' % msgsource)
irc.reply('Error: Unknown user %r.' % msgsource)
return
if not utils.isChannel(target):
real_target = utils.nickToUid(irc, target)
if real_target is None:
irc.msg(irc.called_by, 'Error: Unknown user %r.' % target)
irc.reply('Error: Unknown user %r.' % target)
return
else:
real_target = target
if not text:
irc.msg(irc.called_by, 'Error: No text given.')
irc.reply('Error: No text given.')
return
irc.proto.messageClient(sourceuid, real_target, text)
irc.callHooks([sourceuid, 'PYLINK_BOTSPLUGIN_MSG', {'target': real_target, 'text': text, 'parse_as': 'PRIVMSG'}])

View File

@ -17,10 +17,10 @@ def status(irc, source, args):
Returns your current PyLink login status."""
identified = irc.users[source].identified
if identified:
irc.msg(irc.called_by, 'You are identified as \x02%s\x02.' % identified)
irc.reply('You are identified as \x02%s\x02.' % identified)
else:
irc.msg(irc.called_by, 'You are not identified as anyone.')
irc.msg(irc.called_by, 'Operator access: \x02%s\x02' % bool(utils.isOper(irc, source)))
irc.reply('You are not identified as anyone.')
irc.reply('Operator access: \x02%s\x02' % bool(utils.isOper(irc, source)))
def listcommands(irc, source, args):
"""takes no arguments.
@ -32,8 +32,8 @@ def listcommands(irc, source, args):
nfuncs = len(world.commands[cmd])
if nfuncs > 1:
cmds[idx] = '%s(x%s)' % (cmd, nfuncs)
irc.msg(irc.called_by, 'Available commands include: %s' % ', '.join(cmds))
irc.msg(irc.called_by, 'To see help on a specific command, type \x02help <command>\x02.')
irc.reply('Available commands include: %s' % ', '.join(cmds))
irc.reply('To see help on a specific command, type \x02help <command>\x02.')
utils.add_cmd(listcommands, 'list')
@utils.add_cmd
@ -52,7 +52,7 @@ def help(irc, source, args):
else:
funcs = world.commands[command]
if len(funcs) > 1:
irc.msg(irc.called_by, 'The following \x02%s\x02 plugins bind to the \x02%s\x02 command: %s'
irc.reply('The following \x02%s\x02 plugins bind to the \x02%s\x02 command: %s'
% (len(funcs), command, ', '.join([func.__module__ for func in funcs])))
for func in funcs:
doc = func.__doc__
@ -63,7 +63,7 @@ def help(irc, source, args):
# arguments the command takes.
lines[0] = '\x02%s %s\x02 (plugin: %r)' % (command, lines[0], mod)
for line in lines:
irc.msg(irc.called_by, line.strip())
irc.reply(line.strip())
else:
irc.msg(source, "Error: Command %r (from plugin %r) "
"doesn't offer any help." % (command, mod))
@ -77,14 +77,14 @@ def showuser(irc, source, args):
try:
target = args[0]
except IndexError:
irc.msg(irc.called_by, "Error: Not enough arguments. Needs 1: nick.")
irc.reply("Error: Not enough arguments. Needs 1: nick.")
return
u = utils.nickToUid(irc, target) or target
# Only show private info if the person is calling 'showuser' on themselves,
# or is an oper.
verbose = utils.isOper(irc, source) or u == source
if u not in irc.users:
irc.msg(irc.called_by, 'Error: Unknown user %r.' % target)
irc.reply('Error: Unknown user %r.' % target)
return
f = lambda s: irc.msg(source, s)
@ -112,10 +112,10 @@ def showchan(irc, source, args):
try:
channel = utils.toLower(irc, args[0])
except IndexError:
irc.msg(irc.called_by, "Error: Not enough arguments. Needs 1: channel.")
irc.reply("Error: Not enough arguments. Needs 1: channel.")
return
if channel not in irc.channels:
irc.msg(irc.called_by, 'Error: Unknown channel %r.' % channel)
irc.reply('Error: Unknown channel %r.' % channel)
return
f = lambda s: irc.msg(source, s)
@ -155,15 +155,15 @@ def version(irc, source, args):
"""takes no arguments.
Returns the version of the currently running PyLink instance."""
irc.msg(irc.called_by, "PyLink version \x02%s\x02, released under the Mozilla Public License version 2.0." % world.version)
irc.msg(irc.called_by, "The source of this program is available at \x02%s\x02." % world.source)
irc.reply("PyLink version \x02%s\x02, released under the Mozilla Public License version 2.0." % world.version)
irc.reply("The source of this program is available at \x02%s\x02." % world.source)
@utils.add_cmd
def echo(irc, source, args):
"""<text>
Echoes the text given."""
irc.msg(irc.called_by, ' '.join(args))
irc.reply(' '.join(args))
@utils.add_cmd
def rehash(irc, source, args):
@ -178,7 +178,7 @@ def rehash(irc, source, args):
new_conf = conf.validateConf(conf.loadConf(fname))
except Exception as e: # Something went wrong, abort.
log.exception("Error REHASH'ing config: ")
irc.msg(irc.called_by, "Error loading configuration file: %s: %s", type(e).__name__, e)
irc.reply("Error loading configuration file: %s: %s", type(e).__name__, e)
return
conf.conf = new_conf
for network, ircobj in world.networkobjects.copy().items():
@ -198,4 +198,4 @@ def rehash(irc, source, args):
if network not in world.networkobjects:
proto = utils.getProtoModule(sdata['protocol'])
world.networkobjects[network] = classes.Irc(network, proto, new_conf)
irc.msg(irc.called_by, "Done.")
irc.reply("Done.")

View File

@ -17,7 +17,7 @@ def _exec(irc, source, args):
utils.checkAuthenticated(irc, source, allowOper=False)
args = ' '.join(args)
if not args.strip():
irc.msg(irc.called_by, 'No code entered!')
irc.reply('No code entered!')
return
log.info('(%s) Executing %r for %s', irc.name, args, utils.getHostmask(irc, source))
exec(args, globals(), locals())
@ -31,8 +31,8 @@ def _eval(irc, source, args):
utils.checkAuthenticated(irc, source, allowOper=False)
args = ' '.join(args)
if not args.strip():
irc.msg(irc.called_by, 'No code entered!')
irc.reply('No code entered!')
return
log.info('(%s) Evaluating %r for %s', irc.name, args, utils.getHostmask(irc, source))
irc.msg(irc.called_by, eval(args))
irc.reply(eval(args))
utils.add_cmd(_eval, 'eval')

View File

@ -22,12 +22,12 @@ def disconnect(irc, source, args):
netname = args[0]
network = world.networkobjects[netname]
except IndexError: # No argument given.
irc.msg(irc.called_by, 'Error: Not enough arguments (needs 1: network name (case sensitive)).')
irc.reply('Error: Not enough arguments (needs 1: network name (case sensitive)).')
return
except KeyError: # Unknown network.
irc.msg(irc.called_by, 'Error: No such network "%s" (case sensitive).' % netname)
irc.reply('Error: No such network "%s" (case sensitive).' % netname)
return
irc.msg(irc.called_by, "Done.")
irc.reply("Done.")
# Abort the connection! Simple as that.
network.aborted.set()
@ -41,18 +41,18 @@ def connect(irc, source, args):
netname = args[0]
network = world.networkobjects[netname]
except IndexError: # No argument given.
irc.msg(irc.called_by, 'Error: Not enough arguments (needs 1: network name (case sensitive)).')
irc.reply('Error: Not enough arguments (needs 1: network name (case sensitive)).')
return
except KeyError: # Unknown network.
irc.msg(irc.called_by, 'Error: No such network "%s" (case sensitive).' % netname)
irc.reply('Error: No such network "%s" (case sensitive).' % netname)
return
if network.connection_thread.is_alive():
irc.msg(irc.called_by, 'Error: Network "%s" seems to be already connected.' % netname)
irc.reply('Error: Network "%s" seems to be already connected.' % netname)
else: # Reconnect the network!
network.initVars()
network.connection_thread = threading.Thread(target=network.connect)
network.connection_thread.start()
irc.msg(irc.called_by, "Done.")
irc.reply("Done.")
@utils.add_cmd
def autoconnect(irc, source, args):
@ -66,13 +66,13 @@ def autoconnect(irc, source, args):
seconds = float(args[1])
network = world.networkobjects[netname]
except IndexError: # Arguments not given.
irc.msg(irc.called_by, 'Error: Not enough arguments (needs 2: network name (case sensitive), autoconnect time (in seconds)).')
irc.reply('Error: Not enough arguments (needs 2: network name (case sensitive), autoconnect time (in seconds)).')
return
except KeyError: # Unknown network.
irc.msg(irc.called_by, 'Error: No such network "%s" (case sensitive).' % netname)
irc.reply('Error: No such network "%s" (case sensitive).' % netname)
return
except ValueError:
irc.msg(irc.called_by, 'Error: Invalid argument "%s" for <seconds>.' % seconds)
irc.reply('Error: Invalid argument "%s" for <seconds>.' % seconds)
return
network.serverdata['autoconnect'] = seconds
irc.msg(irc.called_by, "Done.")
irc.reply("Done.")

View File

@ -1074,22 +1074,22 @@ def create(irc, source, args):
try:
channel = utils.toLower(irc, args[0])
except IndexError:
irc.msg(irc.called_by, "Error: Not enough arguments. Needs 1: channel.")
irc.reply("Error: Not enough arguments. Needs 1: channel.")
return
if not utils.isChannel(channel):
irc.msg(irc.called_by, 'Error: Invalid channel %r.' % channel)
irc.reply('Error: Invalid channel %r.' % channel)
return
if source not in irc.channels[channel].users:
irc.msg(irc.called_by, 'Error: You must be in %r to complete this operation.' % channel)
irc.reply('Error: You must be in %r to complete this operation.' % channel)
return
utils.checkAuthenticated(irc, source)
localentry = getRelay((irc.name, channel))
if localentry:
irc.msg(irc.called_by, 'Error: Channel %r is already part of a relay.' % channel)
irc.reply('Error: Channel %r is already part of a relay.' % channel)
return
db[(irc.name, channel)] = {'claim': [irc.name], 'links': set(), 'blocked_nets': set()}
initializeChannel(irc, channel)
irc.msg(irc.called_by, 'Done.')
irc.reply('Done.')
@utils.add_cmd
def destroy(irc, source, args):
@ -1099,10 +1099,10 @@ def destroy(irc, source, args):
try:
channel = utils.toLower(irc, args[0])
except IndexError:
irc.msg(irc.called_by, "Error: Not enough arguments. Needs 1: channel.")
irc.reply("Error: Not enough arguments. Needs 1: channel.")
return
if not utils.isChannel(channel):
irc.msg(irc.called_by, 'Error: Invalid channel %r.' % channel)
irc.reply('Error: Invalid channel %r.' % channel)
return
utils.checkAuthenticated(irc, source)
@ -1112,9 +1112,9 @@ def destroy(irc, source, args):
removeChannel(world.networkobjects.get(link[0]), link[1])
removeChannel(irc, channel)
del db[entry]
irc.msg(irc.called_by, 'Done.')
irc.reply('Done.')
else:
irc.msg(irc.called_by, 'Error: No such relay %r exists.' % channel)
irc.reply('Error: No such relay %r exists.' % channel)
return
@utils.add_cmd
@ -1127,7 +1127,7 @@ def link(irc, source, args):
channel = utils.toLower(irc, args[1])
remotenet = args[0].lower()
except IndexError:
irc.msg(irc.called_by, "Error: Not enough arguments. Needs 2-3: remote netname, channel, local channel name (optional).")
irc.reply("Error: Not enough arguments. Needs 2-3: remote netname, channel, local channel name (optional).")
return
try:
localchan = utils.toLower(irc, args[2])
@ -1135,37 +1135,37 @@ def link(irc, source, args):
localchan = channel
for c in (channel, localchan):
if not utils.isChannel(c):
irc.msg(irc.called_by, 'Error: Invalid channel %r.' % c)
irc.reply('Error: Invalid channel %r.' % c)
return
if source not in irc.channels[localchan].users:
irc.msg(irc.called_by, 'Error: You must be in %r to complete this operation.' % localchan)
irc.reply('Error: You must be in %r to complete this operation.' % localchan)
return
utils.checkAuthenticated(irc, source)
if remotenet not in world.networkobjects:
irc.msg(irc.called_by, 'Error: No network named %r exists.' % remotenet)
irc.reply('Error: No network named %r exists.' % remotenet)
return
localentry = getRelay((irc.name, localchan))
if localentry:
irc.msg(irc.called_by, 'Error: Channel %r is already part of a relay.' % localchan)
irc.reply('Error: Channel %r is already part of a relay.' % localchan)
return
try:
entry = db[(remotenet, channel)]
except KeyError:
irc.msg(irc.called_by, 'Error: No such relay %r exists.' % channel)
irc.reply('Error: No such relay %r exists.' % channel)
return
else:
if irc.name in entry['blocked_nets']:
irc.msg(irc.called_by, 'Error: Access denied (network is banned from linking to this channel).')
irc.reply('Error: Access denied (network is banned from linking to this channel).')
return
for link in entry['links']:
if link[0] == irc.name:
irc.msg(irc.called_by, "Error: Remote channel '%s%s' is already"
irc.reply("Error: Remote channel '%s%s' is already"
" linked here as %r." % (remotenet,
channel, link[1]))
return
entry['links'].add((irc.name, localchan))
initializeChannel(irc, localchan)
irc.msg(irc.called_by, 'Done.')
irc.reply('Done.')
@utils.add_cmd
def delink(irc, source, args):
@ -1176,7 +1176,7 @@ def delink(irc, source, args):
try:
channel = utils.toLower(irc, args[0])
except IndexError:
irc.msg(irc.called_by, "Error: Not enough arguments. Needs 1-2: channel, remote netname (optional).")
irc.reply("Error: Not enough arguments. Needs 1-2: channel, remote netname (optional).")
return
try:
remotenet = args[1].lower()
@ -1184,13 +1184,13 @@ def delink(irc, source, args):
remotenet = None
utils.checkAuthenticated(irc, source)
if not utils.isChannel(channel):
irc.msg(irc.called_by, 'Error: Invalid channel %r.' % channel)
irc.reply('Error: Invalid channel %r.' % channel)
return
entry = getRelay((irc.name, channel))
if entry:
if entry[0] == irc.name: # We own this channel.
if not remotenet:
irc.msg(irc.called_by, "Error: You must select a network to "
irc.reply("Error: You must select a network to "
"delink, or use the 'destroy' command to remove "
"this relay entirely (it was created on the current "
"network).")
@ -1203,9 +1203,9 @@ def delink(irc, source, args):
else:
removeChannel(irc, channel)
db[entry]['links'].remove((irc.name, channel))
irc.msg(irc.called_by, 'Done.')
irc.reply('Done.')
else:
irc.msg(irc.called_by, 'Error: No such relay %r.' % channel)
irc.reply('Error: No such relay %r.' % channel)
@utils.add_cmd
def linked(irc, source, args):
@ -1247,37 +1247,37 @@ def linkacl(irc, source, args):
cmd = args[0].lower()
channel = utils.toLower(irc, args[1])
except IndexError:
irc.msg(irc.called_by, missingargs)
irc.reply(missingargs)
return
if not utils.isChannel(channel):
irc.msg(irc.called_by, 'Error: Invalid channel %r.' % channel)
irc.reply('Error: Invalid channel %r.' % channel)
return
relay = getRelay((irc.name, channel))
if not relay:
irc.msg(irc.called_by, 'Error: No such relay %r exists.' % channel)
irc.reply('Error: No such relay %r exists.' % channel)
return
if cmd == 'list':
s = 'Blocked networks for \x02%s\x02: \x02%s\x02' % (channel, ', '.join(db[relay]['blocked_nets']) or '(empty)')
irc.msg(irc.called_by, s)
irc.reply(s)
return
try:
remotenet = args[2]
except IndexError:
irc.msg(irc.called_by, missingargs)
irc.reply(missingargs)
return
if cmd == 'deny':
db[relay]['blocked_nets'].add(remotenet)
irc.msg(irc.called_by, 'Done.')
irc.reply('Done.')
elif cmd == 'allow':
try:
db[relay]['blocked_nets'].remove(remotenet)
except KeyError:
irc.msg(irc.called_by, 'Error: Network %r is not on the blacklist for %r.' % (remotenet, channel))
irc.reply('Error: Network %r is not on the blacklist for %r.' % (remotenet, channel))
else:
irc.msg(irc.called_by, 'Done.')
irc.reply('Done.')
else:
irc.msg(irc.called_by, 'Error: Unknown subcommand %r: valid ones are ALLOW, DENY, and LIST.' % cmd)
irc.reply('Error: Unknown subcommand %r: valid ones are ALLOW, DENY, and LIST.' % cmd)
@utils.add_cmd
def showuser(irc, source, args):
@ -1322,7 +1322,7 @@ def save(irc, source, args):
Saves the relay database to disk."""
utils.checkAuthenticated(irc, source)
exportDB()
irc.msg(irc.called_by, 'Done.')
irc.reply('Done.')
@utils.add_cmd
def claim(irc, source, args):
@ -1335,19 +1335,19 @@ def claim(irc, source, args):
try:
channel = utils.toLower(irc, args[0])
except IndexError:
irc.msg(irc.called_by, "Error: Not enough arguments. Needs 1-2: channel, list of networks (optional).")
irc.reply("Error: Not enough arguments. Needs 1-2: channel, list of networks (optional).")
return
# We override getRelay() here to limit the search to the current network.
relay = (irc.name, channel)
if relay not in db:
irc.msg(irc.called_by, 'Error: No such relay %r exists.' % channel)
irc.reply('Error: No such relay %r exists.' % channel)
return
claimed = db[relay]["claim"]
try:
nets = args[1].strip()
except IndexError: # No networks given.
irc.msg(irc.called_by, 'Channel \x02%s\x02 is claimed by: %s' %
irc.reply('Channel \x02%s\x02 is claimed by: %s' %
(channel, ', '.join(claimed) or '\x1D(none)\x1D'))
else:
if nets == '-' or not nets:
@ -1355,5 +1355,5 @@ def claim(irc, source, args):
else:
claimed = set(nets.split(','))
db[relay]["claim"] = claimed
irc.msg(irc.called_by, 'CLAIM for channel \x02%s\x02 set to: %s' %
irc.reply('CLAIM for channel \x02%s\x02 set to: %s' %
(channel, ', '.join(claimed) or '\x1D(none)\x1D'))