mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 13:19:24 +01:00
Merge branch 'testing'
This commit is contained in:
commit
9f5b3f635a
@ -50,11 +50,8 @@ class AutoMode(callbacks.Plugin):
|
||||
return
|
||||
fallthrough = self.registryValue('fallthrough', channel)
|
||||
def do(type):
|
||||
if ircdb.checkCapability(msg.prefix, 'owner') and not \
|
||||
self.registryValue('owner'):
|
||||
raise Continue
|
||||
cap = ircdb.makeChannelCapability(channel, type)
|
||||
if ircdb.checkCapability(msg.prefix, cap):
|
||||
if ircdb.checkCapability(msg.prefix, cap, ignoreOwner=True):
|
||||
if self.registryValue(type, channel):
|
||||
self.log.info('Sending auto-%s of %s in %s.',
|
||||
type, msg.prefix, channel)
|
||||
|
@ -57,7 +57,9 @@ conf.registerGlobalValue(BadWords,'requireWordBoundaries',
|
||||
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. After changing this setting, the BadWords regexp needs to be
|
||||
regenerated by adding/removing a word to the list, or reloading the
|
||||
plugin.""")))
|
||||
|
||||
class String256(registry.String):
|
||||
def __call__(self):
|
||||
|
@ -1,7 +1,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Supybot-fr\n"
|
||||
"POT-Creation-Date: 2010-10-16 18:51+CEST\n"
|
||||
"POT-Creation-Date: 2011-01-29 11:48+CET\n"
|
||||
"PO-Revision-Date: \n"
|
||||
"Last-Translator: Valentin Lorentz <progval@gmail.com>\n"
|
||||
"Language-Team: Supybot-fr <progval@gmail.com>\n"
|
||||
@ -13,6 +13,13 @@ msgstr ""
|
||||
"X-Poedit-Country: France\n"
|
||||
"X-Poedit-SourceCharset: ASCII\n"
|
||||
|
||||
#: __init__.py:30
|
||||
msgid ""
|
||||
"\n"
|
||||
"Filters bad words on outgoing messages from the bot, so the bot can't be made\n"
|
||||
"to say bad words.\n"
|
||||
msgstr ""
|
||||
|
||||
#: config.py:40
|
||||
msgid "Would you like to add some bad words?"
|
||||
msgstr "Voulez-vous ajouter quelques mots interdits ?"
|
||||
@ -33,17 +40,19 @@ msgid ""
|
||||
" 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 "Détermine si le bot requiert que les gros mots soient indépendants, ou si ils peuvent être dans d'autres mots. Par exemple, si 'pute' est censuré et que c'est True, 'merde' sera censuré, mais pas 'emmerder'. Il est probablement mieux que ceci soit False."
|
||||
" false. After changing this setting, the BadWords regexp needs to be\n"
|
||||
" regenerated by adding/removing a word to the list, or reloading the\n"
|
||||
" plugin."
|
||||
msgstr "Détermine si le bot requiert que les gros mots soient indépendants, ou si ils peuvent être dans d'autres mots. Par exemple, si 'merde' est censuré et que c'est True, 'merde' sera censuré, mais pas 'emmerder'. Il est probablement mieux que ceci soit False. Après avoir modifié ce paramètre, l'expression régulière de BadWords doit être regénérée en ajoutant/supprimant un mot de la liste, ou en rechargeant le plugin."
|
||||
|
||||
#: config.py:71
|
||||
#: config.py:73
|
||||
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 "Détermine par quels caractères seront remplacés les gros mots ; un morceau de ces caractères ayant la même taille que le mot remplacé sera utilisé pour remplacer les gros mots que vous avez configurés."
|
||||
|
||||
#: config.py:79
|
||||
#: config.py:81
|
||||
msgid ""
|
||||
"Determines the manner in which\n"
|
||||
" bad words will be replaced. 'nastyCharacters' (the default) will replace a\n"
|
||||
@ -54,13 +63,13 @@ msgid ""
|
||||
" supybot.plugins.BadWords.simpleReplacement."
|
||||
msgstr "Détermine la manière dont les gros mots sont remplacés. 'nastyCharacters' (par défaut) remplacera un gros mot par le même nombre de 'caractères obscènes' (comme ceux utilisés dans les bandes dessinées ; configurables dans supybot.plugins.BadWords.nastyChars). 'simple' remplacera le mot pas une simple chaîne (peu importe la taille du gros mot) ; cette chaîne est configurable dans supybot.plugins.BadWords.simpleReplacement."
|
||||
|
||||
#: config.py:87
|
||||
#: config.py:89
|
||||
msgid ""
|
||||
"Determines what word will replace bad\n"
|
||||
" words if the replacement method is 'simple'."
|
||||
msgstr "Détermin quel mot remplacera les mots interdits, si la méthode de remplacement est 'simple'."
|
||||
|
||||
#: config.py:90
|
||||
#: config.py:92
|
||||
msgid ""
|
||||
"Determines whether the bot will strip\n"
|
||||
" formatting characters from messages before it checks them for bad words.\n"
|
||||
@ -69,13 +78,33 @@ msgid ""
|
||||
" plugins that do coloring or bolding of text."
|
||||
msgstr "Détermine si le bot retirera les caractères de formattage avant de vérifier qu'ils contiennent des gros mots. Si ceci est False, ce sera relativement simple de contourner la protection. Si c'est True, toutefois, il fera perdre toute couleur ou formattage des autres plugins"
|
||||
|
||||
#: config.py:97
|
||||
#: config.py:99
|
||||
msgid ""
|
||||
"Determines whether the bot will kick people with\n"
|
||||
" a warning when they use bad words."
|
||||
msgstr "Détermine si le bot kickera les gens avec un avertissement lorsqu'ils utilisent des gros mots."
|
||||
|
||||
#: plugin.py:110
|
||||
#: config.py:102
|
||||
msgid ""
|
||||
"You have been kicked for using a word\n"
|
||||
" prohibited in the presence of this bot. Please use more appropriate\n"
|
||||
" language in the future."
|
||||
msgstr "Vous avez été kické(e) parce que vous avez utilisé un mot interdit en la présence de ce bot. Veuillez utiliser un langage plus approprié par le futur."
|
||||
|
||||
#: config.py:104
|
||||
msgid ""
|
||||
"Determines the kick message used by the\n"
|
||||
" bot when kicking users for saying bad words."
|
||||
msgstr "Détermine le message de kick utilisé par le bot lorsqu'il kick des utilisateurs utilisant des gros mots."
|
||||
|
||||
#: plugin.py:46
|
||||
msgid ""
|
||||
"Maintains a list of words that the bot is not allowed to say.\n"
|
||||
" Can also be used to kick people that say these words, if the bot\n"
|
||||
" has op."
|
||||
msgstr ""
|
||||
|
||||
#: plugin.py:113
|
||||
msgid ""
|
||||
"takes no arguments\n"
|
||||
"\n"
|
||||
@ -86,26 +115,26 @@ msgstr ""
|
||||
"\n"
|
||||
"Retourne une liste de mots qui sont censurés."
|
||||
|
||||
#: plugin.py:120
|
||||
#: plugin.py:123
|
||||
msgid "I'm not currently censoring any bad words."
|
||||
msgstr "Je ne censure actuellement aucun mot."
|
||||
|
||||
#: plugin.py:125
|
||||
#: plugin.py:128
|
||||
msgid ""
|
||||
"<word> [<word> ...]\n"
|
||||
"\n"
|
||||
" Adds all <word>s to the list of words the bot isn't to say.\n"
|
||||
" Adds all <word>s to the list of words being censored.\n"
|
||||
" "
|
||||
msgstr ""
|
||||
"<mot> [<mot> ...]\n"
|
||||
"\n"
|
||||
"Ajoute tous les mots à la liste des mots que le bot ne doit pas dire."
|
||||
|
||||
#: plugin.py:137
|
||||
#: plugin.py:140
|
||||
msgid ""
|
||||
"<word> [<word> ...]\n"
|
||||
"\n"
|
||||
" Removes a <word>s from the list of words the bot isn't to say.\n"
|
||||
" Removes <word>s from the list of words being censored.\n"
|
||||
" "
|
||||
msgstr ""
|
||||
"<mot> [<mot> ...]\n"
|
||||
|
@ -5,7 +5,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2010-10-16 18:51+CEST\n"
|
||||
"POT-Creation-Date: 2011-01-29 11:48+CET\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"
|
||||
@ -15,6 +15,14 @@ msgstr ""
|
||||
"Generated-By: pygettext.py 1.5\n"
|
||||
|
||||
|
||||
#: __init__.py:30
|
||||
#, docstring
|
||||
msgid ""
|
||||
"\n"
|
||||
"Filters bad words on outgoing messages from the bot, so the bot can't be made\n"
|
||||
"to say bad words.\n"
|
||||
msgstr ""
|
||||
|
||||
#: config.py:40
|
||||
msgid "Would you like to add some bad words?"
|
||||
msgstr ""
|
||||
@ -35,17 +43,19 @@ msgid ""
|
||||
" 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."
|
||||
" false. After changing this setting, the BadWords regexp needs to be\n"
|
||||
" regenerated by adding/removing a word to the list, or reloading the\n"
|
||||
" plugin."
|
||||
msgstr ""
|
||||
|
||||
#: config.py:71
|
||||
#: config.py:73
|
||||
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
|
||||
#: config.py:81
|
||||
msgid ""
|
||||
"Determines the manner in which\n"
|
||||
" bad words will be replaced. 'nastyCharacters' (the default) will replace a\n"
|
||||
@ -56,13 +66,13 @@ msgid ""
|
||||
" supybot.plugins.BadWords.simpleReplacement."
|
||||
msgstr ""
|
||||
|
||||
#: config.py:87
|
||||
#: config.py:89
|
||||
msgid ""
|
||||
"Determines what word will replace bad\n"
|
||||
" words if the replacement method is 'simple'."
|
||||
msgstr ""
|
||||
|
||||
#: config.py:90
|
||||
#: config.py:92
|
||||
msgid ""
|
||||
"Determines whether the bot will strip\n"
|
||||
" formatting characters from messages before it checks them for bad words.\n"
|
||||
@ -71,13 +81,34 @@ msgid ""
|
||||
" plugins that do coloring or bolding of text."
|
||||
msgstr ""
|
||||
|
||||
#: config.py:97
|
||||
#: config.py:99
|
||||
msgid ""
|
||||
"Determines whether the bot will kick people with\n"
|
||||
" a warning when they use bad words."
|
||||
msgstr ""
|
||||
|
||||
#: plugin.py:110
|
||||
#: config.py:102
|
||||
msgid ""
|
||||
"You have been kicked for using a word\n"
|
||||
" prohibited in the presence of this bot. Please use more appropriate\n"
|
||||
" language in the future."
|
||||
msgstr ""
|
||||
|
||||
#: config.py:104
|
||||
msgid ""
|
||||
"Determines the kick message used by the\n"
|
||||
" bot when kicking users for saying bad words."
|
||||
msgstr ""
|
||||
|
||||
#: plugin.py:46
|
||||
#, docstring
|
||||
msgid ""
|
||||
"Maintains a list of words that the bot is not allowed to say.\n"
|
||||
" Can also be used to kick people that say these words, if the bot\n"
|
||||
" has op."
|
||||
msgstr ""
|
||||
|
||||
#: plugin.py:113
|
||||
#, docstring
|
||||
msgid ""
|
||||
"takes no arguments\n"
|
||||
@ -86,25 +117,25 @@ msgid ""
|
||||
" "
|
||||
msgstr ""
|
||||
|
||||
#: plugin.py:120
|
||||
#: plugin.py:123
|
||||
msgid "I'm not currently censoring any bad words."
|
||||
msgstr ""
|
||||
|
||||
#: plugin.py:125
|
||||
#: plugin.py:128
|
||||
#, docstring
|
||||
msgid ""
|
||||
"<word> [<word> ...]\n"
|
||||
"\n"
|
||||
" Adds all <word>s to the list of words the bot isn't to say.\n"
|
||||
" Adds all <word>s to the list of words being censored.\n"
|
||||
" "
|
||||
msgstr ""
|
||||
|
||||
#: plugin.py:137
|
||||
#: plugin.py:140
|
||||
#, docstring
|
||||
msgid ""
|
||||
"<word> [<word> ...]\n"
|
||||
"\n"
|
||||
" Removes a <word>s from the list of words the bot isn't to say.\n"
|
||||
" Removes <word>s from the list of words being censored.\n"
|
||||
" "
|
||||
msgstr ""
|
||||
|
||||
|
@ -43,6 +43,9 @@ from supybot.i18n import PluginInternationalization, internationalizeDocstring
|
||||
_ = PluginInternationalization('BadWords')
|
||||
|
||||
class BadWords(callbacks.Privmsg):
|
||||
"""Maintains a list of words that the bot is not allowed to say.
|
||||
Can also be used to kick people that say these words, if the bot
|
||||
has op."""
|
||||
def __init__(self, irc):
|
||||
self.__parent = super(BadWords, self)
|
||||
self.__parent.__init__(irc)
|
||||
@ -68,7 +71,7 @@ class BadWords(callbacks.Privmsg):
|
||||
def inFilter(self, irc, msg):
|
||||
self.filtering = True
|
||||
# We need to check for bad words here rather than in doPrivmsg because
|
||||
# messages don't get to doPrivmsg is the user is ignored.
|
||||
# messages don't get to doPrivmsg if the user is ignored.
|
||||
if msg.command == 'PRIVMSG':
|
||||
self.updateRegexp()
|
||||
s = ircutils.stripFormatting(msg.args[1])
|
||||
@ -124,7 +127,7 @@ class BadWords(callbacks.Privmsg):
|
||||
def add(self, irc, msg, args, words):
|
||||
"""<word> [<word> ...]
|
||||
|
||||
Adds all <word>s to the list of words the bot isn't to say.
|
||||
Adds all <word>s to the list of words being censored.
|
||||
"""
|
||||
set = self.words()
|
||||
set.update(words)
|
||||
@ -136,7 +139,7 @@ class BadWords(callbacks.Privmsg):
|
||||
def remove(self, irc, msg, args, words):
|
||||
"""<word> [<word> ...]
|
||||
|
||||
Removes a <word>s from the list of words the bot isn't to say.
|
||||
Removes <word>s from the list of words being censored.
|
||||
"""
|
||||
set = self.words()
|
||||
for word in words:
|
||||
|
@ -34,7 +34,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"<groupe>\n"
|
||||
"\n"
|
||||
"Retourne les variables de configuration qui sont dans le <groupe> de configuration. Si la variable a des sous-variables, elle sera précédée par le signe '@'. Si une variable est une 'ChannelValue', elle sera précédée par le signe '#'. Plus d'informations : http://supybot-fr.tk/Configuration"
|
||||
"Retourne les variables de configuration qui sont dans le <groupe> de configuration. Si la variable a des sous-variables, elle sera précédée par le signe '@'. Si une variable est une 'ChannelValue', elle sera précédée par le signe '#'. Plus d'informations : http://supybot.fr.cr/Configuration"
|
||||
|
||||
#: plugin.py:148
|
||||
msgid "There don't seem to be any values in %s."
|
||||
|
@ -391,7 +391,7 @@ class Filter(callbacks.Plugin):
|
||||
|
||||
Returns <text> colorized like a rainbow.
|
||||
"""
|
||||
colors = utils.iter.cycle([4, 7, 8, 3, 2, 12, 6])
|
||||
colors = utils.iter.cycle(['04', '07', '08', '03', '02', '12', '06'])
|
||||
L = [self._color(c, fg=colors.next()) for c in text]
|
||||
irc.reply(''.join(L) + '\x03')
|
||||
rainbow = wrap(rainbow, ['text'])
|
||||
|
@ -302,7 +302,8 @@ class Google(callbacks.PluginRegexp):
|
||||
url = r'http://google.com/search?q=' + s
|
||||
return url
|
||||
|
||||
_calcRe = re.compile(r'<h\d class="?r"?.*?<b>(.*?)</b>', re.I)
|
||||
_calcRe1 = re.compile(r'<table.*class="?obcontainer"?[^>]*>(.*?)</table>', re.I)
|
||||
_calcRe2 = re.compile(r'<h\d class="?r"?.*?<b>(.*?)</b>', re.I)
|
||||
_calcSupRe = re.compile(r'<sup>(.*?)</sup>', re.I)
|
||||
_calcFontRe = re.compile(r'<font size=-2>(.*?)</font>')
|
||||
_calcTimesRe = re.compile(r'&(?:times|#215);')
|
||||
@ -314,12 +315,15 @@ class Google(callbacks.PluginRegexp):
|
||||
"""
|
||||
url = self._googleUrl(expr)
|
||||
html = utils.web.getUrl(url)
|
||||
match = self._calcRe.search(html)
|
||||
match = self._calcRe1.search(html)
|
||||
if match is None:
|
||||
match = self._calcRe2.search(html)
|
||||
if match is not None:
|
||||
s = match.group(1)
|
||||
s = self._calcSupRe.sub(r'^(\1)', s)
|
||||
s = self._calcFontRe.sub(r',', s)
|
||||
s = self._calcTimesRe.sub(r'*', s)
|
||||
s = utils.web.htmlToText(s)
|
||||
irc.reply(s)
|
||||
else:
|
||||
irc.reply(_('Google\'s calculator didn\'t come up with anything.'))
|
||||
|
@ -39,6 +39,7 @@ class GoogleTestCase(ChannelPluginTestCase):
|
||||
def testCalc(self):
|
||||
self.assertNotRegexp('google calc e^(i*pi)+1', r'didn\'t')
|
||||
self.assertNotRegexp('google calc 1 usd in gbp', r'didn\'t')
|
||||
self.assertRegexp('google calc current time in usa', r'Time in.*USA')
|
||||
|
||||
def testHtmlHandled(self):
|
||||
self.assertNotRegexp('google calc '
|
||||
|
@ -104,5 +104,5 @@ msgstr "Il n'y a pas de note pour %r"
|
||||
|
||||
#: plugin.py:182
|
||||
msgid "Sent %s: <%s> %s"
|
||||
msgstr "Envoyé le %s : <%s> %s"
|
||||
msgstr "Envoyé %s : <%s> %s"
|
||||
|
||||
|
@ -42,6 +42,62 @@ class Scheduler(callbacks.Plugin):
|
||||
self.__parent = super(Scheduler, self)
|
||||
self.__parent.__init__(irc)
|
||||
self.events = {}
|
||||
self._restoreEvents(irc)
|
||||
world.flushers.append(self._flush)
|
||||
|
||||
def _restoreEvents(self, irc):
|
||||
try:
|
||||
pkl = open(filename, 'rb')
|
||||
try:
|
||||
eventdict = pickle.load(pkl)
|
||||
except Exception, e:
|
||||
self.log.debug('Unable to load pickled data: %s', e)
|
||||
return
|
||||
finally:
|
||||
pkl.close()
|
||||
except IOError, e:
|
||||
self.log.debug('Unable to open pickle file: %s', e)
|
||||
return
|
||||
for name, event in eventdict.iteritems():
|
||||
ircobj = callbacks.ReplyIrcProxy(irc, event['msg'])
|
||||
try:
|
||||
if event['type'] == 'single': # non-repeating event
|
||||
n = None
|
||||
if schedule.schedule.counter > int(name):
|
||||
# counter not reset, we're probably reloading the plugin
|
||||
# though we'll never know for sure, because other
|
||||
# plugins can schedule stuff, too.
|
||||
n = int(name)
|
||||
self._add(ircobj, event['msg'],
|
||||
event['time'], event['command'], n)
|
||||
elif event['type'] == 'repeat': # repeating event
|
||||
self._repeat(ircobj, event['msg'], name,
|
||||
event['time'], event['command'], False)
|
||||
except AssertionError, e:
|
||||
if str(e) == 'An event with the same name has already been scheduled.':
|
||||
# we must be reloading the plugin, event is still scheduled
|
||||
self.log.info('Event %s already exists, adding to dict.' % (name,))
|
||||
self.events[name] = event
|
||||
else:
|
||||
raise
|
||||
|
||||
def _flush(self):
|
||||
try:
|
||||
pklfd, tempfn = tempfile.mkstemp(suffix='scheduler', dir=datadir)
|
||||
pkl = os.fdopen(pklfd, 'wb')
|
||||
try:
|
||||
pickle.dump(self.events, pkl)
|
||||
except Exception, e:
|
||||
self.log.warning('Unable to store pickled data: %s', e)
|
||||
pkl.close()
|
||||
shutil.move(tempfn, filename)
|
||||
except (IOError, shutil.Error), e:
|
||||
self.log.warning('File error: %s', e)
|
||||
|
||||
def die(self):
|
||||
self._flush()
|
||||
world.flushers.remove(self._flush)
|
||||
self.__parent.die()
|
||||
|
||||
def _makeCommandFunction(self, irc, msg, command, remove=True):
|
||||
"""Makes a function suitable for scheduling from command."""
|
||||
@ -90,6 +146,15 @@ class Scheduler(callbacks.Plugin):
|
||||
irc.error(_('Invalid event id.'))
|
||||
remove = wrap(remove, ['lowered'])
|
||||
|
||||
def _repeat(self, irc, msg, name, seconds, command, now=True):
|
||||
f = self._makeCommandFunction(irc, msg, command, remove=False)
|
||||
id = schedule.addPeriodicEvent(f, seconds, name, now)
|
||||
assert id == name
|
||||
self.events[name] = {'command':command,
|
||||
'msg':msg,
|
||||
'time':seconds,
|
||||
'type':'repeat'}
|
||||
|
||||
@internationalizeDocstring
|
||||
def repeat(self, irc, msg, args, name, seconds, command):
|
||||
"""<name> <seconds> <command>
|
||||
|
@ -50,7 +50,7 @@ class ChannelDBTestCase(ChannelPluginTestCase):
|
||||
self.assertNotRegexp('seen asldfkjasdlfkj', 'KeyError')
|
||||
|
||||
def testAny(self):
|
||||
self.assertRegexp('seen any', 'test has joined')
|
||||
self.assertRegexp('seen any', 'test <test!user@host.domain.tld> has joined')
|
||||
self.irc.feedMsg(ircmsgs.mode(self.channel, args=('+o', self.nick),
|
||||
prefix=self.prefix))
|
||||
self.assertRegexp('seen any %s' % self.nick,
|
||||
|
@ -303,6 +303,8 @@ class Services(callbacks.Plugin):
|
||||
pass
|
||||
elif ('now recognized' in s) or \
|
||||
('already identified' in s) or \
|
||||
('already logged in' in s) or \
|
||||
('successfully identified' in s) or \
|
||||
('password accepted' in s) or \
|
||||
('now identified' in s):
|
||||
# freenode, oftc, arstechnica, zirc, ....
|
||||
|
@ -85,7 +85,7 @@ class String(callbacks.Plugin):
|
||||
<http://docs.python.org/library/codecs.html#standard-encodings>.
|
||||
"""
|
||||
try:
|
||||
irc.reply(text.decode(encoding).encode('utf-8'))
|
||||
irc.reply(text.decode(encoding))
|
||||
except LookupError:
|
||||
irc.errorInvalid(_('encoding'), encoding)
|
||||
except binascii.Error:
|
||||
|
@ -403,9 +403,6 @@ class Topic(callbacks.Plugin):
|
||||
index into the topics. <channel> is only necessary if the message
|
||||
isn't sent in the channel itself.
|
||||
"""
|
||||
if not self._checkManageCapabilities(irc, msg, channel):
|
||||
capabilities = self.registryValue('requireManageCapability')
|
||||
irc.errorNoCapability(capabilities, Raise=True)
|
||||
topics = self._splitTopic(irc.state.getTopic(channel), channel)
|
||||
irc.reply(topics[number])
|
||||
get = wrap(get, ['inChannel', 'topicNumber'])
|
||||
|
@ -37,7 +37,8 @@ if os.name == 'posix':
|
||||
if utils.findBinaryInPath('aspell') is not None or \
|
||||
utils.findBinaryInPath('ispell') is not None:
|
||||
def testSpell(self):
|
||||
self.assertRegexp('spell Strike', 'correctly')
|
||||
self.assertRegexp('spell Strike',
|
||||
'(correctly|Possible spellings)')
|
||||
# ispell won't find any results. aspell will make some
|
||||
# suggestions.
|
||||
self.assertRegexp('spell z0opadfnaf83nflafl230kasdf023hflasdf',
|
||||
|
@ -314,7 +314,7 @@ def _getRe(f):
|
||||
s = args.pop(0)
|
||||
def isRe(s):
|
||||
try:
|
||||
_ = f(s)
|
||||
foo = f(s)
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
@ -477,6 +477,11 @@ def checkCapability(irc, msg, args, state, cap):
|
||||
if not ircdb.checkCapability(msg.prefix, cap):
|
||||
state.errorNoCapability(cap, Raise=True)
|
||||
|
||||
def checkCapabilityButIgnoreOwner(irc, msg, args, state, cap):
|
||||
cap = ircdb.canonicalCapability(cap)
|
||||
if not ircdb.checkCapability(msg.prefix, cap, ignoreOwner=True):
|
||||
state.errorNoCapability(cap, Raise=True)
|
||||
|
||||
def owner(irc, msg, args, state):
|
||||
checkCapability(irc, msg, args, state, 'owner')
|
||||
|
||||
@ -590,6 +595,7 @@ wrappers = ircutils.IrcDict({
|
||||
'channel': getChannel,
|
||||
'channelDb': getChannelDb,
|
||||
'checkCapability': checkCapability,
|
||||
'checkCapabilityButIgnoreOwner': checkCapabilityButIgnoreOwner,
|
||||
'checkChannelCapability': checkChannelCapability,
|
||||
'color': getIrcColor,
|
||||
'commandName': getCommandName,
|
||||
|
22
src/ircdb.py
22
src/ircdb.py
@ -1,6 +1,7 @@
|
||||
###
|
||||
# Copyright (c) 2002-2009, Jeremiah Fincher
|
||||
# Copyright (c) 2009, James Vega
|
||||
# Copyright (c) 2011, Valentin Lorentz
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@ -152,7 +153,7 @@ class CapabilitySet(set):
|
||||
elif self.__parent.__contains__(_invert(capability)):
|
||||
return False
|
||||
else:
|
||||
raise KeyError, capability
|
||||
return False
|
||||
|
||||
def __repr__(self):
|
||||
return '%s([%s])' % (self.__class__.__name__,
|
||||
@ -165,16 +166,16 @@ class UserCapabilitySet(CapabilitySet):
|
||||
self.__parent = super(UserCapabilitySet, self)
|
||||
self.__parent.__init__(*args, **kwargs)
|
||||
|
||||
def __contains__(self, capability):
|
||||
def __contains__(self, capability, ignoreOwner=False):
|
||||
capability = ircutils.toLower(capability)
|
||||
if capability == 'owner' or capability == antiOwner:
|
||||
if not ignoreOwner and capability == 'owner' or capability == antiOwner:
|
||||
return True
|
||||
elif self.__parent.__contains__('owner'):
|
||||
elif not ignoreOwner and self.__parent.__contains__('owner'):
|
||||
return True
|
||||
else:
|
||||
return self.__parent.__contains__(capability)
|
||||
|
||||
def check(self, capability):
|
||||
def check(self, capability, ignoreOwner=False):
|
||||
"""Returns the appropriate boolean for whether a given capability is
|
||||
'allowed' given its (or its anticapability's) presence in the set.
|
||||
Differs from CapabilitySet in that it handles the 'owner' capability
|
||||
@ -186,7 +187,7 @@ class UserCapabilitySet(CapabilitySet):
|
||||
return not isAntiCapability(capability)
|
||||
else:
|
||||
return isAntiCapability(capability)
|
||||
elif self.__parent.__contains__('owner'):
|
||||
elif not ignoreOwner and self.__parent.__contains__('owner'):
|
||||
if isAntiCapability(capability):
|
||||
return False
|
||||
else:
|
||||
@ -236,7 +237,7 @@ class IrcUser(object):
|
||||
"""Takes from the user the given capability."""
|
||||
self.capabilities.remove(capability)
|
||||
|
||||
def _checkCapability(self, capability):
|
||||
def _checkCapability(self, capability, ignoreOwner=False):
|
||||
"""Checks the user for a given capability."""
|
||||
if self.ignore:
|
||||
if isAntiCapability(capability):
|
||||
@ -244,7 +245,7 @@ class IrcUser(object):
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
return self.capabilities.check(capability)
|
||||
return self.capabilities.check(capability, ignoreOwner)
|
||||
|
||||
def setPassword(self, password, hashed=False):
|
||||
"""Sets the user's password."""
|
||||
@ -1009,7 +1010,8 @@ def _checkCapabilityForUnknownUser(capability, users=users, channels=channels):
|
||||
else:
|
||||
return _x(capability, conf.supybot.capabilities.default())
|
||||
|
||||
def checkCapability(hostmask, capability, users=users, channels=channels):
|
||||
def checkCapability(hostmask, capability, users=users, channels=channels,
|
||||
ignoreOwner=False):
|
||||
"""Checks that the user specified by name/hostmask has the capability given.
|
||||
"""
|
||||
if world.testing:
|
||||
@ -1028,7 +1030,7 @@ def checkCapability(hostmask, capability, users=users, channels=channels):
|
||||
return _checkCapabilityForUnknownUser(capability, users=users,
|
||||
channels=channels)
|
||||
if capability in u.capabilities:
|
||||
return u._checkCapability(capability)
|
||||
return u._checkCapability(capability, ignoreOwner)
|
||||
else:
|
||||
if isChannelCapability(capability):
|
||||
(channel, capability) = fromChannelCapability(capability)
|
||||
|
@ -196,7 +196,7 @@ def banmask(hostmask):
|
||||
L[-1] = '*'
|
||||
return '*!*@' + ':'.join(L)
|
||||
else:
|
||||
if '.' in host:
|
||||
if len(host.split('.')) > 2: # If it is a subdomain
|
||||
return '*!*@*%s' % host[host.find('.'):]
|
||||
else:
|
||||
return '*!*@' + host
|
||||
|
@ -287,6 +287,7 @@ def pluralize(s):
|
||||
@internationalizeFunction('depluralize')
|
||||
def depluralize(s):
|
||||
"""Returns the singular of s."""
|
||||
consonants = 'bcdfghjklmnpqrstvwxz'
|
||||
_depluralizeRegex = re.compile('[%s]ies' % consonants)
|
||||
lowered = s.lower()
|
||||
if lowered in plurals:
|
||||
|
@ -233,6 +233,10 @@ class FunctionsTestCase(SupyTestCase):
|
||||
msg.prefix),
|
||||
'%r didn\'t match %r' % (msg.prefix, banmask))
|
||||
self.assertEqual(ircutils.banmask('foobar!user@host'), '*!*@host')
|
||||
self.assertEqual(ircutils.banmask('foobar!user@host.tld'),
|
||||
'*!*@host.tld')
|
||||
self.assertEqual(ircutils.banmask('foobar!user@sub.host.tld'),
|
||||
'*!*@*.host.tld')
|
||||
self.assertEqual(ircutils.banmask('foo!bar@2001::'), '*!*@2001::*')
|
||||
|
||||
def testSeparateModes(self):
|
||||
|
Loading…
Reference in New Issue
Block a user