-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathplugin.py
More file actions
32 lines (21 loc) · 712 Bytes
/
Copy pathplugin.py
File metadata and controls
32 lines (21 loc) · 712 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import re
plugins = []
help = []
def add_plugin(regexp, func, event='privmsg'):
plugins.append((event, regexp, func))
def dispatch(irc, event, user, target, msg=''):
for trigger, regexp, func in plugins:
r = re.compile(regexp, re.I)
if re.search(r, msg) and event == trigger:
func(irc, user, target, msg)
def add_help(string, message):
help.append((string, message))
def get_help(string=None):
if string is None:
return ', '.join(sorted(map(lambda x: x[0], help)))
else:
for cmd, doc in help:
if cmd == string:
line = "%s: %s" % (cmd, doc)
return line
return "No help for %s" % string