message_entity.go 1.7 KB

12345678910111213141516171819202122232425262728293031
  1. package telegram
  2. type MessageEntityType string
  3. const (
  4. Mention = "mention" // “mention” (@username)
  5. Hashtag = "hashtag" // “hashtag” (#hashtag)
  6. CashTag = "cashtag" // “cashtag” ($USD)
  7. BotCommand = "bot_command" // “bot_command” (/start@jobs_bot)
  8. URL = "url" // “url” (https://telegram.org)
  9. Email = "email" // “email” (do-not-reply@telegram.org)
  10. PhoneNumber = "phone_number" // “phone_number” (+1-212-555-0123)
  11. Bold = "bold" // “bold” (bold text)
  12. Italic = "italic" // “italic” (italic text)
  13. Underline = "underline" // “underline” (underlined text)
  14. Strikethrough = "strikethrough" // “strikethrough” (strikethrough text)
  15. Code = "code" // “code” (monowidth string)
  16. Pre = "pre" // “pre” (monowidth block)
  17. TextLink = "text_link" // “text_link” (for clickable text URLs)
  18. TextMention = "text_mention" // “text_mention” (for users without usernames)
  19. )
  20. // MessageEntity represents one special entity in a text message.
  21. type MessageEntity struct {
  22. Type MessageEntityType `json:"type"` // Type of the entity.
  23. Offset int `json:"offset"` // Offset in UTF-16 code units to the start of the entity
  24. Length int `json:"length"`
  25. URL string `json:"url"` // URL for “text_link” only, url that will be opened after user taps on the text
  26. User *User `json:"user"` // User for “text_mention” only, the mentioned user
  27. Language string `json:"language"` // Language for “pre” only, the programming language of the entity text
  28. }