2019-08-12 04:26:37 +09:00
|
|
|
import times, sequtils, options
|
2019-06-21 03:04:18 +09:00
|
|
|
import norm/sqlite
|
2019-06-20 23:16:20 +09:00
|
|
|
|
2019-09-08 20:01:20 +09:00
|
|
|
import prefs_impl
|
|
|
|
|
2019-08-07 02:02:38 +09:00
|
|
|
type
|
|
|
|
VideoType* = enum
|
|
|
|
vmap, m3u8, mp4
|
|
|
|
|
2019-09-08 19:22:52 +09:00
|
|
|
dbTypes:
|
2019-06-21 03:04:18 +09:00
|
|
|
type
|
|
|
|
Profile* = object
|
|
|
|
username*: string
|
|
|
|
fullname*: string
|
2019-08-12 04:26:55 +09:00
|
|
|
location*: string
|
|
|
|
website*: string
|
2019-06-24 09:09:32 +09:00
|
|
|
bio*: string
|
2019-06-21 03:04:18 +09:00
|
|
|
userpic*: string
|
|
|
|
banner*: string
|
|
|
|
following*: string
|
|
|
|
followers*: string
|
|
|
|
tweets*: string
|
2019-08-12 04:26:55 +09:00
|
|
|
likes*: string
|
2019-08-12 06:24:02 +09:00
|
|
|
media*: string
|
2019-08-16 05:44:59 +09:00
|
|
|
verified*: bool
|
|
|
|
protected*: bool
|
2019-08-12 04:26:55 +09:00
|
|
|
joinDate* {.
|
2019-08-14 02:44:29 +09:00
|
|
|
dbType: "INTEGER"
|
|
|
|
parseIt: it.i.fromUnix()
|
2019-08-16 05:44:59 +09:00
|
|
|
formatIt: dbValue(it.toUnix())
|
2019-08-12 04:26:55 +09:00
|
|
|
.}: Time
|
2019-06-21 03:04:18 +09:00
|
|
|
updated* {.
|
2019-08-14 02:44:29 +09:00
|
|
|
dbType: "INTEGER"
|
|
|
|
parseIt: it.i.fromUnix()
|
2019-08-16 05:44:59 +09:00
|
|
|
formatIt: dbValue(getTime().toUnix())
|
2019-06-21 03:04:18 +09:00
|
|
|
.}: Time
|
2019-06-20 23:16:20 +09:00
|
|
|
|
2019-08-07 02:02:38 +09:00
|
|
|
Video* = object
|
|
|
|
videoId*: string
|
|
|
|
contentId*: string
|
|
|
|
durationMs*: int
|
|
|
|
url*: string
|
|
|
|
thumb*: string
|
|
|
|
views*: string
|
2019-08-16 05:44:59 +09:00
|
|
|
available*: bool
|
2019-08-20 05:03:00 +09:00
|
|
|
reason*: string
|
2019-10-26 22:50:42 +09:00
|
|
|
title*: string
|
|
|
|
description*: string
|
2019-08-07 02:02:38 +09:00
|
|
|
playbackType* {.
|
2019-08-15 22:51:20 +09:00
|
|
|
dbType: "STRING"
|
|
|
|
parseIt: parseEnum[VideoType](it.s)
|
2019-08-16 05:44:59 +09:00
|
|
|
formatIt: dbValue($it)
|
2019-08-07 02:02:38 +09:00
|
|
|
.}: VideoType
|
|
|
|
|
2019-09-08 20:01:20 +09:00
|
|
|
genPrefsType()
|
2019-09-08 19:22:52 +09:00
|
|
|
|
2019-06-21 03:04:18 +09:00
|
|
|
type
|
2019-07-12 02:22:23 +09:00
|
|
|
QueryKind* = enum
|
2019-10-08 20:54:20 +09:00
|
|
|
posts, replies, media, users, tweets, userList
|
2019-07-03 18:46:03 +09:00
|
|
|
|
|
|
|
Query* = object
|
2019-07-12 02:22:23 +09:00
|
|
|
kind*: QueryKind
|
2019-09-13 20:20:08 +09:00
|
|
|
text*: string
|
2019-07-04 18:55:19 +09:00
|
|
|
filters*: seq[string]
|
|
|
|
includes*: seq[string]
|
|
|
|
excludes*: seq[string]
|
2019-08-07 00:41:06 +09:00
|
|
|
fromUser*: seq[string]
|
2019-09-20 05:11:38 +09:00
|
|
|
since*: string
|
|
|
|
until*: string
|
2019-09-20 06:36:21 +09:00
|
|
|
near*: string
|
2019-07-04 18:55:19 +09:00
|
|
|
sep*: string
|
2019-07-03 18:46:03 +09:00
|
|
|
|
2019-08-23 09:15:25 +09:00
|
|
|
Result*[T] = ref object
|
|
|
|
content*: seq[T]
|
|
|
|
minId*: string
|
|
|
|
maxId*: string
|
|
|
|
hasMore*: bool
|
|
|
|
beginning*: bool
|
2019-09-19 09:23:22 +09:00
|
|
|
query*: Query
|
2019-08-23 09:15:25 +09:00
|
|
|
|
2019-06-24 12:14:14 +09:00
|
|
|
Gif* = object
|
|
|
|
url*: string
|
|
|
|
thumb*: string
|
|
|
|
|
2019-07-04 11:18:32 +09:00
|
|
|
GalleryPhoto* = object
|
|
|
|
url*: string
|
|
|
|
tweetId*: string
|
|
|
|
color*: string
|
|
|
|
|
2019-06-29 21:11:23 +09:00
|
|
|
Poll* = object
|
|
|
|
options*: seq[string]
|
|
|
|
values*: seq[int]
|
|
|
|
votes*: string
|
|
|
|
status*: string
|
|
|
|
leader*: int
|
|
|
|
|
2019-07-12 02:22:23 +09:00
|
|
|
CardKind* = enum
|
2019-07-15 23:03:01 +09:00
|
|
|
summary = "summary"
|
|
|
|
summaryLarge = "summary_large_image"
|
|
|
|
promoWebsite = "promo_website"
|
|
|
|
promoVideo = "promo_video_website"
|
|
|
|
player = "player"
|
|
|
|
liveEvent = "live_event"
|
2019-07-12 02:22:23 +09:00
|
|
|
|
|
|
|
Card* = object
|
|
|
|
kind*: CardKind
|
|
|
|
id*: string
|
|
|
|
query*: string
|
|
|
|
url*: string
|
|
|
|
title*: string
|
|
|
|
dest*: string
|
|
|
|
text*: string
|
2019-07-15 23:03:01 +09:00
|
|
|
image*: Option[string]
|
|
|
|
video*: Option[Video]
|
2019-07-12 02:22:23 +09:00
|
|
|
|
2019-06-24 15:07:36 +09:00
|
|
|
Quote* = object
|
2019-10-11 01:22:14 +09:00
|
|
|
id*: int
|
2019-06-24 12:14:14 +09:00
|
|
|
profile*: Profile
|
|
|
|
text*: string
|
2019-07-02 07:52:50 +09:00
|
|
|
reply*: seq[string]
|
|
|
|
hasThread*: bool
|
2019-06-25 09:58:33 +09:00
|
|
|
sensitive*: bool
|
2019-07-04 11:38:23 +09:00
|
|
|
available*: bool
|
2019-09-08 21:34:26 +09:00
|
|
|
tombstone*: string
|
2019-07-02 07:52:50 +09:00
|
|
|
thumb*: string
|
|
|
|
badge*: string
|
2019-06-24 12:14:14 +09:00
|
|
|
|
2019-07-02 06:22:00 +09:00
|
|
|
Retweet* = object
|
|
|
|
by*: string
|
2019-10-11 01:22:14 +09:00
|
|
|
id*: int
|
2019-07-02 06:22:00 +09:00
|
|
|
|
2019-07-02 06:48:25 +09:00
|
|
|
TweetStats* = object
|
|
|
|
replies*: string
|
|
|
|
retweets*: string
|
|
|
|
likes*: string
|
|
|
|
|
2019-06-24 12:14:14 +09:00
|
|
|
Tweet* = ref object
|
2019-10-11 01:22:14 +09:00
|
|
|
id*: int
|
|
|
|
threadId*: int
|
2019-06-20 23:16:20 +09:00
|
|
|
profile*: Profile
|
|
|
|
text*: string
|
|
|
|
time*: Time
|
|
|
|
shortTime*: string
|
2019-07-02 07:52:50 +09:00
|
|
|
reply*: seq[string]
|
2019-06-20 23:16:20 +09:00
|
|
|
pinned*: bool
|
2019-07-02 07:52:50 +09:00
|
|
|
hasThread*: bool
|
2019-09-08 21:34:26 +09:00
|
|
|
available*: bool
|
|
|
|
tombstone*: string
|
2019-07-02 06:48:25 +09:00
|
|
|
stats*: TweetStats
|
2019-07-02 06:22:00 +09:00
|
|
|
retweet*: Option[Retweet]
|
2019-06-24 12:14:14 +09:00
|
|
|
quote*: Option[Quote]
|
2019-07-12 02:22:23 +09:00
|
|
|
card*: Option[Card]
|
2019-06-24 12:14:14 +09:00
|
|
|
gif*: Option[Gif]
|
|
|
|
video*: Option[Video]
|
|
|
|
photos*: seq[string]
|
2019-06-29 21:11:23 +09:00
|
|
|
poll*: Option[Poll]
|
2019-06-20 23:16:20 +09:00
|
|
|
|
2019-10-09 03:47:45 +09:00
|
|
|
Chain* = ref object
|
2019-08-23 09:15:25 +09:00
|
|
|
content*: seq[Tweet]
|
2019-07-01 10:13:12 +09:00
|
|
|
more*: int
|
2019-06-20 23:16:20 +09:00
|
|
|
|
2019-06-24 12:14:14 +09:00
|
|
|
Conversation* = ref object
|
2019-06-20 23:16:20 +09:00
|
|
|
tweet*: Tweet
|
2019-10-09 03:47:45 +09:00
|
|
|
before*: Chain
|
|
|
|
after*: Chain
|
|
|
|
replies*: Result[Chain]
|
2019-06-20 23:16:20 +09:00
|
|
|
|
2019-08-23 09:15:25 +09:00
|
|
|
Timeline* = Result[Tweet]
|
2019-06-25 14:36:36 +09:00
|
|
|
|
2019-07-31 09:15:43 +09:00
|
|
|
Config* = ref object
|
|
|
|
address*: string
|
|
|
|
port*: int
|
2019-08-19 10:02:34 +09:00
|
|
|
useHttps*: bool
|
2019-07-31 09:15:43 +09:00
|
|
|
staticDir*: string
|
2019-10-21 12:19:00 +09:00
|
|
|
title*: string
|
|
|
|
hostname*: string
|
2019-07-31 09:15:43 +09:00
|
|
|
cacheDir*: string
|
|
|
|
profileCacheTime*: int
|
2019-10-23 21:06:47 +09:00
|
|
|
defaultTheme*: string
|
2019-10-24 07:17:38 +09:00
|
|
|
hmacKey*: string
|
2019-07-31 09:15:43 +09:00
|
|
|
|
2019-10-09 03:47:45 +09:00
|
|
|
proc contains*(thread: Chain; tweet: Tweet): bool =
|
2019-08-23 09:15:25 +09:00
|
|
|
thread.content.anyIt(it.id == tweet.id)
|