13 lines
467 B
Nim
13 lines
467 B
Nim
|
import json
|
||
|
import ../types/[message, chat]
|
||
|
|
||
|
proc formatChatUpdate*(response: JsonNode): (seq[Chat], seq[Message]) =
|
||
|
var chats: seq[Chat] = @[]
|
||
|
var messages: seq[Message] = @[]
|
||
|
if response["result"]{"messages"} != nil:
|
||
|
for jsonMsg in response["result"]["messages"]:
|
||
|
messages.add(jsonMsg.toMessage())
|
||
|
if response["result"]{"chats"} != nil:
|
||
|
for jsonChat in response["result"]["chats"]:
|
||
|
chats.add(jsonChat.toChat)
|
||
|
result = (chats, messages)
|