X-Git-Url: http://git.giacomolli.uk/onechat/blobdiff_plain/fc51ee2f545233df3cc1fa2fd4f28a4484c6bc00..f80b058ae0550a56b4e62f8e65c2a74349b970e4:/botapi.go?ds=inline diff --git a/botapi.go b/botapi.go index 57bf9db..f48465c 100644 --- a/botapi.go +++ b/botapi.go @@ -130,16 +130,23 @@ func (b *botAPI) GetUpdates(ctx context.Context, offset int64) ([]botUpdate, err return updates, err } -// SendMessage sends text to chat as plain text, with no parse mode. A call that -// takes longer than sendTimeout fails with errBotNetwork. -func (b *botAPI) SendMessage(ctx context.Context, chat int64, text string) error { +// SendMessage sends text to chat with the format of entities, with no parse +// mode, so the text needs no escaping. With no entities, the text is plain. A +// call that takes longer than sendTimeout fails with errBotNetwork. +func (b *botAPI) SendMessage(ctx context.Context, chat int64, text string, entities []botEntity) error { ctx, cancel := context.WithTimeout(ctx, b.sendTimeout) defer cancel() - return b.call(ctx, "sendMessage", map[string]any{ + params := map[string]any{ "chat_id": chat, "text": text, - }, nil) + } + + if len(entities) > 0 { + params["entities"] = entities + } + + return b.call(ctx, "sendMessage", params, nil) } // SendTyping shows the typing action in chat for about five seconds. A call