Internationalize Alias, Anonymous, AutoMode, and BadWord

This commit is contained in:
Valentin Lorentz 2010-10-16 18:54:18 +02:00
parent 1cc1ec93a5
commit ca23f946e5
12 changed files with 425 additions and 50 deletions

View File

@ -29,6 +29,8 @@
import supybot.conf as conf
import supybot.registry as registry
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Alias')
def configure(advanced):
# This will be called by supybot to configure this module. advanced is

View File

@ -0,0 +1,87 @@
# 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-16 14:10+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:45
#, docstring
msgid ""
"Returns the channel the msg came over or the channel given in args.\n"
"\n"
" If the channel was given in args, args is modified (the channel is\n"
" removed).\n"
" "
msgstr ""
#: plugin.py:164
msgid " at least"
msgstr ""
#: plugin.py:165
msgid ""
"<an alias,%s %n>\n"
"\n"
"Alias for %q."
msgstr ""
#: plugin.py:220
#, docstring
msgid ""
"<alias>\n"
"\n"
" Locks an alias so that no one else can change it.\n"
" "
msgstr ""
#: plugin.py:229 plugin.py:243
msgid "There is no such alias."
msgstr ""
#: plugin.py:234
#, docstring
msgid ""
"<alias>\n"
"\n"
" Unlocks an alias so that people can define new aliases over it.\n"
" "
msgstr ""
#: plugin.py:254
msgid "That name isn't valid. Try %q instead."
msgstr ""
#: plugin.py:292
#, docstring
msgid ""
"<name> <alias>\n"
"\n"
" Defines an alias <name> that executes <alias>. The <alias>\n"
" should be in the standard \"command argument [nestedcommand argument]\"\n"
" arguments to the alias; they'll be filled with the first, second, etc.\n"
" arguments. $1, $2, etc. can be used for required arguments. @1, @2,\n"
" etc. can be used for optional arguments. $* simply means \"all\n"
" remaining arguments,\" and cannot be combined with optional arguments.\n"
" "
msgstr ""
#: plugin.py:315
#, docstring
msgid ""
"<name>\n"
"\n"
" Removes the given alias, if unlocked.\n"
" "
msgstr ""

View File

