Internationalize Nickometer, Praise, Protector, Quote, and QuoteGrabs

This commit is contained in:
Valentin Lorentz 2010-10-17 18:37:13 +02:00
parent ffc609a299
commit 029c0cbe80
15 changed files with 392 additions and 38 deletions

View File

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

View File

@ -0,0 +1,31 @@
# 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-17 18:28+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:84
#, docstring
msgid ""
"[<nick>]\n"
"\n"
" Tells you how lame said nick is. If <nick> is not given, uses the\n"
" nick of the person giving the command.\n"
" "
msgstr ""
#: plugin.py:226
msgid "The \"lame nick-o-meter\" reading for \"%s\" is %s%%."
msgstr ""

View File

@ -53,6 +53,8 @@ import string
import supybot.callbacks as callbacks import supybot.callbacks as callbacks
from supybot.commands import wrap, additional from supybot.commands import wrap, additional
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Nickometer')
def slowExponent(x): def slowExponent(x):
return 1.3 * x * (1 - math.atan(x / 6.0) * 2 / math.pi) return 1.3 * x * (1 - math.atan(x / 6.0) * 2 / math.pi)
@ -77,6 +79,7 @@ class Nickometer(callbacks.Plugin):
self.log.debug('%s lameness points awarded: %s', damage, reason) self.log.debug('%s lameness points awarded: %s', damage, reason)
return damage return damage
@internationalizeDocstring
def nickometer(self, irc, msg, args, nick): def nickometer(self, irc, msg, args, nick):
"""[<nick>] """[<nick>]
@ -220,7 +223,7 @@ class Nickometer(callbacks.Plugin):
# if it's above 99.9%, show as many digits as is interesting # if it's above 99.9%, show as many digits as is interesting
score_string=re.sub('(99\\.9*\\d|\\.\\d).*','\\1',`percentage`) score_string=re.sub('(99\\.9*\\d|\\.\\d).*','\\1',`percentage`)
irc.reply('The "lame nick-o-meter" reading for "%s" is %s%%.' % irc.reply(_('The "lame nick-o-meter" reading for "%s" is %s%%.') %
(originalNick, score_string)) (originalNick, score_string))
self.log.debug('Calculated lameness score for %s as %s ' self.log.debug('Calculated lameness score for %s as %s '

View File

@ -29,6 +29,8 @@
import supybot.conf as conf import supybot.conf as conf
import supybot.registry as registry import supybot.registry as registry
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Praise')
def configure(advanced): def configure(advanced):
# This will be called by supybot to configure this module. advanced is # This will be called by supybot to configure this module. advanced is
@ -42,10 +44,10 @@ def configure(advanced):
Praise = conf.registerPlugin('Praise') Praise = conf.registerPlugin('Praise')
# This is where your configuration variables (if any) should go. For example: # This is where your configuration variables (if any) should go. For example:
# conf.registerGlobalValue(Praise, 'someConfigVariableName', # conf.registerGlobalValue(Praise, 'someConfigVariableName',
# registry.Boolean(False, """Help for someConfigVariableName.""")) # registry.Boolean(False, _("""Help for someConfigVariableName.""")))
conf.registerChannelValue(Praise, 'showIds', conf.registerChannelValue(Praise, 'showIds',
registry.Boolean(False, """Determines whether the bot will show the ids of registry.Boolean(False, _("""Determines whether the bot will show the ids of
a praise when the praise is given.""")) a praise when the praise is given.""")))
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:

View File

@ -0,0 +1,60 @@
# 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-17 18:33+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 show the ids of\n"
" a praise when the praise is given."
msgstr ""
#: plugin.py:40
#, docstring
msgid ""
"Praise is a plugin for ... well, praising things. Feel free to add\n"
" your own flavor to it by customizing what praises it gives. Use \"praise\n"
" add <text>\" to add new ones, making sure to include \"$who\" in <text> where\n"
" you want to insert the thing being praised.\n"
" "
msgstr ""
#: plugin.py:54
msgid "Praises must contain $who."
msgstr ""
#: plugin.py:58
#, docstring
msgid ""
"[<channel>] [<id>] <who|what> [for <reason>]\n"
"\n"
" Praises <who|what> (for <reason>, if given). If <id> is given, uses\n"
" that specific praise. <channel> is only necessary if the message isn't\n"
" sent in the channel itself.\n"
" "
msgstr ""
#: plugin.py:74
msgid "There is no praise with id #%i."
msgstr ""
#: plugin.py:79
msgid "There are no praises in my database for %s."
msgstr ""
#: plugin.py:87
msgid " for "
msgstr ""

View File

@ -32,7 +32,10 @@ import re
from supybot.commands import * from supybot.commands import *
import supybot.plugins as plugins import supybot.plugins as plugins
import supybot.ircutils as ircutils import supybot.ircutils as ircutils
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Praise')
@internationalizeDocstring
class Praise(plugins.ChannelIdDatabasePlugin): class Praise(plugins.ChannelIdDatabasePlugin):
"""Praise is a plugin for ... well, praising things. Feel free to add """Praise is a plugin for ... well, praising things. Feel free to add
your own flavor to it by customizing what praises it gives. Use "praise your own flavor to it by customizing what praises it gives. Use "praise
@ -48,8 +51,9 @@ class Praise(plugins.ChannelIdDatabasePlugin):
def addValidator(self, irc, text): def addValidator(self, irc, text):
if '$who' not in text: if '$who' not in text:
irc.error('Praises must contain $who.', Raise=True) irc.error(_('Praises must contain $who.'), Raise=True)
@internationalizeDocstring
def praise(self, irc, msg, args, channel, id, text): def praise(self, irc, msg, args, channel, id, text):
"""[<channel>] [<id>] <who|what> [for <reason>] """[<channel>] [<id>] <who|what> [for <reason>]
@ -67,20 +71,20 @@ class Praise(plugins.ChannelIdDatabasePlugin):
try: try:
praise = self.db.get(channel, id) praise = self.db.get(channel, id)
except KeyError: except KeyError:
irc.error(format('There is no praise with id #%i.', id)) irc.error(format(_('There is no praise with id #%i.'), id))
return return
else: else:
praise = self.db.random(channel) praise = self.db.random(channel)
if not praise: if not praise:
irc.error(format('There are no praises in my database ' \ irc.error(format(_('There are no praises in my database ' \
'for %s.', channel)) 'for %s.'), channel))
return return
text = self._replaceFirstPerson(praise.text, msg.nick) text = self._replaceFirstPerson(praise.text, msg.nick)
reason = self._replaceFirstPerson(reason, msg.nick) reason = self._replaceFirstPerson(reason, msg.nick)
target = self._replaceFirstPerson(target, msg.nick) target = self._replaceFirstPerson(target, msg.nick)
text = text.replace('$who', target) text = text.replace('$who', target)
if reason: if reason:
text += ' for ' + reason text += _(' for ') + reason
if self.registryValue('showIds', channel): if self.registryValue('showIds', channel):
text += format(' (#%i)', praise.id) text += format(' (#%i)', praise.id)
irc.reply(text, action=True) irc.reply(text, action=True)

View File

@ -30,6 +30,8 @@
import supybot.conf as conf import supybot.conf as conf
import supybot.ircutils as ircutils import supybot.ircutils as ircutils
import supybot.registry as registry import supybot.registry as registry
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Protector')
def configure(advanced): def configure(advanced):
# This will be called by supybot to configure this module. advanced is # This will be called by supybot to configure this module. advanced is
@ -42,17 +44,17 @@ def configure(advanced):
Protector = conf.registerPlugin('Protector') Protector = conf.registerPlugin('Protector')
conf.registerChannelValue(Protector, 'enable', conf.registerChannelValue(Protector, 'enable',
registry.Boolean(True, """Determines whether this plugin is enabled in a registry.Boolean(True, _("""Determines whether this plugin is enabled in a
given channel.""")) given channel.""")))
class ImmuneNicks(conf.ValidNicks): class ImmuneNicks(conf.ValidNicks):
List = ircutils.IrcSet List = ircutils.IrcSet
conf.registerChannelValue(Protector, 'immune', conf.registerChannelValue(Protector, 'immune',
ImmuneNicks([], """Determines what nicks the bot will consider to ImmuneNicks([], _("""Determines what nicks the bot will consider to
be immune from enforcement. These nicks will not even have their actions be immune from enforcement. These nicks will not even have their actions
watched by this plugin. In general, only the ChanServ for this network watched by this plugin. In general, only the ChanServ for this network
will be in this list.""")) will be in this list.""")))

View File

@ -0,0 +1,31 @@
# 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-17 18:34+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 whether this plugin is enabled in a\n"
" given channel."
msgstr ""
#: config.py:54
msgid ""
"Determines what nicks the bot will consider to\n"
" be immune from enforcement. These nicks will not even have their actions\n"
" watched by this plugin. In general, only the ChanServ for this network\n"
" will be in this list."
msgstr ""

View File

@ -32,6 +32,8 @@ import supybot.ircdb as ircdb
import supybot.ircmsgs as ircmsgs import supybot.ircmsgs as ircmsgs
import supybot.ircutils as ircutils import supybot.ircutils as ircutils
import supybot.callbacks as callbacks import supybot.callbacks as callbacks
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Protector')
class Protector(callbacks.Plugin): class Protector(callbacks.Plugin):
def isImmune(self, irc, msg): def isImmune(self, irc, msg):

View File

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

View File

@ -0,0 +1,31 @@
# 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-17 18:34+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:38
#, docstring
msgid ""
"[<channel>]\n"
"\n"
" Returns a random quote from <channel>. <channel> is only necessary if\n"
" the message isn't sent in the channel itself.\n"
" "
msgstr ""
#: plugin.py:47
msgid "I have no quotes in my database for %s."
msgstr ""

View File

@ -29,8 +29,11 @@
from supybot.commands import * from supybot.commands import *
import supybot.plugins as plugins import supybot.plugins as plugins
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Quote')
class Quote(plugins.ChannelIdDatabasePlugin): class Quote(plugins.ChannelIdDatabasePlugin):
@internationalizeDocstring
def random(self, irc, msg, args, channel): def random(self, irc, msg, args, channel):
"""[<channel>] """[<channel>]
@ -41,7 +44,7 @@ class Quote(plugins.ChannelIdDatabasePlugin):
if quote: if quote:
irc.reply(self.showRecord(quote)) irc.reply(self.showRecord(quote))
else: else:
irc.error('I have no quotes in my database for %s.' % channel) irc.error(_('I have no quotes in my database for %s.') % channel)
random = wrap(random, ['channeldb']) random = wrap(random, ['channeldb'])
Class = Quote Class = Quote

View File

@ -29,6 +29,8 @@
import supybot.conf as conf import supybot.conf as conf
import supybot.registry as registry import supybot.registry as registry
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('QuoteGrabs')
def configure(advanced): def configure(advanced):
# This will be called by supybot to configure this module. advanced is # This will be called by supybot to configure this module. advanced is
@ -42,24 +44,24 @@ def configure(advanced):
QuoteGrabs = conf.registerPlugin('QuoteGrabs') QuoteGrabs = conf.registerPlugin('QuoteGrabs')
# This is where your configuration variables (if any) should go. For example: # This is where your configuration variables (if any) should go. For example:
# conf.registerGlobalValue(QuoteGrabs, 'someConfigVariableName', # conf.registerGlobalValue(QuoteGrabs, 'someConfigVariableName',
# registry.Boolean(False, """Help for someConfigVariableName.""")) # registry.Boolean(False, _("""Help for someConfigVariableName.""")))
conf.registerChannelValue(conf.supybot.plugins.QuoteGrabs, 'randomGrabber', conf.registerChannelValue(conf.supybot.plugins.QuoteGrabs, 'randomGrabber',
registry.Boolean(False, """Determines whether the bot will randomly grab registry.Boolean(False, _("""Determines whether the bot will randomly grab
possibly-suitable quotes on occasion. The suitability of a given message possibly-suitable quotes on occasion. The suitability of a given message
is determined by ...""")) is determined by ...""")))
conf.registerChannelValue(conf.supybot.plugins.QuoteGrabs.randomGrabber, conf.registerChannelValue(conf.supybot.plugins.QuoteGrabs.randomGrabber,
'averageTimeBetweenGrabs', 'averageTimeBetweenGrabs',
registry.PositiveInteger(864000, """Determines about how many seconds, on registry.PositiveInteger(864000, _("""Determines about how many seconds, on
average, should elapse between random grabs. This is only an average average, should elapse between random grabs. This is only an average
value; grabs can happen from any time after half this time until never, value; grabs can happen from any time after half this time until never,
although that's unlikely to occur.""")) although that's unlikely to occur.""")))
conf.registerChannelValue(conf.supybot.plugins.QuoteGrabs.randomGrabber, conf.registerChannelValue(conf.supybot.plugins.QuoteGrabs.randomGrabber,
'minimumWords', registry.PositiveInteger(3, """Determines the minimum 'minimumWords', registry.PositiveInteger(3, _("""Determines the minimum
number of words in a message for it to be considered for random number of words in a message for it to be considered for random
grabbing.""")) grabbing.""")))
conf.registerChannelValue(conf.supybot.plugins.QuoteGrabs.randomGrabber, conf.registerChannelValue(conf.supybot.plugins.QuoteGrabs.randomGrabber,
'minimumCharacters', registry.PositiveInteger(8, """Determines the 'minimumCharacters', registry.PositiveInteger(8, _("""Determines the
minimum number of characters in a message for it to be considered for minimum number of characters in a message for it to be considered for
random grabbing.""")) random grabbing.""")))
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:

View File

@ -0,0 +1,170 @@
# 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-17 18:36+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 randomly grab\n"
" possibly-suitable quotes on occasion. The suitability of a given message\n"
" is determined by ..."
msgstr ""
#: config.py:54
msgid ""
"Determines about how many seconds, on\n"
" average, should elapse between random grabs. This is only an average\n"
" value; grabs can happen from any time after half this time until never,\n"
" although that's unlikely to occur."
msgstr ""
#: config.py:59
msgid ""
"Determines the minimum\n"
" number of words in a message for it to be considered for random\n"
" grabbing."
msgstr ""
#: config.py:63
msgid ""
"Determines the\n"
" minimum number of characters in a message for it to be considered for\n"
" random grabbing."
msgstr ""
#: plugin.py:57
msgid "%s (Said by: %s; grabbed by %s at %t)"
msgstr ""
#: plugin.py:210
#, docstring
msgid "Add the help for \"@help QuoteGrabs\" here."
msgstr ""
#: plugin.py:249
#, docstring
msgid ""
"[<channel>] <nick>\n"
"\n"
" Grabs a quote from <channel> by <nick> for the quotegrabs table.\n"
" <channel> is only necessary if the message isn't sent in the channel\n"
" itself.\n"
" "
msgstr ""
#: plugin.py:262
msgid "You can't quote grab yourself."
msgstr ""
#: plugin.py:269
msgid "I couldn't find a proper message to grab."
msgstr ""
#: plugin.py:274
#, docstring
msgid ""
"[<channel>] <number>\n"
"\n"
" Removes the grab <number> (the last by default) on <channel>.\n"
" <channel> is only necessary if the message isn't sent in the channel\n"
" itself.\n"
" "
msgstr ""
#: plugin.py:285
msgid "Nothing to ungrab."
msgstr ""
#: plugin.py:287
msgid "Invalid grab number."
msgstr ""
#: plugin.py:292
#, docstring
msgid ""
"[<channel>] <nick>\n"
"\n"
" Returns <nick>'s latest quote grab in <channel>. <channel> is only\n"
" necessary if the message isn't sent in the channel itself.\n"
" "
msgstr ""
#: plugin.py:300
msgid "I couldn't find a matching quotegrab for %s."
msgstr ""
#: plugin.py:306
#, docstring
msgid ""
"[<channel>] <nick>\n"
"\n"
" Returns a list of shortened quotes that have been grabbed for <nick>\n"
" as well as the id of each quote. These ids can be used to get the\n"
" full quote. <channel> is only necessary if the message isn't sent in\n"
" the channel itself.\n"
" "
msgstr ""
#: plugin.py:323
msgid "I couldn't find any quotegrabs for %s."
msgstr ""
#: plugin.py:329
#, docstring
msgid ""
"[<channel>] [<nick>]\n"
"\n"
" Returns a randomly grabbed quote, optionally choosing only from those\n"
" quotes grabbed for <nick>. <channel> is only necessary if the message\n"
" isn't sent in the channel itself.\n"
" "
msgstr ""
#: plugin.py:339
msgid "Couldn't get a random quote for that nick."
msgstr ""
#: plugin.py:341
msgid "Couldn't get a random quote. Are there any grabbed quotes in the database?"
msgstr ""
#: plugin.py:347
#, docstring
msgid ""
"[<channel>] <id>\n"
"\n"
" Return the quotegrab with the given <id>. <channel> is only necessary\n"
" if the message isn't sent in the channel itself.\n"
" "
msgstr ""
#: plugin.py:355
msgid "No quotegrab for id %s"
msgstr ""
#: plugin.py:361
#, docstring
msgid ""
"[<channel>] <text>\n"
"\n"
" Searches for <text> in a quote. <channel> is only necessary if the\n"
" message isn't sent in the channel itself.\n"
" "
msgstr ""
#: plugin.py:376
msgid "No quotegrabs matching %s"
msgstr ""

View File

@ -40,6 +40,8 @@ import supybot.ircmsgs as ircmsgs
import supybot.plugins as plugins import supybot.plugins as plugins
import supybot.ircutils as ircutils import supybot.ircutils as ircutils
import supybot.callbacks as callbacks import supybot.callbacks as callbacks
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('QuoteGrabs')
class QuoteGrabsRecord(dbi.Record): class QuoteGrabsRecord(dbi.Record):
__fields__ = [ __fields__ = [
@ -52,7 +54,7 @@ class QuoteGrabsRecord(dbi.Record):
def __str__(self): def __str__(self):
grabber = plugins.getUserName(self.grabber) grabber = plugins.getUserName(self.grabber)
return format('%s (Said by: %s; grabbed by %s at %t)', return format(_('%s (Said by: %s; grabbed by %s at %t)'),
self.text, self.hostmask, grabber, self.at) self.text, self.hostmask, grabber, self.at)
class SqliteQuoteGrabsDB(object): class SqliteQuoteGrabsDB(object):
@ -242,6 +244,7 @@ class QuoteGrabs(callbacks.Plugin):
s = 'jots down a new quote for %s' % msg.nick s = 'jots down a new quote for %s' % msg.nick
irc.reply(s, action=True, prefixNick=False) irc.reply(s, action=True, prefixNick=False)
@internationalizeDocstring
def grab(self, irc, msg, args, channel, nick): def grab(self, irc, msg, args, channel, nick):
"""[<channel>] <nick> """[<channel>] <nick>
@ -256,16 +259,17 @@ class QuoteGrabs(callbacks.Plugin):
if chan is None: if chan is None:
raise callbacks.ArgumentError raise callbacks.ArgumentError
if ircutils.nickEqual(nick, msg.nick): if ircutils.nickEqual(nick, msg.nick):
irc.error('You can\'t quote grab yourself.', Raise=True) irc.error(_('You can\'t quote grab yourself.'), Raise=True)
for m in reversed(irc.state.history): for m in reversed(irc.state.history):
if m.command == 'PRIVMSG' and ircutils.nickEqual(m.nick, nick) \ if m.command == 'PRIVMSG' and ircutils.nickEqual(m.nick, nick) \
and ircutils.strEqual(m.args[0], chan): and ircutils.strEqual(m.args[0], chan):
self._grab(channel, irc, m, msg.prefix) self._grab(channel, irc, m, msg.prefix)
irc.replySuccess() irc.replySuccess()
return return
irc.error('I couldn\'t find a proper message to grab.') irc.error(_('I couldn\'t find a proper message to grab.'))
grab = wrap(grab, ['channeldb', 'nick']) grab = wrap(grab, ['channeldb', 'nick'])
@internationalizeDocstring
def ungrab(self, irc, msg, args, channel, grab): def ungrab(self, irc, msg, args, channel, grab):
"""[<channel>] <number> """[<channel>] <number>
@ -278,11 +282,12 @@ class QuoteGrabs(callbacks.Plugin):
irc.replySuccess() irc.replySuccess()
except dbi.NoRecordError: except dbi.NoRecordError:
if grab is None: if grab is None:
irc.error('Nothing to ungrab.') irc.error(_('Nothing to ungrab.'))
else: else:
irc.error('Invalid grab number.') irc.error(_('Invalid grab number.'))
ungrab = wrap(ungrab, ['channeldb', optional('id')]) ungrab = wrap(ungrab, ['channeldb', optional('id')])
@internationalizeDocstring
def quote(self, irc, msg, args, channel, nick): def quote(self, irc, msg, args, channel, nick):
"""[<channel>] <nick> """[<channel>] <nick>
@ -292,10 +297,11 @@ class QuoteGrabs(callbacks.Plugin):
try: try:
irc.reply(self.db.getQuote(channel, nick)) irc.reply(self.db.getQuote(channel, nick))
except dbi.NoRecordError: except dbi.NoRecordError:
irc.error('I couldn\'t find a matching quotegrab for %s.' % nick, irc.error(_('I couldn\'t find a matching quotegrab for %s.') %
Raise=True) nick, Raise=True)
quote = wrap(quote, ['channeldb', 'nick']) quote = wrap(quote, ['channeldb', 'nick'])
@internationalizeDocstring
def list(self, irc, msg, args, channel, nick): def list(self, irc, msg, args, channel, nick):
"""[<channel>] <nick> """[<channel>] <nick>
@ -314,10 +320,11 @@ class QuoteGrabs(callbacks.Plugin):
L.append(item) L.append(item)
irc.reply(utils.str.commaAndify(L)) irc.reply(utils.str.commaAndify(L))
except dbi.NoRecordError: except dbi.NoRecordError:
irc.error('I couldn\'t find any quotegrabs for %s.' % nick, irc.error(_('I couldn\'t find any quotegrabs for %s.') % nick,
Raise=True) Raise=True)
list = wrap(list, ['channeldb', 'nick']) list = wrap(list, ['channeldb', 'nick'])
@internationalizeDocstring
def random(self, irc, msg, args, channel, nick): def random(self, irc, msg, args, channel, nick):
"""[<channel>] [<nick>] """[<channel>] [<nick>]
@ -329,12 +336,13 @@ class QuoteGrabs(callbacks.Plugin):
irc.reply(self.db.random(channel, nick)) irc.reply(self.db.random(channel, nick))
except dbi.NoRecordError: except dbi.NoRecordError:
if nick: if nick:
irc.error('Couldn\'t get a random quote for that nick.') irc.error(_('Couldn\'t get a random quote for that nick.'))
else: else:
irc.error('Couldn\'t get a random quote. Are there any ' irc.error(_('Couldn\'t get a random quote. Are there any '
'grabbed quotes in the database?') 'grabbed quotes in the database?'))
random = wrap(random, ['channeldb', additional('nick')]) random = wrap(random, ['channeldb', additional('nick')])
@internationalizeDocstring
def get(self, irc, msg, args, channel, id): def get(self, irc, msg, args, channel, id):
"""[<channel>] <id> """[<channel>] <id>
@ -344,10 +352,11 @@ class QuoteGrabs(callbacks.Plugin):
try: try:
irc.reply(self.db.get(channel, id)) irc.reply(self.db.get(channel, id))
except dbi.NoRecordError: except dbi.NoRecordError:
irc.error('No quotegrab for id %s' % utils.str.quoted(id), irc.error(_('No quotegrab for id %s') % utils.str.quoted(id),
Raise=True) Raise=True)
get = wrap(get, ['channeldb', 'id']) get = wrap(get, ['channeldb', 'id'])
@internationalizeDocstring
def search(self, irc, msg, args, channel, text): def search(self, irc, msg, args, channel, text):
"""[<channel>] <text> """[<channel>] <text>
@ -364,7 +373,7 @@ class QuoteGrabs(callbacks.Plugin):
L.append(item) L.append(item)
irc.reply(utils.str.commaAndify(L)) irc.reply(utils.str.commaAndify(L))
except dbi.NoRecordError: except dbi.NoRecordError:
irc.error('No quotegrabs matching %s' % utils.str.quoted(text), irc.error(_('No quotegrabs matching %s') % utils.str.quoted(text),
Raise=True) Raise=True)
search = wrap(search, ['channeldb', 'text']) search = wrap(search, ['channeldb', 'text'])