import random class KWAMPlugin: def __init__(self,bot): for i in "kwam": with open("data/"+i+"-words.txt") as f: setattr(self,i,[line.replace("\n","") for line in f.readlines()]) self.bot=bot self.answerRequests = True def answer(self,channel,nick,msg): if not msg.startswith("!kwam"): return if nick==self.bot.owner: if msg.startswith("!kwam "): self.answerRequests = msg.endswith("on") return if self.answerRequests: words = [random.choice(self.k),random.choice(self.w),random.choice(self.a),random.choice(self.m)] self.bot.mention(channel,nick," ".join(words))