types.nim 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. import times, sequtils, options
  2. import norm/sqlite
  3. import prefs_impl
  4. type
  5. VideoType* = enum
  6. vmap, m3u8, mp4
  7. dbTypes:
  8. type
  9. Profile* = object
  10. username*: string
  11. fullname*: string
  12. lowername*: string
  13. location*: string
  14. website*: string
  15. bio*: string
  16. userpic*: string
  17. banner*: string
  18. following*: string
  19. followers*: string
  20. tweets*: string
  21. likes*: string
  22. media*: string
  23. verified*: bool
  24. protected*: bool
  25. joinDate* {.
  26. dbType: "INTEGER"
  27. parseIt: it.i.fromUnix()
  28. formatIt: dbValue(it.toUnix())
  29. .}: Time
  30. updated* {.
  31. dbType: "INTEGER"
  32. parseIt: it.i.fromUnix()
  33. formatIt: dbValue(getTime().toUnix())
  34. .}: Time
  35. Video* = object
  36. videoId*: string
  37. contentId*: string
  38. durationMs*: int
  39. url*: string
  40. thumb*: string
  41. views*: string
  42. available*: bool
  43. reason*: string
  44. title*: string
  45. description*: string
  46. playbackType* {.
  47. dbType: "STRING"
  48. parseIt: parseEnum[VideoType](it.s)
  49. formatIt: dbValue($it)
  50. .}: VideoType
  51. genPrefsType()
  52. type
  53. QueryKind* = enum
  54. posts, replies, media, users, tweets, userList
  55. Query* = object
  56. kind*: QueryKind
  57. text*: string
  58. filters*: seq[string]
  59. includes*: seq[string]
  60. excludes*: seq[string]
  61. fromUser*: seq[string]
  62. since*: string
  63. until*: string
  64. near*: string
  65. sep*: string
  66. Result*[T] = ref object
  67. content*: seq[T]
  68. minId*: string
  69. maxId*: string
  70. hasMore*: bool
  71. beginning*: bool
  72. query*: Query
  73. Gif* = object
  74. url*: string
  75. thumb*: string
  76. GalleryPhoto* = object
  77. url*: string
  78. tweetId*: string
  79. color*: string
  80. Poll* = object
  81. options*: seq[string]
  82. values*: seq[int]
  83. votes*: string
  84. status*: string
  85. leader*: int
  86. CardKind* = enum
  87. summary = "summary"
  88. summaryLarge = "summary_large_image"
  89. promoWebsite = "promo_website"
  90. promoVideo = "promo_video_website"
  91. promoVideoConvo = "promo_video_convo"
  92. player = "player"
  93. liveEvent = "live_event"
  94. Card* = object
  95. kind*: CardKind
  96. id*: string
  97. query*: string
  98. url*: string
  99. title*: string
  100. dest*: string
  101. text*: string
  102. image*: Option[string]
  103. video*: Option[Video]
  104. Quote* = object
  105. id*: int64
  106. profile*: Profile
  107. text*: string
  108. reply*: seq[string]
  109. hasThread*: bool
  110. sensitive*: bool
  111. available*: bool
  112. tombstone*: string
  113. thumb*: string
  114. badge*: string
  115. Retweet* = object
  116. by*: string
  117. id*: int64
  118. TweetStats* = object
  119. replies*: string
  120. retweets*: string
  121. likes*: string
  122. Tweet* = ref object
  123. id*: int64
  124. threadId*: int64
  125. profile*: Profile
  126. text*: string
  127. time*: Time
  128. shortTime*: string
  129. reply*: seq[string]
  130. pinned*: bool
  131. hasThread*: bool
  132. available*: bool
  133. tombstone*: string
  134. location*: string
  135. stats*: TweetStats
  136. retweet*: Option[Retweet]
  137. attribution*: Option[Profile]
  138. mediaTags*: seq[Profile]
  139. quote*: Option[Quote]
  140. card*: Option[Card]
  141. gif*: Option[Gif]
  142. video*: Option[Video]
  143. photos*: seq[string]
  144. poll*: Option[Poll]
  145. Chain* = ref object
  146. content*: seq[Tweet]
  147. more*: int64
  148. Conversation* = ref object
  149. tweet*: Tweet
  150. before*: Chain
  151. after*: Chain
  152. replies*: Result[Chain]
  153. Timeline* = Result[Tweet]
  154. Config* = ref object
  155. address*: string
  156. port*: int
  157. useHttps*: bool
  158. staticDir*: string
  159. title*: string
  160. hostname*: string
  161. cacheDir*: string
  162. profileCacheTime*: int
  163. defaultTheme*: string
  164. hmacKey*: string
  165. proc contains*(thread: Chain; tweet: Tweet): bool =
  166. thread.content.anyIt(it.id == tweet.id)