当前位置: 首页>>代码示例>>Python>>正文


Python Report.error方法代码示例

本文整理汇总了Python中kol.util.Report.error方法的典型用法代码示例。如果您正苦于以下问题:Python Report.error方法的具体用法?Python Report.error怎么用?Python Report.error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kol.util.Report的用法示例。


在下文中一共展示了Report.error方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: botProcessChat

# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import error [as 别名]
def botProcessChat(context, **kwargs):
    returnCode = FilterManager.CONTINUE
    chat = kwargs["chat"]
    
    if chat["type"] == "private":
        if BotUtils.canUserPerformAction(chat["userId"], "execute", kwargs["bot"]):
            doAction = False
            executeAll = False
            wordList = chat["text"].split()
            if len(wordList) > 0:
                if wordList[0].lower() == "execute":
                    doAction = True
                elif wordList[0].lower() == "executeall":
                    doAction = True
                    executeAll = True

            if doAction:
                returnCode = FilterManager.FINISHED
                del wordList[0]
                command = " ".join(wordList)

                if executeAll:
                    for bot in BotManager._bots:
                        if bot.session != None and bot.session.isConnected and hasattr(bot.session, "chatManager"):
                            try:
                                bot.sendChatMessage(command)
                            except AttributeError, inst:
                                Report.error("chat", "Could not execute command: %s" % command, inst)
                else:
                    kwargs["bot"].sendChatMessage(command)
开发者ID:Alecat,项目名称:pykol,代码行数:32,代码来源:CommandExecutor.py

示例2: botEndCycle

# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import error [as 别名]
def botEndCycle(context, **kwargs):
    returnCode = FilterManager.CONTINUE
    bot = kwargs['bot']

    # Check for new kmails?
    aleabot.kmail_check_timer += aleabot.config.get('time_to_sleep')
    if aleabot.kmail_check_timer >= aleabot.config.get('time_to_sleep_kmail'):
        Report.trace('bot', 'Enabling doWork:kmail')
        bot.params['doWork:kmail'] = True
        aleabot.kmail_check_timer = 0
    else:
        Report.trace('bot', 'Disabling doWork:kmail')
        bot.params.pop('doWork:kmail', None)

    # Update clan state in regular intervals (as configured)
    try:
        aleabot.clanstate.set_session(bot.session)
        if aleabot.clanstate.update(aleabot.config.get('clan_state_refresh_time')):
            Report.info('bot', 'Clan state update successful.')
            Report.trace('bot', 'I am in clan: ' + repr(aleabot.clanstate.my_clan()))
            Report.trace('bot', 'I have ' + str(len(aleabot.clanstate.my_whitelists())) + ' whitelists')
            # Set timer to switch back to home clan
            if aleabot.home_clan_timer < 0:
                aleabot.home_clan_timer = 0
    except alea.clan.ClanRequestError as err:
        Report.error('bot', 'Unable to update clan state! Error: ' + str(err))

    # Switch to home clan after some delay
    if aleabot.home_clan_timer >= 0:
        aleabot.home_clan_timer += aleabot.config.get('time_to_sleep')
        if aleabot.home_clan_timer >= aleabot.config.get('home_clan_delay'):
            aleabot.home_clan_timer = -1

            # Breakfast now if not yet breakfasted today
            if 'breakfast' not in bot.states['rollover']:
                alea.breakfast.breakfast(bot.session)
                bot.states['rollover']['breakfast'] = True
                bot.writeState('rollover')

            # Switch to home clan now
            home_clan_id = aleabot.config.get('home_clan_id')
            if home_clan_id > 0 and aleabot.clanstate.my_clan().id() != home_clan_id:
                Report.info('bot', 'Switching back to home clan.')
                try:
                    aleabot.clanstate.switch(alea.clan.Clan(home_clan_id, ''))
                except alea.clan.ClanRequestError as err:
                    Report.error('bot', 'Unable to switch clan! Error: ' + str(err))

    return returnCode
开发者ID:aleabot,项目名称:aleabot,代码行数:51,代码来源:AleabotFilter.py

示例3: parseResponse

# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import error [as 别名]
    def parseResponse(self):
        # Check for errors.
        effectRemovedPattern = PatternManager.getOrCompilePattern("effectRemoved")
        if effectRemovedPattern.search(self.responseText):
            return

        youDontHaveThatEffectPattern = PatternManager.getOrCompilePattern("youDontHaveThatEffect")
        if youDontHaveThatEffectPattern.search(self.responseText):
            raise DontHaveEffectError("Unable to remove effect. The user does not have that effect.")

        youDontHaveSGEEAPattern = PatternManager.getOrCompilePattern("youDontHaveSGEEA")
        if youDontHaveSGEEAPattern.search(self.responseText):
            raise NotEnoughItemsError("Unable to remove effect. You do not have a soft green echo eyedrop antidote.")

        Report.error("request", "Unknown error occurred when trying to remove an effect")
        Report.error("request", self.responseText)
        raise RequestError("Unknown error occurred when trying to remove an effect.")
开发者ID:camperdave,项目名称:pykol,代码行数:19,代码来源:UneffectRequest.py

示例4: parseResponse

# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import error [as 别名]
    def parseResponse(self):
        # Check for errors.
        effectRemovedPattern = PatternManager.getOrCompilePattern('effectRemoved')
        if effectRemovedPattern.search(self.responseText):
            return

        youDontHaveThatEffectPattern = PatternManager.getOrCompilePattern('youDontHaveThatEffect')
        if youDontHaveThatEffectPattern.search(self.responseText):
            raise Error.Error("Unable to remove effect. The user does not have that effect.", Error.EFFECT_NOT_FOUND)

        youDontHaveSGEEAPattern = PatternManager.getOrCompilePattern('youDontHaveSGEEA')
        if youDontHaveSGEEAPattern.search(self.responseText):
            raise Error.Error("Unable to remove effect. You do not have a soft green echo eyedrop antidote.", Error.ITEM_NOT_FOUND)

        Report.error("request", "Unknown error occurred when trying to remove an effect")
        Report.error("request", self.responseText)
        raise Error.Error("Unknown error occurred when trying to remove an effect.", Error.REQUEST_FATAL)
开发者ID:Alecat,项目名称:pykol,代码行数:19,代码来源:UneffectRequest.py

示例5: handleClanChat

# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import error [as 别名]
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)
开发者ID:MicN,项目名称:HogBotGit,代码行数:47,代码来源:ChatBroadcaster.py

示例6: parseResponse

# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import error [as 别名]
    def parseResponse(self):
        weakSkillPattern = PatternManager.getOrCompilePattern('skillTooWeak')
        badSkillPattern = PatternManager.getOrCompilePattern('skillNotTrainable')
        poorSkillPattern = PatternManager.getOrCompilePattern('skillTooPoor')
        haveSkillPattern = PatternManager.getOrCompilePattern('skillHaveAlready')

        if weakSkillPattern.search(self.responseText):
            raise InvalidActionError("You aren't a high enough level to train that skill")
        if badSkillPattern.search(self.responseText):
            raise SkillMissingError("You cannot train that skill at the Guild Hall")
        if poorSkillPattern.search(self.responseText):
            raise NotEnoughMeatError("You cannot afford to train that skill")
        if haveSkillPattern.search(self.responseText):
            raise RequestError("You already know that skill")

        skillLearnedPattern = PatternManager.getOrCompilePattern('skillLearned')
        match = skillLearnedPattern.search(self.responseText)
        if match:
            try:
                skill = SkillDatabase.getSkillFromName(match.group(1))
                self.responseData["skill"] = skill
            except SkillNotFoundError, inst:
                Report.error("bot", inst.message, inst)
开发者ID:camperdave,项目名称:pykol,代码行数:25,代码来源:GuildTrainRequest.py

示例7: breakfast

# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import error [as 别名]
def breakfast(session):
    Report.info('bot', 'Start of breakfast.')

    meatGained = 0

    Report.info('bot', 'Visiting hippy produce stand.')
    try:
        req = HippyProduceStandRequest(session)
        response = req.doRequest()
        meatGained += response['meat']
    except Error.Error as err:
        Report.error('bot', 'Error while visiting hippy produce stand: ' + str(err))

    Report.info('bot', 'Visiting potted meat bush.')
    try:
        req = MeatBushRequest(session)
        response = req.doRequest()
        meatGained += response['meat']
    except Error.Error as err:
        Report.error('bot', 'Error while visiting potted meat bush: ' + str(err))

    Report.info('bot', 'Visiting exotic hanging meat orchid.')
    try:
        req = MeatOrchidRequest(session)
        response = req.doRequest()
        meatGained += response['meat']
    except Error.Error as err:
        Report.error('bot', 'Error while visiting exotic hanging meat orchid: ' + str(err))

    Report.info('bot', 'Visiting potted meat tree.')
    try:
        req = MeatTreeRequest(session)
        response = req.doRequest()
        meatGained += response['meat']
    except Error.Error as err:
        Report.error('bot', 'Error while visiting potted meat tree: ' + str(err))

    Report.info('bot', 'End of breakfast. Meat gained: ' + str(meatGained))
