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

Consistently capitalize errors and other messages

This commit is contained in:
James Lu 2015-08-25 20:55:39 -07:00
parent bc7765b241
commit 2fe9b624e7
3 changed files with 48 additions and 48 deletions

View File

@ -16,7 +16,7 @@ def spawnclient(irc, source, args):
try: try:
nick, ident, host = args[:3] nick, ident, host = args[:3]
except ValueError: except ValueError:
utils.msg(irc, source, "Error: not enough arguments. Needs 3: nick, user, host.") utils.msg(irc, source, "Error: Not enough arguments. Needs 3: nick, user, host.")
return return
irc.proto.spawnClient(irc, nick, ident, host) irc.proto.spawnClient(irc, nick, ident, host)
@ -29,13 +29,13 @@ def quit(irc, source, args):
try: try:
nick = args[0] nick = args[0]
except IndexError: except IndexError:
utils.msg(irc, source, "Error: not enough arguments. Needs 1-2: nick, reason (optional).") utils.msg(irc, source, "Error: Not enough arguments. Needs 1-2: nick, reason (optional).")
return return
if irc.pseudoclient.uid == utils.nickToUid(irc, nick): if irc.pseudoclient.uid == utils.nickToUid(irc, nick):
utils.msg(irc, source, "Error: cannot quit the main PyLink PseudoClient!") utils.msg(irc, source, "Error: Cannot quit the main PyLink PseudoClient!")
return return
u = utils.nickToUid(irc, nick) u = utils.nickToUid(irc, nick)
quitmsg = ' '.join(args[1:]) or 'Client quit' quitmsg = ' '.join(args[1:]) or 'Client Quit'
irc.proto.quitClient(irc, u, quitmsg) irc.proto.quitClient(irc, u, quitmsg)
irc.callHooks([u, 'PYLINK_ADMIN_QUIT', {'text': quitmsg, 'parse_as': 'QUIT'}]) irc.callHooks([u, 'PYLINK_ADMIN_QUIT', {'text': quitmsg, 'parse_as': 'QUIT'}])
@ -50,7 +50,7 @@ def joinclient(irc, source, args):
if not clist: if not clist:
raise IndexError raise IndexError
except IndexError: except IndexError:
utils.msg(irc, source, "Error: not enough arguments. Needs 2: nick, comma separated list of channels.") utils.msg(irc, source, "Error: Not enough arguments. Needs 2: nick, comma separated list of channels.")
return return
u = utils.nickToUid(irc, nick) u = utils.nickToUid(irc, nick)
for channel in clist: for channel in clist:
@ -73,7 +73,7 @@ def nick(irc, source, args):
nick = args[0] nick = args[0]
newnick = args[1] newnick = args[1]
except IndexError: except IndexError:
utils.msg(irc, source, "Error: not enough arguments. Needs 2: nick, newnick.") utils.msg(irc, source, "Error: Not enough arguments. Needs 2: nick, newnick.")
return return
u = utils.nickToUid(irc, nick) u = utils.nickToUid(irc, nick)
if newnick in ('0', u): if newnick in ('0', u):
@ -95,7 +95,7 @@ def part(irc, source, args):
clist = args[1].split(',') clist = args[1].split(',')
reason = ' '.join(args[2:]) reason = ' '.join(args[2:])
except IndexError: except IndexError:
utils.msg(irc, source, "Error: not enough arguments. Needs 2: nick, comma separated list of channels.") utils.msg(irc, source, "Error: Not enough arguments. Needs 2: nick, comma separated list of channels.")
return return
u = utils.nickToUid(irc, nick) u = utils.nickToUid(irc, nick)
for channel in clist: for channel in clist:
@ -117,7 +117,7 @@ def kick(irc, source, args):
target = args[2] target = args[2]
reason = ' '.join(args[3:]) reason = ' '.join(args[3:])
except IndexError: except IndexError:
utils.msg(irc, source, "Error: not enough arguments. Needs 3-4: source nick, channel, target, reason (optional).") utils.msg(irc, source, "Error: Not enough arguments. Needs 3-4: source nick, channel, target, reason (optional).")
return return
u = utils.nickToUid(irc, nick) or nick u = utils.nickToUid(irc, nick) or nick
targetu = utils.nickToUid(irc, target) targetu = utils.nickToUid(irc, target)
@ -139,11 +139,11 @@ def showuser(irc, source, args):
try: try:
target = args[0] target = args[0]
except IndexError: except IndexError:
utils.msg(irc, source, "Error: not enough arguments. Needs 1: nick.") utils.msg(irc, source, "Error: Not enough arguments. Needs 1: nick.")
return return
u = utils.nickToUid(irc, target) u = utils.nickToUid(irc, target)
if u is None: if u is None:
utils.msg(irc, source, 'Error: unknown user %r' % target) utils.msg(irc, source, 'Error: Unknown user %r.' % target)
return return
s = ['\x02%s\x02: %s' % (k, v) for k, v in sorted(irc.users[u].__dict__.items())] s = ['\x02%s\x02: %s' % (k, v) for k, v in sorted(irc.users[u].__dict__.items())]
s = 'Information on user \x02%s\x02: %s' % (target, '; '.join(s)) s = 'Information on user \x02%s\x02: %s' % (target, '; '.join(s))
@ -158,10 +158,10 @@ def showchan(irc, source, args):
try: try:
channel = args[0].lower() channel = args[0].lower()
except IndexError: except IndexError:
utils.msg(irc, source, "Error: not enough arguments. Needs 1: channel.") utils.msg(irc, source, "Error: Not enough arguments. Needs 1: channel.")
return return
if channel not in irc.channels: if channel not in irc.channels:
utils.msg(irc, source, 'Error: unknown channel %r' % channel) utils.msg(irc, source, 'Error: Unknown channel %r.' % channel)
return return
s = ['\x02%s\x02: %s' % (k, v) for k, v in sorted(irc.channels[channel].__dict__.items())] s = ['\x02%s\x02: %s' % (k, v) for k, v in sorted(irc.channels[channel].__dict__.items())]
s = 'Information on channel \x02%s\x02: %s' % (channel, '; '.join(s)) s = 'Information on channel \x02%s\x02: %s' % (channel, '; '.join(s))
@ -176,10 +176,10 @@ def mode(irc, source, args):
try: try:
modesource, target, modes = args[0], args[1], args[2:] modesource, target, modes = args[0], args[1], args[2:]
except IndexError: except IndexError:
utils.msg(irc, source, 'Error: not enough arguments. Needs 3: source nick, target, modes to set.') utils.msg(irc, source, 'Error: Not enough arguments. Needs 3: source nick, target, modes to set.')
return return
if not modes: if not modes:
utils.msg(irc, source, "Error: no modes given to set!") utils.msg(irc, source, "Error: No modes given to set!")
return return
parsedmodes = utils.parseModes(irc, target, modes) parsedmodes = utils.parseModes(irc, target, modes)
targetuid = utils.nickToUid(irc, target) targetuid = utils.nickToUid(irc, target)
@ -205,21 +205,21 @@ def msg(irc, source, args):
try: try:
msgsource, target, text = args[0], args[1], ' '.join(args[2:]) msgsource, target, text = args[0], args[1], ' '.join(args[2:])
except IndexError: except IndexError:
utils.msg(irc, source, 'Error: not enough arguments. Needs 3: source nick, target, text.') utils.msg(irc, source, 'Error: Not enough arguments. Needs 3: source nick, target, text.')
return return
sourceuid = utils.nickToUid(irc, msgsource) sourceuid = utils.nickToUid(irc, msgsource)
if not sourceuid: if not sourceuid:
utils.msg(irc, source, 'Error: unknown user %r' % msgsource) utils.msg(irc, source, 'Error: Unknown user %r.' % msgsource)
return return
if not utils.isChannel(target): if not utils.isChannel(target):
real_target = utils.nickToUid(irc, target) real_target = utils.nickToUid(irc, target)
if real_target is None: if real_target is None:
utils.msg(irc, source, 'Error: unknown user %r' % target) utils.msg(irc, source, 'Error: Unknown user %r.' % target)
return return
else: else:
real_target = target real_target = target
if not text: if not text:
utils.msg(irc, source, 'Error: no text given.') utils.msg(irc, source, 'Error: No text given.')
return return
irc.proto.messageClient(irc, sourceuid, real_target, text) irc.proto.messageClient(irc, sourceuid, real_target, text)
irc.callHooks([sourceuid, 'PYLINK_ADMIN_MSG', {'target': real_target, 'text': text, 'parse_as': 'PRIVMSG'}]) irc.callHooks([sourceuid, 'PYLINK_ADMIN_MSG', {'target': real_target, 'text': text, 'parse_as': 'PRIVMSG'}])

