Make use of format() in a few more places.

This commit is contained in:
James Vega 2005-02-19 00:22:23 +00:00
parent 5985562a31
commit 21970da9f0

View File

@ -296,7 +296,7 @@ class Channel(callbacks.Plugin):
try: try:
bannedHostmask = irc.state.nickToHostmask(bannedNick) bannedHostmask = irc.state.nickToHostmask(bannedNick)
except KeyError: except KeyError:
irc.error('I haven\'t seen %s.' % bannedNick, Raise=True) irc.error(format('I haven\'t seen %s.', bannedNick), Raise=True)
capability = ircdb.makeChannelCapability(channel, 'op') capability = ircdb.makeChannelCapability(channel, 'op')
def makeBanmask(bannedHostmask, options): def makeBanmask(bannedHostmask, options):
(nick, user, host) = ircutils.splitHostmask(bannedHostmask) (nick, user, host) = ircutils.splitHostmask(bannedHostmask)
@ -350,8 +350,8 @@ class Channel(callbacks.Plugin):
if ircdb.checkCapability(bannedHostmask, capability): if ircdb.checkCapability(bannedHostmask, capability):
self.log.warning('%s tried to ban %q, but both have %s', self.log.warning('%s tried to ban %q, but both have %s',
msg.prefix, bannedHostmask, capability) msg.prefix, bannedHostmask, capability)
irc.error('%s has %s too, you can\'t ban him/her/it.' % irc.error(format('%s has %s too, you can\'t ban him/her/it.',
(bannedNick, capability)) bannedNick, capability))
else: else:
doBan() doBan()
else: else:
@ -372,7 +372,7 @@ class Channel(callbacks.Plugin):
Unbans <hostmask> on <channel>. If <hostmask> is not given, unbans Unbans <hostmask> on <channel>. If <hostmask> is not given, unbans
any hostmask currently banned on <channel> that matches your current any hostmask currently banned on <channel> that matches your current
hostmask. Especially useful for unbanning yourself when you get hostmask. Especially useful for unbanning yourself when you get
unexpectedly (or accidentally) banned from the channel. <channel> is unexpectedly (or accidentally) banned from the channel. <channel> is
only necessary if the message isn't sent in the channel itself. only necessary if the message isn't sent in the channel itself.
""" """
@ -385,8 +385,9 @@ class Channel(callbacks.Plugin):
bans.append(banmask) bans.append(banmask)
if bans: if bans:
irc.queueMsg(ircmsgs.unbans(channel, bans)) irc.queueMsg(ircmsgs.unbans(channel, bans))
irc.replySuccess('All bans on %s matching %s ' irc.replySuccess(format('All bans on %s matching %s '
'have been removed.' % (channel, msg.prefix)) 'have been removed.',
channel, msg.prefix))
else: else:
irc.error('No bans matching %s were found on %s.' % irc.error('No bans matching %s were found on %s.' %
(msg.prefix, channel)) (msg.prefix, channel))
@ -423,21 +424,21 @@ class Channel(callbacks.Plugin):
nick = ircutils.toLower(nick) nick = ircutils.toLower(nick)
replyIrc = self.invites.pop((irc, nick), None) replyIrc = self.invites.pop((irc, nick), None)
if replyIrc is not None: if replyIrc is not None:
replyIrc.error('%s is already in %s.' % (nick, channel)) replyIrc.error(format('%s is already in %s.', nick, channel))
def do401(self, irc, msg): def do401(self, irc, msg):
nick = msg.args[1] nick = msg.args[1]
nick = ircutils.toLower(nick) nick = ircutils.toLower(nick)
replyIrc = self.invites.pop((irc, nick), None) replyIrc = self.invites.pop((irc, nick), None)
if replyIrc is not None: if replyIrc is not None:
replyIrc.error('There is no %s on this network.' % nick) replyIrc.error(format('There is no %s on this network.', nick))
def do504(self, irc, msg): def do504(self, irc, msg):
nick = msg.args[1] nick = msg.args[1]
nick = ircutils.toLower(nick) nick = ircutils.toLower(nick)
replyIrc = self.invites.pop((irc, nick), None) replyIrc = self.invites.pop((irc, nick), None)
if replyirc is not None: if replyirc is not None:
replyIrc.error('There is no %s on this server.' % nick) replyIrc.error(format('There is no %s on this server.', nick))
def lobotomize(self, irc, msg, args, channel): def lobotomize(self, irc, msg, args, channel):
"""[<channel>] """[<channel>]
@ -677,14 +678,14 @@ class Channel(callbacks.Plugin):
L = sorted(c.capabilities) L = sorted(c.capabilities)
irc.reply(' '.join(L)) irc.reply(' '.join(L))
capabilities = wrap(capabilities, ['channel']) capabilities = wrap(capabilities, ['channel'])
def disable(self, irc, msg, args, channel, plugin, command): def disable(self, irc, msg, args, channel, plugin, command):
"""[<channel>] [<plugin>] [<command>] """[<channel>] [<plugin>] [<command>]
If you have the #channel,op capability, this will disable the <command> If you have the #channel,op capability, this will disable the <command>
in <channel>. If <plugin> is provided, <command> will be disabled only in <channel>. If <plugin> is provided, <command> will be disabled only
for that plugin. If only <plugin> is provided, all commands in the for that plugin. If only <plugin> is provided, all commands in the
given plugin will be disabled. <channel> is only necessary if the given plugin will be disabled. <channel> is only necessary if the
message isn't sent in the channel itself. message isn't sent in the channel itself.
""" """
chan = ircdb.channels.getChannel(channel) chan = ircdb.channels.getChannel(channel)
@ -695,15 +696,15 @@ class Channel(callbacks.Plugin):
if plugin.isCommand(command): if plugin.isCommand(command):
s = '-%s.%s' % (plugin.name(), command) s = '-%s.%s' % (plugin.name(), command)
else: else:
failMsg = 'The %s plugin does not have a command called %s.'\ failMsg = format('The %s plugin does not have a command '
% (plugin.name(), command) 'called %s.', plugin.name(), command)
elif command: elif command:
# findCallbackForCommand # findCallbackForCommand
if irc.findCallbackForCommand(command): if irc.findCallbackForCommand(command):
s = '-%s' % command s = '-%s' % command
else: else:
failMsg = 'No plugin or command named %s could be found.'\ failMsg = format('No plugin or command named %s could be '
% (command) 'found.', command)
else: else:
raise callbacks.ArgumentError raise callbacks.ArgumentError
if failMsg: if failMsg:
@ -713,16 +714,16 @@ class Channel(callbacks.Plugin):
ircdb.channels.setChannel(channel, chan) ircdb.channels.setChannel(channel, chan)
irc.replySuccess() irc.replySuccess()
disable = wrap(disable, [('checkChannelCapability', 'op'), disable = wrap(disable, [('checkChannelCapability', 'op'),
optional(('plugin', False)), optional(('plugin', False)),
additional('commandName')]) additional('commandName')])
def enable(self, irc, msg, args, channel, plugin, command): def enable(self, irc, msg, args, channel, plugin, command):
"""[<channel>] [<plugin>] [<command>] """[<channel>] [<plugin>] [<command>]
If you have the #channel,op capability, this will enable the <command> If you have the #channel,op capability, this will enable the <command>
in <channel> if it has been disabled. If <plugin> is provided, in <channel> if it has been disabled. If <plugin> is provided,
<command> will be enabled only for that plugin. If only <plugin> is <command> will be enabled only for that plugin. If only <plugin> is
provided, all commands in the given plugin will be enabled. <channel> provided, all commands in the given plugin will be enabled. <channel>
is only necessary if the message isn't sent in the channel itself. is only necessary if the message isn't sent in the channel itself.
""" """
chan = ircdb.channels.getChannel(channel) chan = ircdb.channels.getChannel(channel)
@ -733,15 +734,15 @@ class Channel(callbacks.Plugin):
if plugin.isCommand(command): if plugin.isCommand(command):
s = '-%s.%s' % (plugin.name(), command) s = '-%s.%s' % (plugin.name(), command)
else: else:
failMsg = 'The %s plugin does not have a command called %s.'\ failMsg = format('The %s plugin does not have a command '
% (plugin.name(), command) 'called %s.', plugin.name(), command)
elif command: elif command:
# findCallbackForCommand # findCallbackForCommand
if irc.findCallbackForCommand(command): if irc.findCallbackForCommand(command):
s = '-%s' % command s = '-%s' % command
else: else:
failMsg = 'No plugin or command named %s could be found.'\ failMsg = format('No plugin or command named %s could be '
% (command) 'found.', command)
else: else:
raise callbacks.ArgumentError raise callbacks.ArgumentError
if failMsg: if failMsg:
@ -754,11 +755,11 @@ class Channel(callbacks.Plugin):
fail.append(s) fail.append(s)
ircdb.channels.setChannel(channel, chan) ircdb.channels.setChannel(channel, chan)
if fail: if fail:
irc.error('%s was not disabled.' % s[1:]) irc.error(format('%s was not disabled.', s[1:]))
else: else:
irc.replySuccess() irc.replySuccess()
enable = wrap(enable, [('checkChannelCapability', 'op'), enable = wrap(enable, [('checkChannelCapability', 'op'),
optional(('plugin', False)), optional(('plugin', False)),
additional('commandName')]) additional('commandName')])
def lobotomies(self, irc, msg, args): def lobotomies(self, irc, msg, args):
@ -772,7 +773,7 @@ class Channel(callbacks.Plugin):
L.append(channel) L.append(channel)
if L: if L:
L.sort() L.sort()
s = 'I\'m currently lobotomized in %s.' % utils.str.commaAndify(L) s = format('I\'m currently lobotomized in %L.', L)
irc.reply(s) irc.reply(s)
else: else:
irc.reply('I\'m not currently lobotomized in any channels.') irc.reply('I\'m not currently lobotomized in any channels.')
@ -792,9 +793,9 @@ class Channel(callbacks.Plugin):
"""Internal message for notifying all the #channel,ops in a channel of """Internal message for notifying all the #channel,ops in a channel of
a given situation.""" a given situation."""
capability = ircdb.makeChannelCapability(channel, 'op') capability = ircdb.makeChannelCapability(channel, 'op')
s = 'Alert to all %s ops: %s' % (channel, s) s = format('Alert to all %s ops: %s', channel, s)
if frm is not None: if frm is not None:
s += ' (from %s)' % frm s += format(' (from %s)', frm)
for nick in irc.state.channels[channel].users: for nick in irc.state.channels[channel].users:
hostmask = irc.state.nickToHostmask(nick) hostmask = irc.state.nickToHostmask(nick)
if ircdb.checkCapability(hostmask, capability): if ircdb.checkCapability(hostmask, capability):