@ -37,6 +37,8 @@ from supybot.commands import *
import supybot.ircutils as ircutils
import supybot.registry as registry
import supybot.callbacks as callbacks
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Alias')
# Copied from the old privmsgs.py.
def getChannel(msg, args=()):
@ -159,8 +161,8 @@ def makeNewAlias(name, alias):
self.Proxy(irc, msg, tokens)
flexargs = ''
if biggestDollar and (wildcard or biggestAt):
flexargs = ' at least'
doc =format('<an alias,%s %n>\n\nAlias for %q.',
flexargs = _(' at least')
doc =format(_('<an alias,%s %n>\n\nAlias for %q.'),
flexargs, (biggestDollar, 'argument'), alias)
f = utils.python.changeFunctionName(f, name, doc)
return f
@ -213,6 +215,7 @@ class Alias(callbacks.Plugin):
except AttributeError:
return self.aliases[command[0]][2]
@internationalizeDocstring
def lock(self, irc, msg, args, name):
"""<alias>
@ -223,9 +226,10 @@ class Alias(callbacks.Plugin):
conf.supybot.plugins.Alias.aliases.get(name).locked.setValue(True)
irc.replySuccess()
else:
irc.error('There is no such alias.')
irc.error(_('There is no such alias.'))
lock = wrap(lock, [('checkCapability', 'admin'), 'commandName'])
@internationalizeDocstring
def unlock(self, irc, msg, args, name):
"""<alias>
@ -236,7 +240,7 @@ class Alias(callbacks.Plugin):
conf.supybot.plugins.Alias.aliases.get(name).locked.setValue(False)
irc.replySuccess()
else:
irc.error('There is no such alias.')
irc.error(_('There is no such alias.'))
unlock = wrap(unlock, [('checkCapability', 'admin'), 'commandName'])
_invalidCharsRe = re.compile(r'[\[\]\s]')
@ -247,7 +251,7 @@ class Alias(callbacks.Plugin):
raise AliasError, 'Names cannot contain pipes.'
realName = callbacks.canonicalName(name)
if name != realName:
s = format('That name isn\'t valid. Try %q instead.', realName)
s = format(_('That name isn\'t valid. Try %q instead.'), realName)
raise AliasError, s
name = realName
if self.isCommandMethod(name):
@ -283,6 +287,7 @@ class Alias(callbacks.Plugin):
else:
raise AliasError, 'There is no such alias.'
@internationalizeDocstring
def add(self, irc, msg, args, name, alias):
"""<name> <alias>
@ -305,6 +310,7 @@ class Alias(callbacks.Plugin):
irc.error(str(e))
add = wrap(add, ['commandName', 'text'])
@internationalizeDocstring
def remove(self, irc, msg, args, name):
"""<name>

View File

@ -29,6 +29,8 @@
import supybot.conf as conf
import supybot.registry as registry
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Anonymous')
def configure(advanced):
# This will be called by supybot to configure this module. advanced is
@ -44,20 +46,20 @@ Anonymous = conf.registerPlugin('Anonymous')
# conf.registerGlobalValue(Anonymous, 'someConfigVariableName',
# registry.Boolean(False, """Help for someConfigVariableName."""))
conf.registerChannelValue(conf.supybot.plugins.Anonymous,
'requirePresenceInChannel', registry.Boolean(True, """Determines whether
'requirePresenceInChannel', registry.Boolean(True, _("""Determines whether
the bot should require people trying to use this plugin to be in the
channel they wish to anonymously send to."""))
channel they wish to anonymously send to.""")))
conf.registerGlobalValue(conf.supybot.plugins.Anonymous, 'requireRegistration',
registry.Boolean(True, """Determines whether the bot should require people
trying to use this plugin to be registered."""))
registry.Boolean(True, _("""Determines whether the bot should require
people trying to use this plugin to be registered.""")))
conf.registerGlobalValue(conf.supybot.plugins.Anonymous, 'requireCapability',
registry.String('', """Determines what capability (if any) the bot should
require people trying to use this plugin to have."""))
registry.String('', _("""Determines what capability (if any) the bot should
require people trying to use this plugin to have.""")))
conf.registerGlobalValue(conf.supybot.plugins.Anonymous, 'allowPrivateTarget',
registry.Boolean(False, """Determines whether the bot will require targets
of the "say" command to be public (i.e., channels). If this is True, the
bot will allow people to use the "say" command to send private messages to
other users."""))
registry.Boolean(False, _("""Determines whether the bot will require
targets of the "say" command to be public (i.e., channels). If this is
True, the bot will allow people to use the "say" command to send private
messages to other users.""")))
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:

View File

@ -0,0 +1,79 @@
# 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-16 15:14+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\n"
" the bot should require people trying to use this plugin to be in the\n"
" channel they wish to anonymously send to."
msgstr ""
#: config.py:53
msgid ""
"Determines whether the bot should require\n"
" people trying to use this plugin to be registered."
msgstr ""
#: config.py:56
msgid ""
"Determines what capability (if any) the bot should\n"
" require people trying to use this plugin to have."
msgstr ""
#: config.py:59
msgid ""
"Determines whether the bot will require \n"
" targets of the \"say\" command to be public (i.e., channels). If this is\n"
" True, the bot will allow people to use the \"say\" command to send private\n"
" messages to other users."
msgstr ""
#: plugin.py:41
#, docstring
msgid ""
"This plugin allows users to act through the bot anonymously. The 'do'\n"
" command has the bot perform an anonymous action in a given channel, and\n"
" the 'say' command allows other people to speak through the bot. Since\n"
" this can be fairly well abused, you might want to set\n"
" supybot.plugins.Anonymous.requireCapability so only users with that\n"
" capability can use this plugin. For extra security, you can require that\n"
" the user be *in* the channel they are trying to address anonymously with\n"
" supybot.plugins.Anonymous.requirePresenceInChannel, or you can require\n"
" that the user be registered by setting\n"
" supybot.plugins.Anonymous.requireRegistration.\n"
" "
msgstr ""
#: plugin.py:81
#, docstring
msgid ""
"<channel|nick> <text>\n"
"\n"
" Sends <text> to <channel|nick>. Can only send to <nick> if\n"
" supybot.plugins.Anonymous.allowPrivateTarget is True.\n"
" "
msgstr ""
#: plugin.py:95
#, docstring
msgid ""
"<channel> <action>\n"
"\n"
" Performs <action> in <channel>.\n"
" "
msgstr ""

