plugins/wtf_plugin.py
changeset 24 7d7edae239c9
parent 23 f34555473aaf
equal deleted inserted replaced
23:f34555473aaf 24:7d7edae239c9
     5 
     5 
     6 WTF_FILE = 'static/wtf.txt'
     6 WTF_FILE = 'static/wtf.txt'
     7 
     7 
     8 def handler_wtf(type, source, parameters):
     8 def handler_wtf(type, source, parameters):
     9     parameters = parameters.rstrip(" ?\n").lstrip()
     9     parameters = parameters.rstrip(" ?\n").lstrip()
       
    10 
       
    11     # 1 entry = "keyword\tdefinition"
    10     word = parameters.upper() + "\t"
    12     word = parameters.upper() + "\t"
    11 
    13 
    12     if not parameters:
    14     if not parameters:
    13         if type == 'private':
    15         if type == 'private':
    14             smsg(type, source, "Gimme an acronym!")
    16             smsg(type, source, "Gimme an acronym!")
    15         return
    17         return
    16 
    18 
       
    19     # Look up the keyword in the wtf file...  We may have several hits.
    17     reply = ''.join(line for line in file(WTF_FILE) if line.startswith(word))
    20     reply = ''.join(line for line in file(WTF_FILE) if line.startswith(word))
    18 
    21 
    19     if not reply:
    22     if not reply:
    20         if type == 'private':
    23         if type == 'private':
    21             reply = "Sorry, I don't know what " + parameters + " means..."
    24             reply = "Sorry, I don't know what " + parameters + " means..."