25
SatiAPI.py
25
SatiAPI.py
@@ -16,7 +16,7 @@ urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||
class SatiAPI:
|
||||
"""A API wrapper for Satisfactory dedicated server"""
|
||||
__AUTHOR__ = 'anima'
|
||||
__VERSION__ = '0.8.6'
|
||||
__VERSION__ = '0.9.0'
|
||||
|
||||
def __init__(self, host: str = None, port: int = 7777, token: str = None, conffile: str = 'conf.yml', logfile: str = 'SatiAPI.log', loglevel: int = 20) -> None:
|
||||
"""create a wrapper for satisfactory dedicated server
|
||||
@@ -283,6 +283,26 @@ class SatiAPI:
|
||||
response = self.__query('SetAdminPassword', data, True)
|
||||
return self._save_token(response)
|
||||
|
||||
def set_client_password(self, password: str = None):
|
||||
"""Updates the currently set Client Protection Password. This will invalidate all previously issued Client authentication tokens. Pass empty string to remove the password, and let anyone join the server as Client. Requres Admin privileges. Function does not return any data on success.
|
||||
|
||||
:param password: the new passwort to set will be read from config file it not set
|
||||
:type password: string
|
||||
:return: true if new password successfull set
|
||||
:rtype: bool
|
||||
"""
|
||||
if password is None:
|
||||
password = self._get_config_password('Client')
|
||||
|
||||
if password is None:
|
||||
self._log.error('can not set new client password because no passwort is set')
|
||||
return False
|
||||
|
||||
data = dict()
|
||||
data['Password'] = password
|
||||
response = self.__query('SetClientPassword', data, True)
|
||||
return True
|
||||
|
||||
def get_token(self, password: str = None, privilegeLevel: str = 'Administrator') -> bool:
|
||||
"""get token from satisfacory dedicated server, password is needed!
|
||||
Attempts to log in to the Dedicated Server as a player using either Admin Password or Client Protection Password. This function requires no Authentication.
|
||||
@@ -374,4 +394,5 @@ if __name__ == "__main__":
|
||||
sati = SatiAPI(loglevel=10)
|
||||
# print('Verbundene Spieler: ', sati.get_status()['serverGameState']['numConnectedPlayers'])
|
||||
print(sati.get_status())
|
||||
print(sati.token)
|
||||
print(sati.token)
|
||||
print(sati.set_client_password())
|
||||
Reference in New Issue
Block a user