Add worker for updating from twtxt files
This commit is contained in:
parent
cf9a26b0cb
commit
ec4dab6953
|
@ -1,3 +1,4 @@
|
|||
twtxtlist
|
||||
twtxt
|
||||
nimcache
|
||||
*.db
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
twtxt
|
|
@ -1,4 +1,4 @@
|
|||
import json, httpclient, strutils, times
|
||||
import db_sqlite, json, httpclient, os, strutils, times
|
||||
|
||||
const
|
||||
ISOTime*: string = "yyyy-MM-dd'T'HH:mm:ss'.000000'zzz"
|
||||
|
@ -52,17 +52,22 @@ proc getTweetsFrom*(url: string, username: string): seq[Tweet] =
|
|||
|
||||
return res
|
||||
|
||||
when isMainModule:
|
||||
proc updateTweets*() =
|
||||
var db = open("./data/twtxt.db", nil, nil, nil)
|
||||
|
||||
while true:
|
||||
var users = db.getAllRows sql"select * from users"
|
||||
|
||||
for user in users.items():
|
||||
echo user
|
||||
let
|
||||
now = getLocalTime(getTime())
|
||||
t: Tweet = Tweet(date: now,
|
||||
message: "Test message",
|
||||
username: "Xena")
|
||||
username = user[1]
|
||||
url = user[2]
|
||||
tweets = getTweetsFrom(url, username)
|
||||
|
||||
const testInp = "2016-02-05T19:30:46.964649+00:00 This is a tweet via twtxt!"
|
||||
echo tweets
|
||||
|
||||
echo "xena".parseTweet testInp
|
||||
sleep 300_000 # 5 minutes
|
||||
|
||||
echo pretty(%t, 4)
|
||||
|
||||
echo pretty(%getTweetsFrom("https://xena.greedo.xeserv.us/files/xena.txt", "xena"), 4)
|
||||
when isMainModule:
|
||||
updateTweets()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import asyncdispatch, db_sqlite, jester, moustachu, os, shorturl,
|
||||
strutils, tables, times, typetraits
|
||||
strutils, tables, times, twtxt, typetraits
|
||||
|
||||
const
|
||||
baseTemplate*: string = staticRead "./templates/layout.mustache"
|
||||
|
|
|
@ -5,7 +5,7 @@ author = "Christine Dodrill"
|
|||
description = "a list of twtxt hacker feeds"
|
||||
license = "MIT"
|
||||
srcDir = "src"
|
||||
bin = @["twtxtlist"]
|
||||
bin = @["twtxtlist", "twtxt"]
|
||||
|
||||
# Dependencies
|
||||
|
||||
|
|
Loading…
Reference in New Issue