Added the irclog django project
[pyIRCbot.git] / plugins / giveop_plugin.py
blobd5afcdb9899ff02b08fc6bdbaa40445be0069fd4
1 from pprint import pprint
3 COMMAND = ":op"
4 ADMIN_LIST = ('User1', 'User2', 'User3')
6 class Demo(object):
7 """This is demo plugin, that is showing how the plugins should have beed
8 written.
9 """
10 def __init__(self):
11 print "Give op plugin loaded."
12 self.command = COMMAND
13 self.admin_list = ADMIN_LIST
15 def __call__(self, server):
16 """What to do when running plugin."""
17 # alias
18 data = server.msg_data
19 try:
20 # if command is COMMAND
21 # this may throw IndexError
22 if not data['msg_list'][0] == self.command:
23 return
24 # if user is logged
25 if not data['prefix'].startswith(data['user'] + r'!i='):
26 return
27 # if user is on admin list
28 if not data['user'] in self.admin_list:
29 return
30 # else, give op
31 server.send_raw('MODE %s +o %s' % (data['target'], data['user']))
32 except IndexError:
33 pass