Internationalize Seen, Services, ShrinkUrl, Status, String, and Success

This commit is contained in:
Valentin Lorentz 2010-10-20 09:10:03 +02:00
parent aaa0c480af
commit 371a40e004
18 changed files with 1002 additions and 111 deletions

View File

@ -29,6 +29,8 @@
import supybot.conf as conf
import supybot.registry as registry
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Seen')
def configure(advanced):
# This will be called by supybot to configure this module. advanced is
@ -42,7 +44,7 @@ def configure(advanced):
Seen = conf.registerPlugin('Seen')
# This is where your configuration variables (if any) should go. For example:
# conf.registerGlobalValue(Seen, 'someConfigVariableName',
# registry.Boolean(False, """Help for someConfigVariableName."""))
# registry.Boolean(False, _("""Help for someConfigVariableName.""")))
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:

118
plugins/Seen/messages.pot Normal file
View File

@ -0,0 +1,118 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2010-10-20 08:52+CEST\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: ENCODING\n"
"Generated-By: pygettext.py 1.5\n"
#: plugin.py:203 plugin.py:284
msgid "%s was last seen in %s %s ago: %s"
msgstr ""
#: plugin.py:210
msgid "%s (%s ago)"
msgstr ""
#: plugin.py:212
msgid "%s could be %L"
msgstr ""
#: plugin.py:212
msgid "or"
msgstr ""
#: plugin.py:214
msgid "I haven't seen anyone matching %s."
msgstr ""
#: plugin.py:216 plugin.py:288
msgid "I have not seen %s."
msgstr ""
#: plugin.py:220
#, docstring
msgid ""
"[<channel>] <nick>\n"
"\n"
" Returns the last time <nick> was seen and what <nick> was last seen\n"
" saying. <channel> is only necessary if the message isn't sent on the\n"
" channel itself.\n"
" "
msgstr ""
#: plugin.py:231
#, docstring
msgid ""
"[<channel>] [--user <name>] [<nick>]\n"
"\n"
" Returns the last time <nick> was seen and what <nick> was last seen\n"
" doing. This includes any form of activity, instead of just PRIVMSGs.\n"
" If <nick> isn't specified, returns the last activity seen in\n"
" <channel>. If --user is specified, looks up name in the user database\n"
" and returns the last time user was active in <channel>. <channel> is\n"
" only necessary if the message isn't sent on the channel itself.\n"
" "
msgstr ""
#: plugin.py:261
msgid "Someone was last seen in %s %s ago: %s"
msgstr ""
#: plugin.py:265
msgid "I have never seen anyone."
msgstr ""
#: plugin.py:269
#, docstring
msgid ""
"[<channel>]\n"
"\n"
" Returns the last thing said in <channel>. <channel> is only necessary\n"
" if the message isn't sent in the channel itself.\n"
" "
msgstr ""
#: plugin.py:292
#, docstring
msgid ""
"[<channel>] <name>\n"
"\n"
" Returns the last time <name> was seen and what <name> was last seen\n"
" saying. This looks up <name> in the user seen database, which means\n"
" that it could be any nick recognized as user <name> that was seen.\n"
" <channel> is only necessary if the message isn't sent in the channel\n"
" itself.\n"
" "
msgstr ""
#: plugin.py:305
#, docstring
msgid ""
"[<channel>] <nick>\n"
"\n"
" Returns the messages since <nick> last left the channel.\n"
" "
msgstr ""
#: plugin.py:312
msgid "You must be in %s to use this command."
msgstr ""
#: plugin.py:333
msgid "I couldn't find in my history of %s messages where %r last left the %s"
msgstr ""
#: plugin.py:342
msgid "Either %s didn't leave, or no messages were sent while %s was gone."
msgstr ""

View File

