From 5a4d808f8927d60fe7c98f80d23a38368cb9d8a6 Mon Sep 17 00:00:00 2001 From: xing Date: Tue, 11 Jul 2023 12:28:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index 7601dc9..9ea00e7 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + str "github.com/fthvgb1/wp-go/helper/strings" "io" "log" "net/http" @@ -62,39 +63,45 @@ func penti(w http.ResponseWriter, req *http.Request) { func zhihuDaily(w http.ResponseWriter, req *http.Request) { io.WriteString(w, fetch("https://feedx.best/rss/zhihudaily.xml", func(s string) string { - return filterItem(s, time.Now(), 1) + return filterItem(s, time.Now(), recentDay) })) } func tjxz(w http.ResponseWriter, r *http.Request) { io.WriteString(w, fetch("https://feedx.best/rss/tjxz.xml", func(s string) string { - return filterItem(s, time.Now(), 1) + return filterItem(s, time.Now(), recentDay) })) } func bbcLearn(w http.ResponseWriter, _ *http.Request) { io.WriteString(w, fetch("https://www.bbc.co.uk/learningenglish/chinese", func(s string) string { - return bbclearn.LearnParse(s, 1) + return bbclearn.LearnParse(s, recentDay) })) } func theNewYorker(w http.ResponseWriter, r *http.Request) { io.WriteString(w, fetch("https://feedx.best/rss/newyorker.xml", func(s string) string { - return filterItem(s, time.Now(), 1) + return filterItem(s, time.Now(), recentDay) })) } func voaLearnEnglish(w http.ResponseWriter, r *http.Request) { io.WriteString(w, fetch("https://feedx.best/rss/voalearningenglish.xml", func(s string) string { - return filterItem(s, time.Now(), 1) + return filterItem(s, time.Now(), recentDay) })) } +var recentDay = 1 + func main() { port := os.Getenv("port") if port == "" { port = ":80" } + day := os.Getenv("rss_recent_day") + if day != "" { + recentDay = str.ToInt[int](day) + } time.Local = time.FixedZone("CST", 3600*8) http.HandleFunc("/pentitugua", penti) //喷嚏图挂 http.HandleFunc("/zhihuDaily", zhihuDaily) //知乎日报