Example #1
0
def handleClanChat(context, **kwargs):
    chat = kwargs["chat"]
    bot = kwargs["bot"]
    globalState = bot.states["global"]

    # Do nothing if the bot is squelched.
    if DataUtils.getBoolean(globalState, "isSquelched", False):
        return FilterManager.CONTINUE

        # Do nothing if the text is prefixed by PRIVATE:
    lowerText = chat["text"].lower()
    if lowerText.find("private:") == 0:
        return FilterManager.CONTINUE

        # Do nothing for broadcasted messages.
    if chat["userName"] == "System Message":
        return FilterManager.CONTINUE

        # Construct the message to send to the other bots.
    msg = None
    if chat["type"] == "normal":
        msg = "/clan [%s] %s" % (chat["userName"], chat["text"])
    elif chat["type"] == "emote":
        msg = "/clan <%s %s>" % (chat["userName"], chat["text"])

        # Send the message to the other bots.
    if msg != None:
        thisBot = kwargs["bot"]
        for bot in BotManager._bots:
            if bot.id != thisBot.id:
                bot.sendChatMessage(msg)

    return FilterManager.CONTINUE
Example #2
0
def botProcessChat(context, **kwargs):
    returnCode = FilterManager.CONTINUE
    chat = kwargs["chat"]

    if chat["type"] in ["normal", "emote"] and chat["channel"] == "clan":
        returnCode = handleClanChat(context, **kwargs)
    elif chat["type"] in ["private"]:
        returnCode = handlePrivateChat(context, **kwargs)
    elif chat["type"] in ["logonNotification"] and DataUtils.getBoolean(
        kwargs["bot"].params, "doWork:doRosterAnnouncements", False
    ):
        returnCode = handleLogonNotification(context, **kwargs)
    elif chat["type"] in ["logoffNotification"] and DataUtils.getBoolean(
        kwargs["bot"].params, "doWork:doRosterAnnouncements", False
    ):
        returnCode = handleLogoffNotification(context, **kwargs)
    return returnCode
Example #3
0
def handleClanChat(context, **kwargs):
    chat = kwargs["chat"]
    bot = kwargs["bot"]
    globalState = bot.states["global"]

    # Do nothing if the text is prefixed by PRIVATE:
    lowerText = chat["text"].lower()
    if lowerText.find("private:") == 0 or lowerText[0:2] == "p:":
        return FilterManager.CONTINUE

    if DataUtils.getBoolean(kwargs["bot"].params, "doWork:doLogChat", False):
        HogDatabase.logChat(chat["userId"], chat["userName"], bot.params["userClan"], chat["text"])

    # Do nothing if the bot is squelched.
    if DataUtils.getBoolean(globalState, "isSquelched", False):
        return FilterManager.CONTINUE

    # Do nothing for broadcasted messages.
    if chat["userName"] == "System Message":
        return FilterManager.CONTINUE

    # Construct the message to send to the other bots.
    msg = None
    if "chatBroadcastDelimiters" in bot.params:
        chars = bot.params["chatBroadcastDelimiters"]
        if chat["type"] == "normal":
            msg = "%s%s%s %s" % (chars[0], chat["userName"], chars[1], chat["text"])
        elif chat["type"] == "emote":
            msg = "/me %s%s%s %s" % (chars[0], chat["userName"], chars[1], chat["text"])
    else:
        if chat["type"] == "normal":
            msg = "[%s] %s" % (chat["userName"], chat["text"])
        elif chat["type"] == "emote":
            msg = "/me [%s] %s" % (chat["userName"], chat["text"])

    # Send the message to the other bots.
    if msg != None:
        thisBot = kwargs["bot"]
        for bot in BotManager._bots:
            if bot.id != thisBot.id:
                if bot.session != None and bot.session.isConnected and hasattr(bot.session, "chatManager"):
                    try:
                        bot.sendChatMessage(msg)
                    except AttributeError, inst:
                        Report.error("chat", "Could not broadcast message.", inst)
Example #4
0
def handleClanChat(context, **kwargs):
    chat = kwargs["chat"]
    bot = kwargs["bot"]
    globalState = bot.states["global"]

    # Do nothing if the bot is squelched.
    if DataUtils.getBoolean(globalState, "isSquelched", False):
        return FilterManager.CONTINUE

    # Do nothing if the text is prefixed by PRIVATE:
    lowerText = chat["text"].lower()
    if lowerText.find("private:") == 0:
        return FilterManager.CONTINUE

    # Do nothing for broadcasted messages.
    if chat["userName"] == "System Message":
        return FilterManager.CONTINUE

    # Construct the message to send to the other bots.
    msg = None
    if "chatBroadcastDelimiters" in bot.params:
        chars = bot.params["chatBroadcastDelimiters"]
        if chat["type"] == "normal":
            msg = "%s%s%s %s" % (chars[0], chat["userName"], chars[1],
                                 chat["text"])
        elif chat["type"] == "emote":
            msg = "/me %s%s%s %s" % (chars[0], chat["userName"], chars[1],
                                     chat["text"])
    else:
        if chat["type"] == "normal":
            msg = "[%s] %s" % (chat["userName"], chat["text"])
        elif chat["type"] == "emote":
            msg = "/me [%s] %s" % (chat["userName"], chat["text"])

    # Send the message to the other bots.
    if msg != None:
        thisBot = kwargs["bot"]
        for bot in BotManager._bots:
            if bot.id != thisBot.id:
                if bot.session != None and bot.session.isConnected and hasattr(
                        bot.session, "chatManager"):
                    try:
                        bot.sendChatMessage(msg)
                    except AttributeError, inst:
                        Report.error("chat", "Could not broadcast message.",
                                     inst)