from bot import IRCLine BOT = None def respond(event,msg): if event.target.startswith("#"): prefix = event.hostmask.nick+": " target = event.target else: prefix = "" target = event.hostmask.nick BOT.socket.send(IRCLine("PRIVMSG",target,":"+msg).line) import search def _search(event): query = " ".join(event.parts) results = search.search(query) if len(results)==0: respond(event,"No results found for \"{}\"".format(query)) return respond(event,"Top result: {result[0]} - {result[1]}".format(result=results[0])) def register(bot): global BOT BOT=bot bot.event_manager.on("command_search",_search) bot.event_manager.on("command_help",_search) bot.event_manager.on("command_wiki",_search)