feat: sending audio messages (#55)

Co-authored-by: Andrei Smirnov <andrei.smirnov@toptal.com>
This commit is contained in:
Andrei Smirnov 2021-09-29 00:10:22 +03:00 committed by GitHub
parent 5285cf7d8c
commit 4a5094644f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -350,6 +350,10 @@ proc editMessage*(self: ChatModel, messageId: string, msg: string) =
var response = status_chat.editMessage(messageId, msg)
discard self.processMessageUpdateAfterSend(response)
proc sendAudio*(self: ChatModel, chatId: string, audioBase64: string, durationMs: uint64) =
var response = status_chat.sendAudioMessage(chatId, audioBase64, durationMs)
discard self.processMessageUpdateAfterSend(response)
proc sendImage*(self: ChatModel, chatId: string, image: string) =
var response = status_chat.sendImageMessage(chatId, image)
discard self.processMessageUpdateAfterSend(response)

View File

@ -127,6 +127,19 @@ proc sendChatMessage*(chatId: string, msg: string, replyTo: string, contentType:
}
])
proc sendAudioMessage*(chatId: string, audioBase64: string, durationMs: uint64): string =
let preferredUsername = getSetting[string](Setting.PreferredUsername, "")
callPrivateRPC("sendChatMessage".prefix, %* [
{
"chatId": chatId,
"contentType": ContentType.Audio.int,
"base64Audio": audioBase64,
"audioDurationMs": durationMs,
"ensName": preferredUsername,
"text": "Update to latest version to hear this audio!"
}
])
proc sendImageMessage*(chatId: string, image: string): string =
let preferredUsername = getSetting[string](Setting.PreferredUsername, "")
callPrivateRPC("sendChatMessage".prefix, %* [