plugins/wtf_plugin.py
author Mikael Berthe <mikael@lilotux.net>
Tue, 01 May 2007 23:59:21 +0200
changeset 17 069f7fd5545d
parent 12 d79701227a04
child 21 2fea9969b088
permissions -rw-r--r--
Fix permissions

#$ neutron_plugin 01

import re

WTF_FILE = 'static/wtf.txt'

def handler_wtf(type, source, parameters):
	parameters = parameters.rstrip(" ?\n").lstrip()
	word = parameters.upper() + "\t"

	if not parameters:
		smsg(type, source, "Gimme an acronym!")
		return

	reply = ''.join(line for line in file(WTF_FILE) \
		if line.startswith(word))

	if not reply:
		reply = "Sorry, I don't know what " + parameters + " means..."
	else:
		reply= re.sub("\t+", ": ", reply.rstrip())

	smsg(type, source, reply)

register_command_handler(handler_wtf, 'wtf', 0,
                         'Translates acronyms for you', 'wtf', ['wtf wtf'])