33 lines
775 B
Python
33 lines
775 B
Python
|
#!/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)
|
||
|
|