Add listcustomemoji
This commit is contained in:
parent
ea433a93c8
commit
6225ace7e3
1 changed files with 28 additions and 0 deletions
|
@ -434,6 +434,31 @@ def removereaction(mm_api: mattermost.MMApi, cmdline_args):
|
||||||
mm_api._delete(f"/v4/users/me/posts/{cmdline_args.msgid}/reactions/{cmdline_args.emoji_name}")
|
mm_api._delete(f"/v4/users/me/posts/{cmdline_args.msgid}/reactions/{cmdline_args.emoji_name}")
|
||||||
|
|
||||||
|
|
||||||
|
def str_for_emoji(emoji, cmdline_args):
|
||||||
|
obj = {
|
||||||
|
k: v
|
||||||
|
for k, v in emoji.items()
|
||||||
|
if (v or k == "name") and (k != "update_at" or emoji["update_at"] != emoji["create_at"])
|
||||||
|
}
|
||||||
|
|
||||||
|
if cmdline_args.format == "json":
|
||||||
|
return json.dumps(emoji)
|
||||||
|
if cmdline_args.format == "tsv":
|
||||||
|
name = tsv_escape(emoji.get("name", ""))
|
||||||
|
return f"{emoji['id']}\t{name}"
|
||||||
|
|
||||||
|
def listcustomemoji(mm_api: mattermost.MMApi, cmdline_args):
|
||||||
|
page = 0
|
||||||
|
per_page = 200 # Maximum allowed in API
|
||||||
|
response = []
|
||||||
|
while page == 0 or response:
|
||||||
|
response = mm_api._get(f"/v4/emoji?page={page}&per_page={per_page}&sort=name")
|
||||||
|
for emoji in response:
|
||||||
|
print(str_for_emoji(emoji, cmdline_args))
|
||||||
|
page += 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def status(mm_api: mattermost.MMApi, cmdline_args):
|
def status(mm_api: mattermost.MMApi, cmdline_args):
|
||||||
if not cmdline_args.status:
|
if not cmdline_args.status:
|
||||||
raise ValueError("No status selected")
|
raise ValueError("No status selected")
|
||||||
|
@ -521,6 +546,7 @@ ACTIONS = {
|
||||||
"edit": {"function": edit},
|
"edit": {"function": edit},
|
||||||
"addreaction": {"function": addreaction},
|
"addreaction": {"function": addreaction},
|
||||||
"removereaction": {"function": removereaction},
|
"removereaction": {"function": removereaction},
|
||||||
|
"listcustomemoji": {"function": listcustomemoji},
|
||||||
"status": {"function": status},
|
"status": {"function": status},
|
||||||
"customstatus": {"function": customstatus},
|
"customstatus": {"function": customstatus},
|
||||||
"lastread": {"function": lastread},
|
"lastread": {"function": lastread},
|
||||||
|
@ -632,6 +658,8 @@ The input format accepted on stdin is one JSON object per line. The possible fie
|
||||||
parser_removereaction.add_argument("msgid", help="ID of message")
|
parser_removereaction.add_argument("msgid", help="ID of message")
|
||||||
parser_removereaction.add_argument("emoji_name", help="name of the emoji to remove (without colons)")
|
parser_removereaction.add_argument("emoji_name", help="name of the emoji to remove (without colons)")
|
||||||
|
|
||||||
|
parser_listcustomemoji = subparsers.add_parser("listcustomemoji", help="list all custom emoji on the server")
|
||||||
|
|
||||||
parser_status = subparsers.add_parser("status", help="update user status")
|
parser_status = subparsers.add_parser("status", help="update user status")
|
||||||
parser_status.add_argument("--online", dest="status", action="store_const", const="online", help="Set status to online")
|
parser_status.add_argument("--online", dest="status", action="store_const", const="online", help="Set status to online")
|
||||||
parser_status.add_argument("--away", dest="status", action="store_const", const="away", help="Set status to away")
|
parser_status.add_argument("--away", dest="status", action="store_const", const="away", help="Set status to away")
|
||||||
|
|
Loading…
Reference in a new issue