mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-27 21:19:31 +01:00
plugins/bots: change over to irc.error() use
This commit is contained in:
parent
940430b075
commit
289ab78052
@ -15,7 +15,7 @@ def spawnclient(irc, source, args):
|
|||||||
try:
|
try:
|
||||||
nick, ident, host = args[:3]
|
nick, ident, host = args[:3]
|
||||||
except ValueError:
|
except ValueError:
|
||||||
irc.reply("Error: Not enough arguments. Needs 3: nick, user, host.")
|
irc.error("Not enough arguments. Needs 3: nick, user, host.")
|
||||||
return
|
return
|
||||||
irc.proto.spawnClient(nick, ident, host, manipulatable=True)
|
irc.proto.spawnClient(nick, ident, host, manipulatable=True)
|
||||||
|
|
||||||
@ -29,10 +29,10 @@ def quit(irc, source, args):
|
|||||||
try:
|
try:
|
||||||
nick = args[0]
|
nick = args[0]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
irc.reply("Error: Not enough arguments. Needs 1-2: nick, reason (optional).")
|
irc.error("Not enough arguments. Needs 1-2: nick, reason (optional).")
|
||||||
return
|
return
|
||||||
if irc.pseudoclient.uid == irc.nickToUid(nick):
|
if irc.pseudoclient.uid == irc.nickToUid(nick):
|
||||||
irc.reply("Error: Cannot quit the main PyLink PseudoClient!")
|
irc.error("Cannot quit the main PyLink PseudoClient!")
|
||||||
return
|
return
|
||||||
|
|
||||||
u = irc.nickToUid(nick)
|
u = irc.nickToUid(nick)
|
||||||
@ -40,7 +40,7 @@ def quit(irc, source, args):
|
|||||||
quitmsg = ' '.join(args[1:]) or 'Client Quit'
|
quitmsg = ' '.join(args[1:]) or 'Client Quit'
|
||||||
|
|
||||||
if not irc.isManipulatableClient(u):
|
if not irc.isManipulatableClient(u):
|
||||||
irc.reply("Error: Cannot force quit a protected PyLink services client.")
|
irc.error("Cannot force quit a protected PyLink services client.")
|
||||||
return
|
return
|
||||||
|
|
||||||
irc.proto.quit(u, quitmsg)
|
irc.proto.quit(u, quitmsg)
|
||||||
@ -66,21 +66,21 @@ def joinclient(irc, source, args):
|
|||||||
try:
|
try:
|
||||||
clist = args[0]
|
clist = args[0]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
irc.reply("Error: Not enough arguments. Needs 1-2: nick (optional), comma separated list of channels.")
|
irc.error("Not enough arguments. Needs 1-2: nick (optional), comma separated list of channels.")
|
||||||
return
|
return
|
||||||
|
|
||||||
clist = clist.split(',')
|
clist = clist.split(',')
|
||||||
if not clist:
|
if not clist:
|
||||||
irc.reply("Error: No valid channels given.")
|
irc.error("No valid channels given.")
|
||||||
return
|
return
|
||||||
|
|
||||||
if not (irc.isManipulatableClient(u) or irc.getServiceBot(u)):
|
if not (irc.isManipulatableClient(u) or irc.getServiceBot(u)):
|
||||||
irc.reply("Error: Cannot force join a protected PyLink services client.")
|
irc.error("Cannot force join a protected PyLink services client.")
|
||||||
return
|
return
|
||||||
|
|
||||||
for channel in clist:
|
for channel in clist:
|
||||||
if not utils.isChannel(channel):
|
if not utils.isChannel(channel):
|
||||||
irc.reply("Error: Invalid channel name %r." % channel)
|
irc.error("Invalid channel name %r." % channel)
|
||||||
return
|
return
|
||||||
irc.proto.join(u, channel)
|
irc.proto.join(u, channel)
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ def nick(irc, source, args):
|
|||||||
nick = irc.pseudoclient.nick
|
nick = irc.pseudoclient.nick
|
||||||
newnick = args[0]
|
newnick = args[0]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
irc.reply("Error: Not enough arguments. Needs 1-2: nick (optional), newnick.")
|
irc.error("Not enough arguments. Needs 1-2: nick (optional), newnick.")
|
||||||
return
|
return
|
||||||
u = irc.nickToUid(nick)
|
u = irc.nickToUid(nick)
|
||||||
|
|
||||||
@ -113,11 +113,11 @@ def nick(irc, source, args):
|
|||||||
newnick = u
|
newnick = u
|
||||||
|
|
||||||
elif not utils.isNick(newnick):
|
elif not utils.isNick(newnick):
|
||||||
irc.reply('Error: Invalid nickname %r.' % newnick)
|
irc.error('Invalid nickname %r.' % newnick)
|
||||||
return
|
return
|
||||||
|
|
||||||
elif not (irc.isManipulatableClient(u) or irc.getServiceBot(u)):
|
elif not (irc.isManipulatableClient(u) or irc.getServiceBot(u)):
|
||||||
irc.reply("Error: Cannot force nick changes for a protected PyLink services client.")
|
irc.error("Cannot force nick changes for a protected PyLink services client.")
|
||||||
return
|
return
|
||||||
|
|
||||||
irc.proto.nick(u, newnick)
|
irc.proto.nick(u, newnick)
|
||||||
@ -149,22 +149,22 @@ def part(irc, source, args):
|
|||||||
try:
|
try:
|
||||||
clist = args[0]
|
clist = args[0]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
irc.reply("Error: Not enough arguments. Needs 1-2: nick (optional), comma separated list of channels.")
|
irc.error("Not enough arguments. Needs 1-2: nick (optional), comma separated list of channels.")
|
||||||
return
|
return
|
||||||
reason = ' '.join(args[1:])
|
reason = ' '.join(args[1:])
|
||||||
|
|
||||||
clist = clist.split(',')
|
clist = clist.split(',')
|
||||||
if not clist:
|
if not clist:
|
||||||
irc.reply("Error: No valid channels given.")
|
irc.error("No valid channels given.")
|
||||||
return
|
return
|
||||||
|
|
||||||
if not (irc.isManipulatableClient(u) or irc.getServiceBot(u)):
|
if not (irc.isManipulatableClient(u) or irc.getServiceBot(u)):
|
||||||
irc.reply("Error: Cannot force part a protected PyLink services client.")
|
irc.error("Cannot force part a protected PyLink services client.")
|
||||||
return
|
return
|
||||||
|
|
||||||
for channel in clist:
|
for channel in clist:
|
||||||
if not utils.isChannel(channel):
|
if not utils.isChannel(channel):
|
||||||
irc.reply("Error: Invalid channel name %r." % channel)
|
irc.error("Invalid channel name %r." % channel)
|
||||||
return
|
return
|
||||||
irc.proto.part(u, channel, reason)
|
irc.proto.part(u, channel, reason)
|
||||||
|
|
||||||
@ -197,18 +197,18 @@ def msg(irc, source, args):
|
|||||||
target = args[0]
|
target = args[0]
|
||||||
text = ' '.join(args[1:])
|
text = ' '.join(args[1:])
|
||||||
except IndexError:
|
except IndexError:
|
||||||
irc.reply('Error: Not enough arguments. Needs 2-3: source nick (optional), target, text.')
|
irc.error('Not enough arguments. Needs 2-3: source nick (optional), target, text.')
|
||||||
return
|
return
|
||||||
|
|
||||||
if not text:
|
if not text:
|
||||||
irc.reply('Error: No text given.')
|
irc.error('No text given.')
|
||||||
return
|
return
|
||||||
|
|
||||||
if not utils.isChannel(target):
|
if not utils.isChannel(target):
|
||||||
# Convert nick of the message target to a UID, if the target isn't a channel
|
# Convert nick of the message target to a UID, if the target isn't a channel
|
||||||
real_target = irc.nickToUid(target)
|
real_target = irc.nickToUid(target)
|
||||||
if real_target is None: # Unknown target user, if target isn't a valid channel name
|
if real_target is None: # Unknown target user, if target isn't a valid channel name
|
||||||
irc.reply('Error: Unknown user %r.' % target)
|
irc.error('Unknown user %r.' % target)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
real_target = target
|
real_target = target
|
||||||
|
Loading…
Reference in New Issue
Block a user