Skip to content

Commit

Permalink
Updated some headars and ported the types over to python
Browse files Browse the repository at this point in the history
  • Loading branch information
p0t4t0sandwich committed Sep 18, 2023
1 parent 3527205 commit 969e898
Show file tree
Hide file tree
Showing 14 changed files with 797 additions and 17 deletions.
13 changes: 6 additions & 7 deletions ampapi/ampapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,12 @@ async def api_call_async(self, endpoint: str, data: dict = {}) -> dict:
:rtype: dict
"""
# Check the last API call time, and if it's been more than the relog interval, relog.
if round(time.time()) - self.lastAPICall > self.relogInterval:
self.lastAPICall = round(time.time())
now: int = round(time.time())
if now - self.lastAPICall > self.relogInterval:
self.lastAPICall = now
self.Login()
else:
self.lastAPICall = round(time.time())
self.lastAPICall = now
session = {"SESSIONID": self.sessionId}

data_added = dict(session, **data)
Expand All @@ -105,15 +106,14 @@ def Login(self) -> dict:
"""
data: dict = {
"username": self.username,
"password": "",
"token": self.rememberMeToken,
"rememberMe": True,
}

# If remember me token is empty, use the password.
if self.rememberMeToken == "":
data["password"] = self.password
else:
data["password"] = ""

loginResult: dict = self.api_call("Core/Login", data)

Expand All @@ -130,15 +130,14 @@ async def LoginAsync(self) -> dict:
"""
data: dict = {
"username": self.username,
"password": "",
"token": self.rememberMeToken,
"rememberMe": True,
}

# If remember me token is empty, use the password.
if self.rememberMeToken == "":
data["password"] = self.password
else:
data["password"] = ""

loginResult: dict = await self.api_call_async("Core/Login", data)

Expand Down
2 changes: 1 addition & 1 deletion ampapi/apimodules/ADSModule.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/python3
# author: p0t4t0sandich
# description: A Python library for the AMP API
# description: An API that allows you to communicate with AMP installations from within Python

from typing import Any
from ampapi.ampapi import AMPAPI
Expand Down
2 changes: 1 addition & 1 deletion ampapi/apimodules/Core.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/python3
# author: p0t4t0sandich
# description: A Python library for the AMP API
# description: An API that allows you to communicate with AMP installations from within Python

from typing import Any
from ampapi.ampapi import AMPAPI
Expand Down
2 changes: 1 addition & 1 deletion ampapi/apimodules/EmailSenderPlugin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/python3
# author: p0t4t0sandich
# description: A Python library for the AMP API
# description: An API that allows you to communicate with AMP installations from within Python

from typing import Any
from ampapi.ampapi import AMPAPI
Expand Down
2 changes: 1 addition & 1 deletion ampapi/apimodules/FileManagerPlugin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/python3
# author: p0t4t0sandich
# description: A Python library for the AMP API
# description: An API that allows you to communicate with AMP installations from within Python

from typing import Any
from ampapi.ampapi import AMPAPI
Expand Down
2 changes: 1 addition & 1 deletion ampapi/apimodules/LocalFileBackupPlugin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/python3
# author: p0t4t0sandich
# description: A Python library for the AMP API
# description: An API that allows you to communicate with AMP installations from within Python

from typing import Any
from ampapi.ampapi import AMPAPI
Expand Down
2 changes: 1 addition & 1 deletion ampapi/apimodules/MinecraftModule.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/python3
# author: p0t4t0sandich
# description: A Python library for the AMP API
# description: An API that allows you to communicate with AMP installations from within Python

from typing import Any
from ampapi.ampapi import AMPAPI
Expand Down
2 changes: 1 addition & 1 deletion ampapi/apimodules/RCONPlugin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/python3
# author: p0t4t0sandich
# description: A Python library for the AMP API
# description: An API that allows you to communicate with AMP installations from within Python

from typing import Any
from ampapi.ampapi import AMPAPI
Expand Down
2 changes: 1 addition & 1 deletion ampapi/apimodules/steamcmdplugin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/python3
# author: p0t4t0sandich
# description: A Python library for the AMP API
# description: An API that allows you to communicate with AMP installations from within Python

from typing import Any
from ampapi.ampapi import AMPAPI
Expand Down
Loading

0 comments on commit 969e898

Please sign in to comment.