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:
parent
bc7765b241
commit
2fe9b624e7
@ -16,7 +16,7 @@ def spawnclient(irc, source, args):
|
||||
try:
|
||||
nick, ident, host = args[:3]
|
||||
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
|
||||
irc.proto.spawnClient(irc, nick, ident, host)
|
||||
|
||||
@ -29,13 +29,13 @@ def quit(irc, source, args):
|
||||
try:
|
||||
nick = args[0]
|
||||
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
|
||||
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
|
||||
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.callHooks([u, 'PYLINK_ADMIN_QUIT', {'text': quitmsg, 'parse_as': 'QUIT'}])
|
||||
|
||||
@ -50,7 +50,7 @@ def joinclient(irc, source, args):
|
||||
if not clist:
|
||||
raise 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
|
||||
u = utils.nickToUid(irc, nick)
|
||||
for channel in clist:
|
||||
@ -73,7 +73,7 @@ def nick(irc, source, args):
|
||||
nick = args[0]
|
||||
newnick = args[1]
|
||||
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
|
||||
u = utils.nickToUid(irc, nick)
|
||||
if newnick in ('0', u):
|
||||
@ -95,7 +95,7 @@ def part(irc, source, args):
|
||||
clist = args[1].split(',')
|
||||
reason = ' '.join(args[2:])
|
||||
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
|
||||
u = utils.nickToUid(irc, nick)
|
||||
for channel in clist:
|
||||
@ -117,7 +117,7 @@ def kick(irc, source, args):
|
||||
target = args[2]
|
||||
reason = ' '.join(args[3:])
|
||||
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
|
||||
u = utils.nickToUid(irc, nick) or nick
|
||||
targetu = utils.nickToUid(irc, target)
|
||||
@ -139,11 +139,11 @@ def showuser(irc, source, args):
|
||||
try:
|
||||
target = args[0]
|
||||
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
|
||||
u = utils.nickToUid(irc, target)
|
||||
if u is None:
|
||||
utils.msg(irc, source, 'Error: unknown user %r' % target)
|
||||
utils.msg(irc, source, 'Error: Unknown user %r.' % target)
|
||||
return
|
||||
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))
|
||||
@ -158,10 +158,10 @@ def showchan(irc, source, args):
|
||||
try:
|
||||
channel = args[0].lower()
|
||||
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
|
||||
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
|
||||
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))
|
||||
@ -176,10 +176,10 @@ def mode(irc, source, args):
|
||||
try:
|
||||
modesource, target, modes = args[0], args[1], args[2:]
|
||||
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
|
||||
if not modes:
|
||||
utils.msg(irc, source, "Error: no modes given to set!")
|
||||
utils.msg(irc, source, "Error: No modes given to set!")
|
||||
return
|
||||
parsedmodes = utils.parseModes(irc, target, modes)
|
||||
targetuid = utils.nickToUid(irc, target)
|
||||
@ -205,21 +205,21 @@ def msg(irc, source, args):
|
||||
try:
|
||||
msgsource, target, text = args[0], args[1], ' '.join(args[2:])
|
||||
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
|
||||
sourceuid = utils.nickToUid(irc, msgsource)
|
||||
if not sourceuid:
|
||||
utils.msg(irc, source, 'Error: unknown user %r' % msgsource)
|
||||
utils.msg(irc, source, 'Error: Unknown user %r.' % msgsource)
|
||||
return
|
||||
if not utils.isChannel(target):
|
||||
real_target = utils.nickToUid(irc, target)
|
||||
if real_target is None:
|
||||
utils.msg(irc, source, 'Error: unknown user %r' % target)
|
||||
utils.msg(irc, source, 'Error: Unknown user %r.' % target)
|
||||
return
|
||||
else:
|
||||
real_target = target
|
||||
if not text:
|
||||
utils.msg(irc, source, 'Error: no text given.')
|
||||
utils.msg(irc, source, 'Error: No text given.')
|
||||
return
|
||||
irc.proto.messageClient(irc, sourceuid, real_target, text)
|
||||
irc.callHooks([sourceuid, 'PYLINK_ADMIN_MSG', {'target': real_target, 'text': text, 'parse_as': 'PRIVMSG'}])
|
||||
|
@ -37,7 +37,7 @@ def identify(irc, source, args):
|
||||
log.info("(%s) Successful login to %r by %s.",
|
||||
irc.name, username, utils.getHostmask(irc, source))
|
||||
else:
|
||||
utils.msg(irc, source, 'Incorrect credentials.')
|
||||
utils.msg(irc, source, 'Error: Incorrect credentials.')
|
||||
u = irc.users[source]
|
||||
log.warning("(%s) Failed login to %r from %s.",
|
||||
irc.name, username, utils.getHostmask(irc, source))
|
||||
|
@ -110,7 +110,7 @@ def save(irc, source, args):
|
||||
exportDB()
|
||||
utils.msg(irc, source, 'Done.')
|
||||
else:
|
||||
utils.msg(irc, source, 'Error: you are not authenticated!')
|
||||
utils.msg(irc, source, 'Error: You are not authenticated!')
|
||||
return
|
||||
|
||||
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
|
||||
# messages from.
|
||||
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.' % \
|
||||
irc.users[target].nick, notice=True)
|
||||
return
|
||||
@ -754,16 +754,16 @@ def create(irc, source, args):
|
||||
try:
|
||||
channel = args[0].lower()
|
||||
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
|
||||
if not utils.isChannel(channel):
|
||||
utils.msg(irc, source, 'Error: invalid channel %r.' % channel)
|
||||
utils.msg(irc, source, 'Error: Invalid channel %r.' % channel)
|
||||
return
|
||||
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
|
||||
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
|
||||
db[(irc.name, channel)] = {'claim': [irc.name], 'links': set(), 'blocked_nets': set()}
|
||||
initializeChannel(irc, channel)
|
||||
@ -777,13 +777,13 @@ def destroy(irc, source, args):
|
||||
try:
|
||||
channel = args[0].lower()
|
||||
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
|
||||
if not utils.isChannel(channel):
|
||||
utils.msg(irc, source, 'Error: invalid channel %r.' % channel)
|
||||
utils.msg(irc, source, 'Error: Invalid channel %r.' % channel)
|
||||
return
|
||||
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
|
||||
|
||||
entry = (irc.name, channel)
|
||||
@ -794,7 +794,7 @@ def destroy(irc, source, args):
|
||||
del db[entry]
|
||||
utils.msg(irc, source, 'Done.')
|
||||
else:
|
||||
utils.msg(irc, source, 'Error: no such relay %r exists.' % channel)
|
||||
utils.msg(irc, source, 'Error: No such relay %r exists.' % channel)
|
||||
return
|
||||
|
||||
@utils.add_cmd
|
||||
@ -807,7 +807,7 @@ def link(irc, source, args):
|
||||
channel = args[1].lower()
|
||||
remotenet = args[0].lower()
|
||||
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
|
||||
try:
|
||||
localchan = args[2].lower()
|
||||
@ -815,33 +815,33 @@ def link(irc, source, args):
|
||||
localchan = channel
|
||||
for c in (channel, localchan):
|
||||
if not utils.isChannel(c):
|
||||
utils.msg(irc, source, 'Error: invalid channel %r.' % c)
|
||||
utils.msg(irc, source, 'Error: Invalid channel %r.' % c)
|
||||
return
|
||||
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
|
||||
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
|
||||
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
|
||||
localentry = findRelay((irc.name, localchan))
|
||||
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
|
||||
try:
|
||||
entry = db[(remotenet, channel)]
|
||||
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
|
||||
else:
|
||||
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
|
||||
for link in entry['links']:
|
||||
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,
|
||||
channel, link[1]))
|
||||
return
|
||||
@ -858,17 +858,17 @@ def delink(irc, source, args):
|
||||
try:
|
||||
channel = args[0].lower()
|
||||
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
|
||||
try:
|
||||
remotenet = args[1].lower()
|
||||
except IndexError:
|
||||
remotenet = None
|
||||
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
|
||||
if not utils.isChannel(channel):
|
||||
utils.msg(irc, source, 'Error: invalid channel %r.' % channel)
|
||||
utils.msg(irc, source, 'Error: Invalid channel %r.' % channel)
|
||||
return
|
||||
entry = findRelay((irc.name, channel))
|
||||
if entry:
|
||||
@ -889,7 +889,7 @@ def delink(irc, source, args):
|
||||
db[entry]['links'].remove((irc.name, channel))
|
||||
utils.msg(irc, source, 'Done.')
|
||||
else:
|
||||
utils.msg(irc, source, 'Error: no such relay %r.' % channel)
|
||||
utils.msg(irc, source, 'Error: No such relay %r.' % channel)
|
||||
|
||||
def initializeAll(irc):
|
||||
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.
|
||||
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):
|
||||
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
|
||||
try:
|
||||
cmd = args[0].lower()
|
||||
@ -1004,11 +1004,11 @@ def linkacl(irc, source, args):
|
||||
utils.msg(irc, source, missingargs)
|
||||
return
|
||||
if not utils.isChannel(channel):
|
||||
utils.msg(irc, source, 'Error: invalid channel %r.' % channel)
|
||||
utils.msg(irc, source, 'Error: Invalid channel %r.' % channel)
|
||||
return
|
||||
relay = findRelay((irc.name, channel))
|
||||
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
|
||||
if cmd == 'list':
|
||||
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:
|
||||
db[relay]['blocked_nets'].remove(remotenet)
|
||||
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:
|
||||
utils.msg(irc, source, 'Done.')
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user