-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhugs.py
47 lines (39 loc) · 1.18 KB
/
hugs.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""
hugs.py - A simple willie Module for interacting with 'hug' actions
Copyright 2013, Tim Dreyer
Licensed under the Eiffel Forum License 2.
http://bitbucket.org/tdreyer/fineline
"""
import random
import re
import time
from willie.module import rule, rate
try:
import imp
import sys
from permissions import perm_chk
except:
try:
ffp, pathname, description = imp.find_module('permissions',['/home/dropbox/Dropbox/WillieBot'])
permissions = imp.load_source('permissions', pathname, ffp)
sys.modules['permissions'] = permissions
finally:
if ffp:
ffp.close()
from permissions import perm_chk
random.seed()
@rule(u'\001ACTION [a-zA-Z0-9 ,]*?' +
u'((hugs? $nickname)|(gives $nickname a hug))')
@rate(90)
def hugback(willie, trigger):
"""Returns a 'hug' action directed at the bot."""
if not perm_chk(trigger.hostmask, "Ia", willie):
return
willie.action(random.choice([
u'hugs %s back' % trigger.nick,
u'returns the hug',
u'grips %s tightly' % trigger.nick,
u'holds on for too long, mumbling something about warmth.'
]))
if __name__ == "__main__":
print __doc__.strip()