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


Python manager.PatternManager类代码示例

本文整理汇总了Python中kol.manager.PatternManager的典型用法代码示例。如果您正苦于以下问题:Python PatternManager类的具体用法?Python PatternManager怎么用?Python PatternManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: parseResponse

	def parseResponse(self):
		hardcoreRoninPattern = PatternManager.getOrCompilePattern('userInHardcoreRonin')
		ignoringPattern = PatternManager.getOrCompilePattern('userIgnoringUs')
		if hardcoreRoninPattern.search(self.responseText):
			raise UserInHardcoreRoninError("Unable to send items or meat. User is in hardcore or ronin.")
		elif ignoringPattern.search(self.responseText):
			raise UserIsIgnoringError("Unable to send message. User is ignoring us.")
开发者ID:TeKRunneR,项目名称:pykol,代码行数:7,代码来源:SendMessageRequest.py

示例2: parseResponse

    def parseResponse(self):
        cantAffordItemPattern = PatternManager.getOrCompilePattern('cantAffordItem')
        if cantAffordItemPattern.search(self.responseText):
            raise Error.Error("You can not afford to buy this item.", Error.NOT_ENOUGH_MEAT)

        noItemAtThatPricePattern = PatternManager.getOrCompilePattern('mallNoItemAtThatPrice')
        if noItemAtThatPricePattern.search(self.responseText):
            raise Error.Error("That item is not sold here at that price.", Error.ITEM_NOT_FOUND)

        ignoreListPattern = PatternManager.getOrCompilePattern('cantBuyItemIgnoreList')
        if ignoreListPattern.search(self.responseText):
            raise Error.Error("The owner of that store has balleeted you.", Error.USER_IS_IGNORING)

        mallHitLimitPattern = PatternManager.getOrCompilePattern('mallHitLimit')
        if mallHitLimitPattern.search(self.responseText):
            raise Error.Error("You have hit the limit for this item at this store.", Error.LIMIT_REACHED)

        items = ParseResponseUtils.parseItemsReceived(self.responseText, self.session)
        if len(items) == 0:
            raise Error.Error("Unknown error: %s" % self.responseText, Error.REQUEST_GENERIC)
        self.responseData["items"] = items

        spentMeatPattern = PatternManager.getOrCompilePattern('meatSpent')
        match = spentMeatPattern.search(self.responseText)
        self.responseData['meatSpent'] = int(match.group(1).replace(',', ''))
开发者ID:Alecat,项目名称:pykol,代码行数:25,代码来源:MallItemPurchaseRequest.py

示例3: parseResponse

	def parseResponse(self):
		cantAffordItemPattern = PatternManager.getOrCompilePattern('cantAffordItem')
		if cantAffordItemPattern.search(self.responseText):
			raise NotEnoughMeatError("You can not afford to buy this item.")
		
		noItemAtThatPricePattern = PatternManager.getOrCompilePattern('mallNoItemAtThatPrice')
		if noItemAtThatPricePattern.search(self.responseText):
			raise NotSoldHereError("That item is not sold here at that price.")
		
		ignoreListPattern = PatternManager.getOrCompilePattern('cantBuyItemIgnoreList')
		if ignoreListPattern.search(self.responseText):
			raise UserIsIgnoringError("The owner of that store has balleeted you.")
		
		mallHitLimitPattern = PatternManager.getOrCompilePattern('mallHitLimit')
		if mallHitLimitPattern.search(self.responseText):
			raise MallLimitError("You have hit the limit for this item at this store.")
		
		items = ParseResponseUtils.parseItemsReceived(self.responseText, self.session)
		if len(items) == 0:
			raise RequestError("Unknown error: %s" % self.responseText)
		self.responseData["items"] = items
		
		spentMeatPattern = PatternManager.getOrCompilePattern('meatSpent')
		match = spentMeatPattern.search(self.responseText)
		self.responseData['meatSpent'] = int(match.group(1).replace(',', ''))
开发者ID:NardoLoopa,项目名称:pykol,代码行数:25,代码来源:MallItemPurchaseRequest.py

