From 992e337cb45a61f0abf09ca3730f4b7d2fe1cea1 Mon Sep 17 00:00:00 2001 From: SiHuan Date: Sat, 24 Oct 2020 18:43:39 +0800 Subject: [PATCH 01/24] add 106 door --- worker/106.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 worker/106.py diff --git a/worker/106.py b/worker/106.py new file mode 100644 index 0000000..41619d6 --- /dev/null +++ b/worker/106.py @@ -0,0 +1,10 @@ +import requests +from zzcore import StdAns + +class Ans(StdAns): + AllowGroup = [959613860] + def GETMSG(self): + seconds = int(requests.get("http://127.0.0.1:8095/").text) + m, s = divmod(seconds, 60) + h, m = divmod(m, 60) + return f'{h}小时{m}分钟{s}秒前有人来过。' \ No newline at end of file From 6f33254e75163e826ab807625f60564089514e35 Mon Sep 17 00:00:00 2001 From: MocyRee <50027802+MocyRee@users.noreply.github.com> Date: Sun, 25 Oct 2020 19:04:17 +0800 Subject: [PATCH 02/24] Update 106.py --- worker/106.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/worker/106.py b/worker/106.py index 41619d6..daf366e 100644 --- a/worker/106.py +++ b/worker/106.py @@ -2,9 +2,9 @@ import requests from zzcore import StdAns class Ans(StdAns): - AllowGroup = [959613860] + AllowGroup = [959613860, 983250332] def GETMSG(self): seconds = int(requests.get("http://127.0.0.1:8095/").text) m, s = divmod(seconds, 60) h, m = divmod(m, 60) - return f'{h}小时{m}分钟{s}秒前有人来过。' \ No newline at end of file + return f'{h}小时{m}分钟{s}秒前有人来过。' From 1fb0bd23d4da0d7c57609918737cf5eff2152257 Mon Sep 17 00:00:00 2001 From: SiHuan Date: Thu, 29 Oct 2020 22:26:11 +0800 Subject: [PATCH 03/24] lsp add lingxiao group --- worker/lsp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worker/lsp.py b/worker/lsp.py index d3c68d3..a1d99e7 100644 --- a/worker/lsp.py +++ b/worker/lsp.py @@ -4,7 +4,7 @@ import requests from config import LOLIKEYS class Ans(StdAns): - AllowGroup = [973510746, 805197917,343700338,125733077,1084566280,920863253,798595664,655057127,196268763, 247022495, 474907856] + AllowGroup = [973510746, 805197917,343700338,125733077,1084566280,920863253,798595664,655057127,196268763, 247022495, 474907856, 940333876] def GETMSG(self): keys = LOLIKEYS From a6fba1675ee32a5c1828b1e3f9087f02c6722370 Mon Sep 17 00:00:00 2001 From: SiHuan Date: Fri, 30 Oct 2020 10:13:44 +0800 Subject: [PATCH 04/24] fix lsp keyword search --- worker/lsp.py | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/worker/lsp.py b/worker/lsp.py index a1d99e7..bd7b688 100644 --- a/worker/lsp.py +++ b/worker/lsp.py @@ -3,12 +3,15 @@ import requests from config import LOLIKEYS + class Ans(StdAns): - AllowGroup = [973510746, 805197917,343700338,125733077,1084566280,920863253,798595664,655057127,196268763, 247022495, 474907856, 940333876] + AllowGroup = [973510746, 805197917, 343700338, 125733077, 1084566280, + 920863253, 798595664, 655057127, 196268763, 247022495, 474907856, 940333876] + def GETMSG(self): keys = LOLIKEYS - + try: nowkey = int(self.DATAGET()['nowkey']) except: @@ -20,43 +23,43 @@ class Ans(StdAns): keyword = self.parms[1] if mysakuya(self, keyword) == False: return "不许你们看咲夜的涩图!!" - + code, quota, picurl = getsetu(keys[nowkey], keyword) - + msg = '' if code == -1 or code == -2: msg += f'>_< 天啦喽,loli 不见了 Code:{code}' elif code == 3: msg += '咱没查到,也有可能是Pixiv坏掉惹' elif code == 0: - if len(self.parms) < 2 or (len(self.parms > 2) and self.parms[2] == 'p'): + if len(self.parms) < 2 or (len(self.parms) > 2 and self.parms[2] == 'p'): msg += f'[CQ:image,file={picurl}]' else: msg += f'[CQ:reply,id={self.mid}]咱帮你🔍{keyword}找到了这个\n{picurl}' - + if quota == 0: - nowkey = (nowkey+1)%(len(keys)) + nowkey = (nowkey+1) % (len(keys)) if code == 429: msg += f'>_< 已经没有 loli 啦,帮你换到了key{nowkey},再试一下吧' else: msg += f'额度用光了,下次将使用 key{nowkey}' - self.DATASET({'nowkey':nowkey}) + self.DATASET({'nowkey': nowkey}) return msg - - -def getsetu(apikey, keyword = ''): + + +def getsetu(apikey, keyword=''): url = 'https://api.lolicon.app/setu/' params = { 'apikey': apikey, } if keyword != '': params['keyword'] = keyword - + try: - resp = requests.get(url=url,params=params).json() + resp = requests.get(url=url, params=params).json() except: - return -1, -1 ,'' - + return -1, -1, '' + #quota = str(resp['quota']) #seconds = resp['quota_min_ttl'] #m, s = divmod(seconds, 60) @@ -74,4 +77,5 @@ def getsetu(apikey, keyword = ''): elif resp['code'] == 429: return 429, 0, '' else: + # print(resp['code']) return -2, -1, '' From b9b7d96e856a359f8915e39b3895b622e1d7f1eb Mon Sep 17 00:00:00 2001 From: SiHuan Date: Fri, 18 Dec 2020 21:03:30 +0800 Subject: [PATCH 05/24] add remote mc --- data/mc/rmc/go.mod | 3 ++ data/mc/rmc/main.go | 64 +++++++++++++++++++++++++++++++++ sample_config.py | 4 ++- worker/mc.py | 88 +++++++++++++++++++++++++++++---------------- 4 files changed, 128 insertions(+), 31 deletions(-) create mode 100644 data/mc/rmc/go.mod create mode 100644 data/mc/rmc/main.go diff --git a/data/mc/rmc/go.mod b/data/mc/rmc/go.mod new file mode 100644 index 0000000..e40a8ab --- /dev/null +++ b/data/mc/rmc/go.mod @@ -0,0 +1,3 @@ +module rmc + +go 1.15 diff --git a/data/mc/rmc/main.go b/data/mc/rmc/main.go new file mode 100644 index 0000000..224aabe --- /dev/null +++ b/data/mc/rmc/main.go @@ -0,0 +1,64 @@ +package main + +import ( + "bytes" + "fmt" + "io/ioutil" + "log" + "net/http" + "os/exec" +) + +func checkErr(err error) { + if err != nil { + fmt.Println(err) + } +} + +func handleStatus(writer http.ResponseWriter, request *http.Request) { + cmd := exec.Command("papermc", "status") + var out bytes.Buffer + cmd.Stdout = &out + err := cmd.Run() + if err != nil { + fmt.Fprintf(writer, "Error") + return + } + fmt.Fprintf(writer, out.String()) +} + +func handleList(writer http.ResponseWriter, request *http.Request) { + cmd := exec.Command("papermc", "command", "list") + var out bytes.Buffer + cmd.Stdout = &out + err := cmd.Run() + if err != nil { + fmt.Fprintf(writer, "Error") + return + } + fmt.Fprintf(writer, out.String()) +} + +func handleSay(writer http.ResponseWriter, request *http.Request) { + saywhat, _ := ioutil.ReadAll(request.Body) + cmd := exec.Command("papermc", "command", "say", string(saywhat)) + var out bytes.Buffer + cmd.Stdout = &out + err := cmd.Run() + if err != nil { + fmt.Fprintf(writer, "Error") + return + } + fmt.Fprintf(writer, "0") +} + +func main() { + http.HandleFunc("/status", handleStatus) + http.HandleFunc("/list", handleList) + http.HandleFunc("/say", handleSay) + fmt.Println("Running at port 58941 ...") + err := http.ListenAndServe("172.26.66.2:58941", nil) + if err != nil { + log.Fatal("ListenAndServe: ", err.Error()) + } +} diff --git a/sample_config.py b/sample_config.py index 56baf85..5bd18c1 100644 --- a/sample_config.py +++ b/sample_config.py @@ -6,4 +6,6 @@ AUTHORIZATION = '' HOST = '0.0.0.0' -PORT = 5580 \ No newline at end of file +PORT = 5580 + +REMOTE_MC_URL = '' \ No newline at end of file diff --git a/worker/mc.py b/worker/mc.py index 7691d81..66f2f4a 100644 --- a/worker/mc.py +++ b/worker/mc.py @@ -1,7 +1,9 @@ from zzcore import StdAns -import re +import re, requests from subprocess import getoutput,call +from config import REMOTE_MC_URL + class Ans(StdAns): AllowGroup = [959613860, 125733077, 204097403, 1140391080] AllowUser = [1318000868] @@ -13,39 +15,65 @@ class Ans(StdAns): if cmd in AllowCmd: if cmd == 'status': - output = getoutput('spigot status') - p = re.compile(r'processes = ([0-9]*) \(') - prsnum = re.findall(p,output)[0] - p = re.compile(r' \((.*?)\)',re.S) - prsnames = re.findall(p,output)[0].split(', ') - p = re.compile(r'Total memory usage = (.*)$') - memory = re.findall(p,output)[0] - msg = '咱的MC服务器现在有 ' - for prsname in prsnames: - msg = msg + prsname + ' ' - msg = msg + '这' + prsnum +'个进程,\n一共占用了' + memory +'内存呢。' + msg = getStatus() elif cmd == 'list': - output = getoutput('spigot command list') - p = re.compile(r'There are (.*?)[ of a max]', re.S) - online = re.findall(p,output)[0] - if online == '0': - msg = '咱看着没有人在线哎\n_(-ω-`_)⌒)_' - else: - msg = '有' + online + '个小伙伴在线!' - p = re.compile(r'online: (.*?)[\n>]', re.S) - players = re.findall(p,output)[0].split(', ') - for player in players: - msg = msg + '\n' + player + msg = getList() elif cmd == 'say': saywhat = self.raw_msg['message'][8:] - if not saywhat: - return '汝让咱say what?o(≧口≦)o' - shellcmd = ['spigot','command','say',saywhat] - if call(shellcmd) == 0: - msg = '咱已经把消息传过去了。' - else: - msg = '٩(ŏ﹏ŏ、)۶竟然失败了,汝是不是让我发送奇怪的话过去!' + msg = say(saywhat) else: msg = '汝是不是在mc后面添加了奇怪的参数,咱可只知道 status list 和 say。' return msg + +def getStatus(): + if REMOTE_MC_URL: + output = requests.post(f'{REMOTE_MC_URL}/status') + else: + output = getoutput('papermc status') + + p = re.compile(r'processes = ([0-9]*) \(') + prsnum = re.findall(p,output)[0] + p = re.compile(r' \((.*?)\)',re.S) + prsnames = re.findall(p,output)[0].split(', ') + p = re.compile(r'Total memory usage = (.*)$') + memory = re.findall(p,output)[0] + msg = '咱的MC服务器现在有 ' + for prsname in prsnames: + msg = msg + prsname + ' ' + msg = msg + '这' + prsnum +'个进程,\n一共占用了' + memory +'内存呢。' + return msg + + +def getList(): + if REMOTE_MC_URL: + output = requests.post(f'{REMOTE_MC_URL}/list') + else: + output = getoutput('papermc command list') + + p = re.compile(r'There are (.*?)[ of a max]', re.S) + online = re.findall(p,output)[0] + if online == '0': + msg = '咱看着没有人在线哎\n_(-ω-`_)⌒)_' + else: + msg = '有' + online + '个小伙伴在线!' + p = re.compile(r'online: (.*?)[\n>]', re.S) + players = re.findall(p,output)[0].split(', ') + for player in players: + msg = msg + '\n' + player + return msg + +def say(saywhat): + if not saywhat: + return '汝让咱say what?o(≧口≦)o' + + if REMOTE_MC_URL: + code = requests.post(f'{REMOTE_MC_URL}/say',data=saywhat) + else: + shellcmd = ['papermc','command','say',saywhat] + code = call(shellcmd) + if code == 0: + msg = '咱已经把消息传过去了。' + else: + msg = '٩(ŏ﹏ŏ、)۶竟然失败了,汝是不是让我发送奇怪的话过去!' + return msg \ No newline at end of file From 32c407cfff156667740c76f2e742a0d92da661f8 Mon Sep 17 00:00:00 2001 From: SiHuan Date: Fri, 18 Dec 2020 21:07:22 +0800 Subject: [PATCH 06/24] fix remote mc --- worker/mc.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/worker/mc.py b/worker/mc.py index 66f2f4a..3cb1b89 100644 --- a/worker/mc.py +++ b/worker/mc.py @@ -28,7 +28,7 @@ class Ans(StdAns): def getStatus(): if REMOTE_MC_URL: - output = requests.post(f'{REMOTE_MC_URL}/status') + output = requests.post(f'{REMOTE_MC_URL}/status').text else: output = getoutput('papermc status') @@ -47,7 +47,7 @@ def getStatus(): def getList(): if REMOTE_MC_URL: - output = requests.post(f'{REMOTE_MC_URL}/list') + output = requests.post(f'{REMOTE_MC_URL}/list').text else: output = getoutput('papermc command list') @@ -68,7 +68,7 @@ def say(saywhat): return '汝让咱say what?o(≧口≦)o' if REMOTE_MC_URL: - code = requests.post(f'{REMOTE_MC_URL}/say',data=saywhat) + code = requests.post(f'{REMOTE_MC_URL}/say',data=saywhat).text else: shellcmd = ['papermc','command','say',saywhat] code = call(shellcmd) From b16b749b95ab110451ef27db6de0a87691ac1dfb Mon Sep 17 00:00:00 2001 From: SiHuan Date: Fri, 18 Dec 2020 21:08:31 +0800 Subject: [PATCH 07/24] fix fix remote mc --- worker/mc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worker/mc.py b/worker/mc.py index 3cb1b89..381cd8c 100644 --- a/worker/mc.py +++ b/worker/mc.py @@ -72,7 +72,7 @@ def say(saywhat): else: shellcmd = ['papermc','command','say',saywhat] code = call(shellcmd) - if code == 0: + if code == '0': msg = '咱已经把消息传过去了。' else: msg = '٩(ŏ﹏ŏ、)۶竟然失败了,汝是不是让我发送奇怪的话过去!' From 6db834d42fc76a9841308b519e87f14e87ecf6b3 Mon Sep 17 00:00:00 2001 From: SiHuan Date: Fri, 18 Dec 2020 21:11:18 +0800 Subject: [PATCH 08/24] fix mc allow user --- worker/mc.py | 1 - 1 file changed, 1 deletion(-) diff --git a/worker/mc.py b/worker/mc.py index 381cd8c..5a36c1a 100644 --- a/worker/mc.py +++ b/worker/mc.py @@ -6,7 +6,6 @@ from config import REMOTE_MC_URL class Ans(StdAns): AllowGroup = [959613860, 125733077, 204097403, 1140391080] - AllowUser = [1318000868] def GETMSG(self): if len(self.parms) < 2: return '不加参数是坏文明!' From 0921a5912228f8976f07de350eae983ce53fdcab Mon Sep 17 00:00:00 2001 From: SiHuan Date: Sat, 26 Dec 2020 20:09:56 +0800 Subject: [PATCH 09/24] add rss --- worker/rss.py | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 worker/rss.py diff --git a/worker/rss.py b/worker/rss.py new file mode 100644 index 0000000..8039316 --- /dev/null +++ b/worker/rss.py @@ -0,0 +1,107 @@ +from zzcore import StdAns + +import feedparser, json + +allowCMD = ['sub','unsub','list','get'] + +allSub = [ + { + 'url' : 'https://farseerfc.me/feeds/atom.xml', + 'title' : 'Farseerfc的小窩', + 'lastUpdated' : 'Sat, 12 Dec 2020 22:55:52 +0800', + } +] + +class Ans(StdAns): + + def push(self,title,posttitle,posturl): + msg = f'{title}\n{posttitle} {posturl}' + self.sendmsg(msg) + + def GETMSG(self): + + if len(self.parms) < 2: + return '不加参数是坏文明!' + + gid = str(self.gid) + cmd = self.parms[1] + if cmd not in allowCMD: + return f'咱不知道 {cmd} 是什么东西 ●﹏●' + + try: + nowdata = json.loads(self.DATAGET()[gid]) + except: + nowdata ={ + 'allSub' : {}, + 'status' : False, + } + + if cmd == 'sub': + if len(self.parms) < 3: + return '汝想订阅什么呢?' + + suburl = self.parms[2] + try: + d = feedparser.parse(suburl) + title = d.feed.title + lastUpdated = d.feed.updated + + except: + return "咱好像没能成功订阅 (╥_╥)" + + newsub = { + 'url': suburl, + 'title': title, + 'lastUpdated' : lastUpdated, + } + + nowdata['allSub'][suburl] = newsub + + msg = f'《{title}》订阅成功' + + elif cmd == 'unsub': + if len(self.parms) < 3: + return '汝想退订什么呢?' + + suburl = self.parms[2] + if suburl not in nowdata['allSub'].keys(): + return '汝没有订阅过这个!' + + unsub = nowdata['allSub'].pop(suburl) + + msg = f'《{unsub.title}》已退订' + + elif cmd == 'list': + msg = '订阅列表' + + for sub in nowdata['allSub']: + msg += f'\n{sub.title} {sub.url}' + + elif cmd == 'enable': + nowdata['status'] = True + self.DATASET({gid:json.dumps(nowdata)}) + self.sendmsg("订阅已启用,咱会每隔五分钟抓去订阅,有新内容就会推送哦") + while(nowdata['status']): + nowdata = json.loads(self.DATAGET()[gid]) + for sub in nowdata['allSub']: + try: + d = feedparser.parse(sub['url']) + except: + self.sendmsg(f"咱抓取不到 《{sub['title']}》!") + continue + if d.feed.updated == sub['lastUpdated']: + continue + + newfeedtitle = d.entries[0].title + newfeedlink = d.entries[0].link + self.push(sub['title'], newfeedtitle, newfeedlink) + nowdata['allSub'][sub['url']]['lastUpdated'] = d.feed.updated + self.DATASET({gid:json.dumps(nowdata)}) + + elif cmd == 'disable': + nowdata['status'] = False + msg = '咱不会再推送了!' + + self.DATASET({gid:json.dumps(nowdata)}) + return msg + \ No newline at end of file From 8693914a869fb6d4a9f731c3d52ac9f6daa2ba4f Mon Sep 17 00:00:00 2001 From: SiHuan Date: Sat, 26 Dec 2020 20:17:57 +0800 Subject: [PATCH 10/24] fix rss --- worker/rss.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/worker/rss.py b/worker/rss.py index 8039316..61a844b 100644 --- a/worker/rss.py +++ b/worker/rss.py @@ -2,15 +2,15 @@ from zzcore import StdAns import feedparser, json -allowCMD = ['sub','unsub','list','get'] +allowCMD = ['sub','unsub','list','disable'] -allSub = [ - { - 'url' : 'https://farseerfc.me/feeds/atom.xml', - 'title' : 'Farseerfc的小窩', - 'lastUpdated' : 'Sat, 12 Dec 2020 22:55:52 +0800', - } -] +# allSub = { +# 'https://farseerfc.me/feeds/atom.xml' : { +# 'url' : 'https://farseerfc.me/feeds/atom.xml', +# 'title' : 'Farseerfc的小窩', +# 'lastUpdated' : 'Sat, 12 Dec 2020 22:55:52 +0800', +# } +# } class Ans(StdAns): @@ -75,7 +75,7 @@ class Ans(StdAns): msg = '订阅列表' for sub in nowdata['allSub']: - msg += f'\n{sub.title} {sub.url}' + msg += f"\n{sub['title']} {sub['url']}" elif cmd == 'enable': nowdata['status'] = True From 5960a4eef985fc9adb3905336a89b7eb538ad203 Mon Sep 17 00:00:00 2001 From: SiHuan Date: Sat, 26 Dec 2020 20:21:39 +0800 Subject: [PATCH 11/24] fix rss --- worker/rss.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worker/rss.py b/worker/rss.py index 61a844b..44f1b57 100644 --- a/worker/rss.py +++ b/worker/rss.py @@ -69,7 +69,7 @@ class Ans(StdAns): unsub = nowdata['allSub'].pop(suburl) - msg = f'《{unsub.title}》已退订' + msg = f"《{unsub['title']}》已退订" elif cmd == 'list': msg = '订阅列表' From 4494986292b23193f19e6ab61781f7c1273675a0 Mon Sep 17 00:00:00 2001 From: SiHuan Date: Sat, 26 Dec 2020 20:25:34 +0800 Subject: [PATCH 12/24] fix rss --- worker/rss.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/worker/rss.py b/worker/rss.py index 44f1b57..59375cd 100644 --- a/worker/rss.py +++ b/worker/rss.py @@ -74,7 +74,7 @@ class Ans(StdAns): elif cmd == 'list': msg = '订阅列表' - for sub in nowdata['allSub']: + for sub in nowdata['allSub'].values(): msg += f"\n{sub['title']} {sub['url']}" elif cmd == 'enable': @@ -83,7 +83,7 @@ class Ans(StdAns): self.sendmsg("订阅已启用,咱会每隔五分钟抓去订阅,有新内容就会推送哦") while(nowdata['status']): nowdata = json.loads(self.DATAGET()[gid]) - for sub in nowdata['allSub']: + for sub in nowdata['allSub'].values(): try: d = feedparser.parse(sub['url']) except: From 9ea6965985ec6f852ce3e2fc317baaf8ed0b7bef Mon Sep 17 00:00:00 2001 From: SiHuan Date: Sat, 26 Dec 2020 20:31:53 +0800 Subject: [PATCH 13/24] fix rss --- worker/rss.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/worker/rss.py b/worker/rss.py index 59375cd..36c561e 100644 --- a/worker/rss.py +++ b/worker/rss.py @@ -44,7 +44,7 @@ class Ans(StdAns): try: d = feedparser.parse(suburl) title = d.feed.title - lastUpdated = d.feed.updated + lastUpdated = d.entries[0].published except: return "咱好像没能成功订阅 (╥_╥)" @@ -89,13 +89,13 @@ class Ans(StdAns): except: self.sendmsg(f"咱抓取不到 《{sub['title']}》!") continue - if d.feed.updated == sub['lastUpdated']: + if d.entries[0].published == sub['lastUpdated']: continue newfeedtitle = d.entries[0].title newfeedlink = d.entries[0].link self.push(sub['title'], newfeedtitle, newfeedlink) - nowdata['allSub'][sub['url']]['lastUpdated'] = d.feed.updated + nowdata['allSub'][sub['url']]['lastUpdated'] = d.entries[0].published self.DATASET({gid:json.dumps(nowdata)}) elif cmd == 'disable': From 678edc243a448334fe096e7d0b1feab83e3ada84 Mon Sep 17 00:00:00 2001 From: SiHuan Date: Sat, 26 Dec 2020 20:33:25 +0800 Subject: [PATCH 14/24] fix rss --- worker/rss.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worker/rss.py b/worker/rss.py index 36c561e..a1679e6 100644 --- a/worker/rss.py +++ b/worker/rss.py @@ -2,7 +2,7 @@ from zzcore import StdAns import feedparser, json -allowCMD = ['sub','unsub','list','disable'] +allowCMD = ['sub','unsub','list','disable', 'enable'] # allSub = { # 'https://farseerfc.me/feeds/atom.xml' : { From d9b976d9c68271188ad763012abfe9de1633d3c8 Mon Sep 17 00:00:00 2001 From: SiHuan Date: Sat, 26 Dec 2020 20:36:04 +0800 Subject: [PATCH 15/24] fix rss --- worker/rss.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/worker/rss.py b/worker/rss.py index a1679e6..7566f60 100644 --- a/worker/rss.py +++ b/worker/rss.py @@ -1,6 +1,6 @@ from zzcore import StdAns -import feedparser, json +import feedparser, json, time allowCMD = ['sub','unsub','list','disable', 'enable'] @@ -80,7 +80,7 @@ class Ans(StdAns): elif cmd == 'enable': nowdata['status'] = True self.DATASET({gid:json.dumps(nowdata)}) - self.sendmsg("订阅已启用,咱会每隔五分钟抓去订阅,有新内容就会推送哦") + self.sendmsg("订阅已启用,咱会每隔五分钟抓取订阅,有新内容就会推送哦") while(nowdata['status']): nowdata = json.loads(self.DATAGET()[gid]) for sub in nowdata['allSub'].values(): @@ -97,6 +97,7 @@ class Ans(StdAns): self.push(sub['title'], newfeedtitle, newfeedlink) nowdata['allSub'][sub['url']]['lastUpdated'] = d.entries[0].published self.DATASET({gid:json.dumps(nowdata)}) + time.sleep() elif cmd == 'disable': nowdata['status'] = False From 3016375ee0edad10d5066c76dafd8b621616a6b3 Mon Sep 17 00:00:00 2001 From: SiHuan Date: Sat, 26 Dec 2020 20:47:52 +0800 Subject: [PATCH 16/24] fix rss --- worker/rss.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/worker/rss.py b/worker/rss.py index 7566f60..7c82b09 100644 --- a/worker/rss.py +++ b/worker/rss.py @@ -99,6 +99,8 @@ class Ans(StdAns): self.DATASET({gid:json.dumps(nowdata)}) time.sleep() + return '订阅已经真的停了!' + elif cmd == 'disable': nowdata['status'] = False msg = '咱不会再推送了!' From 0aa5d90994158d8acaf1679591250eca8f26d71d Mon Sep 17 00:00:00 2001 From: SiHuan Date: Sat, 26 Dec 2020 21:56:08 +0800 Subject: [PATCH 17/24] fix rss --- worker/rss.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worker/rss.py b/worker/rss.py index 7c82b09..3f0b0ea 100644 --- a/worker/rss.py +++ b/worker/rss.py @@ -97,7 +97,7 @@ class Ans(StdAns): self.push(sub['title'], newfeedtitle, newfeedlink) nowdata['allSub'][sub['url']]['lastUpdated'] = d.entries[0].published self.DATASET({gid:json.dumps(nowdata)}) - time.sleep() + time.sleep(5000) return '订阅已经真的停了!' From 5989d46349bb08a5279fc38c5d4397afafd631ee Mon Sep 17 00:00:00 2001 From: SiHuan Date: Sat, 26 Dec 2020 22:40:31 +0800 Subject: [PATCH 18/24] fix rss --- worker/rss.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worker/rss.py b/worker/rss.py index 3f0b0ea..90546b9 100644 --- a/worker/rss.py +++ b/worker/rss.py @@ -97,7 +97,7 @@ class Ans(StdAns): self.push(sub['title'], newfeedtitle, newfeedlink) nowdata['allSub'][sub['url']]['lastUpdated'] = d.entries[0].published self.DATASET({gid:json.dumps(nowdata)}) - time.sleep(5000) + time.sleep(300) return '订阅已经真的停了!' From 78d33c4ef556dbe918b682ee09f08c4f7bb788e6 Mon Sep 17 00:00:00 2001 From: SiHuan Date: Wed, 13 Jan 2021 09:50:36 +0800 Subject: [PATCH 19/24] update zhaoan --- worker/zhaoan.py | 8 ++++---- zaoan.py | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 zaoan.py diff --git a/worker/zhaoan.py b/worker/zhaoan.py index df98571..678e2f7 100644 --- a/worker/zhaoan.py +++ b/worker/zhaoan.py @@ -46,7 +46,7 @@ def getWeather(id='101120206'): def calendar(): - ymc = ["十一", "十二", "正", "二", "三", "四", "五", "六", "七", "八", "九", "十"] + ymc = ["冬", "腊", "正", "二", "三", "四", "五", "六", "七", "八", "九", "十"] rmc = ["初一", "初二", "初三", "初四", "初五", "初六", "初七", "初八", "初九", "初十", "十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十", "廿一", "廿二", "廿三", "廿四", "廿五", "廿六", "廿七", "廿八", "廿九", "三十", "卅一"] zmc = ["一", "二", "三", "四", "五", "六", "天"] @@ -54,16 +54,16 @@ def calendar(): y = nowdate.year m = nowdate.month d = nowdate.day - zc = int(nowdate.strftime("%W")) - 34 + zc = int(nowdate.strftime("%W")) - 1 z = zmc[nowdate.weekday()] lunar = sxtwl.Lunar() lunarday = lunar.getDayBySolar(y, m, d) - lunardaychinese = f"{ymc[lunarday.Lmc]}月{rmc[lunarday.Ldi]}日" + lunardaychinese = f"{ymc[lunarday.Lmc]}月{rmc[lunarday.Ldi]}" if lunarday.Lleap: lunardaychinese = "闰" + lunardaychinese - cal = f"{m}月{d}日,农历{lunardaychinese},本学期第{zc}周,星期{z}" + cal = f"{m}月{d}日,{lunardaychinese},寒假第{zc}周,星期{z}" return cal diff --git a/zaoan.py b/zaoan.py new file mode 100644 index 0000000..80b40f3 --- /dev/null +++ b/zaoan.py @@ -0,0 +1,36 @@ +import requests +import json + +url = 'http://127.0.0.1:5580/' +headers = {'Content-Type': 'application/json'} + +gids = [743539576, 959613860, 1107535671] + +data = { + "anonymous": "None", + "font": 1501544, + "group_id": 959613860, + "message": "/zhaoan", + "message_id": 2071, + "message_type": "group", + "post_type": "message", + "raw_message": "/zhaoan", + "self_id": 161795000, + "sender": { + "age": 18, + "area": "济宁", + "card": "", + "level": "活跃", + "nickname": "SiHuan", + "role": "owner", + "sex": "unknown", + "title": "", + "user_id": 1318000000 + }, + "sub_type": "normal", + "time": 1582805370, + "user_id": 1318000000 +} +for gid in gids: + data['group_id'] = gid + requests.post(url=url, headers=headers, data=json.dumps(data)) \ No newline at end of file From ae6fc2c290345b91b6b50d3a20ee8b15cb826dd8 Mon Sep 17 00:00:00 2001 From: SiHuan Date: Wed, 13 Jan 2021 09:52:31 +0800 Subject: [PATCH 20/24] rm zaoan script --- zaoan.py | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 zaoan.py diff --git a/zaoan.py b/zaoan.py deleted file mode 100644 index 80b40f3..0000000 --- a/zaoan.py +++ /dev/null @@ -1,36 +0,0 @@ -import requests -import json - -url = 'http://127.0.0.1:5580/' -headers = {'Content-Type': 'application/json'} - -gids = [743539576, 959613860, 1107535671] - -data = { - "anonymous": "None", - "font": 1501544, - "group_id": 959613860, - "message": "/zhaoan", - "message_id": 2071, - "message_type": "group", - "post_type": "message", - "raw_message": "/zhaoan", - "self_id": 161795000, - "sender": { - "age": 18, - "area": "济宁", - "card": "", - "level": "活跃", - "nickname": "SiHuan", - "role": "owner", - "sex": "unknown", - "title": "", - "user_id": 1318000000 - }, - "sub_type": "normal", - "time": 1582805370, - "user_id": 1318000000 -} -for gid in gids: - data['group_id'] = gid - requests.post(url=url, headers=headers, data=json.dumps(data)) \ No newline at end of file From 1d186058493832bad2e82767e28e4d612804c8d6 Mon Sep 17 00:00:00 2001 From: SiHuan Date: Thu, 14 Jan 2021 09:47:58 +0800 Subject: [PATCH 21/24] update zhaoan --- worker/zhaoan.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/worker/zhaoan.py b/worker/zhaoan.py index 678e2f7..085f02c 100644 --- a/worker/zhaoan.py +++ b/worker/zhaoan.py @@ -36,8 +36,9 @@ def getWeather(id='101120206'): } r = requests.get(url=url, params=params).json() tdw = r['daily'][0] - ndw = r['daily'][1] - weather = f"今日日间{wemoji(tdw['textDay'])},温度{tdw['tempMin']}~{tdw['tempMax']}℃,{tdw['windDirDay']}{tdw['windScaleDay']}级;夜间{wemoji(tdw['textNight'])},{tdw['windDirNight']}{tdw['windScaleNight']}级。明日日间{wemoji(ndw['textDay'])},温度{ndw['tempMin']}~{ndw['tempMax']}℃。" + # ndw = r['daily'][1] + # weather = f"今日日间{wemoji(tdw['textDay'])},温度{tdw['tempMin']}~{tdw['tempMax']}℃,{tdw['windDirDay']}{tdw['windScaleDay']}级;夜间{wemoji(tdw['textNight'])},{tdw['windDirNight']}{tdw['windScaleNight']}级。明日日间{wemoji(ndw['textDay'])},温度{ndw['tempMin']}~{ndw['tempMax']}℃。" + weather = f"今日日间{wemoji(tdw['textDay'])},温度{tdw['tempMin']}~{tdw['tempMax']}℃,{tdw['windDirDay']}{tdw['windScaleDay']}级;夜间{wemoji(tdw['textNight'])},{tdw['windDirNight']}{tdw['windScaleNight']}级。" if float(tdw['precip']) > 0: weather += '\n记得收好衣服,出门带伞~' @@ -51,6 +52,8 @@ def calendar(): "十六", "十七", "十八", "十九", "二十", "廿一", "廿二", "廿三", "廿四", "廿五", "廿六", "廿七", "廿八", "廿九", "三十", "卅一"] zmc = ["一", "二", "三", "四", "五", "六", "天"] nowdate = datetime.now() + kaoyandate = datetime(2021,12,26) + djs = (kaoyandate - nowdate).days y = nowdate.year m = nowdate.month d = nowdate.day @@ -65,5 +68,5 @@ def calendar(): if lunarday.Lleap: lunardaychinese = "闰" + lunardaychinese - cal = f"{m}月{d}日,{lunardaychinese},寒假第{zc}周,星期{z}" + cal = f"{m}月{d}日,{lunardaychinese},寒假第{zc}周,星期{z}\n距离 2022 考研还有 {djs} 天" return cal From 22362ff46e34b57f9ed4f7b4ffd6f24509adcc0d Mon Sep 17 00:00:00 2001 From: SiHuan Date: Thu, 14 Jan 2021 09:50:41 +0800 Subject: [PATCH 22/24] update zhaoan --- worker/zhaoan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worker/zhaoan.py b/worker/zhaoan.py index 085f02c..bac6518 100644 --- a/worker/zhaoan.py +++ b/worker/zhaoan.py @@ -53,7 +53,7 @@ def calendar(): zmc = ["一", "二", "三", "四", "五", "六", "天"] nowdate = datetime.now() kaoyandate = datetime(2021,12,26) - djs = (kaoyandate - nowdate).days + djs = (kaoyandate - nowdate).days - 1 y = nowdate.year m = nowdate.month d = nowdate.day From d6dc0962c6a0c3038a62055c622ecfadd2ed9cd1 Mon Sep 17 00:00:00 2001 From: SiHuan Date: Thu, 14 Jan 2021 09:54:53 +0800 Subject: [PATCH 23/24] update zhaoan --- worker/zhaoan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worker/zhaoan.py b/worker/zhaoan.py index bac6518..aa7ffd5 100644 --- a/worker/zhaoan.py +++ b/worker/zhaoan.py @@ -68,5 +68,5 @@ def calendar(): if lunarday.Lleap: lunardaychinese = "闰" + lunardaychinese - cal = f"{m}月{d}日,{lunardaychinese},寒假第{zc}周,星期{z}\n距离 2022 考研还有 {djs} 天" + cal = f"{m}月{d}日,{lunardaychinese},寒假第{zc}周,星期{z}\n\n距离 2022 考研还有 {djs} 天" return cal From ee52cd135f2003c07cd396e6819a08a0257b0433 Mon Sep 17 00:00:00 2001 From: SiHuan Date: Thu, 14 Jan 2021 14:12:53 +0800 Subject: [PATCH 24/24] update zhaoan --- worker/zhaoan.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/worker/zhaoan.py b/worker/zhaoan.py index aa7ffd5..06da5d3 100644 --- a/worker/zhaoan.py +++ b/worker/zhaoan.py @@ -52,8 +52,8 @@ def calendar(): "十六", "十七", "十八", "十九", "二十", "廿一", "廿二", "廿三", "廿四", "廿五", "廿六", "廿七", "廿八", "廿九", "三十", "卅一"] zmc = ["一", "二", "三", "四", "五", "六", "天"] nowdate = datetime.now() - kaoyandate = datetime(2021,12,26) - djs = (kaoyandate - nowdate).days - 1 + kaoyandate = datetime(2021,12,21) + djs = (kaoyandate - nowdate).days -1 y = nowdate.year m = nowdate.month d = nowdate.day