-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpingpong.py
40 lines (32 loc) · 979 Bytes
/
pingpong.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
# -*- coding: utf-8 -*-
# vim:set ts=8 sts=8 sw=8 tw=80 noet cc=80:
from module import Module, MUC, MUC_MENTION
from utils import oneof
class PingPong(Module):
mapping = {
'ping': 'pong',
'*ping*': '*pong*',
'pink': 'ponk'
}
users = {
'tchab': {
'ping': [ "Für dich immer noch »pink«!",
"Klappe zu, Schwulibert!"],
'*ping*': [ "Für dich immer noch »pink«!",
"Klappe zu, Schwulibert!" ]
}
}
def __init__(self, **keywords):
super(PingPong, self).__init__([MUC, MUC_MENTION], **keywords)
def muc_msg(self, msg, nick, **keywords):
self.pingpong(msg, nick, "%s")
def muc_mention(self, msg, nick, **keywords):
self.pingpong(msg, nick, "%s: %%s" % nick)
def pingpong(self, msg, nick, formatstr):
key = msg.lower();
if nick in self.users and key in self.users[nick]:
self.send_muc(formatstr % \
oneof(self.users[nick][key]))
elif key in self.mapping:
self.send_muc(formatstr % \
self.mapping[key])