本文整理汇总了Python中kol.util.Report.info方法的典型用法代码示例。如果您正苦于以下问题:Python Report.info方法的具体用法?Python Report.info怎么用?Python Report.info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kol.util.Report
的用法示例。
在下文中一共展示了Report.info方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parseResponse
# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import info [as 别名]
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
示例2: uneffect
# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import info [as 别名]
def uneffect(bot, id):
r = UneffectRequest(bot.session, id)
try:
r.doRequest()
resp = "Effect successfully removed!"
except Error:
resp = "Unable to remove effect for unknown reason."
Report.info("bot", resp)
示例3: botEndCycle
# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import info [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
示例4: runBots
# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import info [as 别名]
def runBots():
if len(_bots) > 1:
Report.includeThreadName = True
for bot in _bots:
bot.start()
try:
while _haltEvent.isSet() == False:
time.sleep(15)
except KeyboardInterrupt:
_haltEvent.set()
Report.info("bot", "Shutting down.")
for bot in _bots:
bot.join()
示例5: parseStashActivity
# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import info [as 别名]
def parseStashActivity(self, clanLog):
results = {}
match = STASH_PATTERN.search(clanLog)
if match:
rows = match.group("rows").split("<br>")
for row in rows:
row = row.strip()
if len(row) > 0:
data = self.parseStashActivityRow(row)
category = data["category"]
if not category in results:
results[category] = []
results[category].append(data)
del data["category"]
else:
Report.info("bot", "Stash activity not found in clan activity log")
return results
示例6: botProcessKmail
# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import info [as 别名]
def botProcessKmail(context, **kwargs):
returnCode = FilterManager.CONTINUE
message = kwargs["kmail"]
bot = kwargs["bot"]
cmd = BotUtils.getKmailCommand(message)
if cmd == "uneffect":
arr = message["text"].split()
items = message["items"]
# Get the effect ID.
if len(arr) < 2:
raise Error.Error("You must specify the ID of the effect to remove.", Error.BOT_REQUEST)
try:
effectId = int(arr[1])
except ValueError:
raise Error.Error("Unable to remove effect. Invalid effect ID.", Error.BOT_REQUEST)
# Ensure the user sent a SGEEA.
if len(items) != 1:
raise Error.Error("Please include just a SGEEA in your kmail.", Error.BOT_REQUEST)
sgeea = ItemDatabase.getItemFromName("soft green echo eyedrop antidote")
if items[0]["id"] != sgeea["id"] or items[0]["quantity"] != 1:
raise Error.Error("Please include just a single SGEEA in your kmail.", Error.BOT_REQUEST)
# Perform the request.
m = {}
m["userId"] = message["userId"]
Report.info("bot", "Attempting to remove effect %s..." % effectId)
r = UneffectRequest(bot.session, effectId)
try:
r.doRequest()
m["text"] = "Effect successfully removed!"
except Error.Error, inst:
if inst.code == Error.EFFECT_NOT_FOUND:
m["text"] = "I do not currently have that effect."
m["items"] = items
else:
m["text"] = "Unable to remove effect for unknown reason."
m["items"] = items
bot.sendKmail(m)
returnCode = FilterManager.FINISHED
示例7: runBots
# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import info [as 别名]
def runBots():
if len(_bots) > 1:
Report.setIncludeThreadName(True)
FilterManager.executeFiltersForEvent("runBots")
for bot in _bots:
bot.start()
try:
while _haltEvent.isSet() == False:
time.sleep(15)
except KeyboardInterrupt:
_haltEvent.set()
Report.info("bot", "Shutting down.")
for bot in _bots:
bot.join()
示例8: botProcessChat
# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import info [as 别名]
def botProcessChat(context, **kwargs):
returnCode = FilterManager.CONTINUE
bot = kwargs['bot']
chat = kwargs['chat']
if chat['type'] in ['private']:
# Initialize variables for response formatting
user_name = str(chat['userName'])
user_id = str(chat['userId'])
current_time = time.time()
exprlist = []
exprresults = []
channel = ''
clan = alea.clan.Clan(0, '')
target_name = ''
target_id = '0'
uneffectable = alea.util.Uneffectable('')
msg = ''
try:
# Parse the abomination that our chat partner hath wrought
request = alea.parser.aleabot_parse(chat['text'])
if request[0] == 'rollrequest':
# Handle a dice rolling request
exprlist = request[1]
channel = request[2]
# Get the reply text that applies to this kind of roll request
diceless = all(expr.classify_dice() == 0 for expr in exprlist)
if channel == '':
# Private rolling
if diceless:
msg = aleabot.config.get('rolltext_diceless_private')
else:
msg = aleabot.config.get('rolltext_private')
else:
# Public rolling
if diceless:
msg = aleabot.config.get('rolltext_diceless_public')
else:
msg = aleabot.config.get('rolltext_public')
# Check if channel is allowed, and switch clan if needed
if channel != '':
if channel in aleabot.config.get('channels').split():
# Allowed public channel (e.g. /games)
pass
elif channel in aleabot.config.get('clanchannels').split():
# Allowed clan channel (e.g. /clan, /hobopolis, ...)
aleabot.clanstate.set_session(bot.session)
clan = aleabot.clanstate.player_clan(user_id)
Report.info('bot', '%s asked me to roll in clan %s' % (user_name, clan.name()))
if clan.id() == 0:
Report.warning('bot', 'A player who is not in a clan asked me to roll in ' + channel)
raise ClanlessPlayerError('clanless player')
elif not aleabot.clanstate.have_whitelist(clan):
Report.warning('bot', 'I do not have a whitelist in clan %s' % clan.name())
raise NeedWhitelistError('need whitelist')
else:
Report.info('bot', 'I have a whitelist in clan %s' % clan.name())
aleabot.clanstate.switch(clan)
# Set timer to switch back to home clan
aleabot.home_clan_timer = 0
else:
raise ChannelDisallowedError(channel)
# Apply time-based limits
aleabot.rolllimiter.check(channel, user_id, clan.id(),
current_time, aleabot.config)
# Evaluate dice expressions
exprresults = alea.expr.aleabot_eval(exprlist,
channel != '', aleabot.rng, aleabot.config)
# Update time-based roll limiter
aleabot.rolllimiter.update(channel, user_id, clan.id(),
current_time, aleabot.config)
# Record roll and result in roll verification list
state = bot.states['global']
rollverify_key = 'rollverify_' + user_id
if rollverify_key not in state:
state[rollverify_key] = []
state[rollverify_key].insert(0, (
current_time,
[str(x) for x in exprlist],
[str(x) for x in exprresults],
str(channel),
str(clan.name())))
rollverify_count = aleabot.config.get('rollverify_count')
state[rollverify_key] = state[rollverify_key][0:rollverify_count]
bot.writeState('global')
elif request[0] == 'rollverifyrequest':
# Handle a roll verification request
try:
target_name, target_id = resolve_target(bot,
user_name, user_id, request[1])
# Get config settings
#.........这里部分代码省略.........
示例9: botProcessKmail
# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import info [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'
#.........这里部分代码省略.........
示例10: breakfast
# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import info [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))
示例11:
# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import info [as 别名]
# $Id: SmileHandler.py 646 2008-10-01 04:22:39Z scelis $
from kol.Error import ParseMessageError
from kol.bot import BotUtils
from kol.database import SkillDatabase