Rewritten examples respectively (see the prev. commit)
This commit is contained in:
parent
55ce48819e
commit
29866f0446
7 changed files with 38 additions and 11 deletions
|
@ -6,7 +6,10 @@ from python_aternos import Client, atwss
|
||||||
user = input('Username: ')
|
user = input('Username: ')
|
||||||
pswd = getpass('Password: ')
|
pswd = getpass('Password: ')
|
||||||
resp = input('Show responses? ').upper() == 'Y'
|
resp = input('Show responses? ').upper() == 'Y'
|
||||||
aternos = Client.from_credentials(user, pswd)
|
|
||||||
|
atclient = Client()
|
||||||
|
aternos = atclient.account
|
||||||
|
atclient.login(user, pswd)
|
||||||
|
|
||||||
s = aternos.list_servers()[0]
|
s = aternos.list_servers()[0]
|
||||||
socket = s.wss()
|
socket = s.wss()
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
from getpass import getpass
|
from getpass import getpass
|
||||||
|
from typing import Optional
|
||||||
from python_aternos import Client
|
from python_aternos import Client
|
||||||
|
from python_aternos.atfile import AternosFile
|
||||||
|
|
||||||
user = input('Username: ')
|
user = input('Username: ')
|
||||||
pswd = getpass('Password: ')
|
pswd = getpass('Password: ')
|
||||||
aternos = Client.from_credentials(user, pswd)
|
|
||||||
|
atclient = Client()
|
||||||
|
aternos = atclient.account
|
||||||
|
atclient.login(user, pswd)
|
||||||
|
|
||||||
s = aternos.list_servers()[0]
|
s = aternos.list_servers()[0]
|
||||||
files = s.files()
|
files = s.files()
|
||||||
|
@ -34,6 +39,11 @@ while True:
|
||||||
print('\t' + file.name)
|
print('\t' + file.name)
|
||||||
|
|
||||||
if cmd == 'world':
|
if cmd == 'world':
|
||||||
file = files.get_file('/world')
|
file_w = files.get_file('/world')
|
||||||
|
|
||||||
|
if file_w is None:
|
||||||
|
print('Cannot create /world directory object')
|
||||||
|
continue
|
||||||
|
|
||||||
with open('world.zip', 'wb') as f:
|
with open('world.zip', 'wb') as f:
|
||||||
f.write(file.get_content())
|
f.write(file_w.get_content())
|
||||||
|
|
|
@ -3,9 +3,13 @@ from python_aternos import Client, atserver
|
||||||
|
|
||||||
user = input('Username: ')
|
user = input('Username: ')
|
||||||
pswd = getpass('Password: ')
|
pswd = getpass('Password: ')
|
||||||
aternos = Client.from_credentials(user, pswd)
|
|
||||||
|
atclient = Client()
|
||||||
|
aternos = atclient.account
|
||||||
|
atclient.login(user, pswd)
|
||||||
|
|
||||||
srvs = aternos.list_servers()
|
srvs = aternos.list_servers()
|
||||||
|
|
||||||
for srv in srvs:
|
for srv in srvs:
|
||||||
print('***', srv.domain, '***')
|
print('***', srv.domain, '***')
|
||||||
print(srv.motd)
|
print(srv.motd)
|
||||||
|
|
|
@ -3,7 +3,10 @@ from python_aternos import Client
|
||||||
|
|
||||||
user = input('Username: ')
|
user = input('Username: ')
|
||||||
pswd = getpass('Password: ')
|
pswd = getpass('Password: ')
|
||||||
aternos = Client.from_credentials(user, pswd)
|
|
||||||
|
atclient = Client()
|
||||||
|
aternos = atclient.account
|
||||||
|
atclient.login(user, pswd)
|
||||||
|
|
||||||
srvs = aternos.list_servers()
|
srvs = aternos.list_servers()
|
||||||
print(srvs)
|
print(srvs)
|
||||||
|
|
|
@ -16,14 +16,16 @@ if logs:
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
# Authentication
|
# Authentication
|
||||||
aternos = Client.from_credentials(user, pswd)
|
atclient = Client()
|
||||||
|
aternos = atclient.account
|
||||||
|
atclient.login(user, pswd)
|
||||||
|
|
||||||
server = aternos.list_servers()[0]
|
server = aternos.list_servers()[0]
|
||||||
socket = server.wss()
|
socket = server.wss()
|
||||||
|
|
||||||
|
|
||||||
# Handler for console messages
|
# Handler for console messages
|
||||||
@socket.wssreceiver(Streams.console, ('Server 1',))
|
@socket.wssreceiver(Streams.console, ('Server 1',)) # type: ignore
|
||||||
async def console(
|
async def console(
|
||||||
msg: Dict[Any, Any],
|
msg: Dict[Any, Any],
|
||||||
args: Tuple[str]) -> None:
|
args: Tuple[str]) -> None:
|
||||||
|
|
|
@ -4,7 +4,10 @@ from python_aternos import Client, atwss
|
||||||
|
|
||||||
user = input('Username: ')
|
user = input('Username: ')
|
||||||
pswd = getpass('Password: ')
|
pswd = getpass('Password: ')
|
||||||
aternos = Client.from_credentials(user, pswd)
|
|
||||||
|
atclient = Client()
|
||||||
|
aternos = atclient.account
|
||||||
|
atclient.login(user, pswd)
|
||||||
|
|
||||||
s = aternos.list_servers()[0]
|
s = aternos.list_servers()[0]
|
||||||
socket = s.wss()
|
socket = s.wss()
|
||||||
|
|
|
@ -16,14 +16,16 @@ if logs:
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
# Authentication
|
# Authentication
|
||||||
aternos = Client.from_credentials(user, pswd)
|
atclient = Client()
|
||||||
|
aternos = atclient.account
|
||||||
|
atclient.login(user, pswd)
|
||||||
|
|
||||||
server = aternos.list_servers()[0]
|
server = aternos.list_servers()[0]
|
||||||
socket = server.wss()
|
socket = server.wss()
|
||||||
|
|
||||||
|
|
||||||
# Handler for server status
|
# Handler for server status
|
||||||
@socket.wssreceiver(Streams.status, ('Server 1',))
|
@socket.wssreceiver(Streams.status, ('Server 1',)) # type: ignore
|
||||||
async def state(
|
async def state(
|
||||||
msg: Dict[Any, Any],
|
msg: Dict[Any, Any],
|
||||||
args: Tuple[str]) -> None:
|
args: Tuple[str]) -> None:
|
||||||
|
|
Reference in a new issue