types.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package telegram
  2. import (
  3. "fmt"
  4. "time"
  5. )
  6. // Account TG 账号信息
  7. type Account struct {
  8. Phone string
  9. SessionFile string
  10. AppID int
  11. AppHash string
  12. Device string // DeviceModel e.g. "Xiaomi Mix 4" — empty = gotd default
  13. AppVersion string // e.g. "12.0.0 (6163)"
  14. SystemVersion string // e.g. "Android 13 (33)" — mapped from DB.sdk
  15. LangPack string // e.g. "android"
  16. LangCode string // e.g. "en"
  17. SystemLangCode string // e.g. "en-US"
  18. }
  19. // ChannelInfo 频道基本信息
  20. type ChannelInfo struct {
  21. Username string
  22. Title string
  23. MemberCount int
  24. About string
  25. IsChannel bool
  26. IsGroup bool
  27. }
  28. // Message TG 消息
  29. type Message struct {
  30. ID int
  31. Text string
  32. SenderUsername string // 发送者的 @username(群聊中有值,频道消息为空)
  33. ForwardFromChannel string // forward 来源频道用户名
  34. Links []string // 消息中的 t.me 链接
  35. IsService bool // 系统消息
  36. }
  37. // UserInfo TG 用户信息(验证商户时用)
  38. type UserInfo struct {
  39. ID int64
  40. Username string
  41. FirstName string
  42. LastName string
  43. IsBot bool
  44. IsPremium bool
  45. LastOnline *time.Time
  46. IsChannel bool
  47. IsGroup bool
  48. Exists bool // false 表示不存在/已注销
  49. }
  50. // GroupParticipant 群成员信息
  51. type GroupParticipant struct {
  52. ID int64 `json:"id"`
  53. Username string `json:"username"`
  54. FirstName string `json:"first_name"`
  55. LastName string `json:"last_name"`
  56. IsBot bool `json:"is_bot"`
  57. IsPremium bool `json:"is_premium"`
  58. }
  59. // FloodWaitError FloodWait 错误,包含等待时长
  60. type FloodWaitError struct {
  61. Seconds int
  62. }
  63. func (e *FloodWaitError) Error() string {
  64. return fmt.Sprintf("FloodWait: %d seconds", e.Seconds)
  65. }