types.nim 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. import times, sequtils, options, tables
  2. import prefs_impl
  3. genPrefsType()
  4. type
  5. Token* = ref object
  6. tok*: string
  7. limit*: int
  8. remaining*: int
  9. reset*: Time
  10. init*: Time
  11. # agent*: string
  12. Error* = enum
  13. protectedUser = 22
  14. couldntAuth = 32
  15. doesntExist = 34
  16. notFound = 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. player = "player"
  91. summary = "summary"
  92. summaryLarge = "summary_large_image"
  93. promoWebsite = "promo_website"
  94. promoVideo = "promo_video_website"
  95. promoVideoConvo = "promo_video_convo"
  96. liveEvent = "live_event"
  97. broadcast = "broadcast"
  98. periscope = "periscope_broadcast"
  99. Card* = object
  100. kind*: CardKind
  101. id*: string
  102. query*: string
  103. url*: string
  104. title*: string
  105. dest*: string
  106. text*: string
  107. image*: string
  108. video*: Option[Video]
  109. TweetStats* = object
  110. replies*: int
  111. retweets*: int
  112. likes*: int
  113. Tweet* = ref object
  114. id*: int64
  115. threadId*: int64
  116. replyId*: int64
  117. profile*: Profile
  118. text*: string
  119. time*: Time
  120. reply*: seq[string]
  121. pinned*: bool
  122. hasThread*: bool
  123. available*: bool
  124. tombstone*: string
  125. location*: string
  126. stats*: TweetStats
  127. retweet*: Option[Tweet]
  128. attribution*: Option[Profile]
  129. mediaTags*: seq[Profile]
  130. quote*: Option[Tweet]
  131. card*: Option[Card]
  132. poll*: Option[Poll]
  133. gif*: Option[Gif]
  134. video*: Option[Video]
  135. photos*: seq[string]
  136. Result*[T] = object
  137. content*: seq[T]
  138. top*, bottom*: string
  139. beginning*: bool
  140. query*: Query
  141. Chain* = object
  142. content*: seq[Tweet]
  143. more*: int64
  144. cursor*: string
  145. Conversation* = ref object
  146. tweet*: Tweet
  147. before*: Chain
  148. after*: Chain
  149. replies*: Result[Chain]
  150. Timeline* = Result[Tweet]
  151. List* = object
  152. id*: string
  153. name*: string
  154. userId*: string
  155. username*: string
  156. description*: string
  157. members*: int
  158. banner*: string
  159. GlobalObjects* = ref object
  160. tweets*: Table[string, Tweet]
  161. users*: Table[string, Profile]
  162. Config* = ref object
  163. address*: string
  164. port*: int
  165. useHttps*: bool
  166. staticDir*: string
  167. title*: string
  168. hostname*: string
  169. cacheDir*: string
  170. profileCacheTime*: int
  171. hmacKey*: string
  172. proc contains*(thread: Chain; tweet: Tweet): bool =
  173. thread.content.anyIt(it.id == tweet.id)