Improve coding style
Thanks to Loic.
#$ neutron_plugin 01
import re
WTF_FILE = 'static/wtf.txt'
def handler_wtf(type, source, parameters):
parameters = parameters.rstrip(" ?\n")
parameters = parameters.lstrip()
word = parameters.upper() + "\t"
reply = ""
if not parameters:
smsg(type, source, "Gimme an acronym!")
return
for line in file(WTF_FILE):
if line.startswith(word):
reply += re.sub("\t+", ": ", line)
if not reply:
reply = "Sorry, I don't know what " + parameters + " means..."
smsg(type, source, reply.rstrip())
register_command_handler(handler_wtf, 'wtf', 0,
'Translates acronyms for you', 'wtf', ['wtf wtf'])