Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from mechanize import Browser
- from HTMLParser import HTMLParser
- from multiprocessing import Process, freeze_support
- import time
- import os.path
- import csv
- from datetime import datetime
- import re
- import json
- links = {
- 'buy rm 20': 'http://blocgame.com/policies/buyrm100.php',
- 'buy rm 5': 'http://blocgame.com/policies/buyrm5.php',
- 'buy rm 1': 'http://blocgame.com/policies/buyrm.php',
- 'buy oil 20': 'http://blocgame.com/policies/buyoil100.php',
- 'buy oil 5': 'http://blocgame.com/policies/buyoil5.php',
- 'buy oil 1': 'http://blocgame.com/policies/buyoil.php',
- 'buy food 20': 'http://blocgame.com/policies/buyfood100.php',
- 'buy food 5': 'http://blocgame.com/policies/buyfood5.php',
- 'buy food 1': 'http://blocgame.com/policies/buyfood.php',
- 'buy mg 20': 'http://blocgame.com/policies/buymg100.php',
- 'buy mg 5': 'http://blocgame.com/policies/buyweapons5.php',
- 'buy mg 1': 'http://blocgame.com/policies/buyweapons.php',
- 'sell rm 20': 'http://blocgame.com/policies/sellrm100.php',
- 'sell rm 5': 'http://blocgame.com/policies/sellrm5.php',
- 'sell rm 1': 'http://blocgame.com/policies/sellrm.php',
- 'sell oil 20': 'http://blocgame.com/policies/selloil100.php',
- 'sell oil 5': 'http://blocgame.com/policies/selloil5.php',
- 'sell oil 1': 'http://blocgame.com/policies/selloil.php',
- 'sell food 20': 'http://blocgame.com/policies/sellfood100.php',
- 'sell food 5': 'http://blocgame.com/policies/sellfood5.php',
- 'sell food 1': 'http://blocgame.com/policies/sellfood.php',
- 'sell mg 20': 'http://blocgame.com/policies/sellmg100.php',
- 'sell mg 5': 'http://blocgame.com/policies/sellweapons5.php',
- 'sell mg 1': 'http://blocgame.com/policies/sellweapons.php',
- }
- headers = ['date', 'time', 'budget', 'Oil', 'RM', 'MG', 'food']
- def marketaction(pricelimit, br, stockpilelimit, mode, mg, tolerance, data, cswv):
- model = mode.split(' ')
- atype = model[1]
- resource = model[0]
- action = determineaction(data, mode, resource, atype, stockpilelimit)
- trigger20 = False
- trigger = False
- profit = 0
- price = data[mode]
- ref = data.copy() #initial reference for comparison
- #used for returning total units sold
- budget = data['budget']
- mgmoney = 0
- n = 0
- stockpiletype = resource + ' stockpile'
- if atype == 'buy':
- #price checker
- while int(n) < int(tolerance):
- if n == tolerance:
- break
- if int(price) > int(data[mode]): #if the price is falling, reset counter
- n = 0
- price = data[mode]
- elif int(price) == int(data[mode]): #if the price remains the same, increment
- n += 1
- elif int(price) < int(data[mode]): #if price is increasing, abort
- break
- time.sleep(1)
- data = priceupdate(br)
- #while the price is less than or equal to the set limit
- #and there is enough money in the budget to buy more
- while int(data[mode]) <= int(pricelimit):
- if int(data['budget']) < int(data[mode]) * 20 and trigger20 == False:
- if mg:
- trigger20 = sellmg(br, data, mg)
- data = priceupdate(br)
- elif int(data['budget']) >= int(data[mode]):
- action = determineaction(data, mode, resource, atype, stockpilelimit)
- trigger20 = True #enough money to buy 1, but not 20
- if int(data['budget']) < int(data[mode]) * 5 and trigger == False:
- if mg:
- response = sellmg(br, data, mg)
- trigger = response[1]
- mgmoney += int(data['mg sell']) * int(response[0])
- data = priceupdate(br)
- elif int(data['budget']) >= int(data[mode]):
- action = determineaction(data, mode, resource, atype, stockpilelimit)
- trigger = True #enough money to buy 1, but not 5
- if int(data['budget']) < int(data[mode]):
- print "ran out of money to buy %s" % resource
- break
- br.open(action) #buy resource
- old = data
- data = priceupdate(br) #update dataset
- print "bought %s %s at %s$ per" % (int(data[stockpiletype]) - int(old[stockpiletype]),
- resource, old[mode])
- else: #if not buy then sell
- while int(n) < int(tolerance):
- if n == tolerance:
- break
- if int(price) < int(data[mode]): #if the price is rising, reset counter
- n = 0
- price = data[mode]
- elif int(price) == int(data[mode]): #if the price remains the same, increment
- n += 1
- elif int(price) > int(data[mode]): #if price is falling, abort
- break
- time.sleep(1)
- data = priceupdate(br)
- while int(data[mode]) >= int(pricelimit):
- if int(data[stockpiletype]) < int(stockpilelimit) + 20 and trigger20 == False:
- action = determineaction(data, mode, resource, atype, stockpilelimit)
- trigger20 = True #means current stockpile is less than 20 more than set limit
- if int(data[stockpiletype]) < int(stockpilelimit) + 5 and trigger == False:
- action = determineaction(data, mode, resource, atype, stockpilelimit)
- trigger = True #means current stockpile is less than 5 more than set limit
- if int(data[stockpiletype]) <= int(stockpilelimit):
- print "%s stockpile has bottomed out at %s" % (resource, data[stockpiletype])
- break
- br.open(action)
- old = data
- data = priceupdate(br)
- profit += int(data[mode]) - int(old[mode])
- print "sold %s %s at %s$ per" % (int(old[stockpiletype]) - int(data[stockpiletype]),
- resource, old[mode])
- if csvw:
- write_data(br, False)
- #print status when it ends, easier than having 6 print statements in the main loop
- if atype == 'buy':
- if int(int(data[stockpiletype]) - int(ref[stockpiletype])) == 0:
- print "Price went back up"
- else:
- bought = int(mgmoney) + int(data['budget']) - int(budget)
- bought = int(bought) - int(bought) * 2
- print "Spent %s on %s %s" % (int(bought), int(data[stockpiletype]) - int(ref[stockpiletype]),
- resource)
- else:
- if int(int(data[stockpiletype]) - int(ref[stockpiletype])) == 0:
- print "Price went back down"
- else:
- print "Sold %s %s for %s" % (int(ref[stockpiletype]) - int(data[stockpiletype]),
- resource, int(data['budget']) - int(budget))
- return int(mgmoney) + int(data['budget']) - int(budget)
- def sellmg(br, data, stockpile):
- if int(stockpile) + 5 < int(data['mg stockpile']):
- br.open(links['sell mg 5'])
- print "Sold 5 MG"
- return [5, False]
- elif int(stockpile) < int(data['mg stockpile']):
- br.open(links['sell mg 1'])
- print "Sold 1 MG"
- return [1, False]
- else:
- return [0, True]
- #returning false means there is more MG to liquidize
- def buymg(br, budget, mgprice):
- if int(budget) > int(mgprice) * 20:
- br.open(links['buy mg 20'])
- print "Bought 20 MG for %s$ per" % mgprice
- return [20 * int(mgprice), 20]
- elif int(budget) > int(mgprice) * 5:
- br.open(links['buy mg 5'])
- print "Bought 5 MG for %s$ per" % mgprice
- return [5 * int(mgprice), 5]
- else:
- br.open(links['buy mg 1'])
- print "Bought 1 MG for %s$ per" % mgprice
- return [int(mgprice), 1]
- def determineaction(data, mode, resource, atype, stockpilelimit):
- if atype == "buy":
- if int(data['budget']) >= int(data[mode]) * 20:
- return links['buy ' + resource + ' 20']
- elif int(data['budget']) >= int(data[mode]) * 5:
- return links['buy ' + resource + ' 5']
- else:
- return links['buy ' + resource + ' 1']
- else:
- if int(data[resource + ' stockpile']) > int(stockpilelimit) + 20:
- return links['sell ' + resource + ' 20']
- elif int(data[resource + ' stockpile']) > int(stockpilelimit) + 5:
- return links['sell ' + resource + ' 5']
- else:
- return links['sell ' + resource + ' 1']
- def priceupdate(br, bdat=False):
- parser = pp()
- while True:
- a = br.open("http://blocgame.com/market.php")
- parser.feed(a.read())
- if parser.bdata:
- break
- else:
- return False
- if bdat:
- return parser.bdata
- else:
- return {'oil buy': parser.data[0], 'oil sell': parser.data[1],
- 'rm buy': parser.data[2], 'rm sell': parser.data[3], 'food buy': parser.data[4],
- 'food sell': parser.data[5], 'mg buy': parser.data[6], 'mg sell': parser.data[7],
- 'budget': parser.bdata[0], 'oil stockpile': parser.bdata[1], 'rm stockpile': parser.bdata[2],
- 'mg stockpile': parser.bdata[3], 'food stockpile': parser.bdata[4]}
- class pp(HTMLParser):
- def __init__(self):
- HTMLParser.__init__(self)
- self.recording = 0
- self.brecording = 0
- self.appendnext = False
- self.appendbnext = False
- self.cGDP = True
- self.GDP = 0
- self.GDPkillswitch = False
- self.data = []
- self.bdata = []
- def handle_starttag(self, tag, attributes):
- if tag == 'b':
- self.recording += 1
- if tag == 'a':
- self.appendbnext = True
- if tag == 'i':
- self.cGDP = True
- def handle_endtag(self, tag):
- if tag == 'a':
- self.appendnext = False
- def handle_data(self, data):
- #price parsing
- if self.recording:
- if data == "+$" or data == "-$" or data == " -$":
- self.appendnext = True
- return
- if self.appendnext:
- self.data.append(data)
- self.appendnext = False
- #stockpile parsing
- if self.appendbnext:
- for i in data:
- if i == 'e':
- self.appendbnext = False
- return
- a = (re.findall(r'\d+', data))
- if a:
- if int(self.brecording) < 6:
- if int(self.brecording) == 4: #filter out weapon stockpile
- self.brecording += 1
- else:
- self.bdata.append(a[0])
- self.brecording += 1
- self.appendbnext = False
- #GDP parsing
- if self.cGDP and not self.GDPkillswitch:
- for a in data.split(' '):
- if a == 'million':
- x = (re.findall(r'\d+', data))
- self.GDP = ''
- for p in x:
- self.GDP = self.GDP + str(p)
- self.GDPkillswitch = True
- def checkGDP(username, password):
- br = Browser()
- br.open("http://blocgame.com/")
- br.select_form(predicate=lambda f: f.attrs.get('action') == 'login.php')
- br["username"] = username
- br["password"] = password
- br.submit()
- parser = pp()
- a = br.open("http://blocgame.com/main.php")
- parser.feed(a.read())
- return parser.GDP
- #because profit tracking across sessions is nice
- #and windows doesn't do shared objects very well
- def profitdump(profit=0, mg=0, frun=False):
- if frun:
- if os.path.isfile('data.blob'):
- with open('data.blob', 'rb') as datafile:
- x = datafile.readline()
- if x:
- return x.split(' ')
- else:
- return [profit, mg]
- else: #if no profit data has been previously written, return 0
- return [profit, mg]
- else:
- with open('data.blob', 'wb') as datafile:
- datafile.write(str(profit) + ' ' + str(mg))
- def write_data(br, frun):
- data = priceupdate(br, True)
- fexist = os.path.isfile('trader.csv')
- with open('trader.csv', 'ab') as csvfile:
- csvwriter = csv.writer(csvfile)
- if frun and not fexist: #write headers to new file for sake of convenience
- csvwriter.writerow(headers)
- var = []
- tmp = (str(datetime.now()).split('.')[0]) #strip the miliseconds off the timestamp
- var += tmp.split(' ')
- var = var + data
- csvwriter.writerow(var)
- #really should've made a dictionary
- def dump_preferences(username, password, oilbuy, oilsell, rmbuy, rmsell, rmstop, oilstop,
- foodbuy, foodsell, foodstop, mgbool, allowmgbuy, tolerance, interval):
- print "saving preferences"
- with open('prefs.filenamextensionorFNEforshort', 'w') as prefile:
- x = [username, password, oilbuy, oilsell, rmbuy, rmsell, rmstop, oilstop,
- foodbuy, foodsell, foodstop, mgbool, allowmgbuy, tolerance, interval]
- json.dump(x, prefile)
- def read_preferences():
- with open('prefs.filenamextensionorFNEforshort', 'r') as prefile:
- return json.load(prefile)
- def display_preferences(oilbuy, oilsell, rmbuy, rmsell, rmstop, oilstop,
- foodbuy, foodsell, foodstop, mgbool, allowmgbuy, tolerance, interval, username, password):
- gdp = int(checkGDP(username, password)) * 2
- print "Oil buy price is %s" % oilbuy
- print "Oil sell price is %s" % oilsell
- print "Oil stockpile limit is %s" % oilstop
- print "RM buy price is %s" % rmbuy
- print "RM sell price is %s" % rmsell
- print "RM stockpile limit is %s" % rmstop
- print "Food buy price is %s" % foodbuy
- print "Food sell price is %s" % foodsell
- print "Food stockpile limit is %s" % foodstop
- if mgbool:
- print "Selling MG is allowed"
- else:
- print "Selling MG is not allowed"
- if allowmgbuy:
- if allowmgbuy == 'default':
- print "Buying MG is allowed, with budget limit being %s" % gdp
- else:
- print "Buying MG is allowed, with budget limit being %s" % allowmgbuy
- else:
- print "Buying MG not allowed"
- print "Price watching time is %s" % tolerance
- if int(interval) > 0:
- print "Blocmarket gets queried for new prices every %s seconds" % interval
- else:
- print "Blocmarket gets queried constantly for new prices"
- #primary event loop
- def proloop(csvw, br, oilbuy, oilsell, oilstop, rmbuy, rmsell, rmstop,
- foodbuy, foodsell, foodstop, mgsell, allowmgbuy, tolerance, interval):
- tpvar = profitdump(frun=True)
- profit = int(tpvar[0])
- try:
- mg = int(tpvar[1])
- except:
- mg = 0
- if allowmgbuy == "default":
- GDP = int(checkGDP(username, password)) * 2
- elif allowmgbuy:
- GDP = int(allowmgbuy)
- if csvw:
- write_data(br, True)
- while True:
- data = priceupdate(br)
- if not data:
- print "something happened, restarting"
- return
- if int(data['oil buy']) <= int(oilbuy) and int(data['budget']) >= int(data['oil buy']):
- print "buying oil"
- temp = marketaction(oilbuy, br, 0, 'oil buy', mgsell, tolerance, data, cswv)
- profit += int(temp)
- profitdump(profit)
- elif int(data['oil sell']) >= int(oilsell) and int(data['oil stockpile']) > int(oilstop):
- print "selling oil"
- temp = marketaction(oilsell, br, oilstop, 'oil sell', mgsell, tolerance, data, csvw)
- profit += int(temp)
- profitdump(profit)
- elif int(data['rm buy']) <= int(rmbuy) and int(data['budget']) >= int(data['rm buy']):
- print "buying RM"
- temp = marketaction(rmbuy, br, 0, 'rm buy', mgsell, tolerance, data, csvw)
- profit += int(temp)
- profitdump(profit)
- elif int(data['rm sell']) >= int(rmsell) and int(data['rm stockpile']) > int(rmstop):
- print "selling RM"
- temp = marketaction(rmsell, br, rmstop, 'rm sell', mgsell, tolerance, data, csvw)
- profit += int(temp)
- profitdump(profit)
- elif int(data['food buy']) <= int(foodbuy) and int(data['budget']) >= int(data['food buy']):
- print "buying food"
- temp = marketaction(foodbuy, br, 0, 'food buy', mgsell, tolerance, data, csvw)
- profit += int(temp)
- profitdump(profit)
- elif int(data['food sell']) >= int(foodsell) and int(data['food stockpile']) >= int(foodstop):
- print "selling food"
- temp = marketaction(foodsell, br, foodstop, 'food sell', mgsell, tolerance, data, csvw)
- profit += int(temp)
- profitdump(profit)
- else:
- print "waiting"
- print "profit so far: %s, MG bought so far: %s" % (profit, mg)
- if int(interval) > 0:
- time.sleep(int(interval))
- if allowmgbuy and int(data['budget']) > int(GDP):
- while allowmgbuy and int(data['budget']) > int(GDP):
- temp = buymg(br, int(data['budget']) - int(GDP), int(data['mg buy']))
- profit -= int(temp[0])
- mg += int(temp[1])
- profitdump(profit=profit, mg=mg)
- data = priceupdate(br)
- if csvw:
- write_data(br, False)
- #necessary to make it run properly on windows
- def run(username, password, csvw, oilbuy, oilsell, rmbuy, rmsell, rmstop, oilstop,
- foodbuy, foodsell, foodstop, mgsell, allowmgbuy, tolerance, interval):
- while True:
- br = Browser()
- br.open("http://blocgame.com/")
- br.select_form(predicate=lambda f: f.attrs.get('action') == 'login.php')
- br["username"] = username
- br["password"] = password
- br.submit()
- proloop(csvw, br, oilbuy, oilsell, oilstop, rmbuy, rmsell, rmstop,
- foodbuy, foodsell, foodstop, mgsell, allowmgbuy, tolerance, interval)
- print "something went from, time is %s, retrying in 20 minutes" % str(datetime.now()).split(' ')[1].split('.')[0]
- time.sleep(1200)
- if __name__ == '__main__':
- freeze_support()
- fexist = os.path.isfile('prefs.filenamextensionorFNEforshort')
- choice = ''
- userchoice = ''
- if fexist:
- print "Load preferences from file? (y/n)"
- while True:
- choice = raw_input(">: ")
- if choice == 'n':
- choice = True
- elif choice == 'y':
- choice = False
- else:
- print "fyi y is short for yes and n is short for no"
- print "so literally just type y and press enter if you want to load your preferences"
- print "or n if you don't"
- continue
- break
- if choice:
- print "Load username and password? (y/n)"
- while True:
- userchoice = raw_input(">: ")
- if userchoice == 'y':
- userchoice = True
- elif userchoice == 'n':
- userchoice = False
- else:
- print "fyi y is short for yes and n is short for no"
- print "so literally just type y and press enter if you don't want to enter name and pass"
- print "or n if you don't"
- continue
- break
- if not fexist or choice:
- if userchoice:
- print "loading username and password"
- content = read_preferences()
- username = content[0]
- password = content[1]
- else:
- username = raw_input("Username: ")
- password = raw_input("Password: ")
- while True:
- oilbuy = input("Oil buy price: ")
- oilsell = input("Oil sell price: ")
- rmbuy = input("RM buy price: ")
- rmsell = input("RM sell price: ")
- foodbuy = input("Food buy price: ")
- foodsell = input("Food sell price: ")
- rmstop = input("Minimum RM stockpile: ")
- oilstop = input("Minimum oil stockpile: ")
- foodstop = input("Minimum food stockpile: ")
- if int(oilsell) < int(oilbuy) or int(rmsell) < int(rmbuy) or int(foodsell) < int(foodbuy):
- print "One or more are incorrect\ntry again stupid\n"
- print "protip: buy values are supposed to be lower than sell values"
- continue
- break
- print "Allow selling of MG if budget gets depleted while buying? (y/n)"
- while True:
- mgbool = raw_input(">: ")
- if mgbool == 'y':
- mgbool = True
- break
- elif mgbool == 'n':
- mgbool = False
- break
- else:
- print "It's a simple matter of typing y or n, try again retard"
- if mgbool:
- while True:
- try:
- mgbool = input("Minimum mg stockpile: ")
- except NameError:
- continue
- break
- print "Allow buying of MG if budget goes above set budget limit? (y/n)"
- while True:
- allowmgbuy = raw_input(">: ")
- if allowmgbuy == 'y':
- break
- elif allowmgbuy == 'n':
- allowmgbuy = False
- break
- else:
- print "It's a simple matter of typing y or n, try again retard"
- if allowmgbuy == 'y':
- print "Should budget limit be set to 2x GDP? (y/n)"
- while True:
- allowmgbuy = raw_input(">: ")
- if allomgbuy == 'y':
- allowmgbuy = "default"
- elif allowmgbuy == 'n':
- print "Enter desired budget limit"
- while True:
- try:
- allowmgbuy = input(">: ")
- except:
- print "Enter a number numbnuts"
- continue
- if int(allowmgbuy) > 0:
- break
- else:
- print "The number needs to be more than 0, try again"
- else:
- print "invalid input, try again"
- print "Specify tolerance in seconds for price observation after target price has been reached"
- print "eg how many seconds price should remains same after before buying/selling"
- print "0 means don't observe just sell when target has been reached"
- while True:
- try:
- tolerance = input(">: ")
- except NameError:
- print "Enter a number dipshit"
- continue
- break
- print "Enter time in seconds between market queries (default is 10)"
- print "while 0 is valid, it isn't advised as bloc might shit itself"
- print "but do what you want bruh"
- while True:
- try:
- interval = input(">: ")
- except NameError:
- print "Enter a number dipshit"
- continue
- break
- dump_preferences(username, password, oilbuy, oilsell, rmbuy, rmsell, rmstop, oilstop,
- foodbuy, foodsell, foodstop, mgbool, allowmgbuy, tolerance, interval)
- else:
- try:
- print "loading everything"
- content = read_preferences()
- username = content[0]
- password = content[1]
- oilbuy = content[2]
- oilsell = content[3]
- rmbuy = content[4]
- rmsell = content[5]
- rmstop = content[6]
- oilstop = content[7]
- foodbuy = content[8]
- foodsell = content[9]
- foodstop = content[10]
- mgbool = content[11]
- allowmgbuy = content[12]
- tolerance = content[13]
- interval = content[14]
- print "done"
- except:
- print "something went wrong with loading from file"
- print "delete and put in new data"
- print "ripip in"
- n = 5
- for x in range(5):
- print n
- n -= 1
- time.sleep(1)
- exit("ripipipip")
- print "save data to csv file? (y/n)"
- while True:
- csvw = raw_input(">: ")
- if csvw == 'y':
- csvw = True
- elif csvw == 'n':
- csvw = False
- else:
- print "Invalid choice, try again (it's literally just y or n)"
- continue
- break
- stupid = True
- while True:
- print "Starting marketbot, type stop to change the prices and stockpile limits"
- p = Process(target=run, args=(username, password, csvw, oilbuy, oilsell, rmbuy, rmsell,
- rmstop, oilstop, foodbuy, foodsell, foodstop, mgbool, allowmgbuy, tolerance, interval))
- p.start()
- while True:
- x = raw_input()
- if x == 'stop':
- p.terminate()
- break
- else:
- continue
- print "The current preferences are\n"
- display_preferences(oilbuy, oilsell, rmbuy, rmsell, rmstop, oilstop,
- foodbuy, foodsell, foodstop, mgbool, allowmgbuy, tolerance, interval, username, password)
- print "\n\n\nTo change stockpile limits type stockpile"
- print "To change RM price limits type rm"
- print "To change oil price limits type oil"
- print "To change food price limits type food"
- print "To change MG buy/sell permissions type mg"
- print "To change market query and price watch intervals type time"
- print "To change budget limitations, type budget"
- print "If you want to reset the profit and/or the MG counter, type reset profit/mg/both"
- print "Or to change everything type all"
- print "If you've changed your mind and want to continue, type nevermind"
- while True:
- x = raw_input(">: ")
- if x == "nevermind":
- pass
- elif x == 'stockpile':
- if mgbool:
- mgbool = input("Minimum mg stockpile: ")
- rmstop = input("Minimum RM stockpile: ")
- oilstop = input("Minimum oil stockpile: ")
- foodstop = input("Minimum food stockpile: ")
- elif x == 'rm':
- rmbuy = input("RM buy price: ")
- rmsell = input("RM sell price: ")
- elif x == 'oil':
- oilbuy = input("Oil buy price: ")
- oilsell = input("Oil sell price: ")
- elif x == 'food':
- foodbuy = input("Food buy price: ")
- foodsell = input("Food sell price: ")
- elif x == 'mg':
- print "Allow selling of MG if budget gets depleted while buying? (y/n)"
- while True:
- mgbool = raw_input(">: ")
- if mgbool == 'y':
- mgbool = True
- break
- elif mgbool == 'n':
- mgbool = False
- break
- else:
- print "It's a simple matter of typing y or n, try again retard"
- print "Allow buying of MG if budget goes above set limit? (y/n)"
- while True:
- old = allowmgbuy
- allowmgbuy = raw_input(">: ")
- if allowmgbuy == 'y':
- print "Set new limit? (y/n)"
- while True:
- allowmgbuy = raw_input(">: ")
- if allowmgbuy == 'n':
- allowmgbuy = old
- break
- elif allowmgbuy == 'y':
- print "Set limit to 2x GDP? (y/n)"
- while True:
- allowmgbuy = raw_input(">: ")
- if allowmgbuy == 'y':
- allowmgbuy = "default"
- break
- elif allowmgbuy == 'n':
- print "Enter desired budget limit"
- while True:
- try:
- allowmgbuy = input(">: ")
- except:
- print "Enter a number numbnuts"
- continue
- if int(allowmgbuy) > 0:
- break
- else:
- print "The number needs to be more than 0, try again"
- else:
- print "invalid input"
- continue
- break
- else:
- print "invalid input"
- continue
- break
- break
- elif allowmgbuy == 'n':
- allowmgbuy = False
- break
- else:
- print "It's a simple matter of typing y or n, try again retard"
- elif x == 'time':
- print "Specify tolerance in seconds for price observation"
- while True:
- try:
- tolerance = input(">: ")
- except NameError:
- print "Enter a number dipshit"
- continue
- break
- print "Enter time in seconds between market queries (default is 10)"
- while True:
- try:
- interval = input(">: ")
- except NameError:
- print "Enter a number dipshit"
- continue
- break
- elif x == 'budget':
- print "Allow buying of MG if budget goes above set budget limit? (y/n)"
- while True:
- allowmgbuy = raw_input(">: ")
- if allowmgbuy == 'n':
- allowmgbuy = False
- break
- elif allowmgbuy == 'y':
- print "Should budget limit be set to 2x GDP? (y/n)"
- while True:
- allowmgbuy = raw_input(">: ")
- if allowmgbuy == 'y':
- allowmgbuy = "default"
- elif allowmgbuy == 'n':
- print "Enter desired budget limit"
- while True:
- try:
- allowmgbuy = input(">: ")
- except:
- print "Enter a number numbnuts"
- continue
- if int(allowmgbuy) > 0:
- break
- else:
- print "The number needs to be more than 0, try again"
- else:
- print "invalid input, try again"
- continue
- break
- else:
- print "It's a simple matter of typing y or n, try again retard"
- continue
- break
- elif x == 'all':
- oilbuy = input("Oil buy price: ")
- oilsell = input("Oil sell price: ")
- rmbuy = input("RM buy price: ")
- rmsell = input("RM sell price: ")
- foodbuy = input("Food buy price: ")
- foodsell = input("Food sell price: ")
- if mgbool:
- mgbool = input("Minimum mg stockpile: ")
- rmstop = input("Minimum RM stockpile: ")
- oilstop = input("Minimum oil stockpile: ")
- foodstop = input("Minimum food stockpile: ")
- print "Allow selling of MG if budget gets depleted while buying? (y/n)"
- while True:
- mgbool = raw_input(">: ")
- if mgbool == 'y':
- mgbool = True
- break
- elif mgbool == 'n':
- mgbool = False
- break
- else:
- print "It's a simple matter of typing y or n, try again retard"
- print "Allow buying of MG if budget goes above set budget limit? (y/n)"
- while True:
- allowmgbuy = raw_input(">: ")
- if allowmgbuy == 'y':
- break
- elif allowmgbuy == 'n':
- allowmgbuy = False
- break
- else:
- print "It's a simple matter of typing y or n, try again retard"
- if allowmgbuy == 'y':
- print "Should budget limit be set to 2x GDP? (y/n)"
- while True:
- allowmgbuy = raw_input(">: ")
- if allowmgbuy == 'y':
- allowmgbuy = "default"
- break
- elif allowmgbuy == 'n':
- print "Enter desired budget limit"
- while True:
- try:
- allowmgbuy = input(">: ")
- except:
- print "Enter a number numbnuts"
- continue
- if int(allowmgbuy) > 0:
- break
- else:
- print "The number needs to be more than 0, try again"
- else:
- print "invalid input"
- continue
- break
- print "Specify tolerance in seconds for price observation"
- while True:
- try:
- tolerance = input(">: ")
- except NameError:
- print "Enter a number dipshit"
- continue
- break
- print "Enter time in seconds between market queries (default is 10)"
- while True:
- try:
- interval = input(">: ")
- except NameError:
- print "Enter a number dipshit"
- continue
- break
- elif x.split(' ')[0] == 'reset':
- if x == 'reset mg':
- tp = profitdump(frun=True) #get profit data
- profitdump(profit=tp[0]) #resetting mg
- elif x == 'reset profit':
- tp = profitdump(frun=True) #get profit data
- profitdump(profit=tp[1]) #resetting profit
- elif x == 'reset both':
- profitdump()
- else:
- print "bad input dumbass, try again"
- continue
- else:
- print "bad input dumbass, try again"
- continue
- dump_preferences(username, password, oilbuy, oilsell, rmbuy, rmsell, rmstop, oilstop,
- foodbuy, foodsell, foodstop, mgbool, allowmgbuy, tolerance, interval)
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement