main: set trust mode to always

Otherwise bot would have to trust every user manually
This commit is contained in:
lemoer 2024-12-29 02:05:17 +01:00
parent 5d2d4ff560
commit 062b493367

14
main.py
View File

@ -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()