chat.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package initdata
  2. const (
  3. ChatTypeSender ChatType = "sender"
  4. ChatTypePrivate ChatType = "private"
  5. ChatTypeGroup ChatType = "group"
  6. ChatTypeSupergroup ChatType = "supergroup"
  7. ChatTypeChannel ChatType = "channel"
  8. )
  9. // ChatType describes type of chat.
  10. type ChatType string
  11. // Known returns true if current chat type is known.
  12. func (c ChatType) Known() bool {
  13. switch c {
  14. case ChatTypeSender,
  15. ChatTypePrivate,
  16. ChatTypeGroup,
  17. ChatTypeSupergroup,
  18. ChatTypeChannel:
  19. return true
  20. default:
  21. return false
  22. }
  23. }
  24. // Chat describes chat information:
  25. // https://docs.telegram-mini-apps.com/launch-parameters/init-data#chat
  26. type Chat struct {
  27. // Unique identifier for this chat.
  28. ID int64 `json:"id"`
  29. // Type of chat.
  30. Type ChatType `json:"type"`
  31. // Title of the chat.
  32. Title string `json:"title"`
  33. // Optional. URL of the chat’s photo. The photo can be in .jpeg or .svg
  34. // formats. Only returned for Web Apps launched from the attachment menu.
  35. PhotoURL string `json:"photo_url"`
  36. // Optional. Username of the chat.
  37. Username string `json:"username"`
  38. }