mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-13 11:43:31 +00:00
Small bot optimisations
This commit is contained in:
@@ -190,15 +190,13 @@ tell_list = {}
|
|||||||
if CORE_DATA.DISABLE_ALL_NON_MANDATORY_SOCKET_CONNECTIONS:
|
if CORE_DATA.DISABLE_ALL_NON_MANDATORY_SOCKET_CONNECTIONS:
|
||||||
nudgeable = False
|
nudgeable = False
|
||||||
try:
|
try:
|
||||||
tiedosto = open("replacenames.cache","r")
|
with open("replacenames.cache","r") as tiedosto:
|
||||||
replacenames = pickle.load(tiedosto)
|
replacenames = pickle.load(tiedosto)
|
||||||
tiedosto.close()
|
|
||||||
for i in replacenames.values():
|
for i in replacenames.values():
|
||||||
if len(i) > call_me_max_length:
|
if len(i) > call_me_max_length:
|
||||||
replacenames[replacenames.keys()[replacenames.values().index(i)]] = i[:call_me_max_length]
|
replacenames[replacenames.keys()[replacenames.values().index(i)]] = i[:call_me_max_length]
|
||||||
tiedosto = open("replacenames.cache","w")
|
with open("replacenames.cache","w") as tiedosto:
|
||||||
pickle.dump(replacenames,tiedosto)
|
pickle.dump(replacenames,tiedosto)
|
||||||
tiedosto.close()
|
|
||||||
if "[\0x01]" in i.lower() or "[\\0x01]" in i.lower():
|
if "[\0x01]" in i.lower() or "[\\0x01]" in i.lower():
|
||||||
i = i.replace("[\0x01]","")
|
i = i.replace("[\0x01]","")
|
||||||
i = i.replace("[\0X01]","")
|
i = i.replace("[\0X01]","")
|
||||||
@@ -211,13 +209,12 @@ except EOFError: #Cache corrupt
|
|||||||
replacenames = {}
|
replacenames = {}
|
||||||
print "replacenames.cache is corrupt and couldn't be loaded."
|
print "replacenames.cache is corrupt and couldn't be loaded."
|
||||||
try:
|
try:
|
||||||
tiedosto = open("peopleheknows.cache","r")
|
with open("peopleheknows.cache","r") as tiedosto:
|
||||||
peopleheknows = pickle.load(tiedosto)
|
peopleheknows = pickle.load(tiedosto)
|
||||||
tiedosto.close()
|
|
||||||
except IOError:
|
except IOError:
|
||||||
peopleheknows = [[],[]]
|
peopleheknows = [[],[]]
|
||||||
tiedosto = open("peopleheknows.cache","w")
|
with open("peopleheknows.cache","w") as tiedosto:
|
||||||
tiedosto.close()
|
pass
|
||||||
except EOFError:
|
except EOFError:
|
||||||
peopleheknows = [[],[]]
|
peopleheknows = [[],[]]
|
||||||
print "peopleheknows.cache is corrupt and couldn't be loaded."
|
print "peopleheknows.cache is corrupt and couldn't be loaded."
|
||||||
@@ -401,13 +398,12 @@ def target(who,how_long):
|
|||||||
if debug:
|
if debug:
|
||||||
print "Banned",who,"For",how_long,"seconds"
|
print "Banned",who,"For",how_long,"seconds"
|
||||||
if logbans:
|
if logbans:
|
||||||
tiedosto = open(targetdirectory+"banlog/"+str(int(start))+"-"+str(int(end))+".txt","w")
|
with open(targetdirectory+"banlog/"+str(int(start))+"-"+str(int(end))+".txt","w") as tiedosto:
|
||||||
tiedosto.write("Start of ban on "+who+":"+str(int(start)))
|
tiedosto.write("Start of ban on "+who+":"+str(int(start)))
|
||||||
tiedosto.write("\n")
|
tiedosto.write("\n")
|
||||||
tiedosto.write("End of ban on "+who+":"+str(int(end)))
|
tiedosto.write("End of ban on "+who+":"+str(int(end)))
|
||||||
tiedosto.write("\n")
|
tiedosto.write("\n")
|
||||||
tiedosto.write("In total:"+str(int(end-start))+"Seconds")
|
tiedosto.write("In total:"+str(int(end-start))+"Seconds")
|
||||||
tiedosto.close()
|
|
||||||
else:
|
else:
|
||||||
CALL_OFF = False
|
CALL_OFF = False
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user