message history for dm
This commit is contained in:
@@ -88,7 +88,7 @@ def cmd_history(args):
|
||||
data["messages"] = args[1]
|
||||
if len(args) > 2:
|
||||
data["before"] = args[2]
|
||||
r = requests.post(f"{BASE_URL}/messages", data=data)
|
||||
r = requests.post(f"{BASE_URL}/get/connection/messages", data=data)
|
||||
if r.ok:
|
||||
msgs = r.json() or []
|
||||
if not msgs:
|
||||
@@ -102,18 +102,29 @@ def cmd_connections(args):
|
||||
if not token:
|
||||
print("not logged in")
|
||||
return
|
||||
r = post("/connections", token=token)
|
||||
r = post("/get/connections", token=token)
|
||||
if r.ok:
|
||||
for c in (r.json() or {}).values():
|
||||
print(f" {c['id']} requestor={c['requestorId']} recipient={c['recipientId']} state={c['state']}")
|
||||
else:
|
||||
print(f"error: {r.text}")
|
||||
|
||||
def cmd_delconnection(args):
|
||||
if not token:
|
||||
print("not logged in")
|
||||
return
|
||||
if not args:
|
||||
print("usage: /delconnection <connectionid>")
|
||||
return
|
||||
r = post("/del/connection", token=token, connectionid=args[0])
|
||||
print("deleted" if r.ok else f"error: {r.text}")
|
||||
|
||||
COMMANDS = {
|
||||
"/login": cmd_login,
|
||||
"/send": cmd_send,
|
||||
"/history": cmd_history,
|
||||
"/connections": cmd_connections,
|
||||
"/login": cmd_login,
|
||||
"/send": cmd_send,
|
||||
"/history": cmd_history,
|
||||
"/connections": cmd_connections,
|
||||
"/delconnection": cmd_delconnection,
|
||||
}
|
||||
|
||||
HELP = """
|
||||
@@ -121,6 +132,7 @@ HELP = """
|
||||
/connections – list your connections
|
||||
/send <connectionid> <message…> – send a DM
|
||||
/history <connectionid> [count] [before] – fetch message history
|
||||
/delconnection <connectionid> – delete a connection
|
||||
"""
|
||||
|
||||
# ── websocket ─────────────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user