types.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. ForwardFromChannel string // forward 来源频道用户名
  33. Links []string // 消息中的 t.me 链接
  34. IsService bool // 系统消息
  35. }
  36. // UserInfo TG 用户信息(验证商户时用)
  37. type UserInfo struct {
  38. ID int64
  39. Username string
  40. FirstName string
  41. LastName string
  42. IsBot bool
  43. IsPremium bool
  44. LastOnline *time.Time
  45. IsChannel bool
  46. IsGroup bool
  47. Exists bool // false 表示不存在/已注销
  48. }
  49. // GroupParticipant 群成员信息
  50. type GroupParticipant struct {
  51. ID int64 `json:"id"`
  52. Username string `json:"username"`
  53. FirstName string `json:"first_name"`
  54. LastName string `json:"last_name"`
  55. IsBot bool `json:"is_bot"`
  56. IsPremium bool `json:"is_premium"`
  57. }
  58. // FloodWaitError FloodWait 错误,包含等待时长
  59. type FloodWaitError struct {
  60. Seconds int
  61. }
  62. func (e *FloodWaitError) Error() string {
  63. return fmt.Sprintf("FloodWait: %d seconds", e.Seconds)
  64. }