types.nim 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. Video* = object
  32. id*: string
  33. url*: string
  34. thumb*: string
  35. length*: int
  36. views*: string
  37. available*: bool
  38. Gif* = object
  39. url*: string
  40. thumb*: string
  41. Quote* = object
  42. id*: string
  43. profile*: Profile
  44. link*: string
  45. text*: string
  46. sensitive*: bool
  47. thumb*: Option[string]
  48. badge*: Option[string]
  49. Tweet* = ref object
  50. id*: string
  51. profile*: Profile
  52. link*: string
  53. text*: string
  54. time*: Time
  55. shortTime*: string
  56. replies*: string
  57. retweets*: string
  58. likes*: string
  59. pinned*: bool
  60. quote*: Option[Quote]
  61. retweetBy*: Option[string]
  62. retweetId*: Option[string]
  63. gif*: Option[Gif]
  64. video*: Option[Video]
  65. photos*: seq[string]
  66. Tweets* = seq[Tweet]
  67. Conversation* = ref object
  68. tweet*: Tweet
  69. before*: Tweets
  70. after*: Tweets
  71. replies*: seq[Tweets]
  72. Timeline* = ref object
  73. tweets*: Tweets
  74. minId*: string
  75. maxId*: string
  76. hasMore*: bool
  77. proc contains*(thread: Tweets; tweet: Tweet): bool =
  78. thread.anyIt(it.id == tweet.id)