def handleLogonNotification(context, **kwargs): returnCode = FilterManager.CONTINUE chat = kwargs["chat"] bot = kwargs["bot"] globalState = bot.states["global"] bot.sendChatMessage(HogDatabase.getEnterMessage(chat["userId"], chat["userName"])) if HogDatabase.getAutolog(chat["userId"]) == 1: sendLatestLog(bot, chat["userId"], bot.params["userClan"]) return returnCode
def handlePrivateChat(context, **kwargs): returnCode = FilterManager.CONTINUE chat = kwargs["chat"] bot = kwargs["bot"] globalState = bot.states["global"] arr = chat["text"].split() if chat["text"] == "squelch": if BotUtils.canUserPerformAction(chat["userId"], "squelch", bot): globalState["isSquelched"] = True bot.writeState("global") bot.sendChatMessage("No longer broadcasting /clan to the other clan channels.") else: bot.sendChatMessage("/w %s You do not have permission to perform this action." % chat["userId"]) returnCode = FilterManager.FINISHED elif chat["text"] == "unsquelch": if BotUtils.canUserPerformAction(chat["userId"], "squelch", bot): globalState["isSquelched"] = False bot.writeState("global") bot.sendChatMessage("Now broadcasting /clan to the other clan channels.") else: bot.sendChatMessage("/w %s You do not have permission to perform this action." % chat["userId"]) returnCode = FilterManager.FINISHED elif chat["text"] == "muteall": if BotUtils.canUserPerformAction(chat["userId"], "muteall", bot): for aBot in BotManager._bots: aBot.states["global"]["isSquelched"] = True aBot.writeState("global") aBot.sendChatMessage("All bots have been muted.") else: bot.sendChatMessage("/w %s You do not have permission to perform this action." % chat["userId"]) returnCode = FilterManager.FINISHED elif chat["text"] == "unmuteall": if BotUtils.canUserPerformAction(chat["userId"], "muteall", bot): for aBot in BotManager._bots: aBot.states["global"]["isSquelched"] = False aBot.writeState("global") aBot.sendChatMessage("All bots have been unmuted.") else: bot.sendChatMessage("/w %s You do not have permission to perform this action." % chat["userId"]) returnCode = FilterManager.FINISHED elif chat["text"] == "who": response = bot.sendChatMessage("/who") whoChat = response[0] str = "" for user in whoChat["users"]: if user["userName"] != bot.id: if len(str) > 0: str += ", " str += user["userName"] if len(str) > 0: bot.sendChatMessage("/w %s %s" % (chat["userId"], str)) else: bot.sendChatMessage("/w %s There is no one else in my clan channel." % chat["userId"]) returnCode = FilterManager.FINISHED elif chat["text"] == "help": m = {} m["userId"] = chat["userId"] m["text"] = generateHelpText(bot.params["userName"]) bot.sendKmail(m) returnCode = FilterManager.FINISHED elif chat["text"] == "mymsgs": m = {} m["userId"] = chat["userId"] message = ( "Enter Message: " + HogDatabase.getEnterMessage(chat["userId"], chat["userName"]) + "\n" + "Exit Message: " + HogDatabase.getExitMessage(chat["userId"], chat["userName"]) ) m["text"] = message bot.sendKmail(m) returnCode = FilterManager.FINISHED elif chat["text"] == "autolog": toggle = HogDatabase.toggleAutolog(chat["userId"], chat["userName"]) if toggle == 1: bot.sendChatMessage("/w %s autolog enabled." % (chat["userId"])) else: bot.sendChatMessage("/w %s autolog disabled." % (chat["userId"])) returnCode = FilterManager.FINISHED elif chat["text"] == "log": sendLatestLog(bot, chat["userId"], bot.params["userClan"]) returnCode = FilterManager.FINISHED if len(arr) > 0 and arr[0] == "entermsg": enterMsg = chat["text"].replace("entermsg ", "", 1) HogDatabase.setEnterMessage(chat["userId"], chat["userName"], enterMsg) bot.sendChatMessage("/w %s Enter message changed to: %s" % (chat["userId"], enterMsg)) returnCode = FilterManager.FINISHED elif len(arr) > 0 and arr[0] == "exitmsg": exitMsg = chat["text"].replace("exitmsg ", "", 1) HogDatabase.setExitMessage(chat["userId"], chat["userName"], exitMsg) bot.sendChatMessage("/w %s Exit message changed to: %s" % (chat["userId"], exitMsg)) returnCode = FilterManager.FINISHED elif len(arr) > 0 and arr[0] == "seen": user = chat["text"].replace("seen ", "", 1) lastSeen = HogDatabase.getLastSeen(user) if lastSeen == None or lastSeen[0] == None: bot.sendChatMessage("/w %s %s hasn't been seen by the bot" % (chat["userId"], user)) else: bot.sendChatMessage("/w %s %s last seen on %s" % (chat["userId"], user, lastSeen[0])) returnCode = FilterManager.FINISHED return returnCode