@ -42,6 +42,8 @@ import supybot.ircmsgs as ircmsgs
import supybot.plugins as plugins
import supybot.ircutils as ircutils
import supybot.callbacks as callbacks
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Seen')
class IrcStringAndIntDict(utils.InsensitivePreservingDict):
def key(self, x):
@ -198,21 +200,22 @@ class Seen(callbacks.Plugin):
if len(results) == 1:
(nick, info) = results[0]
(when, said) = info
irc.reply(format('%s was last seen in %s %s ago: %s',
irc.reply(format(_('%s was last seen in %s %s ago: %s'),
nick, channel,
utils.timeElapsed(time.time()-when), said))
elif len(results) > 1:
L = []
for (nick, info) in results:
(when, said) = info
L.append(format('%s (%s ago)', nick,
L.append(format(_('%s (%s ago)'), nick,
utils.timeElapsed(time.time()-when)))
irc.reply(format('%s could be %L', name, (L, 'or')))
irc.reply(format(_('%s could be %L'), name, (L, _('or'))))
else:
irc.reply(format('I haven\'t seen anyone matching %s.', name))
irc.reply(format(_('I haven\'t seen anyone matching %s.'), name))
except KeyError:
irc.reply(format('I have not seen %s.', name))
irc.reply(format(_('I have not seen %s.'), name))
@internationalizeDocstring
def seen(self, irc, msg, args, channel, name):
"""[<channel>] <nick>
@ -223,6 +226,7 @@ class Seen(callbacks.Plugin):
self._seen(irc, channel, name)
seen = wrap(seen, ['channel', 'nick'])
@internationalizeDocstring
def any(self, irc, msg, args, channel, optlist, name):
"""[<channel>] [--user <name>] [<nick>]
@ -254,12 +258,13 @@ class Seen(callbacks.Plugin):
db = self.db
try:
(when, said) = db.seen(channel, '<last>')
irc.reply(format('Someone was last seen in %s %s ago: %s',
irc.reply(format(_('Someone was last seen in %s %s ago: %s'),
channel, utils.timeElapsed(time.time()-when),
said))
except KeyError:
irc.reply('I have never seen anyone.')
irc.reply(_('I have never seen anyone.'))
@internationalizeDocstring
def last(self, irc, msg, args, channel):
"""[<channel>]
@ -276,12 +281,13 @@ class Seen(callbacks.Plugin):
db = self.db
try:
(when, said) = db.seen(channel, user.id)
irc.reply(format('%s was last seen in %s %s ago: %s',
irc.reply(format(_('%s was last seen in %s %s ago: %s'),
user.name, channel,
utils.timeElapsed(time.time()-when), said))
except KeyError:
irc.reply(format('I have not seen %s.', user.name))
irc.reply(format(_('I have not seen %s.'), user.name))
@internationalizeDocstring
def user(self, irc, msg, args, channel, user):
"""[<channel>] <name>
@ -294,6 +300,7 @@ class Seen(callbacks.Plugin):
self._user(irc, channel, user)
user = wrap(user, ['channel', 'otherUser'])
@internationalizeDocstring
def since(self, irc, msg, args, channel, nick):
"""[<channel>] <nick>
@ -302,7 +309,8 @@ class Seen(callbacks.Plugin):
if nick is None:
nick = msg.nick
if nick not in irc.state.channels[channel].users:
irc.error(format('You must be in %s to use this command.', channel))
irc.error(format(_('You must be in %s to use this command.'),
channel))
return
end = None # By default, up until the most recent message.
for (i, m) in utils.seq.renumerate(irc.state.history):
@ -322,8 +330,8 @@ class Seen(callbacks.Plugin):
ircutils.strEqual(m.args[0], channel):
break
else: # I never use this; it only kicks in when the for loop exited normally.
irc.error(format('I couldn\'t find in my history of %s messages '
'where %r last left the %s',
irc.error(format(_('I couldn\'t find in my history of %s messages '
'where %r last left the %s'),
len(irc.state.history), nick, channel))
return
msgs = [m for m in irc.state.history[i:end]
@ -331,8 +339,8 @@ class Seen(callbacks.Plugin):
if msgs:
irc.reply(format('%L', map(ircmsgs.prettyPrint, msgs)))
else:
irc.reply(format('Either %s didn\'t leave, '
'or no messages were sent while %s was gone.', nick, nick))
irc.reply(format(_('Either %s didn\'t leave, '
'or no messages were sent while %s was gone.'), nick, nick))
since = wrap(since, ['channel', additional('nick')])
Class = Seen

View File

@ -31,11 +31,13 @@
import supybot.conf as conf
import supybot.ircutils as ircutils
import supybot.registry as registry
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Services')
def registerNick(nick, password=''):
p = conf.supybot.plugins.Services.Nickserv.get('password')
h = 'Determines what password the bot will use with NickServ when ' \
'identifying as %s.' % nick
h = _('Determines what password the bot will use with NickServ when ' \
'identifying as %s.') % nick
v = conf.registerGlobalValue(p, nick,
registry.String(password, h, private=True))
if password:
@ -44,10 +46,10 @@ def registerNick(nick, password=''):
def configure(advanced):
from supybot.questions import expect, anything, something, yn, getpass
conf.registerPlugin('Services', True)
nick = something('What is your registered nick?')
password = something('What is your password for that nick?')
chanserv = something('What is your ChanServ named?', default='ChanServ')
nickserv = something('What is your NickServ named?', default='NickServ')
nick = something(_('What is your registered nick?'))
password = something(_('What is your password for that nick?'))
chanserv = something(_('What is your ChanServ named?'), default='ChanServ')
nickserv = something(_('What is your NickServ named?'), default='NickServ')
conf.supybot.plugins.Services.nicks.setValue([nick])
conf.supybot.plugins.Services.NickServ.setValue(nickserv)
registerNick(nick, password)
@ -65,42 +67,42 @@ class ValidNickSet(conf.ValidNicks):
Services = conf.registerPlugin('Services')
conf.registerGlobalValue(Services, 'nicks',
ValidNickSet([], """Determines what nicks the bot will use with
services."""))
ValidNickSet([], _("""Determines what nicks the bot will use with
services.""")))
class Networks(registry.SpaceSeparatedSetOfStrings):
List = ircutils.IrcSet
conf.registerGlobalValue(Services, 'disabledNetworks',
Networks(['QuakeNet'], """Determines what networks this plugin will be
disabled on."""))
Networks(_('QuakeNet').split(), _("""Determines what networks this plugin
will be disabled on.""")))
conf.registerGlobalValue(Services, 'noJoinsUntilIdentified',
registry.Boolean(False, """Determines whether the bot will not join any
registry.Boolean(False, _("""Determines whether the bot will not join any
channels until it is identified. This may be useful, for instances, if
you have a vhost that isn't set until you're identified, or if you're
joining +r channels that won't allow you to join unless you identify."""))
joining +r channels that won't allow you to join unless you identify.""")))
conf.registerGlobalValue(Services, 'ghostDelay',
registry.PositiveInteger(60, """Determines how many seconds the bot will
wait between successive GHOST attempts."""))
registry.PositiveInteger(60, _("""Determines how many seconds the bot will
wait between successive GHOST attempts.""")))
conf.registerGlobalValue(Services, 'NickServ',
ValidNickOrEmptyString('', """Determines what nick the 'NickServ' service
has."""))
ValidNickOrEmptyString('', _("""Determines what nick the 'NickServ' service
has.""")))
conf.registerGroup(Services.NickServ, 'password')
conf.registerGlobalValue(Services, 'ChanServ',
ValidNickOrEmptyString('', """Determines what nick the 'ChanServ' service
has."""))
ValidNickOrEmptyString('', _("""Determines what nick the 'ChanServ' service
has.""")))
conf.registerChannelValue(Services.ChanServ, 'password',
registry.String('', """Determines what password the bot will use with
ChanServ.""", private=True))
registry.String('', _("""Determines what password the bot will use with
ChanServ."""), private=True))
conf.registerChannelValue(Services.ChanServ, 'op',
registry.Boolean(False, """Determines whether the bot will request to get
opped by the ChanServ when it joins the channel."""))
registry.Boolean(False, _("""Determines whether the bot will request to get
opped by the ChanServ when it joins the channel.""")))
conf.registerChannelValue(Services.ChanServ, 'halfop',
registry.Boolean(False, """Determines whether the bot will request to get
half-opped by the ChanServ when it joins the channel."""))
registry.Boolean(False, _("""Determines whether the bot will request to get
half-opped by the ChanServ when it joins the channel.""")))
conf.registerChannelValue(Services.ChanServ, 'voice',
registry.Boolean(False, """Determines whether the bot will request to get
voiced by the ChanServ when it joins the channel."""))
registry.Boolean(False, _("""Determines whether the bot will request to get
voiced by the ChanServ when it joins the channel.""")))
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:

View File

