29 lines
697 B
Python
29 lines
697 B
Python
import words, plugin, random
|
|
from titlecase import titlecase
|
|
from bot import IRCLine
|
|
words.loadDict("words")
|
|
|
|
BOT = None
|
|
|
|
def say(target, msg):
|
|
BOT.socket.send(IRCLine("PRIVMSG",target,":"+msg))
|
|
|
|
def backronym(event):
|
|
if not BOT: return None
|
|
channel = event.target
|
|
nick = event.hostmask.nick
|
|
word = event.parts[0]
|
|
result = []
|
|
for char in word:
|
|
fwords = words.getWords("^{}.*".format(char))
|
|
if not fwords:
|
|
say(channel,nick+": Don't be a meanie! (No words start with '{}'!)".format(char))
|
|
else:
|
|
result.append(random.choice(fwords))
|
|
say(channel,nick+": "+titlecase(" ".join(result)))
|
|
|
|
def register(bot):
|
|
global BOT
|
|
BOT = bot
|
|
bot.event_manager.on("command_backronym",backronym)
|