Better handling of client start locations

This commit is contained in:
Salad Dais
2023-12-19 04:24:17 +00:00
parent 7fafb8b5ae
commit 61820f1670
3 changed files with 18 additions and 6 deletions

View File

@@ -26,7 +26,7 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: | run: |
python -m pip install --upgrade pip python -m pip install --upgrade pip wheel
pip install -r requirements.txt pip install -r requirements.txt
pip install -r requirements-test.txt pip install -r requirements-test.txt
sudo apt-get install libopenjp2-7 sudo apt-get install libopenjp2-7

View File

@@ -27,7 +27,7 @@ async def amain():
await client.login( await client.login(
username=os.environ["HIPPO_USERNAME"], username=os.environ["HIPPO_USERNAME"],
password=os.environ["HIPPO_PASSWORD"], password=os.environ["HIPPO_PASSWORD"],
start_location=os.environ.get("HIPPO_START_LOCATION", "home"), start_location=os.environ.get("HIPPO_START_LOCATION", "last"),
) )
print("I'm here") print("I'm here")
await client.send_chat("Hello World!", chat_type=ChatType.SHOUT) await client.send_chat("Hello World!", chat_type=ChatType.SHOUT)

View File

@@ -12,7 +12,7 @@ from typing import *
import aiohttp import aiohttp
import multidict import multidict
from hippolyzer.lib.base.datatypes import Vector3 from hippolyzer.lib.base.datatypes import Vector3, StringEnum
from hippolyzer.lib.base.helpers import proxify, get_resource_filename from hippolyzer.lib.base.helpers import proxify, get_resource_filename
from hippolyzer.lib.base.message.circuit import Circuit from hippolyzer.lib.base.message.circuit import Circuit
from hippolyzer.lib.base.message.llsd_msg_serializer import LLSDMessageSerializer from hippolyzer.lib.base.message.llsd_msg_serializer import LLSDMessageSerializer
@@ -35,6 +35,11 @@ from hippolyzer.lib.client.state import BaseClientSession, BaseClientRegion, Bas
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class StartLocation(StringEnum):
LAST = "last"
HOME = "home"
class ClientSettings(Settings): class ClientSettings(Settings):
# Off by default for now, the cert validation is a big mess due to LL using an internal CA. # Off by default for now, the cert validation is a big mess due to LL using an internal CA.
SSL_VERIFY: bool = SettingDescriptor(False) SSL_VERIFY: bool = SettingDescriptor(False)
@@ -568,9 +573,9 @@ class HippoClient(BaseClientSessionManager):
self, self,
username: str, username: str,
password: str, password: str,
login_uri: Optional[str] = "", login_uri: Optional[str] = None,
agree_to_tos: bool = False, agree_to_tos: bool = False,
start_location: str = "home" start_location: Union[StartLocation, str, None] = StartLocation.LAST
): ):
if self.session: if self.session:
raise RuntimeError("Already logged in!") raise RuntimeError("Already logged in!")
@@ -578,6 +583,13 @@ class HippoClient(BaseClientSessionManager):
if not login_uri: if not login_uri:
login_uri = self.DEFAULT_LOGIN_URI login_uri = self.DEFAULT_LOGIN_URI
if start_location is None:
start_location = StartLocation.LAST
# This isn't a symbolic start location and isn't a URI, must be a sim name.
if start_location not in iter(StartLocation) and not start_location.startswith("uri:"):
start_location = f"uri:{start_location}&128&128&128"
split_username = username.split(" ") split_username = username.split(" ")
if len(split_username) < 2: if len(split_username) < 2:
first_name = split_username[0] first_name = split_username[0]
@@ -603,7 +615,7 @@ class HippoClient(BaseClientSessionManager):
# TODO: What is this? # TODO: What is this?
"platform_version": "2.38.0", "platform_version": "2.38.0",
"read_critical": 0, "read_critical": 0,
"start": start_location, "start": str(start_location),
"token": "", "token": "",
"version": version("hippolyzer"), "version": version("hippolyzer"),
"options": list(self._options), "options": list(self._options),