1
# gozerplugs/plugs/all.py
5
""" allow commands for all users. """
7
__gendoclast__ = ['all-del', ]
10
from gozerbot.commands import cmnds
11
from gozerbot.aliases import aliasget
12
from gozerbot.examples import examples
13
from gozerbot.plughelp import plughelp
14
from gozerbot.tests import tests
16
plughelp.add('all', 'allow commands to be executed by all users')
18
def handle_alladd(bot, ievent):
20
""" add a command to the allow all list. """
23
ievent.missing('<command>')
26
target = aliasget(ievent.rest) or ievent.rest
28
if not 'OPER' in cmnds.perms(target):
29
if target in bot.state['allowed']:
30
ievent.reply('%s is already allowed' % target)
32
bot.state['allowed'].append(target)
34
ievent.reply('%s command is now allowed for all clients' % target)
38
cmnds.add('all-add', handle_alladd, 'OPER')
39
examples.add('all-add', 'add command to be allowed by all users', 'all-add version')
40
tests.add('all-add version', 'version').add('all-del version')
42
def handle_alldel(bot, ievent):
44
""" remove a command from the all allowed list. """
47
ievent.missing('<command>')
50
target = aliasget(ievent.rest) or ievent.rest
52
if target in bot.state['allowed']:
53
bot.state['allowed'].remove(target)
54
ievent.reply('%s command is removed from allowed list' % target)
56
ievent.reply('%s command is not in allowed list' % target)
58
cmnds.add('all-del', handle_alldel, 'OPER')
59
examples.add('all-del', 'remove command from the allowed list', 'all-del version')
60
tests.add('all-add version').add('all-del version', 'version')
62
def handle_alllist(bot, ievent):
64
""" show the all allowed list. """
66
ievent.reply('commands allowed: ', bot.state['allowed'], dot=True)
68
cmnds.add('all-list', handle_alllist, 'USER')
69
examples.add('all-list', 'list commands allowed by all users', 'all-list')
70
tests.add('all-add version').add('all-list', 'version').add('all-del version')