开发者ID:aleabot,项目名称:aleabot,代码行数:40,代码来源:breakfast.py

示例8: parseChatMessages

# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import error [as 别名]

#.........这里部分代码省略.........
            # See if a user logged out.
            if parsedChat == False:
                match = playerLoggedOffPattern.search(line)
                if match:
                    chat["type"] = "logoffNotification"
                    chat["userId"] = int(match.group(1))
                    chat["userName"] = match.group(2)
                    parsedChat = True

            # See if this was a private message.
            if parsedChat == False:
                match = privateChatPattern.search(line)
                if match:
                    chat["type"] = "private"
                    chat["userId"] = int(match.group(1))
                    chat["userName"] = match.group(2)
                    chat["text"] = match.group(3).strip()
                    parsedChat = True

            # See if this is a new kmail notification.
            if parsedChat == False:
                match = newKmailPattern.search(line)
                if match:
                    chat["type"] = "notification:kmail"
                    chat["userId"] = int(match.group(1))
                    chat["userName"] = match.group(2)
                    parsedChat = True

            # See if this is the start of a multi-line message (Gothy or Haiku)
            if parsedChat == False:
                match = multiLinePattern.search(line)
                if match:
                    chat["type"] = "normal"
                    chat["userId"] = int(match.group(1))
                    chat["userName"] = match.group(2)
                    chat["isMultiline"] = True
                    chat["text"] = ""
                    parsedChat = True

            # See if this is the start of a multi-line emote (Gothy or Haiku)
            # I've seen a Haiku emote, don't know if Gothy will trigger for it
            if parsedChat == False:
                match = multiEmotePattern.search(line)
                if match:
                    chat["type"] = "emote"
                    chat["userId"] = int(match.group(1))
                    chat["userName"] = match.group(2)
                    chat["isMultiline"] = True
                    chat["text"] = ""
                    parsedChat = True

        else:
            # See if this is a /who response.
            if parsedChat == False:
                if chatWhoPattern.search(line):
                    chat["type"] = "who"
                    chat["users"] = []
                    chatWhoPersonPattern = PatternManager.getOrCompilePattern("chatWhoPerson")
                    for match in chatWhoPersonPattern.finditer(line):
                        userClass = match.group(1)
                        userId = match.group(2)
                        userName = match.group(3)
                        userInfo = {"userId" : userId, "userName" : userName}
                        if userClass == "afk":
                            userInfo["isAway"] = True
                        chat["users"].append(userInfo)
                    parsedChat = True

        if parsedChat and "text" in chat:
            chat["text"] = cleanChatText(chat["text"])

        # Handle unrecognized chat messages.
        if parsedChat == False:
            # If the last chat was flagged as starting a multiline
            if len(chats) > 0 and "isMultiline" in chats[-1]:
                if chats[-1]["isMultiline"] == True:
                    if len(chats[-1]["text"]) > 0:
                        chats[-1]["text"] += "\n"
                    line = line.replace('<Br>','\n')
                    cleanLine = cleanChatText(line)
                    cleanLine = cleanLine.replace('&nbsp;','').strip()

                    chats[-1]["text"] += cleanLine

                    continue

            # If the last chat was flagged as a System or Mod Announcement, skip past the trailing tags
            elif len(chats) > 0:
                if "type" in chats[-1] and chats[-1]["type"] in ["system message", "mod warning", "mod announcement"]:
                    if line == "</b></font>":
                        continue

            # Any other case we aren't prepared to handle
            Report.error("bot", "Unknown message.  ResponseText = %s" % text)
            chat["type"] = "unknown"
            chat["text"] = StringUtils.htmlEntityDecode(line)

        chats.append(chat)

    return chats
开发者ID:Alecat,项目名称:pykol,代码行数:104,代码来源:ChatUtils.py

示例9: botProcessKmail

# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import error [as 别名]
def botProcessKmail(context, **kwargs):
    returnCode = FilterManager.CONTINUE
    message = kwargs['kmail']
    bot = kwargs['bot']

    user_name = str(message['userName'])
    user_id = str(message['userId'])
    current_time = time.time()
    cmd = BotUtils.getKmailCommand(message)
    meat = message['meat']
    items = message['items']

    # Our response
    response = ''
    # Should items and meat be sent back?
    return_goodies = True
    # Should a candy heart be sent?
    send_heart = False

    # if 1 arrow was sent and the kmail is empty, interpret it as "arrow"
    if cmd == "" and len(items) == 1 and items[0]['id'] == ITEM_ID_ARROW and items[0]['quantity'] == 1 and meat == 0:
        cmd = 'arrow'

    if cmd == 'arrow':
        # Handle arrow request
        if len(items) == 1 and items[0]['id'] == ITEM_ID_ARROW and items[0]['quantity'] == 1 and meat == 0:
            # Everything is okay
            try:
                Report.info('bot', 'Firing arrow at player: ' + user_name)
                arrowreq = CursePlayerRequest(bot.session, user_id, ITEM_ID_ARROW)
                arrowreq.doRequest()
                return_goodies = False
            except Error.Error as err:
                if err.code == Error.ITEM_NOT_FOUND:
                    response = aleabot.config.get('error_arrow_no_arrows')
                elif err.code == Error.USER_NOT_FOUND:
                    response = aleabot.config.get('error_arrow_player_not_found')
                elif err.code == Error.USER_IN_HARDCORE_RONIN:
                    response = aleabot.config.get('error_arrow_ronin')
                elif err.code == Error.ALREADY_COMPLETED:
                    response = aleabot.config.get('error_arrow_already_hit')
                else:
                    response = aleabot.config.get('error_arrow_generic')

        elif len(items) == 0 and meat == 0:
            Report.warning('bot', 'Arrow request without arrow from ' + user_name)
            response = aleabot.config.get('kmailtext_arrow_notattached')

        else:
            Report.warning('bot', 'Arrow request with extra items or meat from ' + user_name)
            response = aleabot.config.get('kmailtext_arrow_extraattached')

    elif cmd == 'donate' or cmd == 'donation':
        # Handle donation
        if len(items) == 0 and meat == 0:
            # Empty donation kmail?
            Report.warning('bot', 'Empty donation received from ' + user_name)
            response = aleabot.config.get('kmailtext_donate_empty')
        else:
            Report.info('bot', 'Donation received from ' + user_name)
            response = aleabot.config.get('kmailtext_donate_thanks')
            return_goodies = False
            send_heart = True

    else:
        # Handle unknown command
        Report.warning('bot', 'Unknown kmail command: ' + cmd)
        response = aleabot.config.get('kmailtext_unknown')

    # Send our response
    if response != '' or (return_goodies and (len(items) != 0 or meat != 0)):
        Report.info('bot', 'Responding to kmail')
        response_kmail = {}
        response_kmail['userId'] = message['userId']
        response_kmail['text'] = format_reply(response + '\n\n' + aleabot.config.get('kmailtext_quote'), user_name=user_name, user_id=user_id, current_time=current_time) + '\n' + quote_kmail(message)
        if return_goodies:
            response_kmail['items'] = items
            response_kmail['meat'] = meat
        try:
            bot.sendKmail(response_kmail)
        except Error.Error as err:
            if err.code == Error.USER_IN_HARDCORE_RONIN:
                Report.error('bot', 'Tried to send items and meat back, but user is in Hardcore or Ronin!')
                response_kmail2 = {}
                response_kmail2['userId'] = message['userId']
                response_kmail2['text'] = format_reply(response + '\n\n' + aleabot.config.get('kmailtext_quote_ronin'), user_name=user_name, user_id=user_id, curent_time=current_time) + '\n' + quote_kmail(message)
                try:
                    bot.sendKmail(response_kmail2)
                except Error.Error as err2:
                    Report.error('bot', 'Unexpected error while sending response_kmail2: ' + str(err2))
            else:
                Report.error('bot', 'Unexpected error while sending response_kmail: ' + str(err))

    # Send a candy heart
    if send_heart:
        try:
            Report.info('bot', 'Sending candy heart to player: ' + user_name)
            heartreq = CursePlayerRequest(bot.session, user_id, ITEM_ID_CANDYHEART)
            heartreq.requestData['texta'] = 'THANK'
            heartreq.requestData['textb'] = 'YOU'
