[WÏP] Add lschan

This commit is contained in:
Midgard 2021-06-02 11:13:00 +02:00
parent d8f1538d68
commit 285215b0f6
Signed by: midgard
GPG key ID: 511C112F1331BBB4

View file

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