(struct msg (tm_epoch tm_rfc3339 nick text))
(struct feed (nick uri))
-(define (str->lines str)
- (string-split str (regexp "[\r\n]+")))
+(define (msg-print odd m)
+ (printf "~a \033[1;37m<~a>\033[0m \033[0;~am~a\033[0m~n"
+ (date->string (seconds->date [msg-tm_epoch m]) #t)
+ [msg-nick m]
+ [if odd 36 33]
+ [msg-text m]))
+
+(define re-msg-begin
+ ; TODO Zulu offset. Maybe in several formats. Which ones?
+ (pregexp "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}"))
(define (str->msg nick str)
(if (not (regexp-match? re-msg-begin str))
[rfc3339-record:year t])])
(msg tm_epoch tm_rfc3339 nick tok_text))))))
+(define (str->lines str)
+ (string-split str (regexp "[\r\n]+")))
+
(define (str->msgs nick str)
(filter-map (λ (line) (str->msg nick line)) (str->lines str)))
; TODO Handle redirects
(if (= status 200) body (raise status)))
-(define re-msg-begin
- ; TODO Zulu offset. Maybe in several formats. Which ones?
- (let ([timestamp "[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}"])
- (pregexp (string-append "^" timestamp))))
-
-(define (msg-print odd m)
- (printf "~a \033[1;37m<~a>\033[0m \033[0;~am~a\033[0m~n"
- (date->string (seconds->date [msg-tm_epoch m]) #t)
- [msg-nick m]
- [if odd 36 33]
- [msg-text m]))
-
(define (timeline-print timeline)
(for ([msg timeline]
[i (in-naturals)])
lines)])
feeds))
-(define (logging)
+(define (setup-logging)
(define logger (make-logger #f #f 'debug #f))
(define log-chan (make-log-receiver logger 'debug))
(void (thread (λ ()
(current-logger logger))
(define (main)
- (logging)
- (define feeds (we-are-twtxt))
+ (setup-logging)
(current-http-response-auto #f)
(current-http-user-agent "tt 0.0.0")
(date-display-format 'rfc2822)
+
+ (define feeds (we-are-twtxt))
(timeline-print (timeline feeds)))
(main)