@ -0,0 +1,235 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2010-10-20 08:55+CEST\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: ENCODING\n"
"Generated-By: pygettext.py 1.5\n"
#: config.py:39
msgid "Determines what password the bot will use with NickServ when identifying as %s."
msgstr ""
#: config.py:49
msgid "What is your registered nick?"
msgstr ""
#: config.py:50
msgid "What is your password for that nick?"
msgstr ""
#: config.py:51
msgid "What is your ChanServ named?"
msgstr ""
#: config.py:52
msgid "What is your NickServ named?"
msgstr ""
#: config.py:70
msgid ""
"Determines what nicks the bot will use with\n"
" services."
msgstr ""
#: config.py:77
msgid ""
"Determines what networks this plugin\n"
" will be disabled on."
msgstr ""
#: config.py:77
msgid "QuakeNet"
msgstr ""
#: config.py:81
msgid ""
"Determines whether the bot will not join any\n"
" channels until it is identified. This may be useful, for instances, if\n"
" you have a vhost that isn't set until you're identified, or if you're\n"
" joining +r channels that won't allow you to join unless you identify."
msgstr ""
#: config.py:86
msgid ""
"Determines how many seconds the bot will\n"
" wait between successive GHOST attempts."
msgstr ""
#: config.py:89
msgid ""
"Determines what nick the 'NickServ' service\n"
" has."
msgstr ""
#: config.py:93
msgid ""
"Determines what nick the 'ChanServ' service\n"
" has."
msgstr ""
#: config.py:96
msgid ""
"Determines what password the bot will use with\n"
" ChanServ."
msgstr ""
#: config.py:99
msgid ""
"Determines whether the bot will request to get\n"
" opped by the ChanServ when it joins the channel."
msgstr ""
#: config.py:102
msgid ""
"Determines whether the bot will request to get\n"
" half-opped by the ChanServ when it joins the channel."
msgstr ""
#: config.py:105
msgid ""
"Determines whether the bot will request to get\n"
" voiced by the ChanServ when it joins the channel."
msgstr ""
#: plugin.py:48
#, docstring
msgid ""
"This plugin handles dealing with Services on networks that provide them.\n"
" Basically, you should use the \"password\" command to tell the bot a nick to\n"
" identify with and what password to use to identify with that nick. You can\n"
" use the password command multiple times if your bot has multiple nicks\n"
" registered. Also, be sure to configure the NickServ and ChanServ\n"
" configuration variables to match the NickServ and ChanServ nicks on your\n"
" network. Other commands such as identify, op, etc. should not be\n"
" necessary if the bot is properly configured."
msgstr ""
#: plugin.py:396
msgid "You must set supybot.plugins.Services.ChanServ before I'm able to send the %s command."
msgstr ""
#: plugin.py:402
#, docstring
msgid ""
"[<channel>]\n"
"\n"
" Attempts to get opped by ChanServ in <channel>. <channel> is only\n"
" necessary if the message isn't sent in the channel itself.\n"
" "
msgstr ""
#: plugin.py:408
msgid "I'm already opped in %s."
msgstr ""
#: plugin.py:415
#, docstring
msgid ""
"[<channel>]\n"
"\n"
" Attempts to get voiced by ChanServ in <channel>. <channel> is only\n"
" necessary if the message isn't sent in the channel itself.\n"
" "
msgstr ""
#: plugin.py:421
msgid "I'm already voiced in %s."
msgstr ""
#: plugin.py:438
#, docstring
msgid ""
"[<channel>]\n"
"\n"
" Attempts to get unbanned by ChanServ in <channel>. <channel> is only\n"
" necessary if the message isn't sent in the channel itself, but chances\n"
" are, if you need this command, you're not sending it in the channel\n"
" itself.\n"
" "
msgstr ""
#: plugin.py:459
#, docstring
msgid ""
"[<channel>]\n"
"\n"
" Attempts to get invited by ChanServ to <channel>. <channel> is only\n"
" necessary if the message isn't sent in the channel itself, but chances\n"
" are, if you need this command, you're not sending it in the channel\n"
" itself.\n"
" "
msgstr ""
#: plugin.py:480
#, docstring
msgid ""
"takes no arguments\n"
"\n"
" Identifies with NickServ using the current nick.\n"
" "
msgstr ""
#: plugin.py:489
msgid "I don't have a configured password for my current nick."
msgstr ""
#: plugin.py:492
msgid "You must set supybot.plugins.Services.NickServ before I'm able to do identify."
msgstr ""
#: plugin.py:498
#, docstring
msgid ""
"[<nick>]\n"
"\n"
" Ghosts the bot's given nick and takes it. If no nick is given,\n"
" ghosts the bot's configured nick and takes it.\n"
" "
msgstr ""
#: plugin.py:507
msgid "I cowardly refuse to ghost myself."
msgstr ""
#: plugin.py:512
msgid "You must set supybot.plugins.Services.NickServ before I'm able to ghost a nick."
msgstr ""
#: plugin.py:518
#, docstring
msgid ""
"<nick> [<password>]\n"
"\n"
" Sets the NickServ password for <nick> to <password>. If <password> is\n"
" not given, removes <nick> from the configured nicks.\n"
" "
msgstr ""
#: plugin.py:528
msgid "That nick was not configured with a password."
msgstr ""
#: plugin.py:539
#, docstring
msgid ""
"takes no arguments\n"
"\n"
" Returns the nicks that this plugin is configured to identify and ghost\n"
" with.\n"
" "
msgstr ""
#: plugin.py:549
msgid "I'm not currently configured for any nicks."
msgstr ""

View File