#.........这里部分代码省略.........
开发者ID:aleabot,项目名称:aleabot,代码行数:103,代码来源:AleabotFilter.py

示例10: parseResponse

# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import error [as 别名]
    def parseResponse(self):
        entries = []
        entryPattern = PatternManager.getOrCompilePattern('clanLogEntry')
        for entryMatch in entryPattern.finditer(self.responseText):
            entry = {}
            date = entryMatch.group('date')
            entry['date'] = datetime.strptime(date, "%m/%d/%y, %I:%M%p")
            entry['userId'] = int(entryMatch.group('userId'))
            entry['userName'] = entryMatch.group('userName')
            action = entryMatch.group('action')
            foundAction = False
            
            if foundAction == False:
                pattern = PatternManager.getOrCompilePattern('clanLogFax')
                match = pattern.match(action)
                if match:
                    foundAction = True
                    entry['type'] = CLAN_LOG_FAX
                    entry['monster'] = match.group('monsterName')

            if foundAction == False:
                pattern = PatternManager.getOrCompilePattern('clanLogAttack')
                match = pattern.match(action)
                if match:
                    foundAction = True
                    entry['type'] = CLAN_LOG_ATTACK
                    entry['clanName'] = match.group('clanName')

            if foundAction == False:
                pattern = PatternManager.getOrCompilePattern('clanLogWhitelistAdd')
                match = pattern.match(action)
                if match:
                    foundAction = True
                    entry['type'] = CLAN_LOG_WHITELISTED_PLAYER
                    entry['targetUserName'] = match.group('userName')
                    entry['targetUserId'] = int(match.group('userId'))

            if foundAction == False:
                pattern = PatternManager.getOrCompilePattern('clanLogPlayerJoinedAnotherClan')
                match = pattern.match(action)
                if match:
                    foundAction = True
                    entry['type'] = CLAN_LOG_JOINED_ANOTHER_CLAN

            if foundAction == False:
                pattern = PatternManager.getOrCompilePattern('clanLogPlayerJoinedClanWhitelist')
                match = pattern.match(action)
                if match:
                    foundAction = True
                    entry['type'] = CLAN_LOG_WHITELISTED_IN

            if foundAction == False:
                pattern = PatternManager.getOrCompilePattern('clanLogStashItemAdd')
                match = pattern.match(action)
                if match:
                    foundAction = True
                    entry['type'] = CLAN_LOG_STASH_ADD
                    entry['itemName'] = match.group('itemName')
                    entry['quantity'] = int(match.group('quantity').replace(',', ''))

            if foundAction == False:
                pattern = PatternManager.getOrCompilePattern('clanLogStashItemRemove')
                match = pattern.match(action)
                if match:
                    foundAction = True
                    entry['type'] = CLAN_LOG_STASH_REMOVE
                    entry['itemName'] = match.group('itemName')
                    entry['quantity'] = int(match.group('quantity').replace(',', ''))

            if foundAction == False:
                pattern = PatternManager.getOrCompilePattern('clanLogMeatSpentArmy')
                match = pattern.match(action)
                if match:
                    foundAction = True
                    entry['type'] = CLAN_LOG_MEAT_SPENT_ARMY
                    entry['meat'] = int(match.group('meat').replace(',', ''))

            if foundAction == False:
                pattern = PatternManager.getOrCompilePattern('clanLogChangedRank')
                match = pattern.match(action)
                if match:
                    foundAction = True
                    entry['type'] = CLAN_LOG_CHANGED_RANK
                    entry['targetUserName'] = match.group('userName')
                    entry['targetUserId'] = int(match.group('userId'))

            if foundAction == False:
                pattern = PatternManager.getOrCompilePattern('clanLogChangedTitle')
                match = pattern.match(action)
                if match:
                    foundAction = True
                    entry['type'] = CLAN_LOG_CHANGED_RANK
                    entry['targetUserName'] = match.group('userName')
                    entry['targetUserId'] = int(match.group('userId'))
                    entry['clanTitle'] = match.group('clanTitle')

            if foundAction == False:
                Report.error("request", "Unknown clan log action: %s" % action)
                entry['type'] = CLAN_LOG_UNKNOWN
                entry['action'] = action
#.........这里部分代码省略.........
开发者ID:ijzer,项目名称:cwbot-ndy,代码行数:103,代码来源:ClanLogPartialRequest.py


注:本文中的kol.util.Report.error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。