types.nim 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. import times, sequtils, options, tables
  2. import prefs_impl
  3. genPrefsType()
  4. type
  5. Token* = ref object
  6. tok*: string
  7. remaining*: int
  8. reset*: Time
  9. init*: Time
  10. # agent*: string
  11. Error* = enum
  12. null = 0
  13. protectedUser = 22
  14. couldntAuth = 32
  15. doesntExist = 34
  16. userNotFound = 50
  17. suspended = 63
  18. invalidToken = 89
  19. listIdOrSlug = 112
  20. forbidden = 200
  21. noCsrf = 353
  22. Profile* = object
  23. id*: string
  24. username*: string
  25. fullname*: string
  26. lowername*: string
  27. location*: string
  28. website*: string
  29. bio*: string
  30. userpic*: string
  31. banner*: string
  32. following*: string
  33. followers*: string
  34. tweets*: string
  35. likes*: string
  36. media*: string
  37. verified*: bool
  38. protected*: bool
  39. suspended*: bool
  40. joinDate*: Time
  41. VideoType* = enum
  42. m3u8 = "application/x-mpegURL"
  43. mp4 = "video/mp4"
  44. vmap = "video/vmap"
  45. VideoVariant* = object
  46. videoType*: VideoType
  47. url*: string
  48. bitrate*: int
  49. Video* = object
  50. videoId*: string
  51. contentId*: string
  52. durationMs*: int
  53. url*: string
  54. thumb*: string
  55. views*: string
  56. available*: bool
  57. reason*: string
  58. title*: string
  59. description*: string
  60. playbackType*: VideoType
  61. variants*: seq[VideoVariant]
  62. QueryKind* = enum
  63. posts, replies, media, users, tweets, userList
  64. Query* = object
  65. kind*: QueryKind
  66. text*: string
  67. filters*: seq[string]
  68. includes*: seq[string]
  69. excludes*: seq[string]
  70. fromUser*: seq[string]
  71. since*: string
  72. until*: string
  73. near*: string
  74. sep*: string
  75. Gif* = object
  76. url*: string
  77. thumb*: string
  78. GalleryPhoto* = object
  79. url*: string
  80. tweetId*: string
  81. color*: string
  82. PhotoRail* = seq[GalleryPhoto]
  83. Poll* = object
  84. options*: seq[string]
  85. values*: seq[int]
  86. votes*: int
  87. leader*: int
  88. status*: string
  89. CardKind* = enum
  90. amplify = "amplify"
  91. app = "app"
  92. appPlayer = "appplayer"
  93. player = "player"
  94. summary = "summary"
  95. summaryLarge = "summary_large_image"
  96. promoWebsite = "promo_website"
  97. promoVideo = "promo_video_website"
  98. promoVideoConvo = "promo_video_convo"
  99. promoImageConvo = "promo_image_convo"
  100. promoImageApp = "promo_image_app"
  101. storeLink = "direct_store_link_app"
  102. liveEvent = "live_event"
  103. broadcast = "broadcast"
  104. periscope = "periscope_broadcast"
  105. unified = "unified_card"
  106. moment = "moment"
  107. messageMe = "message_me"
  108. Card* = object
  109. kind*: CardKind
  110. id*: string
  111. query*: string
  112. url*: string
  113. title*: string
  114. dest*: string
  115. text*: string
  116. image*: string
  117. video*: Option[Video]
  118. TweetStats* = object
  119. replies*: int
  120. retweets*: int
  121. likes*: int
  122. Tweet* = ref object
  123. id*: int64
  124. threadId*: int64
  125. replyId*: int64
  126. profile*: Profile
  127. text*: string
  128. time*: Time
  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[Tweet]
  137. attribution*: Option[Profile]
  138. mediaTags*: seq[Profile]
  139. quote*: Option[Tweet]
  140. card*: Option[Card]
  141. poll*: Option[Poll]
  142. gif*: Option[Gif]
  143. video*: Option[Video]
  144. photos*: seq[string]
  145. Result*[T] = object
  146. content*: seq[T]
  147. top*, bottom*: string
  148. beginning*: bool
  149. query*: Query
  150. Chain* = object
  151. content*: seq[Tweet]
  152. more*: int64
  153. cursor*: string
  154. Conversation* = ref object
  155. tweet*: Tweet
  156. before*: Chain
  157. after*: Chain
  158. replies*: Result[Chain]
  159. Timeline* = Result[Tweet]
  160. List* = object
  161. id*: string
  162. name*: string
  163. userId*: string
  164. username*: string
  165. description*: string
  166. members*: int
  167. banner*: string
  168. GlobalObjects* = ref object
  169. tweets*: Table[string, Tweet]
  170. users*: Table[string, Profile]
  171. Config* = ref object
  172. address*: string
  173. port*: int
  174. useHttps*: bool
  175. title*: string
  176. hostname*: string
  177. staticDir*: string
  178. hmacKey*: string
  179. minTokens*: int
  180. cacheDir*: string
  181. rssCacheTime*: int
  182. listCacheTime*: int
  183. redisHost*: string
  184. redisPort*: int
  185. redisConns*: int
  186. redisMaxConns*: int
  187. proc contains*(thread: Chain; tweet: Tweet): bool =
  188. thread.content.anyIt(it.id == tweet.id)