From 285215b0f6072c7f53de654b6b8b36ad733fdf2c Mon Sep 17 00:00:00 2001 From: Midgard Date: Wed, 2 Jun 2021 11:13:00 +0200 Subject: [PATCH] =?UTF-8?q?[W=C3=8FP]=20Add=20lschan?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mmcli.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/mmcli.py b/mmcli.py index bdc5857..b58bf50 100755 --- a/mmcli.py +++ b/mmcli.py @@ -167,6 +167,21 @@ def login(mm_api, parsed): assert False +def lschan(mm_api: mattermost.MMApi, parsed): + teams = {} + + for team in mm_api.get_teams(): + teams[team["id"]] = team + teams[team["id"]]["joined"] = False + + for team in mm_api._get(f"/v4/users/me/teams"): + teams[team["id"]] = team + teams[team["id"]]["joined"] = True + + mm_api.get_team_channels() + mm_api.get_channels_for_user("me") + + def cat(mm_api: mattermost.MMApi, parsed): # channels = [ @@ -286,6 +301,7 @@ def str_for_post(attribute, post, parsed): ACTIONS = { + "lschan": {"function": lschan}, "login": {"function": login, "accesstoken_required": False}, "cat": {"function": cat}, "send": {"function": send}, @@ -332,6 +348,9 @@ Hint: JSON output can be filtered on the command line with jq(1). parser_login.add_argument("--password", default=os.getenv(ENVVAR_PASSWORD)) parser_login.add_argument("--totp", default=os.getenv(ENVVAR_TOTP)) + parser_cat = subparsers.add_parser("lschan", help="list channels") + parser_cat.add_argument("-f", "--follow", action="store_true", help="keep running, printing changes to channels as they come in") + # TODO support multiple channels # parser_cat = subparsers.add_parser("cat", help="list messages in channel(s)") # parser_cat.add_argument(