|
@@ -46,7 +46,7 @@ def register(username=None, password=None, game_key=''):
|
|
|
|
|
|
if password is None:
|
|
if password is None:
|
|
if sys.stdin.isatty():
|
|
if sys.stdin.isatty():
|
|
- password = getpass.getpass('Password: ')
|
|
|
|
|
|
+ password = getpass('Password: ')
|
|
else:
|
|
else:
|
|
password = input('Password: ')
|
|
password = input('Password: ')
|
|
|
|
|
|
@@ -61,6 +61,16 @@ def register(username=None, password=None, game_key=''):
|
|
print('Registration failed with message:', response['error_message'])
|
|
print('Registration failed with message:', response['error_message'])
|
|
|
|
|
|
|
|
|
|
|
|
+def cancel_order(order_no=None):
|
|
|
|
+ if order_no is None:
|
|
|
|
+ order_no = input('Order No.: ')
|
|
|
|
+
|
|
|
|
+ response = client_request('cancel_order', {"session_id": connection.session_id, "order_id": order_no})
|
|
|
|
+
|
|
|
|
+ if 'error_message' in response:
|
|
|
|
+ print('Order cancelling failed with message:', response['error_message'])
|
|
|
|
+
|
|
|
|
+
|
|
# noinspection PyShadowingBuiltins
|
|
# noinspection PyShadowingBuiltins
|
|
def help():
|
|
def help():
|
|
print('Allowed commands:')
|
|
print('Allowed commands:')
|
|
@@ -75,8 +85,11 @@ def help():
|
|
print(' -', p)
|
|
print(' -', p)
|
|
else:
|
|
else:
|
|
print('`' + cmd + '`', 'takes no arguments')
|
|
print('`' + cmd + '`', 'takes no arguments')
|
|
|
|
+ print()
|
|
|
|
|
|
- print('NOTE: All arguments are optional!')
|
|
|
|
|
|
+ print('NOTE:')
|
|
|
|
+ print(' Commands can be combined in one line with ; between them.')
|
|
|
|
+ print(' All arguments for all commands are optional!')
|
|
|
|
|
|
|
|
|
|
def depot():
|
|
def depot():
|
|
@@ -91,6 +104,18 @@ def depot():
|
|
print('Depot access failed.')
|
|
print('Depot access failed.')
|
|
|
|
|
|
|
|
|
|
|
|
+def leaderboard():
|
|
|
|
+ response = client_request('leaderboard', {"session_id": connection.session_id})
|
|
|
|
+ success = 'data' in response
|
|
|
|
+ if success:
|
|
|
|
+ print(tabulate(response['data'], headers=['User', 'Score'], tablefmt="pipe"))
|
|
|
|
+ else:
|
|
|
|
+ if 'error_message' in response:
|
|
|
|
+ print('Leaderboard access failed with message:', response['error_message'])
|
|
|
|
+ else:
|
|
|
|
+ print('Leaderboard access failed.')
|
|
|
|
+
|
|
|
|
+
|
|
def activate_key(key=''):
|
|
def activate_key(key=''):
|
|
if key == '':
|
|
if key == '':
|
|
print('Entering a game key may get you some money or other useful stuff.')
|
|
print('Entering a game key may get you some money or other useful stuff.')
|
|
@@ -144,19 +169,21 @@ def buy(amount=None, object_name=None, limit='', stop_loss='', time_until_expira
|
|
'to see if the order has been executed already.')
|
|
'to see if the order has been executed already.')
|
|
|
|
|
|
|
|
|
|
-def sell(amount=None, object_name=None, limit='', stop_loss='', time_until_expiration=None):
|
|
|
|
|
|
+def sell(amount=None, object_name=None, limit=None, stop_loss=None, time_until_expiration=None):
|
|
if object_name is None: # TODO list some available objects
|
|
if object_name is None: # TODO list some available objects
|
|
object_name = input('Name of object to sell: ')
|
|
object_name = input('Name of object to sell: ')
|
|
if amount is None:
|
|
if amount is None:
|
|
amount = input('Amount: ')
|
|
amount = input('Amount: ')
|
|
- if limit == '':
|
|
|
|
|
|
+ if limit is None:
|
|
set_limit = yn_dialog('Do you want to place a limit?')
|
|
set_limit = yn_dialog('Do you want to place a limit?')
|
|
if set_limit:
|
|
if set_limit:
|
|
limit = input('Limit: ')
|
|
limit = input('Limit: ')
|
|
- stop_loss = yn_dialog('Is this a stop-loss limit?')
|
|
|
|
else:
|
|
else:
|
|
limit = None
|
|
limit = None
|
|
stop_loss = None
|
|
stop_loss = None
|
|
|
|
+ if limit is not None:
|
|
|
|
+ stop_loss = yn_dialog('Is this a stop-loss limit?')
|
|
|
|
+
|
|
if time_until_expiration is None:
|
|
if time_until_expiration is None:
|
|
time_until_expiration = input('Time until order expires (minutes, default 60):')
|
|
time_until_expiration = input('Time until order expires (minutes, default 60):')
|
|
if time_until_expiration == '':
|
|
if time_until_expiration == '':
|