From 40310c4d5ad29b4ec6c88b018623f49a0c2c4f65 Mon Sep 17 00:00:00 2001 From: GLolol Date: Sun, 11 Jan 2015 19:47:20 -0800 Subject: [PATCH 01/15] Karma: only track karma for nicks --- plugins/Karma/plugin.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/Karma/plugin.py b/plugins/Karma/plugin.py index 2b8671530..3ce2bc7f4 100644 --- a/plugins/Karma/plugin.py +++ b/plugins/Karma/plugin.py @@ -250,6 +250,10 @@ class Karma(callbacks.Plugin): for s in inc: if thing.endswith(s): thing = thing[:-len(s)] + # Don't reply if the target isn't a nick + if 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.')) @@ -259,6 +263,9 @@ class Karma(callbacks.Plugin): for s in dec: if thing.endswith(s): thing = thing[:-len(s)] + if 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.')) From 472921389897757edeeb1027dd3cead728228a74 Mon Sep 17 00:00:00 2001 From: GLolol Date: Mon, 12 Jan 2015 18:08:44 -0800 Subject: [PATCH 02/15] Karma: refactor _doKarma handling --- plugins/Karma/plugin.py | 49 +++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/plugins/Karma/plugin.py b/plugins/Karma/plugin.py index 3ce2bc7f4..59275410d 100644 --- a/plugins/Karma/plugin.py +++ b/plugins/Karma/plugin.py @@ -246,32 +246,33 @@ 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)] - # Don't reply if the target isn't a nick - if 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): + karma = '' + for s in inc: + if thing.endswith(s): + thing = thing[:-len(s)] + # Don't reply if the target isn't a nick + if 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 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)) + 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 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): From bc7430cce49296a888a18ad9dd4782ecc64cd3e8 Mon Sep 17 00:00:00 2001 From: James Lu Date: Wed, 14 Jan 2015 21:26:50 -0500 Subject: [PATCH 03/15] Karma: make onlyNicks a config option Conflicts: plugins/Karma/plugin.py --- plugins/Karma/config.py | 3 +++ plugins/Karma/plugin.py | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) 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 59275410d..c29bedabb 100644 --- a/plugins/Karma/plugin.py +++ b/plugins/Karma/plugin.py @@ -246,12 +246,13 @@ class Karma(callbacks.Plugin): def _doKarma(self, irc, msg, channel, thing): inc = self.registryValue('incrementChars', channel) dec = self.registryValue('decrementChars', 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 thing.lower() not in map(ircutils.toLower, + if onlynicks and thing.lower() not in map(ircutils.toLower, irc.state.channels[channel].users): return if ircutils.strEqual(thing, msg.nick) and \ @@ -263,7 +264,7 @@ class Karma(callbacks.Plugin): for s in dec: if thing.endswith(s): thing = thing[:-len(s)] - if thing.lower() not in map(ircutils.toLower, + if onlynicks and thing.lower() not in map(ircutils.toLower, irc.state.channels[channel].users): return if ircutils.strEqual(thing, msg.nick) and \ From 981ec12baa410fb373b755fac1273e812cd744de Mon Sep 17 00:00:00 2001 From: James Lu Date: Fri, 16 Jan 2015 19:44:29 -0500 Subject: [PATCH 04/15] Karma: add tests for onlyNicks --- plugins/Karma/test.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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: From 21cfa58a519c14ddbee0dc20f9d6d996d637b10b Mon Sep 17 00:00:00 2001 From: nyuszika7h Date: Sat, 24 Jan 2015 11:50:37 +0100 Subject: [PATCH 05/15] ShrinkUrl: Update PO files from messages.pot --- plugins/ShrinkUrl/locales/fr.po | 48 ++++++++------ plugins/ShrinkUrl/locales/it.po | 111 ++++++++++++++++++++------------ 2 files changed, 97 insertions(+), 62 deletions(-) diff --git a/plugins/ShrinkUrl/locales/fr.po b/plugins/ShrinkUrl/locales/fr.po index 320f5ef36..83cf625b5 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" +"POT-Creation-Date: 2014-12-20 11:59+EET\n" "PO-Revision-Date: \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 +#: config.py:45 config.py:49 msgid "Valid values include 'ln', 'tiny', 'xrl', 'goo', 'ur1', and 'x0'." msgstr "" "Les valeurs valides incluent 'ln', 'tiny', 'xrl', '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,7 +125,7 @@ msgstr "" "\n" "Retourne une version de TinyURL.com de l'." -#: plugin.py:245 +#: plugin.py:248 msgid "" "\n" "\n" @@ -133,7 +136,7 @@ msgstr "" "\n" "Retourne une version de xrl.us de l'." -#: plugin.py:275 +#: plugin.py:281 msgid "" "\n" "\n" @@ -144,7 +147,7 @@ msgstr "" "\n" "Retourne une version de goo.gl de l'." -#: plugin.py:305 +#: plugin.py:311 msgid "" "\n" "\n" @@ -155,7 +158,7 @@ msgstr "" "\n" "Retourne une version de ur1 de l'." -#: plugin.py:332 +#: plugin.py:338 msgid "" "\n" "\n" @@ -166,7 +169,7 @@ msgstr "" "\n" "Retourne une version de x0.no de l'." -#: plugin.py:359 +#: plugin.py:365 msgid "" "\n" "\n" @@ -176,3 +179,6 @@ msgstr "" "\n" "\n" "Retourne la version large 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..4a4a1a5d0 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: 2014-12-20 11:59+EET\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', 'xrl', 'goo', 'ur1', and 'x0'." +msgstr "" +"I valori validi comprendono \"ln\", \"tiny\", \"xrl\", \"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,8 +132,7 @@ msgstr "" " Restituisce una versione di TinyURL.com di \n" " " -#: plugin.py:224 -#, docstring +#: plugin.py:248 msgid "" "\n" "\n" @@ -138,8 +144,7 @@ msgstr "" " Restituisce una versione di xrl.us di .\n" " " -#: plugin.py:255 -#, docstring +#: plugin.py:281 msgid "" "\n" "\n" @@ -151,8 +156,20 @@ msgstr "" " Restituisce una versione di goo.gl di .\n" " " -#: plugin.py:281 -#, docstring +#: plugin.py:311 +#, fuzzy +msgid "" +"\n" +"\n" +" Returns an ur1 version of .\n" +" " +msgstr "" +"\n" +"\n" +" Restituisce una versione di xrl.us di .\n" +" " + +#: plugin.py:338 msgid "" "\n" "\n" @@ -164,3 +181,15 @@ msgstr "" " Restituisce una versione di x0.no di .\n" " " +#: plugin.py:365 +#, fuzzy +msgid "" +"\n" +"\n" +" Returns an expanded version of .\n" +" " +msgstr "" +"\n" +"\n" +" Restituisce una versione di x0.no di .\n" +" " From 1d722f9c307234f19e2d9be7d815b2b7e7a0e6ad Mon Sep 17 00:00:00 2001 From: nyuszika7h Date: Sat, 24 Jan 2015 19:33:33 +0100 Subject: [PATCH 06/15] ShrinkUrl: Remove xrl.us > Please note: Adding new links has been disabled since September 2014 > after 14 months notice. Source: http://metamark.net/ --- plugins/ShrinkUrl/config.py | 6 ++--- plugins/ShrinkUrl/locales/fi.po | 39 ++++++++++++++++----------------- plugins/ShrinkUrl/locales/fr.po | 37 +++++++++++++++---------------- plugins/ShrinkUrl/locales/it.po | 37 +++++++++++++++---------------- plugins/ShrinkUrl/messages.pot | 21 +++++------------- plugins/ShrinkUrl/plugin.py | 29 ------------------------ plugins/ShrinkUrl/test.py | 5 ----- 7 files changed, 64 insertions(+), 110 deletions(-) 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 83cf625b5..f4531dae5 100644 --- a/plugins/ShrinkUrl/locales/fr.po +++ b/plugins/ShrinkUrl/locales/fr.po @@ -1,8 +1,8 @@ msgid "" msgstr "" "Project-Id-Version: Limnoria\n" -"POT-Creation-Date: 2014-12-20 11:59+EET\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" @@ -23,9 +23,9 @@ msgstr "" "snarfer ?" #: config.py:45 config.py:49 -msgid "Valid values include 'ln', 'tiny', 'xrl', 'goo', 'ur1', and 'x0'." +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:70 msgid "" @@ -125,18 +125,7 @@ msgstr "" "\n" "Retourne une version de TinyURL.com de l'." -#: plugin.py:248 -msgid "" -"\n" -"\n" -" Returns an xrl.us version of .\n" -" " -msgstr "" -"\n" -"\n" -"Retourne une version de xrl.us de l'." - -#: plugin.py:281 +#: plugin.py:252 msgid "" "\n" "\n" @@ -147,7 +136,7 @@ msgstr "" "\n" "Retourne une version de goo.gl de l'." -#: plugin.py:311 +#: plugin.py:282 msgid "" "\n" "\n" @@ -158,7 +147,7 @@ msgstr "" "\n" "Retourne une version de ur1 de l'." -#: plugin.py:338 +#: plugin.py:309 msgid "" "\n" "\n" @@ -169,7 +158,7 @@ msgstr "" "\n" "Retourne une version de x0.no de l'." -#: plugin.py:365 +#: plugin.py:336 msgid "" "\n" "\n" @@ -180,5 +169,15 @@ msgstr "" "\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 4a4a1a5d0..622c31e29 100644 --- a/plugins/ShrinkUrl/locales/it.po +++ b/plugins/ShrinkUrl/locales/it.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: Limnoria\n" -"POT-Creation-Date: 2014-12-20 11:59+EET\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" @@ -21,9 +21,9 @@ msgstr "" #: config.py:45 config.py:49 #, fuzzy -msgid "Valid values include 'ln', 'tiny', 'xrl', 'goo', 'ur1', and 'x0'." +msgid "Valid values include 'ln', 'tiny', 'goo', 'ur1', and 'x0'." msgstr "" -"I valori validi comprendono \"ln\", \"tiny\", \"xrl\", \"goo\" e \"x0\"." +"I valori validi comprendono \"ln\", \"tiny\", \"goo\" e \"x0\"." #: config.py:70 msgid "" @@ -132,19 +132,7 @@ msgstr "" " Restituisce una versione di TinyURL.com di \n" " " -#: plugin.py:248 -msgid "" -"\n" -"\n" -" Returns an xrl.us version of .\n" -" " -msgstr "" -"\n" -"\n" -" Restituisce una versione di xrl.us di .\n" -" " - -#: plugin.py:281 +#: plugin.py:252 msgid "" "\n" "\n" @@ -156,7 +144,7 @@ msgstr "" " Restituisce una versione di goo.gl di .\n" " " -#: plugin.py:311 +#: plugin.py:282 #, fuzzy msgid "" "\n" @@ -169,7 +157,7 @@ msgstr "" " Restituisce una versione di xrl.us di .\n" " " -#: plugin.py:338 +#: plugin.py:309 msgid "" "\n" "\n" @@ -181,7 +169,7 @@ msgstr "" " Restituisce una versione di x0.no di .\n" " " -#: plugin.py:365 +#: plugin.py:336 #, fuzzy msgid "" "\n" @@ -193,3 +181,14 @@ msgstr "" "\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 ef0cdb1a7..9298b8ec1 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, ['url'])) - _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, ['url'])) - _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') From c06ed4598368a15a7c0f77aaca2dfb5a4743703d Mon Sep 17 00:00:00 2001 From: James Lu Date: Sun, 1 Feb 2015 20:52:00 -0500 Subject: [PATCH 07/15] Channel: prevent mass-highlights with 'nicks' by defaulting the output to private This adds a new config variable plugins.Channel.nicksInPrivate. Cherry-picked from commit GLolol@2cc9e9d. --- plugins/Channel/config.py | 4 ++++ plugins/Channel/plugin.py | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) 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', From 720b299e82bcbb35e9a4e54362da431982841cb9 Mon Sep 17 00:00:00 2001 From: Ben McGinnes Date: Fri, 6 Feb 2015 18:11:52 +1100 Subject: [PATCH 08/15] Clearsign authorisation via subkey. Replacement code which might work to enable advanced keys with signing subkeys to be correctly handled by the bot by associating the subkey with the relevant master key. Signing format still only clearsigning, the key details are more important and auth via encrypted token and decryption is likely to be more reliable anyway as there is far less chance of some other protocol messing with the signed content. Effectively no chance, though the odd corrupted packet here and there is still possible. Whereas with clearsigning it can be broken by all manner of rewriting in transit (which happens often enough with signed email as it is). See also Issue #1045 for greater detail of what needs to be fixed and what is to be done about it. --- plugins/User/plugin.py | 56 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 10 deletions(-) diff --git a/plugins/User/plugin.py b/plugins/User/plugin.py index 87968b455..61e6a70b2 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): """ @@ -524,20 +525,55 @@ class User(callbacks.Plugin): verified = gpg.keyring.verify(data) if verified and verified.valid: keyid = verified.key_id + fprint = verified.pubkey_fingerprint + kprint = fprint[-16:] prefix, expiry = self._tokens.pop(token) found = False - for (id, user) in ircdb.users.items(): - if keyid in [x[-len(keyid):] for x in user.gpgkeys]: - try: - user.addAuth(msg.prefix) - except ValueError: - irc.error(_('Your secure flag is true and your ' - 'hostmask doesn\'t match any of your ' - 'known hostmasks.'), Raise=True) + pkeys = gpg.list_keys(False) + pnum = len(pkeys) + for x in range(pnum): + if keyid or kprint in pkeys[x]["keyid"] and keyid in user.gpgkeys and if keyid is kprint: + user.addAuth(msg.prefix) ircdb.users.setUser(user, flush=False) - irc.reply(_('You are now authenticated as %s.') % - user.name) + irc.reply(_('You are now authenticated as %s with %s.') + % (user.name, keyid)) return + elif keyid or kprint in pkeys[x]["keyid"] and keyid not in user.gpgkeys and kprint is in user.gpgkeys and keyid is not kprint: + user.addAuth(msg.prefix) + ircdb.users.setUser(user, flush=False) + irc.reply(_('You are now authenticated as %s with %s using the %s subkey.') + % (user.name, keyid, kprint)) + return + elif keyid or kprint in pkeys[x]["keyid"] and keyid is kprint and keyid not in user.gpgkeys: + irc.error(_('I have a record of key %s, but it is not associated with the %s account.') % (keyid, user.name)) + return + elif keyid or kprint in pkeys[x]["keyid"] and keyid is not kprint and keyid not in user.gpgkeys and kprint not in user.gpgkeys: + irc.error(_('I have a record of key %s, but it is not associated with any account.') % (keyid)) + return + elif keyid is kprint and keyid not in pkeys[x]["keyid"] and keyid in user.gpgkeys: + irc.error(_('The %s key is registered to the %s account, but not currently available to me. Please add the key again') % (keyid, user.name)) + # Possibly replace this with key retrieval attempt. + # try: + # code to retrieve key from server + # except AnErrorOfSomeKind: + # the current error message. + return + elif keyid and kprint not in pkeys[x]["keyid"] and keyid is not kprint and keyid not in user.gpgkeys and kprint not in user.gpgkeys: + irc.error(_('Unknown GPG key.'), Raise=True) + return + #for (id, user) in ircdb.users.items(): + # if keyid in [x[-len(keyid):] for x in user.gpgkeys]: + # user.addAuth(msg.prefix) + # try: + # user.addAuth(msg.prefix) + # except ValueError: + # irc.error(_('Your secure flag is true and your ' + # 'hostmask doesn\'t match any of your ' + # 'known hostmasks.'), Raise=True) + # ircdb.users.setUser(user, flush=False) + # irc.reply(_('You are now authenticated as %s.') % + # user.name) + # return irc.error(_('Unknown GPG key.'), Raise=True) else: irc.error(_('Signature could not be verified. Make sure ' From 544befd2d0bfb68103490da8b9c4d7ba21335899 Mon Sep 17 00:00:00 2001 From: Mikaela Suomalainen Date: Fri, 6 Feb 2015 11:58:24 +0200 Subject: [PATCH 09/15] src/i18n.py: mention supported languages Closes #1046 I used Admin for sources of what languages are supported as it's usually recommended to start translating from there (first plugins, then core). --- src/i18n.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/i18n.py b/src/i18n.py index 9d832272b..f1fcfc336 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 de, es, fi, + fr and it.""")) conf.supybot.language.addCallback(reloadLocalesIfRequired) def getPluginDir(plugin_name): From 432b8f8fb536207970c37ef8c9f0f56df64b83f2 Mon Sep 17 00:00:00 2001 From: Ben McGinnes Date: Fri, 6 Feb 2015 21:33:30 +1100 Subject: [PATCH 10/15] Solved the subkey selection issue. Changes one line and adds six to do this: * change keyid = verified.keyid to be keyid0; * added an if/else check to see if it's the subkey or master key; and * then set keyid according the result of that check; * then continues as normal. --- plugins/User/plugin.py | 58 +++++++++++------------------------------- 1 file changed, 15 insertions(+), 43 deletions(-) diff --git a/plugins/User/plugin.py b/plugins/User/plugin.py index 61e6a70b2..3c16614bb 100644 --- a/plugins/User/plugin.py +++ b/plugins/User/plugin.py @@ -524,56 +524,28 @@ class User(callbacks.Plugin): 'Authentication aborted.'), Raise=True) verified = gpg.keyring.verify(data) if verified and verified.valid: - keyid = verified.key_id + keyid0 = verified.key_id fprint = verified.pubkey_fingerprint kprint = fprint[-16:] prefix, expiry = self._tokens.pop(token) found = False - pkeys = gpg.list_keys(False) - pnum = len(pkeys) - for x in range(pnum): - if keyid or kprint in pkeys[x]["keyid"] and keyid in user.gpgkeys and if keyid is kprint: + if keyid0 == kprint: + keyid = keyid0 + else: + keyid = kprint + for (id, user) in ircdb.users.items(): + if keyid in [x[-len(keyid):] for x in user.gpgkeys]: user.addAuth(msg.prefix) + try: + user.addAuth(msg.prefix) + except ValueError: + irc.error(_('Your secure flag is true and your ' + 'hostmask doesn\'t match any of your ' + 'known hostmasks.'), Raise=True) ircdb.users.setUser(user, flush=False) - irc.reply(_('You are now authenticated as %s with %s.') - % (user.name, keyid)) + irc.reply(_('You are now authenticated as %s.') % + user.name) return - elif keyid or kprint in pkeys[x]["keyid"] and keyid not in user.gpgkeys and kprint is in user.gpgkeys and keyid is not kprint: - user.addAuth(msg.prefix) - ircdb.users.setUser(user, flush=False) - irc.reply(_('You are now authenticated as %s with %s using the %s subkey.') - % (user.name, keyid, kprint)) - return - elif keyid or kprint in pkeys[x]["keyid"] and keyid is kprint and keyid not in user.gpgkeys: - irc.error(_('I have a record of key %s, but it is not associated with the %s account.') % (keyid, user.name)) - return - elif keyid or kprint in pkeys[x]["keyid"] and keyid is not kprint and keyid not in user.gpgkeys and kprint not in user.gpgkeys: - irc.error(_('I have a record of key %s, but it is not associated with any account.') % (keyid)) - return - elif keyid is kprint and keyid not in pkeys[x]["keyid"] and keyid in user.gpgkeys: - irc.error(_('The %s key is registered to the %s account, but not currently available to me. Please add the key again') % (keyid, user.name)) - # Possibly replace this with key retrieval attempt. - # try: - # code to retrieve key from server - # except AnErrorOfSomeKind: - # the current error message. - return - elif keyid and kprint not in pkeys[x]["keyid"] and keyid is not kprint and keyid not in user.gpgkeys and kprint not in user.gpgkeys: - irc.error(_('Unknown GPG key.'), Raise=True) - return - #for (id, user) in ircdb.users.items(): - # if keyid in [x[-len(keyid):] for x in user.gpgkeys]: - # user.addAuth(msg.prefix) - # try: - # user.addAuth(msg.prefix) - # except ValueError: - # irc.error(_('Your secure flag is true and your ' - # 'hostmask doesn\'t match any of your ' - # 'known hostmasks.'), Raise=True) - # ircdb.users.setUser(user, flush=False) - # irc.reply(_('You are now authenticated as %s.') % - # user.name) - # return irc.error(_('Unknown GPG key.'), Raise=True) else: irc.error(_('Signature could not be verified. Make sure ' From 861efee8f2439bd638a70b405cda765ef82e74c7 Mon Sep 17 00:00:00 2001 From: Ben McGinnes Date: Fri, 6 Feb 2015 21:44:20 +1100 Subject: [PATCH 11/15] Removed a relic of poor coding options. --- plugins/User/plugin.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/User/plugin.py b/plugins/User/plugin.py index 3c16614bb..172bdecc4 100644 --- a/plugins/User/plugin.py +++ b/plugins/User/plugin.py @@ -535,7 +535,6 @@ class User(callbacks.Plugin): keyid = kprint for (id, user) in ircdb.users.items(): if keyid in [x[-len(keyid):] for x in user.gpgkeys]: - user.addAuth(msg.prefix) try: user.addAuth(msg.prefix) except ValueError: From a7bbc46eb9979ec4d35694d046bc8c52209592cc Mon Sep 17 00:00:00 2001 From: Ben McGinnes Date: Sat, 7 Feb 2015 04:27:51 +1100 Subject: [PATCH 12/15] Streamlining the patch back down to a single line. Since the keyid should always match the master key, regardless of whether there's a subkey or not, reduced this to simply make keyid be the last 16 chars of the master key's fingerprint. --- plugins/User/plugin.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/plugins/User/plugin.py b/plugins/User/plugin.py index 172bdecc4..39a03a089 100644 --- a/plugins/User/plugin.py +++ b/plugins/User/plugin.py @@ -524,15 +524,9 @@ class User(callbacks.Plugin): 'Authentication aborted.'), Raise=True) verified = gpg.keyring.verify(data) if verified and verified.valid: - keyid0 = verified.key_id - fprint = verified.pubkey_fingerprint - kprint = fprint[-16:] + keyid = verified.pubkey_fingerprint[-16:] prefix, expiry = self._tokens.pop(token) found = False - if keyid0 == kprint: - keyid = keyid0 - else: - keyid = kprint for (id, user) in ircdb.users.items(): if keyid in [x[-len(keyid):] for x in user.gpgkeys]: try: From 5e4501d7d218d131b5a7bfc438a3cb8acb56bec2 Mon Sep 17 00:00:00 2001 From: James Lu Date: Fri, 6 Feb 2015 15:40:44 -0800 Subject: [PATCH 13/15] i18n.py: mention 'en' as supported lang & quote the language codes for less ambiguity. Ref #1046. --- src/i18n.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/i18n.py b/src/i18n.py index f1fcfc336..ddd12ff7e 100644 --- a/src/i18n.py +++ b/src/i18n.py @@ -70,8 +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 if translations exist. Currently supported are de, es, fi, - fr and it.""")) + language if translations exist. Currently supported are 'en', 'de', + 'es', 'fi', 'fr' and 'it'.""")) conf.supybot.language.addCallback(reloadLocalesIfRequired) def getPluginDir(plugin_name): From 29de1e137d06373ff8ffdf2a70c9e34d9bd9ac3d Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sat, 7 Feb 2015 08:14:18 +0100 Subject: [PATCH 14/15] Fix 2to3 progression percentage (no long go over 100%). --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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( From cb6669015e4dfd113f3daf6e3797708d7ce307c1 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sat, 7 Feb 2015 08:15:00 +0100 Subject: [PATCH 15/15] Make ircutils.standardSubstitute accept None as irc and msg. (Preliminary for GH-1041.) --- src/ircutils.py | 67 +++++++++++++++++++++++++++---------------- test/test_ircutils.py | 3 ++ 2 files changed, 45 insertions(+), 25 deletions(-) diff --git a/src/ircutils.py b/src/ircutils.py index 9768e676d..324c455bc 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), @@ -714,8 +691,48 @@ def standardSubstitute(irc, msg, text, env=None): 's': localtime[5], 'sec': localtime[5], 'second': localtime[5], 'tz': time.strftime('%Z', localtime), }) - 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')