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