diff --git a/src/twtxt.nim b/src/twtxt.nim index 5cc9663..97c696a 100644 --- a/src/twtxt.nim +++ b/src/twtxt.nim @@ -59,13 +59,17 @@ proc updateTweets*() = var users = db.getAllRows sql"select * from users" for user in users.items(): - echo user + echo "updating " & $user + let username = user[1] url = user[2] tweets = getTweetsFrom(url, username) - echo tweets + for tweet in tweets.items(): + try: + db.exec(sql"insert into tweets values(null, ?, ?, ?);", username, tweet.date.timeInfoToTime().toSeconds(), tweet.message) + except: discard sleep 300_000 # 5 minutes diff --git a/twtxtlist.nimble b/twtxtlist.nimble index 8efd8a4..75e3ffb 100644 --- a/twtxtlist.nimble +++ b/twtxtlist.nimble @@ -18,4 +18,6 @@ task db, "SQLite database prompt": task run, "Run app": exec "nimble build" + exec "./twtxt &" exec "./twtxtlist" + exec "killall twtxt"