Skip to content
This repository has been archived by the owner on Aug 1, 2018. It is now read-only.

Commit

Permalink
disable all failure hints to reduce fools.
Browse files Browse the repository at this point in the history
  • Loading branch information
sffxzzp committed Jul 2, 2018
1 parent fce677f commit f634d90
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions saliens.py
Expand Up @@ -53,10 +53,11 @@ class weblib:
}
jar = requests.cookies.RequestsCookieJar()
def myprint(self, string):
try:
print(string)
except:
print("Network Error!")
pass
# try:
# print(string)
# except:
# print("Network Error!")
def get(self, url, name=''):
try:
req = requests.get(url, headers = self.headers, cookies = self.jar, timeout=90)
Expand Down Expand Up @@ -146,14 +147,14 @@ def leavePlanet(self):
self.getPlayerInfo()
if "active_planet" in self.playerInfo:
errorTime += 1
self.myprint("%s|Bot: %s|LeaveGame|Failed|Retry after 10s..." % (getTime(), self.name))
# self.myprint("%s|Bot: %s|LeaveGame|Failed|Retry after 10s..." % (getTime(), self.name))
time.sleep(10)
self.leaveGame()
else:
break
self.getPlayerInfo()
if "active_planet" in self.playerInfo:
self.myprint("%s|Bot: %s|LeavePlanet|Failed|RestartInstance" % (getTime(), self.name))
# self.myprint("%s|Bot: %s|LeavePlanet|Failed|RestartInstance" % (getTime(), self.name))
return False
def leaveGame(self, gameid=-1):
if gameid==-1:
Expand All @@ -176,13 +177,13 @@ def joinBossZone(self):
self.name)
eresult = int(findstr('\d+', req[1]["X-eresult"])[0])
if eresult != 1:
self.myprint("%s|Bot: %s|JoinBossZone: %s|Failed|RestartInstance" % (getTime(), self.name, self.zone_position))
# self.myprint("%s|Bot: %s|JoinBossZone: %s|Failed|RestartInstance" % (getTime(), self.name, self.zone_position))
return False
else:
time.sleep(4)
return True
except:
self.myprint("%s|Bot: %s|JoinBossZone: %s|Failed|RestartInstance" % (getTime(), self.name, self.zone_position))
# self.myprint("%s|Bot: %s|JoinBossZone: %s|Failed|RestartInstance" % (getTime(), self.name, self.zone_position))
return False
def fightBoss(self):
bossFailsAllowed = 10
Expand All @@ -206,12 +207,12 @@ def fightBoss(self):
eresult = int(findstr('\d+', req[1]["X-eresult"])[0])
res = json.loads(req[0])["response"]
if eresult == 11:
self.myprint("%s|Bot: %s|BossFight|InvalidState|RestartInstance" % (getTime(), self.name))
# self.myprint("%s|Bot: %s|BossFight|InvalidState|RestartInstance" % (getTime(), self.name))
break
if eresult != 1:
bossFailsAllowed -= 1
if bossFailsAllowed < 1:
self.myprint("%s|Bot: %s|BossFight|ErrorTooMuch|RestartInstance" % (getTime(), self.name))
# self.myprint("%s|Bot: %s|BossFight|ErrorTooMuch|RestartInstance" % (getTime(), self.name))
break
if "boss_status" in res:
if "boss_players" not in res["boss_status"]:
Expand Down Expand Up @@ -261,15 +262,15 @@ def getJoinInfo(self):
skipped = "|ZoneSkipped"
else:
skipped = ""
self.myprint("%s|Bot: %s%s|Msg: %s|Retry after 10s..." % (getTime(), self.name, skipped, req[1]["X-error_message"]))
# self.myprint("%s|Bot: %s%s|Msg: %s|Retry after 10s..." % (getTime(), self.name, skipped, req[1]["X-error_message"]))
time.sleep(10)
return False
def bug(self, gameid):
self.myprint("%s|Bot: %s|AlreadyInGame|GameId: %s|BUG???" % (getTime(), self.name, str(gameid)))
# self.myprint("%s|Bot: %s|AlreadyInGame|GameId: %s|BUG???" % (getTime(), self.name, str(gameid)))
stillBug = True
while stillBug == True:
stillBug = self.getScoreInfo(1)
self.myprint("%s|Bot: %s|AlreadyInGame|GameId: %s|LeaveGame" % (getTime(), self.name, str(gameid)))
# self.myprint("%s|Bot: %s|AlreadyInGame|GameId: %s|LeaveGame" % (getTime(), self.name, str(gameid)))
self.leaveGame(gameid)
def getScoreInfo(self, errorTime=0):
if errorTime == 0:
Expand All @@ -295,7 +296,7 @@ def getScoreInfo(self, errorTime=0):
return True
else:
if errorTime > 1:
self.myprint("%s|Bot: %s|UploadScore|Failed" % (getTime(), self.name))
# self.myprint("%s|Bot: %s|UploadScore|Failed" % (getTime(), self.name))
return False
else:
time.sleep(1)
Expand Down Expand Up @@ -358,7 +359,7 @@ def getHardZone(self):
self.myprint("%s|Bot: %s|SelectZone: %s|Progress: %s" % (getTime(), self.name, self.zone_position, zone["capture_progress"]))
break
if self.zone_position == -1:
self.myprint("%s|Bot: %s|SwitchPlanet|Getting info..." % (getTime(), self.name))
# self.myprint("%s|Bot: %s|SwitchPlanet|Getting info..." % (getTime(), self.name))
self.getBestPlanet()
if "active_planet" in self.playerInfo:
if self.bestPlanet != self.playerInfo["active_planet"]:
Expand All @@ -381,7 +382,8 @@ def handler(data):
try:
bot.loadcfg(data)
except:
print("%s|Bot: %s|LoadConfig|Error!" % (getTime(), data[0]))
pass
# print("%s|Bot: %s|LoadConfig|Error!" % (getTime(), data[0]))
bot.getPlayerInfo()
bot.getBestPlanet()
while True:
Expand Down

3 comments on commit f634d90

@HONGJICAI
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个commit强啊

@xxzbg
Copy link

@xxzbg xxzbg commented on f634d90 Jul 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

确实是不会失败了.. 0.0

@fenguoerbian
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个commit牛逼!

Please sign in to comment.