5
""" op on join or op on !op command"""
7
__copyright__ = 'this file is in the public domain'
9
from gozerbot.generic import getwho, rlog
10
from gozerbot.commands import cmnds
11
from gozerbot.examples import examples
12
from gozerbot.callbacks import callbacks
13
from gozerbot.users import users
14
from gozerbot.plughelp import plughelp
15
from gozerbot.persistconfig import PersistConfig
18
plughelp.add('ops', 'op on command or op on join .. for op on join the user\
19
needs to have the channel name in his/hers status .. see addstatus ')
22
cfg.define('oponsplit', 0)
24
def opjoincb(bot, ievent):
25
""" see if we should op a user on join """
26
# don't try to op the bot
27
if ievent.nick == bot.nick:
29
if ievent.channel in bot.state['no-op']:
32
if cfg.get('oponsplit') or ievent.nick.lower() not in bot.splitted:
33
if users.status(ievent.userhost, ievent.channel.upper()):
34
if ievent.channel not in bot.state['opchan']:
36
bot.doop(ievent.channel, ievent.nick)
38
bot.splitted.remove(ievent.nick.lower())
40
callbacks.add('JOIN', opjoincb, threaded=True)
42
def handle_op1(bot, ievent):
43
""" op [<nick>] .. op an user """
44
if ievent.channel in bot.state['no-op']:
45
ievent.reply('opping is disabled in %s' % ievent.channel)
47
if ievent.channel not in bot.state['opchan']:
48
ievent.reply("i'm not op in %s" % ievent.channel)
54
userhost = getwho(bot, nick)
56
userhost = ievent.userhost
57
if users.status(userhost, ievent.channel.upper()):
58
bot.doop(ievent.channel, nick)
60
ievent.reply("%s doesn't have %s status" % (nick, \
61
ievent.channel.upper()))
63
cmnds.add('op', handle_op1, 'USER')
64
examples.add('op', 'op [<nick>] .. give ops to <nick> or op the person \
65
giving the command', '1) op 2) op dunker')
67
def handle_splitted(bot, ievent):
68
""" splitted .. show splitted list """
69
ievent.reply(str(bot.splitted))
71
cmnds.add('splitted', handle_splitted, 'OPER')
72
examples.add('splitted', 'show whos on the splitted list', 'splitted')
74
def handle_splittedclear(bot, ievent):
75
""" splitted-clear .. clear splitted list """
79
cmnds.add('splitted-clear', handle_splittedclear, 'OPER')
80
examples.add('splitted-clear', 'clear the splitted list', 'splitted-clear')
82
def handle_opsdisable(bot, ievent):
83
""" disable opping in channel """
85
chan = ievent.args[0].lower()
88
oplist = bot.state['no-op']
89
if chan not in oplist:
90
bot.state['no-op'].append(chan)
92
ievent.reply('opping in %s disabled' % chan)
93
if chan in bot.state['opchan']:
94
bot.delop(ievent.channel, bot.nick)
96
ievent.reply('opping %s is already disabled' % chan)
98
cmnds.add('ops-disable', handle_opsdisable, 'OPER')
99
examples.add('ops-disable', 'ops-disable [<channel>] .. disable opping in \
100
provided channel or the channel command was given in', '1) ops-disable 2) \
101
ops-disable #dunkbots')
103
def handle_opsenable(bot, ievent):
104
""" enable opping in channel """
106
chan = ievent.args[0].lower()
108
chan = ievent.channel
109
oplist = bot.state['no-op']
111
bot.state['no-op'].remove(chan)
113
ievent.reply('opping in %s is enabled' % chan)
115
ievent.reply('opping in %s is already enabled' % chan)
117
cmnds.add('ops-enable', handle_opsenable, 'OPER')
118
examples.add('ops-enable', 'ops-enable [<channel>] .. enable opping in \
119
provided channel or the channel command was given in', '1) ops-enable 2) \
120
ops-enable #dunkbots')
122
def handle_opsnoop(bot, ievent):
123
""" show in which channels opping is disabled """
124
ievent.reply('opping is disabled in %s' % bot.state['no-op'])
126
cmnds.add('ops-list', handle_opsnoop, 'OPER')
128
def checkmode(bot, ievent):
129
""" check mode string """
133
args = ievent.arguments
134
chan = args[0].lower()
138
rlog(10, 'op', 'unknow mode string format: %s' % str(ievent))
147
if i == 'o' and plus:
148
if who[teller].lower() == bot.nick.lower():
149
if ievent.channel in bot.state['no-op']:
150
bot.delop(ievent.channel, bot.nick)
152
rlog(1, 'irc', 'opped on %s' % chan)
153
bot.state['opchan'].append(chan)
154
if i == 'o' and not plus:
155
if who[teller].lower() == bot.nick.lower():
156
rlog(1, 'irc', 'deopped on %s' % chan)
158
bot.state['opchan'].remove(chan)
163
callbacks.add('MODE', checkmode)