Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

safety: Fix channel operator check #719

Merged
merged 1 commit into from
Jan 26, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions willie/modules/safety.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down