author | Mikael Berthe <mikael@lilotux.net> |
Sun, 20 May 2007 12:33:55 +0200 | |
changeset 41 | ca6e989ca850 |
parent 24 | 7d7edae239c9 |
permissions | -rw-r--r-- |
0
93b25987d3e5
Initial Mercurial repository
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
1 |
#$ neutron_plugin 01 |
23
f34555473aaf
Update coding style for my modules
Mikael Berthe <mikael@lilotux.net>
parents:
21
diff
changeset
|
2 |
# 2007-05 Mikael Berthe <mikael@lilotux.net> |
0
93b25987d3e5
Initial Mercurial repository
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
3 |
|
93b25987d3e5
Initial Mercurial repository
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
4 |
import re |
93b25987d3e5
Initial Mercurial repository
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
5 |
|
93b25987d3e5
Initial Mercurial repository
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
6 |
WTF_FILE = 'static/wtf.txt' |
93b25987d3e5
Initial Mercurial repository
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
7 |
|
93b25987d3e5
Initial Mercurial repository
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
8 |
def handler_wtf(type, source, parameters): |
23
f34555473aaf
Update coding style for my modules
Mikael Berthe <mikael@lilotux.net>
parents:
21
diff
changeset
|
9 |
parameters = parameters.rstrip(" ?\n").lstrip() |
24 | 10 |
|
11 |
# 1 entry = "keyword\tdefinition" |
|
23
f34555473aaf
Update coding style for my modules
Mikael Berthe <mikael@lilotux.net>
parents:
21
diff
changeset
|
12 |
word = parameters.upper() + "\t" |
0
93b25987d3e5
Initial Mercurial repository
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
13 |
|
23
f34555473aaf
Update coding style for my modules
Mikael Berthe <mikael@lilotux.net>
parents:
21
diff
changeset
|
14 |
if not parameters: |
f34555473aaf
Update coding style for my modules
Mikael Berthe <mikael@lilotux.net>
parents:
21
diff
changeset
|
15 |
if type == 'private': |
f34555473aaf
Update coding style for my modules
Mikael Berthe <mikael@lilotux.net>
parents:
21
diff
changeset
|
16 |
smsg(type, source, "Gimme an acronym!") |
f34555473aaf
Update coding style for my modules
Mikael Berthe <mikael@lilotux.net>
parents:
21
diff
changeset
|
17 |
return |
10 | 18 |
|
24 | 19 |
# Look up the keyword in the wtf file... We may have several hits. |
23
f34555473aaf
Update coding style for my modules
Mikael Berthe <mikael@lilotux.net>
parents:
21
diff
changeset
|
20 |
reply = ''.join(line for line in file(WTF_FILE) if line.startswith(word)) |
0
93b25987d3e5
Initial Mercurial repository
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
21 |
|
23
f34555473aaf
Update coding style for my modules
Mikael Berthe <mikael@lilotux.net>
parents:
21
diff
changeset
|
22 |
if not reply: |
f34555473aaf
Update coding style for my modules
Mikael Berthe <mikael@lilotux.net>
parents:
21
diff
changeset
|
23 |
if type == 'private': |
f34555473aaf
Update coding style for my modules
Mikael Berthe <mikael@lilotux.net>
parents:
21
diff
changeset
|
24 |
reply = "Sorry, I don't know what " + parameters + " means..." |
f34555473aaf
Update coding style for my modules
Mikael Berthe <mikael@lilotux.net>
parents:
21
diff
changeset
|
25 |
else: |
f34555473aaf
Update coding style for my modules
Mikael Berthe <mikael@lilotux.net>
parents:
21
diff
changeset
|
26 |
return |
f34555473aaf
Update coding style for my modules
Mikael Berthe <mikael@lilotux.net>
parents:
21
diff
changeset
|
27 |
else: |
f34555473aaf
Update coding style for my modules
Mikael Berthe <mikael@lilotux.net>
parents:
21
diff
changeset
|
28 |
reply= re.sub("\t+", ": ", reply.rstrip()) |
0
93b25987d3e5
Initial Mercurial repository
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
29 |
|
23
f34555473aaf
Update coding style for my modules
Mikael Berthe <mikael@lilotux.net>
parents:
21
diff
changeset
|
30 |
smsg(type, source, reply) |
0
93b25987d3e5
Initial Mercurial repository
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
31 |
|
10 | 32 |
register_command_handler(handler_wtf, 'wtf', 0, |
33 |
'Translates acronyms for you', 'wtf', ['wtf wtf']) |
|
23
f34555473aaf
Update coding style for my modules
Mikael Berthe <mikael@lilotux.net>
parents:
21
diff
changeset
|
34 |
|
f34555473aaf
Update coding style for my modules
Mikael Berthe <mikael@lilotux.net>
parents:
21
diff
changeset
|
35 |
# vim:set et sts=4: |