示例4: parseResponse

    def parseResponse(self):
        response = {}
        
        bountyAvailablePattern = PatternManager.getOrCompilePattern('bountyAvailable')
        if bountyAvailablePattern.search(self.responseText):
            bountyAvailable = True
        else:
            bountyAvailable = False

        bountyChosenPattern = PatternManager.getOrCompilePattern('bountyChosen')
        bountyActivePattern1 = PatternManager.getOrCompilePattern('bountyActive1')
        bountyActivePattern2 = PatternManager.getOrCompilePattern('bountyActive2')
        
        if bountyChosenPattern.search(self.responseText) or \
            bountyActivePattern1.search(self.responseText) or \
            bountyActivePattern2.search(self.responseText):
                bountyActive = True
        else:
            bountyActive = False

        dailyBounties = []
        if bountyAvailable:
            bountyPattern = PatternManager.getOrCompilePattern('dailyBountyItem')
            for match in bountyPattern.finditer(self.responseText):
                itemId = int(match.group('itemid'))
                item = ItemDatabase.getItemFromId(itemId)
                dailyBounties.append(item)
        
        response['bountyAvailable'] = bountyAvailable
        response['bountyActive'] = bountyActive
        response['dailyBounties'] = dailyBounties
        
        self.responseData = response
开发者ID:Alecat,项目名称:pykol,代码行数:33,代码来源:BountyHunterRequest.py

示例5: parseStatPointsGained

def parseStatPointsGained(text, checkMuscle=True, checkMysticality=True, checkMoxie=True):
	statPoints = {}
	
	if checkMuscle:
		muscPattern = PatternManager.getOrCompilePattern('musclePointGainLoss')
		muscMatch = muscPattern.search(text)
		if muscMatch:
			if muscMatch.group(1) == "gain":
				statPoints["muscle"] = '+'
			else:
				statPoints["muscle"] = '-'
				
	if checkMysticality:
		mystPattern = PatternManager.getOrCompilePattern('mystPointGainLoss')
		mystMatch = mystPattern.search(text)
		if mystMatch:
			if mystMatch.group(1) == "gain":
				statPoints["mysticality"] = '+'
			else:
				statPoints["mysticality"] = '-'
				
	if checkMoxie:
		moxPattern = PatternManager.getOrCompilePattern('moxiePointGainLoss')
		moxMatch = moxPattern.search(text)
		if moxMatch:
			if moxMatch.group(1) == "gain":
				statPoints["moxie"] = '+'
			else:
				statPoints["moxie"] = '-'
				
	return statPoints
开发者ID:ZJ,项目名称:pykol,代码行数:31,代码来源:ParseResponseUtils.py

示例6: parseDungeonChatMessage

def parseDungeonChatMessage(context, **kwargs):
    chat = kwargs["chat"]
    bot = kwargs["bot"]
    state = bot.states["global"]

    trappedPattern = PatternManager.getOrCompilePattern("imprisonedByChums")
    rescuedPattern = PatternManager.getOrCompilePattern("freedFromChums")

    if chat["text"].find("has put a tire on the fire") > 0:
        numTires = 0
        if "hobo:tiresStacked" in state:
            numTires = state["hobo:tiresStacked"]
        numTires += 1
        state["hobo:tiresStacked"] = numTires
        bot.writeState("global")
    elif chat["text"].find("has started a tirevalanche") > 0:
        state["hobo:tiresStacked"] = 0
        bot.writeState("global")
    elif rescuedPattern.match(chat["text"]):
        if "hobo:sewerTrapped" in state:
            del state["hobo:sewerTrapped"]
            bot.writeState("global")
    else:
        match = trappedPattern.match(chat["text"])
        if match:
            state["hobo:sewerTrapped"] = match.group(1)
            bot.writeState("global")
开发者ID:ZJ,项目名称:pykol,代码行数:27,代码来源:RaidHelper.py

