diff --git a/plugins/Channel/config.py b/plugins/Channel/config.py index a126b8640..19f7462be 100644 --- a/plugins/Channel/config.py +++ b/plugins/Channel/config.py @@ -47,6 +47,10 @@ Channel = conf.registerPlugin('Channel') conf.registerChannelValue(Channel, 'alwaysRejoin', registry.Boolean(True, _("""Determines whether the bot will always try to rejoin a channel whenever it's kicked from the channel."""))) +conf.registerChannelValue(Channel, 'nicksInPrivate', + registry.Boolean(True, _("""Determines whether the output of 'nicks' will + be sent in private. This prevents mass-highlights of a channel's users, + accidental or on purpose."""))) # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: diff --git a/plugins/Channel/plugin.py b/plugins/Channel/plugin.py index c2b010bed..75834daa2 100644 --- a/plugins/Channel/plugin.py +++ b/plugins/Channel/plugin.py @@ -910,7 +910,8 @@ class Channel(callbacks.Plugin): keys = [option for (option, arg) in optlist] if 'count' not in keys: utils.sortBy(str.lower, L) - irc.reply(utils.str.commaAndify(L)) + private = self.registryValue("nicksInPrivate", channel) + irc.reply(utils.str.commaAndify(L), private=private) else: irc.reply(str(len(L))) nicks = wrap(nicks, ['inChannel', diff --git a/plugins/Karma/config.py b/plugins/Karma/config.py index 376348b20..fcc62db1f 100644 --- a/plugins/Karma/config.py +++ b/plugins/Karma/config.py @@ -66,5 +66,8 @@ conf.registerChannelValue(Karma, 'allowSelfRating', conf.registerChannelValue(Karma, 'allowUnaddressedKarma', registry.Boolean(True, _("""Determines whether the bot will increase/decrease karma without being addressed."""))) +conf.registerChannelValue(Karma, 'onlyNicks', + registry.Boolean(False, _("""Determines whether the bot will + only increase/decrease karma for nicks in the current channel."""))) # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: diff --git a/plugins/Karma/plugin.py b/plugins/Karma/plugin.py index 2b8671530..c29bedabb 100644 --- a/plugins/Karma/plugin.py +++ b/plugins/Karma/plugin.py @@ -246,25 +246,34 @@ class Karma(callbacks.Plugin): def _doKarma(self, irc, msg, channel, thing): inc = self.registryValue('incrementChars', channel) dec = self.registryValue('decrementChars', channel) - if thing.endswith(tuple(inc + dec)): - for s in inc: - if thing.endswith(s): - thing = thing[:-len(s)] - if ircutils.strEqual(thing, msg.nick) and \ - not self.registryValue('allowSelfRating', channel): + onlynicks = self.registryValue('onlyNicks', channel) + karma = '' + for s in inc: + if thing.endswith(s): + thing = thing[:-len(s)] + # Don't reply if the target isn't a nick + if onlynicks and thing.lower() not in map(ircutils.toLower, + irc.state.channels[channel].users): + return + if ircutils.strEqual(thing, msg.nick) and \ + not self.registryValue('allowSelfRating', channel): irc.error(_('You\'re not allowed to adjust your own karma.')) return - self.db.increment(channel, self._normalizeThing(thing)) - karma = self.db.get(channel, self._normalizeThing(thing)) - for s in dec: - if thing.endswith(s): - thing = thing[:-len(s)] - if ircutils.strEqual(thing, msg.nick) and \ - not self.registryValue('allowSelfRating', channel): - irc.error(_('You\'re not allowed to adjust your own karma.')) - return - self.db.decrement(channel, self._normalizeThing(thing)) - karma = self.db.get(channel, self._normalizeThing(thing)) + self.db.increment(channel, self._normalizeThing(thing)) + karma = self.db.get(channel, self._normalizeThing(thing)) + for s in dec: + if thing.endswith(s): + thing = thing[:-len(s)] + if onlynicks and thing.lower() not in map(ircutils.toLower, + irc.state.channels[channel].users): + return + if ircutils.strEqual(thing, msg.nick) and \ + not self.registryValue('allowSelfRating', channel): + irc.error(_('You\'re not allowed to adjust your own karma.')) + return + self.db.decrement(channel, self._normalizeThing(thing)) + karma = self.db.get(channel, self._normalizeThing(thing)) + if karma: self._respond(irc, channel, thing, karma[0]-karma[1]) def invalidCommand(self, irc, msg, tokens): diff --git a/plugins/Karma/test.py b/plugins/Karma/test.py index f615646d5..b5e4e5edc 100644 --- a/plugins/Karma/test.py +++ b/plugins/Karma/test.py @@ -204,4 +204,21 @@ class KarmaTestCase(ChannelPluginTestCase): karma.response.setValue(resp) karma.allowUnaddressedKarma.setValue(unaddressed) + def testOnlyNicks(self): + # We use this to join a dummy user to test upon + msg = ircmsgs.join(self.channel, prefix='hello!foo@bar') + self.irc.feedMsg(msg) + karma = conf.supybot.plugins.Karma + resp = karma.response() + onlynicks = karma.onlyNicks() + try: + karma.onlynicks.setValue(True) + karma.response.setValue(True) + self.assertSnarfNoResponse('abcd++') + self.assertSnarfRegexp('hello--', 'is now') + self.assertSnarfNoResponse('abcd--') + self.assertSnarfRegexp('hello++', 'is now') + finally: + karma.onlynicks.setValue(onlynicks) + karma.response.setValue(resp) # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: diff --git a/plugins/ShrinkUrl/config.py b/plugins/ShrinkUrl/config.py index b2e213a37..08e651f96 100644 --- a/plugins/ShrinkUrl/config.py +++ b/plugins/ShrinkUrl/config.py @@ -42,11 +42,11 @@ def configure(advanced): conf.supybot.plugins.ShrinkUrl.shrinkSnarfer.setValue(True) class ShrinkService(registry.OnlySomeStrings): - """Valid values include 'ln', 'tiny', 'xrl', 'goo', 'ur1', and 'x0'.""" - validStrings = ('ln', 'tiny', 'xrl', 'goo', 'ur1', 'x0') + """Valid values include 'ln', 'tiny', 'goo', 'ur1', and 'x0'.""" + validStrings = ('ln', 'tiny', 'goo', 'ur1', 'x0') class ShrinkCycle(registry.SpaceSeparatedListOfStrings): - """Valid values include 'ln', 'tiny', 'xrl', 'goo', 'ur1', and 'x0'.""" + """Valid values include 'ln', 'tiny', 'goo', 'ur1', and 'x0'.""" Value = ShrinkService def __init__(self, *args, **kwargs): diff --git a/plugins/ShrinkUrl/locales/fi.po b/plugins/ShrinkUrl/locales/fi.po index af622fcbb..289e1c8fd 100644 --- a/plugins/ShrinkUrl/locales/fi.po +++ b/plugins/ShrinkUrl/locales/fi.po @@ -5,8 +5,8 @@ msgid "" msgstr "" "Project-Id-Version: Limnoria\n" -"POT-Creation-Date: 2014-12-20 11:59+EET\n" -"PO-Revision-Date: 2014-12-20 12:21+0200\n" +"POT-Creation-Date: 2015-01-24 19:31+CET\n" +"PO-Revision-Date: 2015-01-24 19:31+0100\n" "Last-Translator: Mikaela Suomalainen \n" "Language-Team: suomi <>\n" "Language: fi\n" @@ -28,8 +28,8 @@ msgstr "" " tämän kaappaajan olevan käytössä?" #: config.py:45 config.py:49 -msgid "Valid values include 'ln', 'tiny', 'xrl', 'goo', 'ur1', and 'x0'." -msgstr "Kelvolliset arvot ovat 'ln', 'tiny', 'xrl', 'goo', 'ur1' ja 'x0' ." +msgid "Valid values include 'ln', 'tiny', 'goo', 'ur1', and 'x0'." +msgstr "Kelvolliset arvot ovat 'ln', 'tiny', 'goo', 'ur1' ja 'x0' ." #: config.py:70 msgid "" @@ -145,19 +145,7 @@ msgstr "" "osoitteesta>.\n" " " -#: plugin.py:248 -msgid "" -"\n" -"\n" -" Returns an xrl.us version of .\n" -" " -msgstr "" -"\n" -"\n" -" Palauttaa xrl.us palvelun lyhentämän version .\n" -" " - -#: plugin.py:281 +#: plugin.py:252 msgid "" "\n" "\n" @@ -168,7 +156,7 @@ msgstr "" "\n" " Palauttaa goo.gl-palvelun lyhentämän version ." -#: plugin.py:311 +#: plugin.py:282 msgid "" "\n" "\n" @@ -179,7 +167,7 @@ msgstr "" " Palauttaa ur1-version .\n" " " -#: plugin.py:338 +#: plugin.py:309 msgid "" "\n" "\n" @@ -191,7 +179,7 @@ msgstr "" " Palauttaa x0.no palvelun lyhentämän version .\n" " " -#: plugin.py:365 +#: plugin.py:336 msgid "" "\n" "\n" @@ -202,5 +190,16 @@ msgstr "" " Palauttaa laajennetun version .\n" " " +#~ msgid "" +#~ "\n" +#~ "\n" +#~ " Returns an xrl.us version of .\n" +#~ " " +#~ msgstr "" +#~ "\n" +#~ "\n" +#~ " Palauttaa xrl.us palvelun lyhentämän version .\n" +#~ " " + #~ msgid "Valid values include 'ln', 'tiny', 'xrl', 'goo', and 'x0'." #~ msgstr "Kelvolliset arvot ovat 'ln', 'tiny', 'xrl', 'goo' ja 'x0' ." diff --git a/plugins/ShrinkUrl/locales/fr.po b/plugins/ShrinkUrl/locales/fr.po index 320f5ef36..f4531dae5 100644 --- a/plugins/ShrinkUrl/locales/fr.po +++ b/plugins/ShrinkUrl/locales/fr.po @@ -1,10 +1,11 @@ msgid "" msgstr "" "Project-Id-Version: Limnoria\n" -"POT-Creation-Date: 2013-03-03 19:39+CET\n" -"PO-Revision-Date: \n" +"POT-Creation-Date: 2015-01-24 19:31+CET\n" +"PO-Revision-Date: 2015-01-24 19:32+0100\n" "Last-Translator: Valentin Lorentz \n" "Language-Team: Limnoria \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -21,16 +22,12 @@ msgstr "" "canal pour en envoyer une version plus courte. Voulez-vous activer ce " "snarfer ?" -#: config.py:45 -msgid "Valid values include 'ln', 'tiny', 'xrl', 'goo', and 'x0'." -msgstr "Les valeurs valides incluent 'ln', 'tiny', 'xrl', 'goo', et 'x0'." - -#: config.py:49 -msgid "Valid values include 'ln', 'tiny', 'xrl', 'goo', 'ur1', and 'x0'." +#: config.py:45 config.py:49 +msgid "Valid values include 'ln', 'tiny', 'goo', 'ur1', and 'x0'." msgstr "" -"Les valeurs valides incluent 'ln', 'tiny', 'xrl', 'goo', 'ur1', et 'x0'." +"Les valeurs valides incluent 'ln', 'tiny', 'goo', 'ur1', et 'x0'." -#: config.py:71 +#: config.py:70 msgid "" "Determines whether the\n" " shrink snarfer is enabled. This snarfer will watch for URLs in the\n" @@ -45,7 +42,7 @@ msgstr "" "URL raccourcie avec ln-s.net ou tinyurl.com, comme défini par supybot." "plugins.ShrinkUrl.default." -#: config.py:78 +#: config.py:77 msgid "" "Determines whether the snarfer will show the\n" " domain of the URL being snarfed along with the shrunken URL." @@ -53,13 +50,13 @@ msgstr "" "Détermine si le snarfer affichera le domaine de l'URL snarfée avec l'URL " "raccourcie." -#: config.py:81 +#: config.py:80 msgid "" "The minimum length a URL must be before\n" " the bot will shrink it." msgstr "La taille minimum d'une URL pour que le bot la raccourcice." -#: config.py:84 +#: config.py:83 msgid "" "Determines what URLs are to be snarfed; URLs\n" " matching the regexp given will not be snarfed. Give the empty string " @@ -70,7 +67,7 @@ msgstr "" "l'expression régulière ne seront par snarfées. Donnez une chaîne vide si il " "n'y a pas d'URL que vous voulez exclure." -#: config.py:88 +#: config.py:87 msgid "" "Determines whether the bot will shrink the\n" " URLs of outgoing messages if those URLs are longer than\n" @@ -79,20 +76,20 @@ msgstr "" "Détermine si le bot raccourcira les URLs des messages sortant si ces URLs " "sont plus longues que supybot.plugins.ShrinkUrl.minimumLength." -#: config.py:92 +#: config.py:91 msgid "" "Determines what website the bot will use when\n" " shrinking a URL." msgstr "Détermine quel site web le bot utilisera pour raccourcir une URL" -#: config.py:95 +#: config.py:94 msgid "" "Determines whether this plugin will bold\n" " certain portions of its replies." msgstr "" "Détermine si ce plugin mettra en gras certaines portions de ses réponses." -#: config.py:98 +#: config.py:97 msgid "" "If set to a non-empty value, specifies the list of\n" " services to rotate through for the shrinkSnarfer and outFilter." @@ -100,7 +97,13 @@ msgstr "" "Si définit à une valeur non vide, définit la liste des services à faire " "tourner pour shrinkSnarfer et outFilter." -#: plugin.py:189 +#: plugin.py:90 +msgid "" +"This plugin features commands to shorten URLs through different services,\n" +" like tinyurl." +msgstr "" + +#: plugin.py:192 msgid "" "\n" "\n" @@ -111,7 +114,7 @@ msgstr "" "\n" "Retourne une version de ln-s.net de l'." -#: plugin.py:216 +#: plugin.py:219 msgid "" "\n" "\n" @@ -122,18 +125,7 @@ msgstr "" "\n" "Retourne une version de TinyURL.com de l'." -#: plugin.py:245 -msgid "" -"\n" -"\n" -" Returns an xrl.us version of .\n" -" " -msgstr "" -"\n" -"\n" -"Retourne une version de xrl.us de l'." - -#: plugin.py:275 +#: plugin.py:252 msgid "" "\n" "\n" @@ -144,7 +136,7 @@ msgstr "" "\n" "Retourne une version de goo.gl de l'." -#: plugin.py:305 +#: plugin.py:282 msgid "" "\n" "\n" @@ -155,7 +147,7 @@ msgstr "" "\n" "Retourne une version de ur1 de l'." -#: plugin.py:332 +#: plugin.py:309 msgid "" "\n" "\n" @@ -166,7 +158,7 @@ msgstr "" "\n" "Retourne une version de x0.no de l'." -#: plugin.py:359 +#: plugin.py:336 msgid "" "\n" "\n" @@ -176,3 +168,16 @@ msgstr "" "\n" "\n" "Retourne la version large de l'." + +#~ msgid "" +#~ "\n" +#~ "\n" +#~ " Returns an xrl.us version of .\n" +#~ " " +#~ msgstr "" +#~ "\n" +#~ "\n" +#~ "Retourne une version de xrl.us de l'." + +#~ msgid "Valid values include 'ln', 'tiny', 'xrl', 'goo', and 'x0'." +#~ msgstr "Les valeurs valides incluent 'ln', 'tiny', 'xrl', 'goo', et 'x0'." diff --git a/plugins/ShrinkUrl/locales/it.po b/plugins/ShrinkUrl/locales/it.po index 55dd8c37d..622c31e29 100644 --- a/plugins/ShrinkUrl/locales/it.po +++ b/plugins/ShrinkUrl/locales/it.po @@ -1,8 +1,8 @@ msgid "" msgstr "" "Project-Id-Version: Limnoria\n" -"POT-Creation-Date: 2011-02-26 09:49+CET\n" -"PO-Revision-Date: 2012-06-09 09:03+0200\n" +"POT-Creation-Date: 2015-01-24 19:31+CET\n" +"PO-Revision-Date: 2015-01-24 11:45+0100\n" "Last-Translator: skizzhg \n" "Language-Team: Italian \n" "Language: it\n" @@ -10,7 +10,6 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" - #: config.py:39 msgid "" "This plugin offers a snarfer that will go retrieve a shorter\n" @@ -20,17 +19,13 @@ msgstr "" "Questo plugin offre un cattura URL che riporterà una versione accorciata\n" " di quelli lunghi inviati al canale. Lo si vuole abilitare?\n" -#: config.py:45 -#, docstring -msgid "Valid values include 'ln', 'tiny', 'xrl', 'goo', and 'x0'." -msgstr "I valori validi comprendono \"ln\", \"tiny\", \"xrl\", \"goo\" e \"x0\"." +#: config.py:45 config.py:49 +#, fuzzy +msgid "Valid values include 'ln', 'tiny', 'goo', 'ur1', and 'x0'." +msgstr "" +"I valori validi comprendono \"ln\", \"tiny\", \"goo\" e \"x0\"." -#: config.py:49 -#, docstring -msgid "Valid values include 'ln', 'tiny', 'xrl', 'goo', and 'x0'." -msgstr "I valori validi comprendono \"ln\", \"tiny\", \"xrl\" \"goo\" e \"x0\"." - -#: config.py:71 +#: config.py:70 msgid "" "Determines whether the\n" " shrink snarfer is enabled. This snarfer will watch for URLs in the\n" @@ -39,59 +34,67 @@ msgid "" " smaller URL from either ln-s.net or tinyurl.com, as denoted in\n" " supybot.plugins.ShrinkUrl.default." msgstr "" -"Determina se l'accorcia URL è abilitato. Questo controllerà gli URL che passano\n" +"Determina se l'accorcia URL è abilitato. Questo controllerà gli URL che " +"passano\n" " in canale e se sono sufficientemente lunghi (determinato da\n" -" supybot.plugins.ShrinkUrl.minimumLength) il bot ne invierà uno più corto\n" -" tramite ln-s.net o tinyurl.com, come definito in supybot.plugins.ShrinkUrl.default." +" supybot.plugins.ShrinkUrl.minimumLength) il bot ne invierà uno più " +"corto\n" +" tramite ln-s.net o tinyurl.com, come definito in supybot.plugins." +"ShrinkUrl.default." -#: config.py:78 +#: config.py:77 msgid "" "Determines whether the snarfer will show the\n" " domain of the URL being snarfed along with the shrunken URL." msgstr "" -"Determina se l'accorcia URL mostrerà il dominio dell'URL originale assieme a quello accorciato." +"Determina se l'accorcia URL mostrerà il dominio dell'URL originale assieme a " +"quello accorciato." -#: config.py:81 +#: config.py:80 msgid "" "The minimum length a URL must be before\n" " the bot will shrink it." msgstr "" -"La lunghezza minima che un URL deve avere affinché il bot decida di accorciarlo." +"La lunghezza minima che un URL deve avere affinché il bot decida di " +"accorciarlo." -#: config.py:84 +#: config.py:83 msgid "" "Determines what URLs are to be snarfed; URLs\n" -" matching the regexp given will not be snarfed. Give the empty string if\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 "" -"Determina quali URL debbano essere intercettati; quelli che corrispondono alla\n" -" regexp fornita non verranno coinvolti. Se non si vuole escludere alcun URL,\n" +"Determina quali URL debbano essere intercettati; quelli che corrispondono " +"alla\n" +" regexp fornita non verranno coinvolti. Se non si vuole escludere alcun " +"URL,\n" " aggiungere una stringa vuota." -#: config.py:88 +#: config.py:87 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 "" -"Determina se il bot accorcerà gli URL dei messaggi in uscita se questi sono più\n" +"Determina se il bot accorcerà gli URL dei messaggi in uscita se questi sono " +"più\n" " lunghi del valore di supybot.plugins.ShrinkUrl.minimumLength." -#: config.py:92 +#: config.py:91 msgid "" "Determines what website the bot will use when\n" " shrinking a URL." -msgstr "" -"Determina quale sito web il bot userà per accorciare un URL." +msgstr "Determina quale sito web il bot userà per accorciare un URL." -#: config.py:95 +#: config.py:94 msgid "" "Determines whether this plugin will bold\n" " certain portions of its replies." msgstr "" "Determina se il plugin riporterà in grassetto alcune porzioni delle risposte." -#: config.py:98 +#: config.py:97 msgid "" "If set to a non-empty value, specifies the list of\n" " services to rotate through for the shrinkSnarfer and outFilter." @@ -99,8 +102,13 @@ msgstr "" "Se impostato ad un valore non vuoto, specifica l'elenco dei servizi a cui\n" " rivolgersi per le variabili shrinkSnarfer e outFilter." -#: plugin.py:171 -#, docstring +#: plugin.py:90 +msgid "" +"This plugin features commands to shorten URLs through different services,\n" +" like tinyurl." +msgstr "" + +#: plugin.py:192 msgid "" "\n" "\n" @@ -112,8 +120,7 @@ msgstr "" " Restituisce una versione di ln-s.net di .\n" " " -#: plugin.py:196 -#, docstring +#: plugin.py:219 msgid "" "\n" "\n" @@ -125,21 +132,7 @@ msgstr "" " Restituisce una versione di TinyURL.com di \n" " " -#: plugin.py:224 -#, docstring -msgid "" -"\n" -"\n" -" Returns an xrl.us version of .\n" -" " -msgstr "" -"\n" -"\n" -" Restituisce una versione di xrl.us di .\n" -" " - -#: plugin.py:255 -#, docstring +#: plugin.py:252 msgid "" "\n" "\n" @@ -151,8 +144,20 @@ msgstr "" " Restituisce una versione di goo.gl di .\n" " " -#: plugin.py:281 -#, docstring +#: plugin.py:282 +#, fuzzy +msgid "" +"\n" +"\n" +" Returns an ur1 version of .\n" +" " +msgstr "" +"\n" +"\n" +" Restituisce una versione di xrl.us di .\n" +" " + +#: plugin.py:309 msgid "" "\n" "\n" @@ -164,3 +169,26 @@ msgstr "" " Restituisce una versione di x0.no di .\n" " " +#: plugin.py:336 +#, fuzzy +msgid "" +"\n" +"\n" +" Returns an expanded version of .\n" +" " +msgstr "" +"\n" +"\n" +" Restituisce una versione di x0.no di .\n" +" " + +#~ msgid "" +#~ "\n" +#~ "\n" +#~ " Returns an xrl.us version of .\n" +#~ " " +#~ msgstr "" +#~ "\n" +#~ "\n" +#~ " Restituisce una versione di xrl.us di .\n" +#~ " " diff --git a/plugins/ShrinkUrl/messages.pot b/plugins/ShrinkUrl/messages.pot index dac12252f..256a4f321 100644 --- a/plugins/ShrinkUrl/messages.pot +++ b/plugins/ShrinkUrl/messages.pot @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2014-12-20 11:59+EET\n" +"POT-Creation-Date: 2015-01-24 19:31+CET\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -24,7 +24,7 @@ msgstr "" #: config.py:45 config.py:49 #, docstring -msgid "Valid values include 'ln', 'tiny', 'xrl', 'goo', 'ur1', and 'x0'." +msgid "Valid values include 'ln', 'tiny', 'goo', 'ur1', and 'x0'." msgstr "" #: config.py:70 @@ -106,16 +106,7 @@ msgid "" " " msgstr "" -#: plugin.py:248 -#, docstring -msgid "" -"\n" -"\n" -" Returns an xrl.us version of .\n" -" " -msgstr "" - -#: plugin.py:281 +#: plugin.py:252 #, docstring msgid "" "\n" @@ -124,7 +115,7 @@ msgid "" " " msgstr "" -#: plugin.py:311 +#: plugin.py:282 #, docstring msgid "" "\n" @@ -133,7 +124,7 @@ msgid "" " " msgstr "" -#: plugin.py:338 +#: plugin.py:309 #, docstring msgid "" "\n" @@ -142,7 +133,7 @@ msgid "" " " msgstr "" -#: plugin.py:365 +#: plugin.py:336 #, docstring msgid "" "\n" diff --git a/plugins/ShrinkUrl/plugin.py b/plugins/ShrinkUrl/plugin.py index ea9f934e9..0e6f76de4 100644 --- a/plugins/ShrinkUrl/plugin.py +++ b/plugins/ShrinkUrl/plugin.py @@ -229,35 +229,6 @@ class ShrinkUrl(callbacks.PluginRegexp): irc.errorPossibleBug(str(e)) tiny = thread(wrap(tiny, ['httpUrl'])) - _xrlApi = 'http://metamark.net/api/rest/simple' - @retry - def _getXrlUrl(self, url): - quotedurl = utils.web.urlquote(url) - try: - return self.db.get('xrl', quotedurl) - except KeyError: - data = utils.web.urlencode({'long_url': url}) - text = utils.web.getUrl(self._xrlApi, data=data).decode() - if text.startswith('ERROR:'): - raise ShrinkError(text[6:]) - self.db.set('xrl', quotedurl, text) - return text - - @internationalizeDocstring - def xrl(self, irc, msg, args, url): - """ - - Returns an xrl.us version of . - """ - try: - xrlurl = self._getXrlUrl(url) - m = irc.reply(xrlurl) - if m is not None: - m.tag('shrunken') - except ShrinkError as e: - irc.error(str(e)) - xrl = thread(wrap(xrl, ['httpUrl'])) - _gooApi = 'https://www.googleapis.com/urlshortener/v1/url' @retry def _getGooUrl(self, url): diff --git a/plugins/ShrinkUrl/test.py b/plugins/ShrinkUrl/test.py index 948114007..b8df89d35 100644 --- a/plugins/ShrinkUrl/test.py +++ b/plugins/ShrinkUrl/test.py @@ -41,8 +41,6 @@ class ShrinkUrlTestCase(ChannelPluginTestCase): (udUrl, r'http://tinyurl.com/u479')], 'ln': [(sfUrl, r'http://ln-s.net/\+PE-'), (udUrl, r'http://ln-s.net/2\$K')], - 'xrl': [(sfUrl, r'http://xrl.us/bfq8ik'), - (udUrl, r'http://xrl.us/bfnyji')], 'goo': [(sfUrl, r'http://goo.gl/3c59N'), (udUrl, r'http://goo.gl/ocTga')], 'ur1': [(sfUrl, r'http://ur1.ca/9xl25'), @@ -98,9 +96,6 @@ class ShrinkUrlTestCase(ChannelPluginTestCase): def testLnsnarf(self): self._snarf('ln') - def testXrlsnarf(self): - self._snarf('xrl') - def testGoosnarf(self): self._snarf('goo') diff --git a/plugins/User/plugin.py b/plugins/User/plugin.py index 87968b455..39a03a089 100644 --- a/plugins/User/plugin.py +++ b/plugins/User/plugin.py @@ -500,6 +500,7 @@ class User(callbacks.Plugin): r'-----BEGIN PGP SIGNATURE-----\r?\n.*' r'\r?\n-----END PGP SIGNATURE-----', re.S) + @internationalizeDocstring def auth(self, irc, msg, args, url): """ @@ -523,7 +524,7 @@ class User(callbacks.Plugin): 'Authentication aborted.'), Raise=True) verified = gpg.keyring.verify(data) if verified and verified.valid: - keyid = verified.key_id + keyid = verified.pubkey_fingerprint[-16:] prefix, expiry = self._tokens.pop(token) found = False for (id, user) in ircdb.users.items(): diff --git a/setup.py b/setup.py index ba5bcacfe..d5d31079e 100644 --- a/setup.py +++ b/setup.py @@ -36,6 +36,7 @@ import time import datetime import tempfile import subprocess +from math import ceil debug = '--debug' in sys.argv @@ -142,7 +143,7 @@ try: if self._total_files//10 != 0 and \ self._refactored_files % (self._total_files//10) == 0: print('Refactoring files: %i%% (%i on %i).' % - (self._refactored_files/(self._total_files//10)*10, + (ceil(self._refactored_files*100./self._total_files), self._refactored_files, self._total_files)) self._refactored_files += 1 return super(DistutilsRefactoringTool, self).refactor_file( diff --git a/src/i18n.py b/src/i18n.py index 9d832272b..ddd12ff7e 100644 --- a/src/i18n.py +++ b/src/i18n.py @@ -70,7 +70,8 @@ def import_conf(): conf = __import__('supybot.conf').conf conf.registerGlobalValue(conf.supybot, 'language', conf.registry.String(currentLocale, """Determines the bot's default - language. Valid values are things like en, fr, de, etc.""")) + language if translations exist. Currently supported are 'en', 'de', + 'es', 'fi', 'fr' and 'it'.""")) conf.supybot.language.addCallback(reloadLocalesIfRequired) def getPluginDir(plugin_name): diff --git a/src/ircutils.py b/src/ircutils.py index 49caf9d06..c7968954a 100644 --- a/src/ircutils.py +++ b/src/ircutils.py @@ -667,40 +667,17 @@ for (k, v) in mircColors.items(): def standardSubstitute(irc, msg, text, env=None): """Do the standard set of substitutions on text, and return it""" - if isChannel(msg.args[0]): - channel = msg.args[0] - else: - channel = 'somewhere' def randInt(): return str(random.randint(-1000, 1000)) def randDate(): t = pow(2,30)*random.random()+time.time()/4.0 return time.ctime(t) - def randNick(): - if channel != 'somewhere': - L = list(irc.state.channels[channel].users) - if len(L) > 1: - n = msg.nick - while n == msg.nick: - n = utils.iter.choice(L) - return n - else: - return msg.nick - else: - return 'someone' ctime = time.strftime("%a %b %d %H:%M:%S %Y") localtime = time.localtime() gmtime = time.strftime("%a %b %d %H:%M:%S %Y", time.gmtime()) vars = CallableValueIrcDict({ - 'who': msg.nick, - 'nick': msg.nick, - 'user': msg.user, - 'host': msg.host, - 'channel': channel, - 'botnick': irc.nick, 'now': ctime, 'ctime': ctime, 'utc': gmtime, 'gmt': gmtime, - 'randnick': randNick, 'randomnick': randNick, 'randdate': randDate, 'randomdate': randDate, 'rand': randInt, 'randint': randInt, 'randomint': randInt, 'today': time.strftime('%d %b %Y', localtime), @@ -715,8 +692,48 @@ def standardSubstitute(irc, msg, text, env=None): 'tz': time.strftime('%Z', localtime), 'version': 'Supybot %s' % version, }) - if msg.reply_env: - vars.update(msg.reply_env) + if irc: + vars.update({ + 'botnick': irc.nick, + }) + + if msg: + vars.update({ + 'who': msg.nick, + 'nick': msg.nick, + 'user': msg.user, + 'host': msg.host, + }) + if msg.reply_env: + vars.update(msg.reply_env) + + if irc and msg: + if isChannel(msg.args[0]): + channel = msg.args[0] + else: + channel = 'somewhere' + def randNick(): + if channel != 'somewhere': + L = list(irc.state.channels[channel].users) + if len(L) > 1: + n = msg.nick + while n == msg.nick: + n = utils.iter.choice(L) + return n + else: + return msg.nick + else: + return 'someone' + vars.update({ + 'randnick': randNick, 'randomnick': randNick, + 'channel': channel, + }) + else: + vars.update({ + 'channel': 'somewhere', + 'randnick': 'someone', 'randomnick': 'someone', + }) + if env is not None: vars.update(env) t = string.Template(text) diff --git a/test/test_ircutils.py b/test/test_ircutils.py index b0fca5261..ebb2ac572 100644 --- a/test/test_ircutils.py +++ b/test/test_ircutils.py @@ -216,6 +216,9 @@ class FunctionsTestCase(SupyTestCase): vars = {'foo': 'bar', 'b': 'c', 'i': 100, 'f': lambda: 'called'} self.assertEqual(f(irc, msg, '$foo', vars), 'bar') + self.assertEqual(f(irc, None, '$foo', vars), 'bar') + self.assertEqual(f(None, None, '$foo', vars), 'bar') + self.assertEqual(f(None, msg, '$foo', vars), 'bar') self.assertEqual(f(irc, msg, '${foo}', vars), 'bar') self.assertEqual(f(irc, msg, '$b', vars), 'c') self.assertEqual(f(irc, msg, '${b}', vars), 'c')