View File

@ -37,7 +37,7 @@ def identify(irc, source, args):
log.info("(%s) Successful login to %r by %s.", log.info("(%s) Successful login to %r by %s.",
irc.name, username, utils.getHostmask(irc, source)) irc.name, username, utils.getHostmask(irc, source))
else: else:
utils.msg(irc, source, 'Incorrect credentials.') utils.msg(irc, source, 'Error: Incorrect credentials.')
u = irc.users[source] u = irc.users[source]
log.warning("(%s) Failed login to %r from %s.", log.warning("(%s) Failed login to %r from %s.",
irc.name, username, utils.getHostmask(irc, source)) irc.name, username, utils.getHostmask(irc, source))

View File

@ -110,7 +110,7 @@ def save(irc, source, args):
exportDB() exportDB()
utils.msg(irc, source, 'Done.') utils.msg(irc, source, 'Done.')
else: else:
utils.msg(irc, source, 'Error: you are not authenticated!') utils.msg(irc, source, 'Error: You are not authenticated!')
return return
def getPrefixModes(irc, remoteirc, channel, user): def getPrefixModes(irc, remoteirc, channel, user):
@ -347,7 +347,7 @@ def handle_privmsg(irc, numeric, command, args):
# on the remote network, and we won't have anything to send our # on the remote network, and we won't have anything to send our
# messages from. # messages from.
if homenet not in remoteusers.keys(): if homenet not in remoteusers.keys():
utils.msg(irc, numeric, 'Error: you must be in a common channel ' utils.msg(irc, numeric, 'Error: You must be in a common channel '
'with %r in order to send messages.' % \ 'with %r in order to send messages.' % \
irc.users[target].nick, notice=True) irc.users[target].nick, notice=True)
return return
@ -754,16 +754,16 @@ def create(irc, source, args):
try: try:
channel = args[0].lower() channel = args[0].lower()
except IndexError: except IndexError:
utils.msg(irc, source, "Error: not enough arguments. Needs 1: channel.") utils.msg(irc, source, "Error: Not enough arguments. Needs 1: channel.")
return return
if not utils.isChannel(channel): if not utils.isChannel(channel):
utils.msg(irc, source, 'Error: invalid channel %r.' % channel) utils.msg(irc, source, 'Error: Invalid channel %r.' % channel)
return return
if source not in irc.channels[channel].users: if source not in irc.channels[channel].users:
utils.msg(irc, source, 'Error: you must be in %r to complete this operation.' % channel) utils.msg(irc, source, 'Error: You must be in %r to complete this operation.' % channel)
return return
if not utils.isOper(irc, source): if not utils.isOper(irc, source):
utils.msg(irc, source, 'Error: you must be opered in order to complete this operation.') utils.msg(irc, source, 'Error: You must be opered in order to complete this operation.')
return return
db[(irc.name, channel)] = {'claim': [irc.name], 'links': set(), 'blocked_nets': set()} db[(irc.name, channel)] = {'claim': [irc.name], 'links': set(), 'blocked_nets': set()}
initializeChannel(irc, channel) initializeChannel(irc, channel)
@ -777,13 +777,13 @@ def destroy(irc, source, args):
try: try:
channel = args[0].lower() channel = args[0].lower()
except IndexError: except IndexError:
utils.msg(irc, source, "Error: not enough arguments. Needs 1: channel.") utils.msg(irc, source, "Error: Not enough arguments. Needs 1: channel.")
return return
if not utils.isChannel(channel): if not utils.isChannel(channel):
utils.msg(irc, source, 'Error: invalid channel %r.' % channel) utils.msg(irc, source, 'Error: Invalid channel %r.' % channel)
return return
if not utils.isOper(irc, source): if not utils.isOper(irc, source):
utils.msg(irc, source, 'Error: you must be opered in order to complete this operation.') utils.msg(irc, source, 'Error: You must be opered in order to complete this operation.')
return return
entry = (irc.name, channel) entry = (irc.name, channel)
@ -794,7 +794,7 @@ def destroy(irc, source, args):
del db[entry] del db[entry]
utils.msg(irc, source, 'Done.') utils.msg(irc, source, 'Done.')
else: else:
utils.msg(irc, source, 'Error: no such relay %r exists.' % channel) utils.msg(irc, source, 'Error: No such relay %r exists.' % channel)
return return
@utils.add_cmd @utils.add_cmd
@ -807,7 +807,7 @@ def link(irc, source, args):
channel = args[1].lower() channel = args[1].lower()
remotenet = args[0].lower() remotenet = args[0].lower()
except IndexError: except IndexError:
utils.msg(irc, source, "Error: not enough arguments. Needs 2-3: remote netname, channel, local channel name (optional).") utils.msg(irc, source, "Error: Not enough arguments. Needs 2-3: remote netname, channel, local channel name (optional).")
return return
try: try:
localchan = args[2].lower() localchan = args[2].lower()
@ -815,33 +815,33 @@ def link(irc, source, args):
localchan = channel localchan = channel
for c in (channel, localchan): for c in (channel, localchan):
if not utils.isChannel(c): if not utils.isChannel(c):
utils.msg(irc, source, 'Error: invalid channel %r.' % c) utils.msg(irc, source, 'Error: Invalid channel %r.' % c)
return return
if source not in irc.channels[localchan].users: if source not in irc.channels[localchan].users:
utils.msg(irc, source, 'Error: you must be in %r to complete this operation.' % localchan) utils.msg(irc, source, 'Error: You must be in %r to complete this operation.' % localchan)
return return
if not utils.isOper(irc, source): if not utils.isOper(irc, source):
utils.msg(irc, source, 'Error: you must be opered in order to complete this operation.') utils.msg(irc, source, 'Error: You must be opered in order to complete this operation.')
return return
if remotenet not in utils.networkobjects: if remotenet not in utils.networkobjects:
utils.msg(irc, source, 'Error: no network named %r exists.' % remotenet) utils.msg(irc, source, 'Error: No network named %r exists.' % remotenet)
return return
localentry = findRelay((irc.name, localchan)) localentry = findRelay((irc.name, localchan))
if localentry: if localentry:
utils.msg(irc, source, 'Error: channel %r is already part of a relay.' % localchan) utils.msg(irc, source, 'Error: Channel %r is already part of a relay.' % localchan)
return return
try: try:
entry = db[(remotenet, channel)] entry = db[(remotenet, channel)]
except KeyError: except KeyError:
utils.msg(irc, source, 'Error: no such relay %r exists.' % channel) utils.msg(irc, source, 'Error: No such relay %r exists.' % channel)
return return
else: else:
if irc.name in entry['blocked_nets']: if irc.name in entry['blocked_nets']:
utils.msg(irc, source, 'Error: access denied (network is banned from linking to this channel).') utils.msg(irc, source, 'Error: Access denied (network is banned from linking to this channel).')
return return
for link in entry['links']: for link in entry['links']:
if link[0] == irc.name: if link[0] == irc.name:
utils.msg(irc, source, "Error: remote channel '%s%s' is already" utils.msg(irc, source, "Error: Remote channel '%s%s' is already"
" linked here as %r." % (remotenet, " linked here as %r." % (remotenet,
channel, link[1])) channel, link[1]))
return return
@ -858,17 +858,17 @@ def delink(irc, source, args):
try: try:
channel = args[0].lower() channel = args[0].lower()
except IndexError: except IndexError:
utils.msg(irc, source, "Error: not enough arguments. Needs 1-2: channel, remote netname (optional).") utils.msg(irc, source, "Error: Not enough arguments. Needs 1-2: channel, remote netname (optional).")
return return
try: try:
remotenet = args[1].lower() remotenet = args[1].lower()
except IndexError: except IndexError:
remotenet = None remotenet = None
if not utils.isOper(irc, source): if not utils.isOper(irc, source):
utils.msg(irc, source, 'Error: you must be opered in order to complete this operation.') utils.msg(irc, source, 'Error: You must be opered in order to complete this operation.')
return return
if not utils.isChannel(channel): if not utils.isChannel(channel):
utils.msg(irc, source, 'Error: invalid channel %r.' % channel) utils.msg(irc, source, 'Error: Invalid channel %r.' % channel)
return return
entry = findRelay((irc.name, channel)) entry = findRelay((irc.name, channel))
if entry: if entry:
@ -889,7 +889,7 @@ def delink(irc, source, args):
db[entry]['links'].remove((irc.name, channel)) db[entry]['links'].remove((irc.name, channel))
utils.msg(irc, source, 'Done.') utils.msg(irc, source, 'Done.')
else: else:
utils.msg(irc, source, 'Error: no such relay %r.' % channel) utils.msg(irc, source, 'Error: No such relay %r.' % channel)
def initializeAll(irc): def initializeAll(irc):
log.debug('(%s) initializeAll: waiting for utils.started', irc.name) log.debug('(%s) initializeAll: waiting for utils.started', irc.name)
@ -993,9 +993,9 @@ def linkacl(irc, source, args):
Allows blocking / unblocking certain networks from linking to a relay, based on a blacklist. Allows blocking / unblocking certain networks from linking to a relay, based on a blacklist.
LINKACL LIST returns a list of blocked networks for a channel, while the ALLOW and DENY subcommands allow manipulating this blacklist.""" LINKACL LIST returns a list of blocked networks for a channel, while the ALLOW and DENY subcommands allow manipulating this blacklist."""
missingargs = "Error: not enough arguments. Needs 2-3: subcommand (ALLOW/DENY/LIST), channel, remote network (for ALLOW/DENY)." missingargs = "Error: Not enough arguments. Needs 2-3: subcommand (ALLOW/DENY/LIST), channel, remote network (for ALLOW/DENY)."
if not utils.isOper(irc, source): if not utils.isOper(irc, source):
utils.msg(irc, source, 'Error: you must be opered in order to complete this operation.') utils.msg(irc, source, 'Error: You must be opered in order to complete this operation.')
return return
try: try:
cmd = args[0].lower() cmd = args[0].lower()
@ -1004,11 +1004,11 @@ def linkacl(irc, source, args):
utils.msg(irc, source, missingargs) utils.msg(irc, source, missingargs)
return return
if not utils.isChannel(channel): if not utils.isChannel(channel):
utils.msg(irc, source, 'Error: invalid channel %r.' % channel) utils.msg(irc, source, 'Error: Invalid channel %r.' % channel)
return return
relay = findRelay((irc.name, channel)) relay = findRelay((irc.name, channel))
if not relay: if not relay:
utils.msg(irc, source, 'Error: no such relay %r exists.' % channel) utils.msg(irc, source, 'Error: No such relay %r exists.' % channel)
return return
if cmd == 'list': if cmd == 'list':
s = 'Blocked networks for \x02%s\x02: \x02%s\x02' % (channel, ', '.join(db[relay]['blocked_nets']) or '(empty)') s = 'Blocked networks for \x02%s\x02: \x02%s\x02' % (channel, ', '.join(db[relay]['blocked_nets']) or '(empty)')
@ -1027,8 +1027,8 @@ def linkacl(irc, source, args):
try: try:
db[relay]['blocked_nets'].remove(remotenet) db[relay]['blocked_nets'].remove(remotenet)
except KeyError: except KeyError:
utils.msg(irc, source, 'Error: network %r is not on the blacklist for %r.' % (remotenet, channel)) utils.msg(irc, source, 'Error: Network %r is not on the blacklist for %r.' % (remotenet, channel))
else: else:
utils.msg(irc, source, 'Done.') utils.msg(irc, source, 'Done.')
else: else:
utils.msg(irc, source, 'Error: unknown subcommand %r: valid ones are ALLOW, DENY, and LIST.' % cmd) utils.msg(irc, source, 'Error: Unknown subcommand %r: valid ones are ALLOW, DENY, and LIST.' % cmd)