~aleteoryx/tclfeed-bsky

ref: 0ad9282cf54a813e893af8092815302543ec55cc tclfeed-bsky/main.tcl -rwxr-xr-x 865 bytes
0ad9282cAleteoryx a lot. chiefly httpd 30 days ago
                                                                                
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
#!/bin/env tclsh
package require logger
package require json
package require json::write
package require sqlite3
package require inifile
package require sha1

source config.tcl

source ws.tcl
source jetstream.tcl
source httpd.tcl
source feed.tcl

set log [logger::init tclfeed]
${log}::info "tclfeed v0.0.1"

#::json::write indented 0

### DB STUFF ###
sqlite3 db [::ini::value $config database path]
db eval {SELECT count(*) as n FROM sqlite_master WHERE name="posts";} values {
  if ![set values(n)] {
    ${log}::info "Initializing db!"
    db eval {CREATE TABLE posts (uri TEXT NOT NULL PRIMARY KEY, ts TEXT NOT NULL);}
  }
}

### JETSTREAM ###
jetstream::listen [::ini::value $config atproto jetstream_host] db

### HTTPD ###
httpd::router main {
  /xrpc/app.bsky.feed.getFeedSkeleton {::feed::serve_skeleton {tcl posts}}
}
httpd::listen main 3000

vwait nil