View File

@ -33,7 +33,10 @@ import supybot.utils as utils
from supybot.commands import *
import supybot.ircmsgs as ircmsgs
import supybot.callbacks as callbacks
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Anonymous')
@internationalizeDocstring
class Anonymous(callbacks.Plugin):
"""This plugin allows users to act through the bot anonymously. The 'do'
command has the bot perform an anonymous action in a given channel, and
@ -73,6 +76,7 @@ class Anonymous(callbacks.Plugin):
action),
Raise=True)
@internationalizeDocstring
def say(self, irc, msg, args, target, text):
"""<channel|nick> <text>
@ -86,6 +90,7 @@ class Anonymous(callbacks.Plugin):
irc.noReply()
say = wrap(say, [first('nick', 'inChannel'), 'text'])
@internationalizeDocstring
def do(self, irc, msg, args, channel, text):
"""<channel> <action>

View File

@ -29,6 +29,8 @@
import supybot.conf as conf
import supybot.registry as registry
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('AutoMode')
def configure(advanced):
# This will be called by supybot to configure this module. advanced is
@ -41,30 +43,33 @@ def configure(advanced):
AutoMode = conf.registerPlugin('AutoMode')
conf.registerChannelValue(AutoMode, 'enable',
registry.Boolean(True, """Determines whether this plugin is enabled."""))
registry.Boolean(True, _("""Determines whether this plugin is enabled.
""")))
conf.registerGlobalValue(AutoMode, 'owner',
registry.Boolean(True, """Determines whether this plugin will automode owners."""))
registry.Boolean(True, _("""Determines whether this plugin will automode
owners.""")))
conf.registerChannelValue(AutoMode, 'fallthrough',
registry.Boolean(False, """Determines whether the bot will "fall through" to
halfop/voicing when auto-opping is turned off but auto-halfopping/voicing
are turned on."""))
registry.Boolean(False, _("""Determines whether the bot will "fall through
to halfop/voicing when auto-opping is turned off but
auto-halfopping/voicing are turned on.""")))
conf.registerChannelValue(AutoMode, 'op',
registry.Boolean(True, """Determines whether the bot will automatically op
people with the <channel>,op capability when they join the channel."""))
registry.Boolean(True, _("""Determines whether the bot will automatically
op people with the <channel>,op capability when they join the channel.
""")))
conf.registerChannelValue(AutoMode, 'halfop',
registry.Boolean(True, """Determines whether the bot will automatically
registry.Boolean(True, _("""Determines whether the bot will automatically
halfop people with the <channel>,halfop capability when they join the
channel."""))
channel.""")))
conf.registerChannelValue(AutoMode, 'voice',
registry.Boolean(True, """Determines whether the bot will automatically
registry.Boolean(True, _("""Determines whether the bot will automatically
voice people with the <channel>,voice capability when they join the
channel."""))
channel.""")))
conf.registerChannelValue(AutoMode, 'ban',
registry.Boolean(True, """Determines whether the bot will automatically ban
people who join the channel and are on the banlist."""))
registry.Boolean(True, _("""Determines whether the bot will automatically
ban people who join the channel and are on the banlist.""")))
conf.registerChannelValue(AutoMode.ban, 'period',
registry.PositiveInteger(86400, """Determines how many seconds the bot will
automatically ban a person when banning."""))
registry.PositiveInteger(86400, _("""Determines how many seconds the bot
will automatically ban a person when banning.""")))

View File

@ -0,0 +1,69 @@
# 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-16 18:48+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 this plugin is enabled.\n"
" "
msgstr ""
#: config.py:49
msgid ""
"Determines whether this plugin will automode\n"
" owners."
msgstr ""
#: config.py:52
msgid ""
"Determines whether the bot will \"fall through\n"
" to halfop/voicing when auto-opping is turned off but\n"
" auto-halfopping/voicing are turned on."
msgstr ""
#: config.py:56
msgid ""
"Determines whether the bot will automatically\n"
" op people with the <channel>,op capability when they join the channel.\n"
" "
msgstr ""
#: config.py:60
msgid ""
"Determines whether the bot will automatically\n"
" halfop people with the <channel>,halfop capability when they join the\n"
" channel."
msgstr ""
#: config.py:64
msgid ""
"Determines whether the bot will automatically\n"
" voice people with the <channel>,voice capability when they join the\n"
" channel."
msgstr ""
#: config.py:68
msgid ""
"Determines whether the bot will automatically\n"
" ban people who join the channel and are on the banlist."
msgstr ""
#: config.py:71
msgid ""
"Determines how many seconds the bot\n"
" will automatically ban a person when banning."
msgstr ""

View File

@ -35,6 +35,8 @@ 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('AutoMode')
class Continue(Exception):
pass # Used below, look in the "do" function nested in doJoin.

View File

@ -31,12 +31,15 @@ import time
import supybot.conf as conf
import supybot.registry as registry
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('BadWords')
def configure(advanced):
from supybot.questions import output, expect, anything, something, yn
conf.registerPlugin('BadWords', True)
if yn('Would you like to add some bad words?'):
words = anything('What words? (separate individual words by spaces)')
if yn(_('Would you like to add some bad words?')):
words = anything(_('What words? (separate individual words by '
'spaces)'))
conf.supybot.plugins.BadWords.words.set(words)
class LastModifiedSetOfStrings(registry.SpaceSeparatedSetOfStrings):
@ -47,14 +50,14 @@ class LastModifiedSetOfStrings(registry.SpaceSeparatedSetOfStrings):
BadWords = conf.registerPlugin('BadWords')
conf.registerGlobalValue(BadWords, 'words',
LastModifiedSetOfStrings([], """Determines what words are
considered to be 'bad' so the bot won't say them."""))
LastModifiedSetOfStrings([], _("""Determines what words are
considered to be 'bad' so the bot won't say them.""")))
conf.registerGlobalValue(BadWords,'requireWordBoundaries',
registry.Boolean(False, """Determines whether the bot will require bad
registry.Boolean(False, _("""Determines whether the bot will require bad
words to be independent words, or whether it will censor them within other
words. For instance, if 'darn' is a bad word, then if this is true, 'darn'
will be censored, but 'darnit' will not. You probably want this to be
false."""))
false.""")))
class String256(registry.String):
def __call__(self):
@ -65,39 +68,39 @@ class String256(registry.String):
return self.value
conf.registerGlobalValue(BadWords, 'nastyChars',
String256('!@#&', """Determines what characters will replace bad words; a
String256('!@#&', _("""Determines what characters will replace bad words; a
chunk of these characters matching the size of the replaced bad word will
be used to replace the bad words you've configured."""))
be used to replace the bad words you've configured.""")))
class ReplacementMethods(registry.OnlySomeStrings):
validStrings = ('simple', 'nastyCharacters')
conf.registerGlobalValue(BadWords, 'replaceMethod',
ReplacementMethods('nastyCharacters', """Determines the manner in which
ReplacementMethods('nastyCharacters', _("""Determines the manner in which
bad words will be replaced. 'nastyCharacters' (the default) will replace a
bad word with the same number of 'nasty characters' (like those used in
comic books; configurable by supybot.plugins.BadWords.nastyChars).
'simple' will replace a bad word with a simple strings (regardless of the
length of the bad word); this string is configurable via
supybot.plugins.BadWords.simpleReplacement."""))
supybot.plugins.BadWords.simpleReplacement.""")))
conf.registerGlobalValue(BadWords,'simpleReplacement',
registry.String('[CENSORED]', """Determines what word will replace bad
words if the replacement method is 'simple'."""))
registry.String('[CENSORED]', _("""Determines what word will replace bad
words if the replacement method is 'simple'.""")))
conf.registerGlobalValue(BadWords, 'stripFormatting',
registry.Boolean(True, """Determines whether the bot will strip
registry.Boolean(True, _("""Determines whether the bot will strip
formatting characters from messages before it checks them for bad words.
If this is False, it will be relatively trivial to circumvent this plugin's
filtering. If it's True, however, it will interact poorly with other
plugins that do coloring or bolding of text."""))
plugins that do coloring or bolding of text.""")))
conf.registerChannelValue(BadWords, 'kick',
registry.Boolean(False, """Determines whether the bot will kick people with
a warning when they use bad words."""))
registry.Boolean(False, _("""Determines whether the bot will kick people with
a warning when they use bad words.""")))
conf.registerChannelValue(BadWords.kick, 'message',
registry.NormalizedString("""You have been kicked for using a word
registry.NormalizedString(_("""You have been kicked for using a word
prohibited in the presence of this bot. Please use more appropriate
language in the future.""", """Determines the kick message used by the bot
when kicking users for saying bad words."""))
language in the future."""), _("""Determines the kick message used by the
bot when kicking users for saying bad words.""")))
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:

