|
@@ -39,7 +39,7 @@ def login(username=None, password=None):
|
|
print('Login failed.')
|
|
print('Login failed.')
|
|
|
|
|
|
|
|
|
|
-def register(username=None, game_key='', password=None, retype_password=None):
|
|
|
|
|
|
+def register(username=None, game_key='', password=None, retype_pw=None):
|
|
if connection.session_id is not None:
|
|
if connection.session_id is not None:
|
|
connection.session_id = None
|
|
connection.session_id = None
|
|
fake_loading_bar('Signing out', duration=0.7)
|
|
fake_loading_bar('Signing out', duration=0.7)
|
|
@@ -50,19 +50,19 @@ def register(username=None, game_key='', password=None, retype_password=None):
|
|
if password is None:
|
|
if password is None:
|
|
if sys.stdin.isatty():
|
|
if sys.stdin.isatty():
|
|
password = getpass('New password: ')
|
|
password = getpass('New password: ')
|
|
- retype_password = getpass('Retype password: ')
|
|
|
|
|
|
+ retype_pw = getpass('Retype password: ')
|
|
else:
|
|
else:
|
|
password = input('New password: ')
|
|
password = input('New password: ')
|
|
- retype_password = input('Retype password: ')
|
|
|
|
- if password != retype_password:
|
|
|
|
|
|
+ retype_pw = input('Retype password: ')
|
|
|
|
+ if password != retype_pw:
|
|
print('Passwords do not match.')
|
|
print('Passwords do not match.')
|
|
return
|
|
return
|
|
- elif retype_password is None:
|
|
|
|
|
|
+ elif retype_pw is None:
|
|
if sys.stdin.isatty():
|
|
if sys.stdin.isatty():
|
|
- retype_password = getpass('Retype password: ')
|
|
|
|
|
|
+ retype_pw = getpass('Retype password: ')
|
|
else:
|
|
else:
|
|
- retype_password = input('Retype password: ')
|
|
|
|
- if password != retype_password:
|
|
|
|
|
|
+ retype_pw = input('Retype password: ')
|
|
|
|
+ if password != retype_pw:
|
|
print('Passwords do not match.')
|
|
print('Passwords do not match.')
|
|
return
|
|
return
|
|
|
|
|
|
@@ -91,25 +91,25 @@ def cancel_order(order_no=None):
|
|
print('Order cancelling failed with message:', response['error_message'])
|
|
print('Order cancelling failed with message:', response['error_message'])
|
|
|
|
|
|
|
|
|
|
-def change_password(password=None, retype_password=None):
|
|
|
|
- if password != retype_password:
|
|
|
|
|
|
+def change_password(password=None, retype_pw=None):
|
|
|
|
+ if password != retype_pw:
|
|
password = None
|
|
password = None
|
|
if password is None:
|
|
if password is None:
|
|
if sys.stdin.isatty():
|
|
if sys.stdin.isatty():
|
|
password = getpass('New password: ')
|
|
password = getpass('New password: ')
|
|
- retype_password = getpass('Retype password: ')
|
|
|
|
|
|
+ retype_pw = getpass('Retype password: ')
|
|
else:
|
|
else:
|
|
password = input('New password: ')
|
|
password = input('New password: ')
|
|
- retype_password = input('Retype password: ')
|
|
|
|
- if password != retype_password:
|
|
|
|
|
|
+ retype_pw = input('Retype password: ')
|
|
|
|
+ if password != retype_pw:
|
|
print('Passwords do not match.')
|
|
print('Passwords do not match.')
|
|
return
|
|
return
|
|
- elif retype_password is None:
|
|
|
|
|
|
+ elif retype_pw is None:
|
|
if sys.stdin.isatty():
|
|
if sys.stdin.isatty():
|
|
- retype_password = getpass('Retype password: ')
|
|
|
|
|
|
+ retype_pw = getpass('Retype password: ')
|
|
else:
|
|
else:
|
|
- retype_password = input('Retype password: ')
|
|
|
|
- if password != retype_password:
|
|
|
|
|
|
+ retype_pw = input('Retype password: ')
|
|
|
|
+ if password != retype_pw:
|
|
print('Passwords do not match.')
|
|
print('Passwords do not match.')
|
|
return
|
|
return
|
|
|
|
|
|
@@ -136,11 +136,11 @@ def help():
|
|
command_table.append([cmd] + [p for p in params])
|
|
command_table.append([cmd] + [p for p in params])
|
|
|
|
|
|
print(_my_tabulate(command_table,tablefmt='pipe',headers=['command',
|
|
print(_my_tabulate(command_table,tablefmt='pipe',headers=['command',
|
|
- 'parameter 1',
|
|
|
|
- 'parameter 2',
|
|
|
|
- 'parameter 3',
|
|
|
|
- 'parameter 4',
|
|
|
|
- 'parameter 5',
|
|
|
|
|
|
+ 'param 1',
|
|
|
|
+ 'param 2',
|
|
|
|
+ 'param 3',
|
|
|
|
+ 'param 4',
|
|
|
|
+ 'param 5',
|
|
]))
|
|
]))
|
|
print('NOTE:')
|
|
print('NOTE:')
|
|
print(' All parameters for all commands are optional!')
|
|
print(' All parameters for all commands are optional!')
|
|
@@ -210,7 +210,7 @@ def yn_dialog(msg):
|
|
return False
|
|
return False
|
|
|
|
|
|
|
|
|
|
-def buy(amount=None, object_name=None, limit='', stop_loss='', time_until_expiration=None):
|
|
|
|
|
|
+def buy(object_name=None, amount=None, limit='', stop_loss='', expiry=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 buy: ')
|
|
object_name = input('Name of object to buy: ')
|
|
if amount is None:
|
|
if amount is None:
|
|
@@ -226,10 +226,10 @@ def buy(amount=None, object_name=None, limit='', stop_loss='', time_until_expira
|
|
if limit is not None and stop_loss == '':
|
|
if limit is not None and stop_loss == '':
|
|
stop_loss = yn_dialog('Is this a stop-loss limit?')
|
|
stop_loss = yn_dialog('Is this a stop-loss limit?')
|
|
|
|
|
|
- if time_until_expiration is None:
|
|
|
|
- time_until_expiration = input('Time until order expires (minutes, default 43200):')
|
|
|
|
- if time_until_expiration == '':
|
|
|
|
- time_until_expiration = 43200
|
|
|
|
|
|
+ if expiry is None:
|
|
|
|
+ expiry = input('Time until order expires (minutes, default 43200):')
|
|
|
|
+ if expiry == '':
|
|
|
|
+ expiry = 43200
|
|
fake_loading_bar('Loading Data', duration=1.3)
|
|
fake_loading_bar('Loading Data', duration=1.3)
|
|
response = client_request('order', {"buy": True,
|
|
response = client_request('order', {"buy": True,
|
|
"session_id": connection.session_id,
|
|
"session_id": connection.session_id,
|
|
@@ -237,7 +237,7 @@ def buy(amount=None, object_name=None, limit='', stop_loss='', time_until_expira
|
|
"ownable": object_name,
|
|
"ownable": object_name,
|
|
"limit": limit,
|
|
"limit": limit,
|
|
"stop_loss": stop_loss,
|
|
"stop_loss": stop_loss,
|
|
- "time_until_expiration": time_until_expiration})
|
|
|
|
|
|
+ "time_until_expiration": expiry})
|
|
if 'error_message' in response:
|
|
if 'error_message' in response:
|
|
print('Order placement failed with message:', response['error_message'])
|
|
print('Order placement failed with message:', response['error_message'])
|
|
else:
|
|
else:
|
|
@@ -245,7 +245,7 @@ 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(object_name=None, amount=None, limit='', stop_loss='', expiry=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:
|
|
@@ -261,10 +261,10 @@ def sell(amount=None, object_name=None, limit='', stop_loss='', time_until_expir
|
|
if limit != '' and stop_loss == '':
|
|
if limit != '' and stop_loss == '':
|
|
stop_loss = yn_dialog('Is this a stop-loss limit?')
|
|
stop_loss = yn_dialog('Is this a stop-loss limit?')
|
|
|
|
|
|
- if time_until_expiration is None:
|
|
|
|
- time_until_expiration = input('Time until order expires (minutes, default 43200):')
|
|
|
|
- if time_until_expiration == '':
|
|
|
|
- time_until_expiration = 43200
|
|
|
|
|
|
+ if expiry is None:
|
|
|
|
+ expiry = input('Time until order expires (minutes, default 43200):')
|
|
|
|
+ if expiry == '':
|
|
|
|
+ expiry = 43200
|
|
fake_loading_bar('Loading Data', duration=1.3)
|
|
fake_loading_bar('Loading Data', duration=1.3)
|
|
response = client_request('order', {"buy": False,
|
|
response = client_request('order', {"buy": False,
|
|
"session_id": connection.session_id,
|
|
"session_id": connection.session_id,
|
|
@@ -272,7 +272,7 @@ def sell(amount=None, object_name=None, limit='', stop_loss='', time_until_expir
|
|
"ownable": object_name,
|
|
"ownable": object_name,
|
|
"limit": limit,
|
|
"limit": limit,
|
|
"stop_loss": stop_loss,
|
|
"stop_loss": stop_loss,
|
|
- "time_until_expiration": time_until_expiration})
|
|
|
|
|
|
+ "time_until_expiration": expiry})
|
|
if 'error_message' in response:
|
|
if 'error_message' in response:
|
|
print('Order placement failed with message:', response['error_message'])
|
|
print('Order placement failed with message:', response['error_message'])
|
|
else:
|
|
else:
|
|
@@ -312,7 +312,7 @@ def orders_on(object_name=None):
|
|
print('Order access failed.')
|
|
print('Order access failed.')
|
|
|
|
|
|
|
|
|
|
-def gift(username=None, amount=None, object_name=None):
|
|
|
|
|
|
+def gift(username=None, object_name=None, amount=None):
|
|
if username is None:
|
|
if username is None:
|
|
username = input('Username of recipient: ')
|
|
username = input('Username of recipient: ')
|
|
if object_name is None:
|
|
if object_name is None:
|