From bcdea938afc374e1505e8587115003e01c7abd04 Mon Sep 17 00:00:00 2001 From: Harri Berglund Date: Sun, 4 Jan 2015 14:18:32 +0200 Subject: [PATCH] safety: Fix channel operator check The isop attribute has been removed from Trigger and thus issuing .safety on/off would cause an AttributeError. --- safety.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/safety.py b/safety.py index ffb3baf5bc..76a5a62c2e 100644 --- a/safety.py +++ b/safety.py @@ -12,8 +12,8 @@ from willie.config import ConfigurationError from willie.formatting import color, bold from willie.logger import get_logger +from willie.module import commands, interval, priority, rule, OP import willie.tools -import willie.module import sys import json import time @@ -157,17 +157,18 @@ def url_handler(bot, trigger): @willie.module.commands('safety') def toggle_safety(bot, trigger): """ Set safety setting for channel """ + if not trigger.admin and bot.privileges[trigger.sender][trigger.nick] < OP: + bot.reply('Only channel operators can change safety settings') + return allowed_states = ['strict', 'on', 'off', 'local', 'local strict'] if not trigger.group(2) or trigger.group(2).lower() not in allowed_states: options = ' / '.join(allowed_states) bot.reply('Available options: %s' % options) return - if not trigger.isop and not trigger.admin: - bot.reply('Only channel operators can change safety settings') channel = trigger.sender.lower() bot.db.set_channel_value(channel, 'safety', trigger.group(2).lower()) - bot.reply('Safety is now set to %s in this channel' % trigger.group(2)) + bot.reply('Safety is now set to "%s" on this channel' % trigger.group(2)) # Clean the cache every day, also when > 1024 entries