소스 검색

add sleep to all three functions

master
Brent Gordon 4 년 전
부모
커밋
7cc63fac64
1개의 변경된 파일8개의 추가작업 그리고 9개의 파일을 삭제
  1. +8
    -9
      bot.rkt

+ 8
- 9
bot.rkt 파일 보기

@@ -26,13 +26,15 @@


(define (search-safebooru)
(sleep (* 3.333333333 60))
(define-values (status header response)(http-sendrecv safebooru (string-append "/posts.json?limit=" limit "&page=" page "&tags="tags ) #:ssl? #t))
(displayln status)
(define posts (read-json response))
(list-ref posts pos))

(define (attach-media)
(sleep (* 3.333333333 60))
(displayln "Obtaining media id")
(define post (search-safebooru))
(define url (hash-ref post 'file_url))
(define md5 (hash-ref post 'md5))
@@ -50,16 +52,16 @@
"Content-Type: " mime-type CRLF CRLF))
(file->bytes filename)
(string->bytes/utf-8 (string-append CRLF "--" boundary "--" CRLF))))
(define-values (status headers response)
(http-sendrecv server (string-append "/api/v1/media") #:ssl? #t #:method #"POST" #:headers (list (string-append "Content-Type: multipart/form-data; boundary=" boundary) (string-append "Authorization: Bearer " token)) #:data data))
(displayln status)
(read-json response))


(define (upload-attachment)
(sleep (* 3.333333333 60))
(displayln "Uploading attachment")
(define attachment (attach-media))
(define id (hash-ref attachment 'id))
(define data
@@ -70,14 +72,11 @@
(define-values (status headers response)
(http-sendrecv server (string-append "/api/v1/statuses") #:ssl? #t #:method #"POST" #:headers (list (string-append "Content-Type: multipart/form-data; boundary=" boundary) (string-append "Authorization: Bearer " token)) #:data data))
(displayln status)
(displayln (read-json response)))
(displayln (read-json response))
(upload-attachment))


;sleep for ten minutes
(define (loop)
(sleep 600)
(upload-attachment)
(loop))

(loop)



불러오는 중...
취소
저장