示例7: parseResponse

    def parseResponse(self):
        notEnoughCloversPattern = PatternManager.getOrCompilePattern('notEnoughClovers')
        noTrinketsPattern = PatternManager.getOrCompilePattern('noTrinkets')
        noHermitPermitPattern = PatternManager.getOrCompilePattern('noHermitPermits')
        notHermitItemPattern = PatternManager.getOrCompilePattern('notHermitItem')

        # Check for errors.
        if notEnoughCloversPattern.search(self.responseText):
            e = Error.Error("The Hermit doesn't have enough clovers for that.", Error.ITEM_NOT_FOUND)
            e.itemId = 24
            raise e
        if noTrinketsPattern.search(self.responseText):
            e = Error.Error("You don't have enough worthless items for that.", Error.ITEM_NOT_FOUND)
            e.itemId = 43
            raise e
        if noHermitPermitPattern.search(self.responseText):
            e = Error.Error("You don't have enough hermit permits for that.", Error.ITEM_NOT_FOUND)
            e.itemId = 42
            raise e
        if notHermitItemPattern.search(self.responseText):
            e = Error.Error("The Hermit doesn't have any of those.", Error.ITEM_NOT_FOUND)
            e.itemId = self.requestData['whichitem']
            raise e

        response = {}
        items = ParseResponseUtils.parseItemsReceived(self.responseText, self.session)
        if len(items) > 0:
            response["items"] = items
        self.responseData = response
开发者ID:Alecat,项目名称:pykol,代码行数:29,代码来源:HermitRequest.py

示例8: parseDungeonChatMessage

def parseDungeonChatMessage(context, **kwargs):
	chat = kwargs["chat"]
	bot = kwargs["bot"]
	state = bot.states["global"]
	
	trappedPattern = PatternManager.getOrCompilePattern('imprisonedByChums')
	rescuedPattern = PatternManager.getOrCompilePattern('freedFromChums')
	
	if chat["text"].find("has put a tire on the fire") > 0:
		numTires = 0
		if "hobo:tiresStacked" in state:
			numTires = state["hobo:tiresStacked"]
		numTires += 1
		state["hobo:tiresStacked"] = numTires
		bot.writeState("global")
	elif chat["text"].find("has started a tirevalanche") > 0:
		state["hobo:tiresStacked"] = 0
		bot.writeState("global")
	elif chat["text"].find("escaped from the C. H. U. M.s by gnawing through their cage") > 0 or rescuedPattern.match(chat["text"]):
		if "hobo:sewerTrapped" in state:
			del state["hobo:sewerTrapped"]
			bot.writeState("global")
	elif chat["text"].find("flooded the sewers leading to Hobopolis") > 0:
		keysToClear = ["hobo:sewerTrapped", "hobo:tiresStacked"]
		for key in keysToClear:
			if key in state:
				del state[key]
		bot.writeState("global")
	else:
		match = trappedPattern.match(chat["text"])
		if match:
			state["hobo:sewerTrapped"] = match.group(1)
			bot.writeState("global")
开发者ID:NardoLoopa,项目名称:pykol,代码行数:33,代码来源:RaidHelper.py

示例9: parseSubstatsGainedLost

def parseSubstatsGainedLost(text, checkMuscle=True, checkMysticality=True, checkMoxie=True):
    substats = {}

    if checkMuscle:
        muscPattern = PatternManager.getOrCompilePattern('muscleGainLoss')
        muscMatch = muscPattern.search(text)
        if muscMatch:
            muscle = int(muscMatch.group(2).replace(',', ''))
            if muscMatch.group(1) == "gain":
                substats["muscle"] = muscle
            else:
                substats["muscle"] = -1 * muscle

    if checkMysticality:
        mystPattern = PatternManager.getOrCompilePattern('mysticalityGainLoss')
        mystMatch = mystPattern.search(text)
        if mystMatch:
            myst = int(mystMatch.group(2).replace(',', ''))
            if mystMatch.group(1) == "gain":
                substats["mysticality"] = myst
            else:
                substats["mysticality"] = -1 * myst

    if checkMoxie:
        moxPattern = PatternManager.getOrCompilePattern('moxieGainLoss')
        moxMatch = moxPattern.search(text)
        if moxMatch:
            moxie = int(moxMatch.group(2).replace(',', ''))
            if moxMatch.group(1) == "gain":
                substats["moxie"] = moxie
            else:
                substats["moxie"] = -1 * moxie

    return substats
