]> git.giacomolli.uk - onechat/blobdiff - botapi_test.go
Send the Telegram replies as rich messages
[onechat] / botapi_test.go
index 9dfbcad8a11d2734bb2b2ba16ea47ce5c633c846..fb57b45b468116c0687419123eedd7421c5fd738 100644 (file)
@@ -322,12 +322,17 @@ func (f *fakeBot) Calls() []fakeBotCall {
        return append([]fakeBotCall(nil), f.calls...)
 }
 
-// Sent returns the texts of the sendMessage calls that succeeded.
+// Sent returns the texts of the sendMessage calls and the Markdown of the
+// sendRichMessage calls that succeeded, in order.
 func (f *fakeBot) Sent() []string {
        var texts []string
        for _, call := range f.Calls() {
-               if call.method == "sendMessage" && call.ok {
+               switch {
+               case !call.ok:
+               case call.method == "sendMessage":
                        texts = append(texts, call.params["text"].(string))
+               case call.method == "sendRichMessage":
+                       texts = append(texts, call.params["rich_message"].(map[string]any)["markdown"].(string))
                }
        }