@ -40,7 +40,10 @@ import supybot.ircmsgs as ircmsgs
import supybot.ircutils as ircutils
import supybot.schedule as schedule
import supybot.callbacks as callbacks
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Services')
@internationalizeDocstring
class Services(callbacks.Plugin):
"""This plugin handles dealing with Services on networks that provide them.
Basically, you should use the "password" command to tell the bot a nick to
@ -390,10 +393,11 @@ class Services(callbacks.Plugin):
'supybot.plugins.Services.ChanServ before '
'I can send commands to ChanServ.', command)
else:
irc.error('You must set supybot.plugins.Services.ChanServ '
'before I\'m able to send the %s command.' % command,
irc.error(_('You must set supybot.plugins.Services.ChanServ '
'before I\'m able to send the %s command.') % command,
Raise=True)
@internationalizeDocstring
def op(self, irc, msg, args, channel):
"""[<channel>]
@ -401,11 +405,12 @@ class Services(callbacks.Plugin):
necessary if the message isn't sent in the channel itself.
"""
if irc.nick in irc.state.channels[channel].ops:
irc.error(format('I\'m already opped in %s.', channel))
irc.error(format(_('I\'m already opped in %s.'), channel))
else:
self._chanservCommand(irc, channel, 'op')
op = wrap(op, [('checkChannelCapability', 'op'), 'inChannel'])
@internationalizeDocstring
def voice(self, irc, msg, args, channel):
"""[<channel>]
@ -413,7 +418,7 @@ class Services(callbacks.Plugin):
necessary if the message isn't sent in the channel itself.
"""
if irc.nick in irc.state.channels[channel].voices:
irc.error(format('I\'m already voiced in %s.', channel))
irc.error(format(_('I\'m already voiced in %s.'), channel))
else:
self._chanservCommand(irc, channel, 'voice')
voice = wrap(voice, [('checkChannelCapability', 'op'), 'inChannel'])
@ -428,6 +433,7 @@ class Services(callbacks.Plugin):
self._chanservCommand(irc, channel, 'unban', log=True)
# Success log in doChanservNotice.
@internationalizeDocstring
def unban(self, irc, msg, args, channel):
"""[<channel>]
@ -448,6 +454,7 @@ class Services(callbacks.Plugin):
self.log.info('%s is +i, attempting ChanServ invite %s.', channel, on)
self._chanservCommand(irc, channel, 'invite', log=True)
@internationalizeDocstring
def invite(self, irc, msg, args, channel):
"""[<channel>]
@ -468,6 +475,7 @@ class Services(callbacks.Plugin):
self.log.info('Joining %s, invited by ChanServ %s.', channel, on)
irc.queueMsg(networkGroup.channels.join(channel))
@internationalizeDocstring
def identify(self, irc, msg, args):
"""takes no arguments
@ -478,13 +486,14 @@ class Services(callbacks.Plugin):
self._doIdentify(irc, irc.nick)
irc.replySuccess()
else:
irc.error('I don\'t have a configured password for '
'my current nick.')
irc.error(_('I don\'t have a configured password for '
'my current nick.'))
else:
irc.error('You must set supybot.plugins.Services.NickServ before '
'I\'m able to do identify.')
irc.error(_('You must set supybot.plugins.Services.NickServ before '
'I\'m able to do identify.'))
identify = wrap(identify, [('checkCapability', 'admin')])
@internationalizeDocstring
def ghost(self, irc, msg, args, nick):
"""[<nick>]
@ -495,15 +504,16 @@ class Services(callbacks.Plugin):
if not nick:
nick = self._getNick()
if ircutils.strEqual(nick, irc.nick):
irc.error('I cowardly refuse to ghost myself.')
irc.error(_('I cowardly refuse to ghost myself.'))
else:
self._doGhost(irc, nick=nick)
irc.replySuccess()
else:
irc.error('You must set supybot.plugins.Services.NickServ before '
'I\'m able to ghost a nick.')
irc.error(_('You must set supybot.plugins.Services.NickServ before '
'I\'m able to ghost a nick.'))
ghost = wrap(ghost, [('checkCapability', 'admin'), additional('nick')])
@internationalizeDocstring
def password(self, irc, msg, args, nick, password):
"""<nick> [<password>]
@ -515,7 +525,7 @@ class Services(callbacks.Plugin):
self.registryValue('nicks').remove(nick)
irc.replySuccess()
except KeyError:
irc.error('That nick was not configured with a password.')
irc.error(_('That nick was not configured with a password.'))
return
else:
self.registryValue('nicks').add(nick)
@ -524,6 +534,7 @@ class Services(callbacks.Plugin):
password = wrap(password, [('checkCapability', 'admin'),
'private', 'nick', 'text'])
@internationalizeDocstring
def nicks(self, irc, msg, args):
"""takes no arguments
@ -535,7 +546,7 @@ class Services(callbacks.Plugin):
utils.sortBy(ircutils.toLower, L)
irc.reply(format('%L', L))
else:
irc.reply('I\'m not currently configured for any nicks.')
irc.reply(_('I\'m not currently configured for any nicks.'))
nicks = wrap(nicks, [('checkCapability', 'admin')])

View File

@ -30,13 +30,15 @@
import supybot.conf as conf
import supybot.registry as registry
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('ShrinkUrl')
def configure(advanced):
from supybot.questions import output, expect, anything, something, yn
conf.registerPlugin('ShrinkUrl', True)
if yn("""This plugin offers a snarfer that will go retrieve a shorter
if yn(_("""This plugin offers a snarfer that will go retrieve a shorter
version of long URLs that are sent to the channel. Would you
like this snarfer to be enabled?""", default=False):
like this snarfer to be enabled?"""), default=False):
conf.supybot.plugins.ShrinkUrl.shrinkSnarfer.setValue(True)
class ShrinkService(registry.OnlySomeStrings):
@ -66,34 +68,34 @@ class ShrinkCycle(registry.SpaceSeparatedListOfStrings):
ShrinkUrl = conf.registerPlugin('ShrinkUrl')
conf.registerChannelValue(ShrinkUrl, 'shrinkSnarfer',
registry.Boolean(False, """Determines whether the
registry.Boolean(False, _("""Determines whether the
shrink snarfer is enabled. This snarfer will watch for URLs in the
channel, and if they're sufficiently long (as determined by
supybot.plugins.ShrinkUrl.minimumLength) it will post a
smaller URL from either ln-s.net or tinyurl.com, as denoted in
supybot.plugins.ShrinkUrl.default."""))
supybot.plugins.ShrinkUrl.default.""")))
conf.registerChannelValue(ShrinkUrl.shrinkSnarfer, 'showDomain',
registry.Boolean(True, """Determines whether the snarfer will show the
domain of the URL being snarfed along with the shrunken URL."""))
registry.Boolean(True, _("""Determines whether the snarfer will show the
domain of the URL being snarfed along with the shrunken URL.""")))
conf.registerChannelValue(ShrinkUrl, 'minimumLength',
registry.PositiveInteger(48, """The minimum length a URL must be before
the bot will shrink it."""))
registry.PositiveInteger(48, _("""The minimum length a URL must be before
the bot will shrink it.""")))
conf.registerChannelValue(ShrinkUrl, 'nonSnarfingRegexp',
registry.Regexp(None, """Determines what URLs are to be snarfed; URLs
registry.Regexp(None, _("""Determines what URLs are to be snarfed; URLs
matching the regexp given will not be snarfed. Give the empty string if
you have no URLs that you'd like to exclude from being snarfed."""))
you have no URLs that you'd like to exclude from being snarfed.""")))
conf.registerChannelValue(ShrinkUrl, 'outFilter',
registry.Boolean(False, """Determines whether the bot will shrink the URLs
of outgoing messages if those URLs are longer than
supybot.plugins.ShrinkUrl.minimumLength."""))
registry.Boolean(False, _("""Determines whether the bot will shrink the
URLs of outgoing messages if those URLs are longer than
supybot.plugins.ShrinkUrl.minimumLength.""")))
conf.registerChannelValue(ShrinkUrl, 'default',
ShrinkService('ln', """Determines what website the bot will use when
shrinking a URL."""))
ShrinkService('ln', _("""Determines what website the bot will use when
shrinking a URL.""")))
conf.registerGlobalValue(ShrinkUrl, 'bold',
registry.Boolean(True, """Determines whether this plugin will bold certain
portions of its replies."""))
registry.Boolean(True, _("""Determines whether this plugin will bold
certain portions of its replies.""")))
conf.registerChannelValue(ShrinkUrl, 'serviceRotation',
ShrinkCycle([], """If set to a non-empty value, specifies the list of
services to rotate through for the shrinkSnarfer and outFilter."""))
ShrinkCycle([], _("""If set to a non-empty value, specifies the list of
services to rotate through for the shrinkSnarfer and outFilter.""")))
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:

