types.nim 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import times, sequtils, strutils, options
  2. import norm/sqlite
  3. export sqlite, options
  4. db("cache.db", "", "", ""):
  5. type
  6. Profile* = object
  7. username*: string
  8. fullname*: string
  9. bio*: string
  10. userpic*: string
  11. banner*: string
  12. following*: string
  13. followers*: string
  14. tweets*: string
  15. verified* {.
  16. dbType: "STRING",
  17. parseIt: parseBool(it.s)
  18. formatIt: $it
  19. .}: bool
  20. protected* {.
  21. dbType: "STRING",
  22. parseIt: parseBool(it.s)
  23. formatIt: $it
  24. .}: bool
  25. updated* {.
  26. dbType: "INTEGER",
  27. parseIt: it.i.fromUnix(),
  28. formatIt: getTime().toUnix()
  29. .}: Time
  30. type
  31. VideoType* = enum
  32. vmap, m3u8, mp4
  33. Video* = object
  34. contentId*: string
  35. playbackType*: VideoType
  36. durationMs*: int
  37. url*: string
  38. thumb*: string
  39. views*: string
  40. available*: bool
  41. Gif* = object
  42. url*: string
  43. thumb*: string
  44. Poll* = object
  45. options*: seq[string]
  46. values*: seq[int]
  47. votes*: string
  48. status*: string
  49. leader*: int
  50. Quote* = object
  51. id*: string
  52. profile*: Profile
  53. text*: string
  54. reply*: seq[string]
  55. hasThread*: bool
  56. sensitive*: bool
  57. thumb*: string
  58. badge*: string
  59. Retweet* = object
  60. by*: string
  61. id*: string
  62. TweetStats* = object
  63. replies*: string
  64. retweets*: string
  65. likes*: string
  66. Tweet* = ref object
  67. id*: string
  68. profile*: Profile
  69. text*: string
  70. time*: Time
  71. shortTime*: string
  72. reply*: seq[string]
  73. pinned*: bool
  74. available*: bool
  75. hasThread*: bool
  76. stats*: TweetStats
  77. retweet*: Option[Retweet]
  78. quote*: Option[Quote]
  79. gif*: Option[Gif]
  80. video*: Option[Video]
  81. photos*: seq[string]
  82. poll*: Option[Poll]
  83. Thread* = ref object
  84. tweets*: seq[Tweet]
  85. more*: int
  86. Conversation* = ref object
  87. tweet*: Tweet
  88. before*: Thread
  89. after*: Thread
  90. replies*: seq[Thread]
  91. Timeline* = ref object
  92. tweets*: seq[Tweet]
  93. minId*: string
  94. maxId*: string
  95. hasMore*: bool
  96. proc contains*(thread: Thread; tweet: Tweet): bool =
  97. thread.tweets.anyIt(it.id == tweet.id)