syntax fixes

This commit is contained in:
Christine Dodrill 2016-02-09 09:29:21 -08:00
parent f256c35d4e
commit 0ad7a41629
2 changed files with 5 additions and 7 deletions

View File

@ -10,7 +10,7 @@ type
username*: string username*: string
proc `$`*(t: Tweet): string = proc `$`*(t: Tweet): string =
return t.date.format(ISOTime) & "\t" & t.message return t.date.format(ISOTime) & " " & t.message
proc `%`*(t: Tweet): JsonNode = proc `%`*(t: Tweet): JsonNode =
%* %*
@ -52,7 +52,7 @@ proc getTweetsFrom*(url: string, username: string): seq[Tweet] =
let body = url.getContent(timeout=20_000) let body = url.getContent(timeout=20_000)
for line in body.splitLines().items(): for line in body.splitLines().items():
if line.len > 0 and line[0] != "#": if line.len > 0 and line[0] != '#':
res.add(username.parseTweet(line)) res.add(username.parseTweet(line))
return res return res
@ -74,7 +74,5 @@ proc updateTweetsOnce*() {. gcsafe .} =
for tweet in tweets.items(): for tweet in tweets.items():
try: try:
db.exec(sql"insert into tweets values(null, ?, ?, ?);", username, tweet.date.timeInfoToTime().toSeconds().int(), tweet.message) db.exec(sql"insert into tweets values(null, ?, ?, ?);", username, tweet.date.timeInfoToTime().toSeconds().int(), tweet.message)
except: except: discard
echo getCurrentExceptionMsg() except: discard
except:
echo getCurrentExceptionMsg()

View File

@ -31,6 +31,6 @@ proc updateSystemUser() =
when isMainModule: when isMainModule:
while true: while true:
spawn updateTweetsOnce() spawn updateTweetsOnce()
updateSystemUser() spawn updateSystemUser()
sleep 300_000 # 5 minutes sleep 300_000 # 5 minutes