View File

@ -0,0 +1,119 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2010-10-20 08:55+CEST\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: ENCODING\n"
"Generated-By: pygettext.py 1.5\n"
#: config.py:39
msgid ""
"This plugin offers a snarfer that will go retrieve a shorter\n"
" version of long URLs that are sent to the channel. Would you\n"
" like this snarfer to be enabled?"
msgstr ""
#: config.py:45 config.py:49
#, docstring
msgid "Valid values include 'ln', 'tiny', 'xrl', and 'x0'."
msgstr ""
#: config.py:71
msgid ""
"Determines whether the\n"
" shrink snarfer is enabled. This snarfer will watch for URLs in the\n"
" channel, and if they're sufficiently long (as determined by\n"
" supybot.plugins.ShrinkUrl.minimumLength) it will post a\n"
" smaller URL from either ln-s.net or tinyurl.com, as denoted in\n"
" supybot.plugins.ShrinkUrl.default."
msgstr ""
#: config.py:78
msgid ""
"Determines whether the snarfer will show the\n"
" domain of the URL being snarfed along with the shrunken URL."
msgstr ""
#: config.py:81
msgid ""
"The minimum length a URL must be before\n"
" the bot will shrink it."
msgstr ""
#: config.py:84
msgid ""
"Determines what URLs are to be snarfed; URLs\n"
" matching the regexp given will not be snarfed. Give the empty string if\n"
" you have no URLs that you'd like to exclude from being snarfed."
msgstr ""
#: config.py:88
msgid ""
"Determines whether the bot will shrink the\n"
" URLs of outgoing messages if those URLs are longer than\n"
" supybot.plugins.ShrinkUrl.minimumLength."
msgstr ""
#: config.py:92
msgid ""
"Determines what website the bot will use when\n"
" shrinking a URL."
msgstr ""
#: config.py:95
msgid ""
"Determines whether this plugin will bold\n"
" certain portions of its replies."
msgstr ""
#: config.py:98
msgid ""
"If set to a non-empty value, specifies the list of\n"
" services to rotate through for the shrinkSnarfer and outFilter."
msgstr ""
#: plugin.py:169
#, docstring
msgid ""
"<url>\n"
"\n"
" Returns an ln-s.net version of <url>.\n"
" "
msgstr ""
#: plugin.py:194
#, docstring
msgid ""
"<url>\n"
"\n"
" Returns a TinyURL.com version of <url>\n"
" "
msgstr ""
#: plugin.py:222
#, docstring
msgid ""
"<url>\n"
"\n"
" Returns an xrl.us version of <url>.\n"
" "
msgstr ""
#: plugin.py:248
#, docstring
msgid ""
"<url>\n"
"\n"
" Returns an x0.no version of <url>.\n"
" "
msgstr ""

View File

@ -37,6 +37,8 @@ import supybot.ircmsgs as ircmsgs
import supybot.plugins as plugins
import supybot.ircutils as ircutils
import supybot.callbacks as callbacks
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('ShrinkUrl')
class CdbShrunkenUrlDB(object):
def __init__(self, filename):
@ -162,6 +164,7 @@ class ShrinkUrl(callbacks.PluginRegexp):
else:
raise ShrinkError, text
@internationalizeDocstring
def ln(self, irc, msg, args, url):
"""<url>
@ -186,6 +189,7 @@ class ShrinkUrl(callbacks.PluginRegexp):
self.db.set('tiny', url, text)
return text
@internationalizeDocstring
def tiny(self, irc, msg, args, url):
"""<url>
@ -213,6 +217,7 @@ class ShrinkUrl(callbacks.PluginRegexp):
self.db.set('xrl', quotedurl, text)
return text
@internationalizeDocstring
def xrl(self, irc, msg, args, url):
"""<url>
@ -238,6 +243,7 @@ class ShrinkUrl(callbacks.PluginRegexp):
self.db.set('x0', url, text)
return text
@internationalizeDocstring
def x0(self, irc, msg, args, url):
"""<url>

View File

@ -29,6 +29,8 @@
import supybot.conf as conf
import supybot.registry as registry
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Status')
def configure(advanced):
# This will be called by supybot to configure this module. advanced is
@ -41,13 +43,13 @@ def configure(advanced):
Status = conf.registerPlugin('Status')
conf.registerGroup(Status, 'cpu')
conf.registerChannelValue(Status.cpu, 'children',
registry.Boolean(True, """Determines whether the cpu command will list the
time taken by children as well as the bot's process."""))
registry.Boolean(True, _("""Determines whether the cpu command will list
the time taken by children as well as the bot's process.""")))
conf.registerChannelValue(Status.cpu, 'threads',
registry.Boolean(False, """Determines whether the cpu command will provide
the number of threads spawned and active."""))
registry.Boolean(False, _("""Determines whether the cpu command will
provide the number of threads spawned and active.""")))
conf.registerChannelValue(Status.cpu, 'memory',
registry.Boolean(True, """Determines whether the cpu command will report
the amount of memory being used by the bot."""))
registry.Boolean(True, _("""Determines whether the cpu command will report
the amount of memory being used by the bot.""")))
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:

155
plugins/Status/messages.pot Normal file
View File

