add list_signal_groups.py
This commit is contained in:
parent
e6b8a0445c
commit
4974f97f6b
32
list_signal_groups.py
Normal file
32
list_signal_groups.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from main import config, SignalAPI
|
||||||
|
from result import is_err
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
api = SignalAPI(config.apiurl, config.number)
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(description='List all groups')
|
||||||
|
parser.add_argument('-i', "--show-group-ids", action='store_true', help='show group ids')
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
groups_result = api.get_groups()
|
||||||
|
|
||||||
|
if is_err(groups_result):
|
||||||
|
print("Error: " + groups_result.unwrap_err())
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
groups = groups_result.unwrap()
|
||||||
|
|
||||||
|
for group in groups:
|
||||||
|
suffix = ""
|
||||||
|
if api.number in group.admins:
|
||||||
|
suffix = " (admin)"
|
||||||
|
|
||||||
|
print(group.name + suffix)
|
||||||
|
|
||||||
|
if args.show_group_ids:
|
||||||
|
print(" id: " + group.id)
|
||||||
|
|
10
main.py
10
main.py
@ -526,13 +526,13 @@ async def main(config: Config, session: Session):
|
|||||||
bot.sync_members_and_tasks(session)
|
bot.sync_members_and_tasks(session)
|
||||||
)
|
)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
with open("config.json", "r") as f:
|
||||||
|
|
||||||
with open("config.json", "r") as f:
|
|
||||||
config = Config.model_validate(json.load(f))
|
config = Config.model_validate(json.load(f))
|
||||||
|
|
||||||
engine = create_engine("sqlite:///data.db")
|
engine = create_engine("sqlite:///data.db")
|
||||||
SQLModel.metadata.create_all(engine)
|
SQLModel.metadata.create_all(engine)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
asyncio.run(main(config, session))
|
asyncio.run(main(config, session))
|
||||||
|
Loading…
Reference in New Issue
Block a user