|
|
|
@ -77,10 +77,17 @@ def main(): |
|
|
|
|
|
|
|
|
|
database_session.initialize(config) |
|
|
|
|
|
|
|
|
|
def handle_disconnect(join_game_packet): |
|
|
|
|
print('Disconnected.') |
|
|
|
|
nonlocal connection |
|
|
|
|
connection.disconnect(immediate=True) |
|
|
|
|
time.sleep(5) |
|
|
|
|
print('Reconnecting.') |
|
|
|
|
if options.offline: |
|
|
|
|
print("Connecting in offline mode...") |
|
|
|
|
connection = Connection( |
|
|
|
|
options.address, options.port, username=options.username) |
|
|
|
|
options.address, options.port, username=options.username, |
|
|
|
|
handle_exception=handle_disconnect) |
|
|
|
|
else: |
|
|
|
|
auth_token = authentication.AuthenticationToken() |
|
|
|
|
try: |
|
|
|
@ -90,21 +97,16 @@ def main(): |
|
|
|
|
sys.exit() |
|
|
|
|
print("Logged in as %s..." % auth_token.username) |
|
|
|
|
connection = Connection( |
|
|
|
|
options.address, options.port, auth_token=auth_token) |
|
|
|
|
|
|
|
|
|
#Initialize the discord part |
|
|
|
|
discord_bot = discord.Client() |
|
|
|
|
options.address, options.port, auth_token=auth_token, |
|
|
|
|
handle_exception=handle_disconnect) |
|
|
|
|
register_handlers(connection) |
|
|
|
|
connection.connect() |
|
|
|
|
|
|
|
|
|
def handle_disconnect(join_game_packet): |
|
|
|
|
print('Disconnected.') |
|
|
|
|
nonlocal connection |
|
|
|
|
connection.disconnect(immediate=True) |
|
|
|
|
time.sleep(5) |
|
|
|
|
print('Reconnecting.') |
|
|
|
|
if options.offline: |
|
|
|
|
print("Connecting in offline mode...") |
|
|
|
|
connection = Connection( |
|
|
|
|
options.address, options.port, username=options.username) |
|
|
|
|
options.address, options.port, username=options.username, |
|
|
|
|
handle_exception=handle_disconnect) |
|
|
|
|
else: |
|
|
|
|
auth_token = authentication.AuthenticationToken() |
|
|
|
|
try: |
|
|
|
@ -114,9 +116,11 @@ def main(): |
|
|
|
|
sys.exit() |
|
|
|
|
print("Logged in as %s..." % auth_token.username) |
|
|
|
|
connection = Connection( |
|
|
|
|
options.address, options.port, auth_token=auth_token) |
|
|
|
|
register_handlers(connection) |
|
|
|
|
connection.connect() |
|
|
|
|
options.address, options.port, auth_token=auth_token, |
|
|
|
|
handle_exception=handle_disconnect) |
|
|
|
|
|
|
|
|
|
#Initialize the discord part |
|
|
|
|
discord_bot = discord.Client() |
|
|
|
|
|
|
|
|
|
def register_handlers(connection): |
|
|
|
|
connection.register_packet_listener( |
|
|
|
|