@ -0,0 +1,155 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2010-10-20 09:05+CEST\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: ENCODING\n"
"Generated-By: pygettext.py 1.5\n"
#: config.py:46
msgid ""
"Determines whether the cpu command will list\n"
" the time taken by children as well as the bot's process."
msgstr ""
#: config.py:49
msgid ""
"Determines whether the cpu command will\n"
" provide the number of threads spawned and active."
msgstr ""
#: config.py:52
msgid ""
"Determines whether the cpu command will report\n"
" the amount of memory being used by the bot."
msgstr ""
#: plugin.py:71
#, docstring
msgid ""
"takes no arguments\n"
"\n"
" Returns the status of the bot.\n"
" "
msgstr ""
#: plugin.py:80
msgid "%s as %L"
msgstr ""
#: plugin.py:81
msgid "I am connected to %L."
msgstr ""
#: plugin.py:83
msgid "I am currently in code profiling mode."
msgstr ""
#: plugin.py:89
#, docstring
msgid ""
"takes no arguments\n"
"\n"
" Returns the current threads that are active.\n"
" "
msgstr ""
#: plugin.py:95
msgid "I have spawned %n; %n %b still currently active: %L."
msgstr ""
#: plugin.py:103
#, docstring
msgid ""
"takes no arguments\n"
"\n"
" Returns some interesting network-related statistics.\n"
" "
msgstr ""
#: plugin.py:111
msgid "an indeterminate amount of time"
msgstr ""
#: plugin.py:112
msgid "I have received %s messages for a total of %s bytes. I have sent %s messages for a total of %s bytes. I have been connected to %s for %s."
msgstr ""
#: plugin.py:121
#, docstring
msgid ""
"takes no arguments\n"
"\n"
" Returns some interesting CPU-related statistics on the bot.\n"
" "
msgstr ""
#: plugin.py:131
msgid "My children have taken %.2f seconds of user time and %.2f seconds of system time for a total of %.2f seconds of CPU time. "
msgstr ""
#: plugin.py:138
msgid "I have taken %.2f seconds of user time and %.2f seconds of system time, for a total of %.2f seconds of CPU time. %s"
msgstr ""
#: plugin.py:160
msgid "Unable to run ps command."
msgstr ""
#: plugin.py:166
msgid " I'm taking up %s kB of memory."
msgstr ""
#: plugin.py:174
#, docstring
msgid ""
"takes no arguments\n"
"\n"
" Returns some interesting command-related statistics.\n"
" "
msgstr ""
#: plugin.py:184
msgid "I offer a total of %n in %n. I have processed %n."
msgstr ""
#: plugin.py:193
#, docstring
msgid ""
"takes no arguments\n"
"\n"
" Returns a list of the commands offered by the bot.\n"
" "
msgstr ""
#: plugin.py:207
#, docstring
msgid ""
"takes no arguments\n"
"\n"
" Returns the amount of time the bot has been running.\n"
" "
msgstr ""
#: plugin.py:211
msgid "I have been running for %s."
msgstr ""
#: plugin.py:218
#, docstring
msgid ""
"takes no arguments\n"
"\n"
" Returns the server the bot is on.\n"
" "
msgstr ""

View File

@ -39,6 +39,8 @@ import supybot.utils as utils
import supybot.world as world
from supybot.commands import *
import supybot.callbacks as callbacks
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Status')
class Status(callbacks.Plugin):
def __init__(self, irc):
@ -64,6 +66,7 @@ class Status(callbacks.Plugin):
def do001(self, irc, msg):
self.connected[irc] = time.time()
@internationalizeDocstring
def status(self, irc, msg, args):
"""takes no arguments
@ -74,13 +77,14 @@ class Status(callbacks.Plugin):
networks.setdefault(Irc.network, []).append(Irc.nick)
networks = networks.items()
networks.sort()
networks = [format('%s as %L', net, nicks) for (net,nicks) in networks]
L = [format('I am connected to %L.', networks)]
networks = [format(_('%s as %L'), net, nicks) for (net,nicks) in networks]
L = [format(_('I am connected to %L.'), networks)]
if world.profiling:
L.append('I am currently in code profiling mode.')
L.append(_('I am currently in code profiling mode.'))
irc.reply(' '.join(L))
status = wrap(status)
@internationalizeDocstring
def threads(self, irc, msg, args):
"""takes no arguments
@ -88,12 +92,13 @@ class Status(callbacks.Plugin):
"""
threads = [t.getName() for t in threading.enumerate()]
threads.sort()
s = format('I have spawned %n; %n %b still currently active: %L.',
s = format(_('I have spawned %n; %n %b still currently active: %L.'),
(world.threadsSpawned, 'thread'),
(len(threads), 'thread'), len(threads), threads)
irc.reply(s)
threads = wrap(threads)
@internationalizeDocstring
def net(self, irc, msg, args):
"""takes no arguments
@ -103,14 +108,15 @@ class Status(callbacks.Plugin):
elapsed = time.time() - self.connected[irc.getRealIrc()]
timeElapsed = utils.timeElapsed(elapsed)
except KeyError:
timeElapsed = 'an indeterminate amount of time'
irc.reply('I have received %s messages for a total of %s bytes. '
timeElapsed = _('an indeterminate amount of time')
irc.reply(_('I have received %s messages for a total of %s bytes. '
'I have sent %s messages for a total of %s bytes. '
'I have been connected to %s for %s.' %
'I have been connected to %s for %s.') %
(self.recvdMsgs, self.recvdBytes,
self.sentMsgs, self.sentBytes, irc.server, timeElapsed))
net = wrap(net)
@internationalizeDocstring
def cpu(self, irc, msg, args):
"""takes no arguments
@ -122,16 +128,16 @@ class Status(callbacks.Plugin):
timeRunning = now - world.startedAt
if self.registryValue('cpu.children', target) and \
user+system < timeRunning+1: # Fudge for FPU inaccuracies.
children = 'My children have taken %.2f seconds of user time ' \
'and %.2f seconds of system time ' \
'for a total of %.2f seconds of CPU time. ' % \
children = _('My children have taken %.2f seconds of user time '
'and %.2f seconds of system time '
'for a total of %.2f seconds of CPU time. ') % \
(childUser, childSystem, childUser+childSystem)
else:
children = ''
activeThreads = threading.activeCount()
response = 'I have taken %.2f seconds of user time and %.2f seconds ' \
'of system time, for a total of %.2f seconds of CPU ' \
'time. %s' % (user, system, user + system, children)
response = _('I have taken %.2f seconds of user time and %.2f seconds '
'of system time, for a total of %.2f seconds of CPU '
'time. %s') % (user, system, user + system, children)
if self.registryValue('cpu.threads', target):
response += format('I have spawned %n; I currently have %i still '
'running.',
@ -151,18 +157,19 @@ class Status(callbacks.Plugin):
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
except OSError:
irc.error('Unable to run ps command.', Raise=True)
(out, _) = inst.communicate()
irc.error(_('Unable to run ps command.'), Raise=True)
(out, foo) = inst.communicate()
inst.wait()
mem = out.splitlines()[1]
elif sys.platform.startswith('netbsd'):
mem = '%s kB' % os.stat('/proc/%s/mem' % pid)[7]
response += ' I\'m taking up %s kB of memory.' % mem
response += _(' I\'m taking up %s kB of memory.') % mem
except Exception:
self.log.exception('Uncaught exception in cpu.memory:')
irc.reply(utils.str.normalizeWhitespace(response))
cpu = wrap(cpu)
@internationalizeDocstring
def cmd(self, irc, msg, args):
"""takes no arguments
@ -174,13 +181,14 @@ class Status(callbacks.Plugin):
if isinstance(cb, callbacks.Plugin):
callbacksPlugin += 1
commands += len(cb.listCommands())
s = format('I offer a total of %n in %n. I have processed %n.',
s = format(_('I offer a total of %n in %n. I have processed %n.'),
(commands, 'command'),
(callbacksPlugin, 'command-based', 'plugin'),
(world.commandsProcessed, 'command'))
irc.reply(s)
cmd = wrap(cmd)
@internationalizeDocstring
def commands(self, irc, msg, args):
"""takes no arguments
@ -194,16 +202,18 @@ class Status(callbacks.Plugin):
irc.reply(format('%L', sorted(commands)))
commands = wrap(commands)
@internationalizeDocstring
def uptime(self, irc, msg, args):
"""takes no arguments
Returns the amount of time the bot has been running.
"""
response = 'I have been running for %s.' % \
response = _('I have been running for %s.') % \
utils.timeElapsed(time.time() - world.startedAt)
irc.reply(response)
uptime = wrap(uptime)
@internationalizeDocstring
def server(self, irc, msg, args):
"""takes no arguments

View File

@ -29,6 +29,8 @@
import supybot.conf as conf
import supybot.registry as registry
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('String')
def configure(advanced):
# This will be called by supybot to configure this module. advanced is
@ -42,13 +44,13 @@ def configure(advanced):
String = conf.registerPlugin('String')
conf.registerGroup(String, 'levenshtein')
conf.registerGlobalValue(String.levenshtein, 'max',
registry.PositiveInteger(256, """Determines the maximum size of a string
registry.PositiveInteger(256, _("""Determines the maximum size of a string
given to the levenshtein command. The levenshtein command uses an O(m*n)
algorithm, which means that with strings of length 256, it can take 1.5
seconds to finish; with strings of length 384, though, it can take 4
seconds to finish, and with strings of much larger lengths, it takes more
and more time. Using nested commands, strings can get quite large, hence
this variable, to limit the size of arguments passed to the levenshtein
command."""))
command.""")))
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:

168
plugins/String/messages.pot Normal file
View File

@ -0,0 +1,168 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2010-10-20 09:08+CEST\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: ENCODING\n"
"Generated-By: pygettext.py 1.5\n"
#: config.py:47
msgid ""
"Determines the maximum size of a string\n"
" given to the levenshtein command. The levenshtein command uses an O(m*n)\n"
" algorithm, which means that with strings of length 256, it can take 1.5\n"
" seconds to finish; with strings of length 384, though, it can take 4\n"
" seconds to finish, and with strings of much larger lengths, it takes more\n"
" and more time. Using nested commands, strings can get quite large, hence\n"
" this variable, to limit the size of arguments passed to the levenshtein\n"
" command."
msgstr ""
#: plugin.py:46
#, docstring
msgid ""
"<letter>\n"
"\n"
" Returns the 8-bit value of <letter>.\n"
" "
msgstr ""
#: plugin.py:55
#, docstring
msgid ""
"<number>\n"
"\n"
" Returns the character associated with the 8-bit value <number>\n"
" "
msgstr ""
#: plugin.py:62
msgid "That number doesn't map to an 8-bit character."
msgstr ""
#: plugin.py:67
#, docstring
msgid ""
"<encoding> <text>\n"
"\n"
" Returns an encoded form of the given text; the valid encodings are\n"
" available in the documentation of the Python codecs module:\n"
" <http://docs.python.org/library/codecs.html#standard-encodings>.\n"
" "
msgstr ""
#: plugin.py:76 plugin.py:90
msgid "encoding"
msgstr ""
#: plugin.py:81
#, docstring
msgid ""
"<encoding> <text>\n"
"\n"
" Returns an un-encoded form of the given text; the valid encodings are\n"
" available in the documentation of the Python codecs module:\n"
" <http://docs.python.org/library/codecs.html#standard-encodings>.\n"
" "
msgstr ""
#: plugin.py:92
msgid "base64 string"
msgstr ""
#: plugin.py:93
msgid "Base64 strings must be a multiple of 4 in length, padded with '=' if necessary."
msgstr ""
#: plugin.py:99
#, docstring
msgid ""
"<string1> <string2>\n"
"\n"
" Returns the levenshtein distance (also known as the \"edit distance\"\n"
" between <string1> and <string2>)\n"
" "
msgstr ""
#: plugin.py:106
msgid "Levenshtein distance is a complicated algorithm, try it with some smaller inputs."
msgstr ""
#: plugin.py:114
#, docstring
msgid ""
"<string> [<length>]\n"
"\n"
" Returns the Soundex hash to a given length. The length defaults to\n"
" 4, since that's the standard length for a soundex hash. For unlimited\n"
" length, use 0.\n"
" "
msgstr ""
#: plugin.py:125
#, docstring
msgid ""
"<text>\n"
"\n"
" Returns the length of <text>.\n"
" "
msgstr ""
#: plugin.py:134
#, docstring
msgid ""
"<regexp> <text>\n"
"\n"
" If <regexp> is of the form m/regexp/flags, returns the portion of\n"
" <text> that matches the regexp. If <regexp> is of the form\n"
" s/regexp/replacement/flags, returns the result of applying such a\n"
" regexp to <text>.\n"
" "
msgstr ""
#: plugin.py:146
msgid "You probably don't want to match the empty string."
msgstr ""
#: plugin.py:156
#, docstring
msgid ""
"<password> <text>\n"
"\n"
" Returns <text> XOR-encrypted with <password>. See\n"
" http://www.yoe.org/developer/xor.html for information about XOR\n"
" encryption.\n"
" "
msgstr ""
#: plugin.py:169
#, docstring
msgid ""
"<text>\n"
"\n"
" Returns the md5 hash of a given string. Read\n"
" http://www.rsasecurity.com/rsalabs/faq/3-6-6.html for more information\n"
" about md5.\n"
" "
msgstr ""
#: plugin.py:180
#, docstring
msgid ""
"<text>\n"
"\n"
" Returns the SHA hash of a given string. Read\n"
" http://www.secure-hash-algorithm-md5-sha-1.co.uk/ for more information\n"
" about SHA.\n"
" "
msgstr ""

View File

@ -36,9 +36,12 @@ from supybot.commands import *
import supybot.plugins as plugins
import supybot.ircutils as ircutils
import supybot.callbacks as callbacks
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('String')
class String(callbacks.Plugin):
@internationalizeDocstring
def ord(self, irc, msg, args, letter):
"""<letter>
@ -47,6 +50,7 @@ class String(callbacks.Plugin):
irc.reply(str(ord(letter)))
ord = wrap(ord, ['letter'])
@internationalizeDocstring
def chr(self, irc, msg, args, i):
"""<number>
@ -55,9 +59,10 @@ class String(callbacks.Plugin):
try:
irc.reply(chr(i))
except ValueError:
irc.error('That number doesn\'t map to an 8-bit character.')
irc.error(_('That number doesn\'t map to an 8-bit character.'))
chr = wrap(chr, ['int'])
@internationalizeDocstring
def encode(self, irc, msg, args, encoding, text):
"""<encoding> <text>
@ -68,9 +73,10 @@ class String(callbacks.Plugin):
try:
irc.reply(text.encode(encoding).rstrip('\n'))
except LookupError:
irc.errorInvalid('encoding', encoding)
irc.errorInvalid(_('encoding'), encoding)
encode = wrap(encode, ['something', 'text'])
@internationalizeDocstring
def decode(self, irc, msg, args, encoding, text):
"""<encoding> <text>
@ -81,13 +87,14 @@ class String(callbacks.Plugin):
try:
irc.reply(text.decode(encoding).encode('utf-8'))
except LookupError:
irc.errorInvalid('encoding', encoding)
irc.errorInvalid(_('encoding'), encoding)
except binascii.Error:
irc.errorInvalid('base64 string',
s='Base64 strings must be a multiple of 4 in '
'length, padded with \'=\' if necessary.')
irc.errorInvalid(_('base64 string'),
s=_('Base64 strings must be a multiple of 4 in '
'length, padded with \'=\' if necessary.'))
decode = wrap(decode, ['something', 'text'])
@internationalizeDocstring
def levenshtein(self, irc, msg, args, s1, s2):
"""<string1> <string2>
@ -96,12 +103,13 @@ class String(callbacks.Plugin):
"""
max = self.registryValue('levenshtein.max')
if len(s1) > max or len(s2) > max:
irc.error('Levenshtein distance is a complicated algorithm, try '
'it with some smaller inputs.')
irc.error(_('Levenshtein distance is a complicated algorithm, try '
'it with some smaller inputs.'))
else:
irc.reply(str(utils.str.distance(s1, s2)))
levenshtein = wrap(levenshtein, ['something', 'text'])
@internationalizeDocstring
def soundex(self, irc, msg, args, text, length):
"""<string> [<length>]
@ -112,6 +120,7 @@ class String(callbacks.Plugin):
irc.reply(utils.str.soundex(text, length))
soundex = wrap(soundex, ['somethingWithoutSpaces', additional('int', 4)])
@internationalizeDocstring
def len(self, irc, msg, args, text):
"""<text>
@ -120,6 +129,7 @@ class String(callbacks.Plugin):
irc.reply(str(len(text)))
len = wrap(len, ['text'])
@internationalizeDocstring
def re(self, irc, msg, args, ff, text):
"""<regexp> <text>
@ -133,7 +143,7 @@ class String(callbacks.Plugin):
else:
f = lambda s: ff.search(s) and ff.search(s).group(0) or ''
if f('') and len(f(' ')) > len(f(''))+1: # Matches the empty string.
s = 'You probably don\'t want to match the empty string.'
s = _('You probably don\'t want to match the empty string.')
irc.error(s)
else:
irc.reply(f(text))
@ -141,6 +151,7 @@ class String(callbacks.Plugin):
first('regexpMatcher', 'regexpReplacer'),
'text'])
@internationalizeDocstring
def xor(self, irc, msg, args, password, text):
"""<password> <text>
@ -153,6 +164,7 @@ class String(callbacks.Plugin):
irc.reply(''.join(ret))
xor = wrap(xor, ['something', 'text'])
@internationalizeDocstring
def md5(self, irc, msg, args, text):
"""<text>
@ -163,6 +175,7 @@ class String(callbacks.Plugin):
irc.reply(utils.crypt.md5(text).hexdigest())
md5 = wrap(md5, ['text'])
@internationalizeDocstring
def sha(self, irc, msg, args, text):
"""<text>

View File

@ -29,6 +29,8 @@
import supybot.conf as conf
import supybot.registry as registry
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Success')
def configure(advanced):
# This will be called by supybot to configure this module. advanced is
@ -42,10 +44,10 @@ def configure(advanced):
Success = conf.registerPlugin('Success')
# This is where your configuration variables (if any) should go. For example:
# conf.registerGlobalValue(Success, 'someConfigVariableName',
# registry.Boolean(False, """Help for someConfigVariableName."""))
# registry.Boolean(False, _("""Help for someConfigVariableName.""")))
conf.registerChannelValue(conf.supybot.plugins.Success, 'prefixNick',
registry.Boolean(True, """Determines whether the bot will prefix the nick
of the user giving an invalid command to the success response."""))
registry.Boolean(True, _("""Determines whether the bot will prefix the nick
of the user giving an invalid command to the success response.""")))
# vim:set shiftwidth=4 softtabstop=8 expandtab textwidth=78

View File

@ -0,0 +1,33 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2010-10-20 09:09+CEST\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: ENCODING\n"
"Generated-By: pygettext.py 1.5\n"
#: config.py:49
msgid ""
"Determines whether the bot will prefix the nick\n"
" of the user giving an invalid command to the success response."
msgstr ""
#: plugin.py:39
#, docstring
msgid ""
"This plugin was written initially to work with MoobotFactoids, the two\n"
" of them to provide a similar-to-moobot-and-blootbot interface for factoids.\n"
" Basically, it replaces the standard 'The operation succeeded.' messages\n"
" with messages kept in a database, able to give more personable\n"
" responses."
msgstr ""

View File

@ -31,7 +31,10 @@ import supybot.conf as conf
from supybot.commands import *
import supybot.plugins as plugins
import supybot.ircutils as ircutils
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Success')
@internationalizeDocstring
class Success(plugins.ChannelIdDatabasePlugin):
"""This plugin was written initially to work with MoobotFactoids, the two
of them to provide a similar-to-moobot-and-blootbot interface for factoids.