LabCleaningBot: add assert_is_base_group_admin()
This commit is contained in:
parent
7d3137dc61
commit
8292edb3b6
14
main.py
14
main.py
@ -442,6 +442,7 @@ If due to any reason you can not participate, please just change your "👍" rea
|
|||||||
unfulfillable_tasks = []
|
unfulfillable_tasks = []
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
self.assert_is_base_group_admin()
|
||||||
|
|
||||||
sync_result = self.sync_members_as_active_users(session)
|
sync_result = self.sync_members_as_active_users(session)
|
||||||
|
|
||||||
@ -498,11 +499,24 @@ You have time to answer for {format_seconds(task.timeout)}."""
|
|||||||
|
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
|
def assert_is_base_group_admin(self):
|
||||||
|
group_info_result = self.api.get_group(self.base_group)
|
||||||
|
|
||||||
|
if is_err(group_info_result):
|
||||||
|
print("Error, could not get info about base_group " + self.base_group + ": " + group_info_result.unwrap_err())
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
group_info = group_info_result.unwrap()
|
||||||
|
if config.number not in group_info.admins:
|
||||||
|
print("Error: Bot is not an admin of the base group.")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
async def main(config: Config, session: Session):
|
async def main(config: Config, session: Session):
|
||||||
api = SignalAPI(config.apiurl, config.number)
|
api = SignalAPI(config.apiurl, config.number)
|
||||||
|
|
||||||
bot = LabCleaningBot(api, config.lab_cleaning_signal_base_group)
|
bot = LabCleaningBot(api, config.lab_cleaning_signal_base_group)
|
||||||
|
bot.assert_is_base_group_admin()
|
||||||
|
|
||||||
await asyncio.gather(
|
await asyncio.gather(
|
||||||
bot.receiver(session),
|
bot.receiver(session),
|
||||||
|
Loading…
Reference in New Issue
Block a user