pull/265/merge
Artem 6 years ago committed by GitHub
commit 6861137cd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      bot.go
  2. 2
      go.mod
  3. 15
      types.go

@ -307,6 +307,20 @@ func (bot *BotAPI) Send(c Chattable) (Message, error) {
return message, err
}
// helper to get raw params
func (bot *BotAPI) PreviewParams(c Chattable) (map[string]string, error) {
paramsMap := make(map[string]string)
params, err := c.params()
if params == nil {
return paramsMap, err
}
for key, value := range params {
paramsMap[key] = value
}
return paramsMap, nil
}
// SendMediaGroup sends a media group and returns the resulting messages.
func (bot *BotAPI) SendMediaGroup(config MediaGroupConfig) ([]Message, error) {
params, _ := config.params()

@ -1,3 +1,3 @@
module github.com/go-telegram-bot-api/telegram-bot-api/v5
module github.com/temamagic/telegram-bot-api
require github.com/technoweenie/multipartstreamer v1.0.1

@ -7,6 +7,7 @@ import (
"net/url"
"strings"
"time"
"unicode/utf16"
)
// APIResponse is a response from the Telegram API with the result
@ -270,6 +271,20 @@ func (entity MessageEntity) ParseURL() (*url.URL, error) {
return url.Parse(entity.URL)
}
// GetEntityText attempts to get entity text value from utf16.
func (m *Message) GetEntityText(entity MessageEntity) string {
if m.Text == "" {
return ""
}
// Encode it into utf16
utfEncodedString := utf16.Encode([]rune(m.Text))
runeString := utf16.Decode(utfEncodedString[entity.Offset : entity.Offset+entity.Length])
// Transform []rune into string
str := string(runeString)
return str
}
// PhotoSize contains information about photos.
type PhotoSize struct {
FileID string `json:"file_id"`