diff --git a/main.py b/main.py index 1963294..867c87e 100644 --- a/main.py +++ b/main.py @@ -62,6 +62,15 @@ class SignalAPI: self.apiurl = apiurl self.number = number + def set_trust_mode_to_always(self) -> Result[None, str]: + # /v1/configuration/{number}/settings + r = requests.post(f"{self.apiurl}/v1/configuration/{self.number}/settings", json={"trust_mode": "always"}) + + if r.status_code == 204: + return Ok(None) + else: + return Err(r.json()['error']) + def set_username(self, username) -> Result[UsernameSetResponse, str]: # post request to set username # /v1/accounts/{number}/username @@ -532,6 +541,11 @@ You have time to answer for {format_seconds(task.timeout)}.""" async def main(config: Config, session: Session): api = SignalAPI(config.apiurl, config.number) + set_trust_mode_result = api.set_trust_mode_to_always() + if is_err(set_trust_mode_result): + print("Error while setting trust mode to always: " + set_trust_mode_result.unwrap_err()) + exit(1) + bot = LabCleaningBot(api, config.lab_cleaning_signal_base_group) bot.assert_is_base_group_admin()