View File

@ -0,0 +1,110 @@
# 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-16 18:51+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:40
msgid "Would you like to add some bad words?"
msgstr ""
#: config.py:41
msgid "What words? (separate individual words by spaces)"
msgstr ""
#: config.py:53
msgid ""
"Determines what words are\n"
" considered to be 'bad' so the bot won't say them."
msgstr ""
#: config.py:56
msgid ""
"Determines whether the bot will require bad\n"
" words to be independent words, or whether it will censor them within other\n"
" words. For instance, if 'darn' is a bad word, then if this is true, 'darn'\n"
" will be censored, but 'darnit' will not. You probably want this to be\n"
" false."
msgstr ""
#: config.py:71
msgid ""
"Determines what characters will replace bad words; a\n"
" chunk of these characters matching the size of the replaced bad word will\n"
" be used to replace the bad words you've configured."
msgstr ""
#: config.py:79
msgid ""
"Determines the manner in which\n"
" bad words will be replaced. 'nastyCharacters' (the default) will replace a\n"
" bad word with the same number of 'nasty characters' (like those used in\n"
" comic books; configurable by supybot.plugins.BadWords.nastyChars).\n"
" 'simple' will replace a bad word with a simple strings (regardless of the\n"
" length of the bad word); this string is configurable via\n"
" supybot.plugins.BadWords.simpleReplacement."
msgstr ""
#: config.py:87
msgid ""
"Determines what word will replace bad\n"
" words if the replacement method is 'simple'."
msgstr ""
#: config.py:90
msgid ""
"Determines whether the bot will strip\n"
" formatting characters from messages before it checks them for bad words.\n"
" If this is False, it will be relatively trivial to circumvent this plugin's\n"
" filtering. If it's True, however, it will interact poorly with other\n"
" plugins that do coloring or bolding of text."
msgstr ""
#: config.py:97
msgid ""
"Determines whether the bot will kick people with\n"
" a warning when they use bad words."
msgstr ""
#: plugin.py:110
#, docstring
msgid ""
"takes no arguments\n"
"\n"
" Returns the list of words being censored.\n"
" "
msgstr ""
#: plugin.py:120
msgid "I'm not currently censoring any bad words."
msgstr ""
#: plugin.py:125
#, docstring
msgid ""
"<word> [<word> ...]\n"
"\n"
" Adds all <word>s to the list of words the bot isn't to say.\n"
" "
msgstr ""
#: plugin.py:137
#, docstring
msgid ""
"<word> [<word> ...]\n"
"\n"
" Removes a <word>s from the list of words the bot isn't to say.\n"
" "
msgstr ""

View File

@ -39,6 +39,8 @@ import supybot.ircmsgs as ircmsgs
from supybot.commands import *
import supybot.ircutils as ircutils
import supybot.callbacks as callbacks
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('BadWords')
class BadWords(callbacks.Privmsg):
def __init__(self, irc):
@ -103,6 +105,7 @@ class BadWords(callbacks.Privmsg):
s = r'\b%s\b' % s
self.regexp = re.compile(s, re.I)
@internationalizeDocstring
def list(self, irc, msg, args):
"""takes no arguments
@ -114,9 +117,10 @@ class BadWords(callbacks.Privmsg):
utils.sortBy(str.lower, L)
irc.reply(format('%L', L))
else:
irc.reply('I\'m not currently censoring any bad words.')
irc.reply(_('I\'m not currently censoring any bad words.'))
list = wrap(list, ['admin'])
@internationalizeDocstring
def add(self, irc, msg, args, words):
"""<word> [<word> ...]
@ -128,6 +132,7 @@ class BadWords(callbacks.Privmsg):
irc.replySuccess()
add = wrap(add, ['admin', many('something')])
@internationalizeDocstring
def remove(self, irc, msg, args, words):
"""<word> [<word> ...]