nitter/src/types.nim

61 lines
1.3 KiB
Nim
Raw Normal View History

2019-06-20 18:04:18 +00:00
import times, sequtils, strutils, options
import norm/sqlite
2019-06-20 14:16:20 +00:00
2019-06-20 18:04:18 +00:00
export sqlite, options
db("cache.db", "", "", ""):
type
Profile* = object
username*: string
fullname*: string
2019-06-24 00:09:32 +00:00
bio*: string
2019-06-20 18:04:18 +00:00
userpic*: string
banner*: string
following*: string
followers*: string
tweets*: string
verified* {.
dbType: "STRING",
parseIt: parseBool(it.s)
formatIt: $it
.}: bool
protected* {.
dbType: "STRING",
parseIt: parseBool(it.s)
formatIt: $it
.}: bool
updated* {.
dbType: "INTEGER",
parseIt: it.i.fromUnix(),
formatIt: getTime().toUnix()
.}: Time
2019-06-20 14:16:20 +00:00
2019-06-20 18:04:18 +00:00
type
2019-06-20 14:16:20 +00:00
Tweet* = object
id*: string
profile*: Profile
link*: string
text*: string
time*: Time
shortTime*: string
replies*: string
retweets*: string
likes*: string
pinned*: bool
photos*: seq[string]
2019-06-20 18:04:18 +00:00
retweetBy*: Option[string]
gif*: Option[string]
video*: Option[string]
videoThumb*: Option[string]
2019-06-20 14:16:20 +00:00
Tweets* = seq[Tweet]
Conversation* = object
tweet*: Tweet
before*: Tweets
after*: Tweets
replies*: seq[Tweets]
proc contains*(thread: Tweets; tweet: Tweet): bool =
thread.anyIt(it.id == tweet.id)