开发者ID:Alecat,项目名称:pykol,代码行数:34,代码来源:ParseResponseUtils.py

示例10: parseResponse

	def parseResponse(self):
		dontHaveMeatpastePattern = PatternManager.getOrCompilePattern('noMeatpaste')
		itemsDontMeatpastePattern = PatternManager.getOrCompilePattern('itemsDontMeatpaste')
		dontHaveItemsPattern = PatternManager.getOrCompilePattern('dontHaveItemsMeatpaste')
		
		# Check for errors.
		if dontHaveMeatpastePattern.search(self.responseText):
			raise NotEnoughItemsError("Unable to combine items. You don't have any meatpaste.")
		elif itemsDontMeatpastePattern.search(self.responseText):
			raise InvalidRecipeError("Unable to combine items. The submitted ingredients do not meatpaste together.")
		elif dontHaveItemsPattern.search(self.responseText):
			raise NotEnoughItemsError("Unable to combine items. You don't have all of the items you are trying to meatpaste.")
			
		# Find the items attached to the message.
		singleItemPattern = PatternManager.getOrCompilePattern('acquireSingleItem')
		match = singleItemPattern.search(self.responseText)
		if match:
			descId = int(match.group(1))
			item = ItemDatabase.getItemFromDescId(descId, self.session)
			item["quantity"] = 1
		else:
			multiItemPattern = PatternManager.getOrCompilePattern('acquireMultipleItems')
			match = multiItemPattern.search(self.responseText)
			if match:
				descId = int(match.group(1))
				item = ItemDatabase.getItemFromDescId(descId, self.session)
				quantity = int(match.group(2).replace(',', ''))
				item["quantity"] = quantity
			else:
				raise RequestError("Unknown error.")
		
		self.responseData["items"] = item
开发者ID:ZJ,项目名称:pykol,代码行数:32,代码来源:MeatpastingRequest.py

示例11: __init__

 def __init__(self, session):
     super(ClanLogPartialRequest, self).__init__(
         session, 
         [PatternManager.getOrCompilePattern('clanLogFax'),
          PatternManager.getOrCompilePattern('clanLogEntry')],
         5*1024)
     self.url = session.serverURL + "clan_log.php"
开发者ID:ijzer,项目名称:cwbot-ndy,代码行数:7,代码来源:ClanLogPartialRequest.py

示例12: parseResponse

 def parseResponse(self):
     items = []
     itemMatchPattern = PatternManager.getOrCompilePattern('mallItemSearchResult')
     itemDetailsPattern = PatternManager.getOrCompilePattern('mallItemSearchDetails')
     for itemMatch in itemMatchPattern.finditer(self.responseText):
         matchText = itemMatch.group(1)
         match = itemDetailsPattern.search(matchText)
         itemId = int(match.group('itemId'))
         try:
             item = ItemDatabase.getItemFromId(itemId)
             item["price"] = int(match.group('price').replace(',', ''))
             item["storeId"] = int(match.group('storeId'))
             item["storeName"] = match.group('storeName').replace('<br>', ' ')
             item["quantity"] = int(match.group('quantity').replace(',', ''))
             limit = match.group('limit').replace(',', '')
             if len(limit) > 0:
                 limit = int(limit)
             item["limit"] = limit
             if matchText.find('limited"') >= 0:
                 item["hitLimit"] = True
             items.append(item)
         except Error.Error, inst:
             if inst.code == Error.ITEM_NOT_FOUND:
                 Report.info("itemdatabase", "Unrecognized item found in mall search: %s" % itemId, inst)
             else:
                 raise inst
开发者ID:MicN,项目名称:HogBotGit,代码行数:26,代码来源:MallItemSearchRequest.py

