author | Mikael Berthe <mikael@lilotux.net> |
Wed, 02 May 2007 00:00:09 +0200 | |
changeset 19 | f2d744db28b9 |
parent 17 | 069f7fd5545d |
child 21 | 2fea9969b088 |
permissions | -rw-r--r-- |
0
93b25987d3e5
Initial Mercurial repository
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
1 |
#$ neutron_plugin 01 |
93b25987d3e5
Initial Mercurial repository
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
2 |
|
93b25987d3e5
Initial Mercurial repository
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
3 |
import re |
93b25987d3e5
Initial Mercurial repository
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
4 |
|
93b25987d3e5
Initial Mercurial repository
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
5 |
WTF_FILE = 'static/wtf.txt' |
93b25987d3e5
Initial Mercurial repository
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
6 |
|
93b25987d3e5
Initial Mercurial repository
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
7 |
def handler_wtf(type, source, parameters): |
12
d79701227a04
Small improvement to wtf_plugin
Mikael Berthe <mikael@lilotux.net>
parents:
10
diff
changeset
|
8 |
parameters = parameters.rstrip(" ?\n").lstrip() |
10 | 9 |
word = parameters.upper() + "\t" |
0
93b25987d3e5
Initial Mercurial repository
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
10 |
|
10 | 11 |
if not parameters: |
12 |
smsg(type, source, "Gimme an acronym!") |
|
13 |
return |
|
14 |
||
12
d79701227a04
Small improvement to wtf_plugin
Mikael Berthe <mikael@lilotux.net>
parents:
10
diff
changeset
|
15 |
reply = ''.join(line for line in file(WTF_FILE) \ |
d79701227a04
Small improvement to wtf_plugin
Mikael Berthe <mikael@lilotux.net>
parents:
10
diff
changeset
|
16 |
if line.startswith(word)) |
0
93b25987d3e5
Initial Mercurial repository
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
17 |
|
93b25987d3e5
Initial Mercurial repository
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
18 |
if not reply: |
10 | 19 |
reply = "Sorry, I don't know what " + parameters + " means..." |
12
d79701227a04
Small improvement to wtf_plugin
Mikael Berthe <mikael@lilotux.net>
parents:
10
diff
changeset
|
20 |
else: |
d79701227a04
Small improvement to wtf_plugin
Mikael Berthe <mikael@lilotux.net>
parents:
10
diff
changeset
|
21 |
reply= re.sub("\t+", ": ", reply.rstrip()) |
0
93b25987d3e5
Initial Mercurial repository
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
22 |
|
12
d79701227a04
Small improvement to wtf_plugin
Mikael Berthe <mikael@lilotux.net>
parents:
10
diff
changeset
|
23 |
smsg(type, source, reply) |
0
93b25987d3e5
Initial Mercurial repository
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
24 |
|
10 | 25 |
register_command_handler(handler_wtf, 'wtf', 0, |
26 |
'Translates acronyms for you', 'wtf', ['wtf wtf']) |