示例13: parseResponse

	def parseResponse(self):
		noMeatForPastePattern = PatternManager.getOrCompilePattern('noMeatForMeatpasting')
		
		# Check for errors.
		if noMeatForPastePattern.search(self.responseText):
			raise NotEnoughMeatError("Unable to make the requested item. You don't have enough meat")

		# Find the items attached to the message.
		singleItemPattern = PatternManager.getOrCompilePattern('acquireSingleItem')
		match = singleItemPattern.search(self.responseText)
		if match:
			descId = int(match.group(1))
			item = ItemDatabase.getItemFromDescId(descId, self.session)
			item["quantity"] = 1
		else:
			multiItemPattern = PatternManager.getOrCompilePattern('acquireMultipleItems')
			match = multiItemPattern.search(self.responseText)
			if match:
				descId = int(match.group(1))
				item = ItemDatabase.getItemFromDescId(descId, self.session)
				quantity = int(match.group(2).replace(',', ''))
				item["quantity"] = quantity
			else:
				raise RequestError("Unknown error.")
		
		self.responseData["items"] = item
开发者ID:ZJ,项目名称:pykol,代码行数:26,代码来源:MakePasteRequest.py

示例14: parseResponse

	def parseResponse(self):
		cantPulverizePattern = PatternManager.getOrCompilePattern('cantPulverizeItem')
		if cantPulverizePattern.search(self.responseText) != None:
			item = ItemDatabase.getItemFromId(self.itemId, self.session)
			raise UnableToPulverizeItemError("'%s' is not an item that can be pulverized." % item["name"])
		
		notEnoughItemsPattern = PatternManager.getOrCompilePattern('notEnoughItems')
		if notEnoughItemsPattern.search(self.responseText) != None:
			item = ItemDatabase.getItemFromId(self.itemId, self.session)
			if self.quantity == 1:
				itemStr = item["name"]
			else:
				itemStr = item["plural"]
			raise NotEnoughItemsError("You do not have %s %s" % (self.quantity % itemStr))
			
		items = []
		
		singleItemPattern = PatternManager.getOrCompilePattern('acquireSingleItem')
		for match in singleItemPattern.finditer(self.responseText):
			descId = int(match.group(1))
			item = ItemDatabase.getItemFromDescId(descId, self.session)
			item["quantity"] = 1
			items.append(item)
		
		multiItemPattern = PatternManager.getOrCompilePattern('acquireMultipleItems')
		for match in multiItemPattern.finditer(self.responseText):
			descId = int(match.group(1))
			quantity = int(match.group(2).replace(',', ''))
			item = ItemDatabase.getItemFromDescId(descId, self.session)
			item["quantity"] = quantity
			items.append(item)
		
		self.responseData["results"] = items
开发者ID:ZJ,项目名称:pykol,代码行数:33,代码来源:PulverizeRequest.py

示例15: parseResponse

    def parseResponse(self):
        usernamePattern = PatternManager.getOrCompilePattern('profileUserName')
        match = usernamePattern.search(self.responseText)
        self.responseData["userName"] = match.group(1)

        playerClanPattern = PatternManager.getOrCompilePattern('profileClan')
        match = playerClanPattern.search(self.responseText)
        if match:
            self.responseData["clanId"] = int(match.group(1))
            self.responseData["clanName"] = match.group(2)

        numberAscensionsPattern = PatternManager.getOrCompilePattern('profileNumAscensions')
        match = numberAscensionsPattern.search(self.responseText)
        if match:
            self.responseData["numAscensions"] = int(match.group(1))
        else:
            self.responseData["numAscensions"] = 0

        numberTrophiesPattern = PatternManager.getOrCompilePattern('profileNumTrophies')
        match = numberTrophiesPattern.search(self.responseText)
        if match:
            self.responseData["numTrophies"] = int(match.group(1))
        else:
            self.responseData["numTrophies"] = 0

        numberTattoosPattern = PatternManager.getOrCompilePattern('profileNumTattoos')
        match = numberTattoosPattern.search(self.responseText)
        if match:
            self.responseData["numTattoos"] = int(match.group(1))
        else:
            self.responseData["numTattoos"] = 0
开发者ID:Alecat,项目名称:pykol,代码行数:31,代码来源:UserProfileRequest.py


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