commit
41dba98a31
17 changed files with 476 additions and 89 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -5,4 +5,5 @@ config.py
|
|||
.idea
|
||||
test.py
|
||||
push.cmd
|
||||
data/pcr/char.list
|
||||
data/pcr/char.list
|
||||
venv
|
3
data/mc/rmc/go.mod
Normal file
3
data/mc/rmc/go.mod
Normal file
|
@ -0,0 +1,3 @@
|
|||
module rmc
|
||||
|
||||
go 1.15
|
64
data/mc/rmc/main.go
Normal file
64
data/mc/rmc/main.go
Normal file
|
@ -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())
|
||||
}
|
||||
}
|
22
req.txt
22
req.txt
|
@ -1,30 +1,52 @@
|
|||
astroid==2.3.3
|
||||
autopep8==1.5
|
||||
backcall==0.2.0
|
||||
certifi==2019.11.28
|
||||
chardet==3.0.4
|
||||
Click==7.0
|
||||
decorator==4.4.2
|
||||
entrypoints==0.3
|
||||
flake8==3.7.9
|
||||
Flask==1.1.1
|
||||
idna==2.9
|
||||
importlib-metadata==1.5.0
|
||||
inflect==4.1.0
|
||||
ipykernel==5.3.4
|
||||
ipython==7.18.1
|
||||
ipython-genutils==0.2.0
|
||||
isort==4.3.21
|
||||
itsdangerous==1.1.0
|
||||
jaraco.itertools==5.0.0
|
||||
jedi==0.17.2
|
||||
Jinja2==2.11.1
|
||||
jupyter-client==6.1.7
|
||||
jupyter-core==4.6.3
|
||||
lazy-object-proxy==1.4.3
|
||||
MarkupSafe==1.1.1
|
||||
mccabe==0.6.1
|
||||
more-itertools==8.2.0
|
||||
parso==0.7.1
|
||||
pexpect==4.8.0
|
||||
pickleshare==0.7.5
|
||||
prompt-toolkit==3.0.7
|
||||
ptyprocess==0.6.0
|
||||
pycodestyle==2.5.0
|
||||
pydub==0.24.1
|
||||
pyflakes==2.1.1
|
||||
Pygments==2.7.0
|
||||
pylint==2.4.4
|
||||
python-dateutil==2.8.1
|
||||
pyzmq==19.0.2
|
||||
redis==3.4.1
|
||||
requests==2.23.0
|
||||
six==1.14.0
|
||||
sxtwl==1.1.0
|
||||
toml==0.10.1
|
||||
tornado==6.0.4
|
||||
traitlets==5.0.4
|
||||
typed-ast==1.4.1
|
||||
urllib3==1.25.8
|
||||
wcwidth==0.2.5
|
||||
Werkzeug==1.0.0
|
||||
wolframalpha==4.0.0
|
||||
wrapt==1.11.2
|
||||
|
|
3
route.py
3
route.py
|
@ -2,9 +2,6 @@ from worker import emmm
|
|||
|
||||
|
||||
def ZZRouter(data):
|
||||
if data['post_type'] != 'message' or data['message_type'] != 'group' or data['message'][0] != '/':
|
||||
return
|
||||
|
||||
uid = data['user_id']
|
||||
gid = data['group_id']
|
||||
role = data['sender']['role']
|
||||
|
|
|
@ -6,4 +6,6 @@ AUTHORIZATION = ''
|
|||
|
||||
HOST = '0.0.0.0'
|
||||
|
||||
PORT = 5580
|
||||
PORT = 5580
|
||||
|
||||
REMOTE_MC_URL = ''
|
10
worker/106.py
Normal file
10
worker/106.py
Normal file
|
@ -0,0 +1,10 @@
|
|||
import requests
|
||||
from zzcore import StdAns
|
||||
|
||||
class Ans(StdAns):
|
||||
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}秒前有人来过。'
|
|
@ -2,7 +2,7 @@ from zzcore import StdAns, mysakuya
|
|||
|
||||
|
||||
class Ans(StdAns):
|
||||
NotAllowGroup = [204097403]
|
||||
NotAllowGroup = [204097403, 1107535671]
|
||||
|
||||
def CheckPermission(self):
|
||||
if self.gid in self.NotAllowGroup:
|
||||
|
|
|
@ -3,12 +3,15 @@ import requests
|
|||
|
||||
from config import LOLIKEYS
|
||||
|
||||
|
||||
class Ans(StdAns):
|
||||
AllowGroup = [973510746, 805197917,343700338,125733077,1084566280,920863253,798595664,655057127,196268763, 204097403, 247022495, 474907856]
|
||||
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, ''
|
||||
|
|
89
worker/mc.py
89
worker/mc.py
|
@ -1,10 +1,11 @@
|
|||
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]
|
||||
def GETMSG(self):
|
||||
if len(self.parms) < 2:
|
||||
return '不加参数是坏文明!'
|
||||
|
@ -13,39 +14,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').text
|
||||
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').text
|
||||
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).text
|
||||
else:
|
||||
shellcmd = ['papermc','command','say',saywhat]
|
||||
code = call(shellcmd)
|
||||
if code == '0':
|
||||
msg = '咱已经把消息传过去了。'
|
||||
else:
|
||||
msg = '٩(ŏ﹏ŏ、)۶竟然失败了,汝是不是让我发送奇怪的话过去!'
|
||||
return msg
|
|
@ -18,8 +18,8 @@ class Ans(StdAns):
|
|||
resp = requests.get(url=url,params=params).json()
|
||||
# print(resp)
|
||||
musicid = resp['result']['songs'][0]['id']
|
||||
musicname = resp['result']['songs'][0]['name']
|
||||
msg = '[CQ:share,url=https://music.163.com/song/' + str(musicid) + '/,title=' + str(musicname) + ']'
|
||||
# musicname = resp['result']['songs'][0]['name']
|
||||
msg = f'[CQ:music,type=163,id={musicid}]'
|
||||
except Exception as e:
|
||||
print(e)
|
||||
msg = '什么东西坏掉了,大概是网易云吧...不可能是咱!'
|
||||
|
|
|
@ -1,36 +1,40 @@
|
|||
from zzcore import StdAns
|
||||
import requests
|
||||
import json
|
||||
|
||||
class Ans(StdAns):
|
||||
def GETMSG(self):
|
||||
if len(self.parms) < 2:
|
||||
return '歌名都不指定就能搜到歌了?'
|
||||
url = 'https://c.y.qq.com/soso/fcgi-bin/client_search_cp'
|
||||
params = {
|
||||
'ct': 24,
|
||||
'qqmusic_ver': 1298,
|
||||
'new_json': 1,
|
||||
'remoteplace': 'txt.yqq.song',
|
||||
'searchid': '',
|
||||
't': 0,
|
||||
'aggr': 1,
|
||||
'cr': 1,
|
||||
'catZhida': 1,
|
||||
'loseless': 0,
|
||||
'flag_qc': 0,
|
||||
'p': 1,
|
||||
'n': 20,
|
||||
'w':self.raw_msg['message'][8:],
|
||||
}
|
||||
try:
|
||||
resp = requests.get(url=url,params=params)
|
||||
resp = re.match("callback%((.+)%)", resp).json()
|
||||
if resp['data']['song']['totalnum'] == 0:
|
||||
return '辣鸡曲库没这首,或者你的关键词有问题'
|
||||
mid = resp['data']['song']['list'][0]['mid']
|
||||
mname = resp['data']['song']['list'][0]['name']
|
||||
msg = '[CQ:share,url=https://y.qq.com/n/yqq/song/' + str(mid) + '.html,title=' + str(mname) + ']'
|
||||
except Exception as e:
|
||||
print(e)
|
||||
msg = '辣鸡q音,太弟弟了('
|
||||
return msg
|
||||
def GETMSG(self):
|
||||
if len(self.parms) < 2:
|
||||
return '不加参数是坏文明!'
|
||||
url = 'https://c.y.qq.com/soso/fcgi-bin/client_search_cp'
|
||||
params = {
|
||||
'ct': 24,
|
||||
'qqmusic_ver': 1298,
|
||||
'new_json': 1,
|
||||
'remoteplace': 'txt.yqq.song',
|
||||
'searchid': '',
|
||||
't': 0,
|
||||
'aggr': 1,
|
||||
'cr': 1,
|
||||
'catZhida': 1,
|
||||
'loseless': 0,
|
||||
'flag_qc': 0,
|
||||
'p': 1,
|
||||
'n': 20,
|
||||
'w':self.raw_msg['message'][8:],
|
||||
}
|
||||
try:
|
||||
resp = requests.get(url=url,params=params).text
|
||||
resp = json.loads(list(resp.split('callback('))[1][:-1])
|
||||
# print(resp)
|
||||
if resp['data']['song']['totalnum'] == 0:
|
||||
return '啊嘞嘞好像没有诶qaq'
|
||||
mid = resp['data']['song']['list'][0]['mid']
|
||||
# id = resp['data']['song']['list'][0]['id']
|
||||
msg = f'[CQ:music,type=qq,id={mid}]'
|
||||
# mname = resp['data']['song']['list'][0]['name']
|
||||
# msg = '[CQ:share,url=https://y.qq.com/n/yqq/song/' + str(mid) + '.html,title=' + str(mname) + ']'
|
||||
except Exception as e:
|
||||
print(e)
|
||||
msg = '什么东西坏掉了,大概是疼讯吧...不可能是咱!'
|
||||
return msg
|
||||
|
|
84
worker/run.py
Normal file
84
worker/run.py
Normal file
|
@ -0,0 +1,84 @@
|
|||
import json
|
||||
import requests
|
||||
from zzcore import StdAns
|
||||
from config import GLOTTOKEN
|
||||
|
||||
LANGS = {
|
||||
'assembly': {'filename': 'main.assembly', 'url': 'https://run.glot.io/languages/assembly'},
|
||||
'ats': {'filename': 'main.ats', 'url': 'https://run.glot.io/languages/ats'},
|
||||
'bash': {'filename': 'main.bash', 'url': 'https://run.glot.io/languages/bash'},
|
||||
'c': {'filename': 'main.c', 'url': 'https://run.glot.io/languages/c'},
|
||||
'clojure': {'filename': 'main.clojure', 'url': 'https://run.glot.io/languages/clojure'},
|
||||
'cobol': {'filename': 'main.cobol', 'url': 'https://run.glot.io/languages/cobol'},
|
||||
'coffeescript': {'filename': 'main.coffeescript', 'url': 'https://run.glot.io/languages/coffeescript'},
|
||||
'cpp': {'filename': 'main.cpp', 'url': 'https://run.glot.io/languages/cpp'},
|
||||
'crystal': {'filename': 'main.crystal', 'url': 'https://run.glot.io/languages/crystal'},
|
||||
'csharp': {'filename': 'main.csharp', 'url': 'https://run.glot.io/languages/csharp'},
|
||||
'd': {'filename': 'main.d', 'url': 'https://run.glot.io/languages/d'},
|
||||
'elixir': {'filename': 'main.elixir', 'url': 'https://run.glot.io/languages/elixir'},
|
||||
'elm': {'filename': 'main.elm', 'url': 'https://run.glot.io/languages/elm'},
|
||||
'erlang': {'filename': 'main.erlang', 'url': 'https://run.glot.io/languages/erlang'},
|
||||
'fsharp': {'filename': 'main.fsharp', 'url': 'https://run.glot.io/languages/fsharp'},
|
||||
'go': {'filename': 'main.go', 'url': 'https://run.glot.io/languages/go'},
|
||||
'groovy': {'filename': 'main.groovy', 'url': 'https://run.glot.io/languages/groovy'},
|
||||
'haskell': {'filename': 'main.haskell', 'url': 'https://run.glot.io/languages/haskell'},
|
||||
'idris': {'filename': 'main.idris', 'url': 'https://run.glot.io/languages/idris'},
|
||||
'java': {'filename': 'main.java', 'url': 'https://run.glot.io/languages/java'},
|
||||
'javascript': {'filename': 'main.javascript', 'url': 'https://run.glot.io/languages/javascript'},
|
||||
'julia': {'filename': 'main.julia', 'url': 'https://run.glot.io/languages/julia'},
|
||||
'kotlin': {'filename': 'main.kotlin', 'url': 'https://run.glot.io/languages/kotlin'},
|
||||
'lua': {'filename': 'main.lua', 'url': 'https://run.glot.io/languages/lua'},
|
||||
'mercury': {'filename': 'main.mercury', 'url': 'https://run.glot.io/languages/mercury'},
|
||||
'nim': {'filename': 'main.nim', 'url': 'https://run.glot.io/languages/nim'},
|
||||
'ocaml': {'filename': 'main.ocaml', 'url': 'https://run.glot.io/languages/ocaml'},
|
||||
'perl': {'filename': 'main.perl', 'url': 'https://run.glot.io/languages/perl'},
|
||||
'perl6': {'filename': 'main.perl6', 'url': 'https://run.glot.io/languages/perl6'},
|
||||
'php': {'filename': 'main.php', 'url': 'https://run.glot.io/languages/php'},
|
||||
'python': {'filename': 'main.python', 'url': 'https://run.glot.io/languages/python'},
|
||||
'ruby': {'filename': 'main.ruby', 'url': 'https://run.glot.io/languages/ruby'},
|
||||
'rust': {'filename': 'main.rust', 'url': 'https://run.glot.io/languages/rust'},
|
||||
'scala': {'filename': 'main.scala', 'url': 'https://run.glot.io/languages/scala'},
|
||||
'swift': {'filename': 'main.swift', 'url': 'https://run.glot.io/languages/swift'},
|
||||
'typescript': {'filename': 'main.typescript', 'url': 'https://run.glot.io/languages/typescript'}
|
||||
}
|
||||
|
||||
class Ans(StdAns):
|
||||
|
||||
def GETMSG(self):
|
||||
if len(self.parms) < 3:
|
||||
return '''Usage:
|
||||
/run <lang>
|
||||
<your code>
|
||||
|
||||
支持的语言:assembly ats bash c clojure cobol coffeescript cpp crystal csharp d elixir elm erlang fsharp go groovy haskell idris java javascript julia kotlin lua mercury nim ocaml perl perl6 php python ruby rust scala swift typescript
|
||||
'''
|
||||
lang = self.parms[1]
|
||||
i = 6 + len(lang)
|
||||
content = self.raw_msg['message'][i:]
|
||||
try :
|
||||
langconfig = LANGS[lang]
|
||||
name = langconfig['filename']
|
||||
url = langconfig['url'] + '/latest'
|
||||
except :
|
||||
return f'不支持的语言 {lang}'
|
||||
|
||||
msg = glot(name, content, url)
|
||||
return msg
|
||||
|
||||
|
||||
|
||||
def glot(name, content, url):
|
||||
headers = {
|
||||
'Authorization': f'Token {GLOTTOKEN}',
|
||||
'Content-type': 'application/json',
|
||||
}
|
||||
|
||||
data = {
|
||||
"files": [{
|
||||
"name": name,
|
||||
"content": content,
|
||||
}]
|
||||
}
|
||||
resp = requests.post(url=url, headers=headers, json=data).json()
|
||||
r = f"stdout:\n{resp['stdout']}\nstderr:\n{resp['stderr']}\nerror:\n{resp['error']}"
|
||||
return r
|
41
worker/talk.py
Normal file
41
worker/talk.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
from zzcore import StdAns
|
||||
|
||||
from pydub import AudioSegment
|
||||
from base64 import b64encode
|
||||
import requests, io
|
||||
|
||||
class Ans(StdAns):
|
||||
def GETMSG(self):
|
||||
if len(self.parms) < 2:
|
||||
text = "想让我说点什么呢?"
|
||||
else:
|
||||
text = self.raw_msg['message'][5:]
|
||||
|
||||
try:
|
||||
b = tts(text)
|
||||
msg = f'[CQ:record,file=base64://{str(b)}]'
|
||||
except:
|
||||
msg = '什么东西坏掉了,...咱不能说话了!'
|
||||
return msg
|
||||
|
||||
def tts(text):
|
||||
url = "https://tts.baidu.com/text2audio"
|
||||
params = {
|
||||
'cuid': 'baike',
|
||||
'lan': 'zh',
|
||||
'ctp': 1,
|
||||
'pdt': 301,
|
||||
'vol': 5,
|
||||
'rate': 32,
|
||||
'per': 5118,
|
||||
'tex': text,
|
||||
}
|
||||
|
||||
r = requests.get(url=url, params=params)
|
||||
s = io.BytesIO(r.content)
|
||||
r.close()
|
||||
# s.seek(0,0)
|
||||
song = AudioSegment.from_mp3(s)
|
||||
amr = song.export(format="amr", parameters=["-ar", "8000"])
|
||||
b = b64encode(amr.read()).decode("utf-8")
|
||||
return b
|
56
worker/weather.py
Normal file
56
worker/weather.py
Normal file
|
@ -0,0 +1,56 @@
|
|||
import random
|
||||
import requests
|
||||
import datetime
|
||||
from zzcore import StdAns
|
||||
|
||||
class Ans(StdAns):
|
||||
"""docstring for Ans"""
|
||||
|
||||
def GETMSG(self):
|
||||
try:
|
||||
return self.get_weather()
|
||||
except Exception as e:
|
||||
return "啊哦,出错了"
|
||||
|
||||
def get_weather(self):
|
||||
ran = random.randint(0, 9999999999)
|
||||
url = "https://api.caiyunapp.com/v2/Y2FpeXVuIGFuZHJpb2QgYXBp/120.127164,36.000129/weather?lang=zh_CN&device_id={}".format(ran)
|
||||
res = requests.get(url).json()
|
||||
msg = "XZZ为您播报近期天气\n-------------------------------------\n"
|
||||
msg += "日期 | 温度 | 湿度 | 天气 |\n-------------------------------------"
|
||||
result = res["result"]["daily"]
|
||||
now = datetime.datetime.now()
|
||||
weather_summary = {
|
||||
"CLEAR_DAY": "晴",
|
||||
"CLEAR_NIGHT": "晴",
|
||||
"CLOUD_DAY_WIDGET": "多云转晴",
|
||||
"CLOUDY": "阴",
|
||||
"HAZE": "霾",
|
||||
"HAZE_WIDGET": "霾",
|
||||
"PARTLY_CLOUD_NIGHT": "多云转晴",
|
||||
"PARTLY_CLOUD_NIGHT_WIDGET": "多云转晴",
|
||||
"PARTLY_CLOUD_WIDGET": "阴",
|
||||
"PARTLY_CLOUDY_DAY": "多云转晴",
|
||||
"PARTLY_CLOUDY_NIGHT": "多云转晴",
|
||||
"RAIN": "雨",
|
||||
"RAIN_HEAVY": "大雨",
|
||||
"RAIN_LIGHT": "小雨",
|
||||
"RAIN_MIDDLE": "中雨",
|
||||
"RAIN_NORMAL_WIDGET": "大雨",
|
||||
"SNOW": "雪",
|
||||
"SNOW_WIDGET": "雪",
|
||||
"SUNSHINE_NIGHT_WIDGET": "晴",
|
||||
"SUNSHINE_WIDGET": "晴",
|
||||
"WIND": "晴",
|
||||
}
|
||||
for i in range(5):
|
||||
msg += "\n"
|
||||
msg += "{} | ".format((now + datetime.timedelta(days=i)).strftime("%Y-%m-%d"))
|
||||
msg += "{} | ".format(format(result["temperature"][i]["avg"], ".2f"))
|
||||
msg += "{} | ".format(format(result["humidity"][i]["avg"], ".2f"))
|
||||
msg += "{} | ".format(weather_summary[result["skycon"][i]["value"]])
|
||||
return msg
|
||||
|
||||
if __name__ == "__main__":
|
||||
Ans().GETMSG()
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
from zzcore import StdAns, mysakuya
|
||||
import requests
|
||||
# import requests
|
||||
import random
|
||||
|
||||
class Ans(StdAns):
|
||||
def GETMSG(self):
|
||||
|
@ -11,5 +12,7 @@ class Ans(StdAns):
|
|||
return msg
|
||||
|
||||
def wyy():
|
||||
r = requests.get(url='http://api.heerdev.top:4995/nemusic/random').json()
|
||||
return r['text']
|
||||
# r = requests.get(url='http://api.heerdev.top:4995/nemusic/random').json()
|
||||
# return r['text']
|
||||
zyy = ["生而为人,为人民服务。", "治世良药,天下赤潮。", "共产主义真好,如果有第二次,我依旧会奉献出全部。", "日推到这首国际歌的同志,一定很进步吧。", "陌生人,如果你刷到这条评论,就参加革命吧。", "温柔吗?革命烈士拿命换的。", "我今天被通缉了,陌生人能替我交个党费吗?", "这么晚还在看毛选的同志,一定心怀理想吧。", "我爱你,就像社会主义初级阶段,没有期限。", "我才五年级,老马讲什么都听不懂了,因为他坚持奋斗福报走资理论。", "自己有多开心,马恩知道,列毛知道,你也一定会知道。", "当你感到孤独的时候,去聆听国际歌,你会找到你的同志的。", "君埋泉下泥销骨,我寄人间建设社会主义现代化。", "生而为人民服务,死而佑华夏千秋。", "听党指挥的你一定很温柔吧。", "在将来,社会上所有人会平等对待每一个人。", "火药是用来做烟火的,锤子是到工厂干活用的镰刀是做农活用的,希望你们能听懂我在说什么。", "爸爸说他不回来吃饭了,因为那是他最后的斗争了。", "有的人8岁就入了党,80岁还在为共产主义事业奋斗。", "你相信吗?也许在另一个平行时空上,地球插满了红旗。", "我能够想到最浪漫的事,就是和你一起建设社会主义。", "是什么让你参加了革命?是那些饥寒交迫的人。", "很喜欢《人间革命》中的一句话,全世界无产者联合起来!", "我想过最浪漫的事情,就是和你在一起,一起做资本主义的掘墓人,一起把资本家吊在路灯上。", "我喜欢你,从初级阶段直到共产主义!", "我认识的人很多,而且我的同志遍布五湖四海。", "你说革命,革命不是请客吃饭,不能那样雅致,那样从容不迫。", "我是七个孩子的父亲(七子之歌)。", "奋斗了三十年他终究还是离开了我们,但他还在我们身边。", "《人间革命》里有这样一句话:仅一夜之间,我的心判若两人。他自工农红军中来,原来只为给我一场社会的大改造。你来时红旗漫卷,我久病难医,你走时换了人间,我自主独立。", "是什么原因让你参加革命啊?这共产主义实现真正实现的时候一定很幸福吧。", "我通过了你的入党申请,现在我们可以开始为全人类解放的伟大事业共同奋斗了。", "上帝为什么要造亚当和夏娃,因为三个人才能成立党支部。", "你走以后,中国梦由我辈当起。", "资产阶级的白鸽不会亲吻乌鸦,世间没有跨阶级的爱。", "我说起风了,不是指天气。", "江姐在我出生前就走了。", "人间值得。", "中国真好,下次还来。"]
|
||||
return random.choice(zyy)
|
69
worker/zhaoan.py
Normal file
69
worker/zhaoan.py
Normal file
|
@ -0,0 +1,69 @@
|
|||
from zzcore import StdAns
|
||||
import requests
|
||||
import sxtwl
|
||||
from datetime import datetime
|
||||
from config import HFWEATHERKEY
|
||||
|
||||
|
||||
class Ans(StdAns):
|
||||
def GETMSG(self):
|
||||
msg = f'早上好,今天是{calendar()}\n\n'
|
||||
msg += getWeather() + '\n\n'
|
||||
t = requests.get('https://v1.hitokoto.cn/?c=k&encode=text').text
|
||||
# t = ("预祝大家四六级考试顺利。")
|
||||
msg += t
|
||||
return msg
|
||||
|
||||
|
||||
def getWeather(id='101120206'):
|
||||
def wemoji(text):
|
||||
if '雪' in text:
|
||||
return text + '🌨'
|
||||
if '雨' in text:
|
||||
return text + '🌧️'
|
||||
if '阴' in text:
|
||||
return text + '⛅'
|
||||
if '云' in text:
|
||||
return text + '🌤'
|
||||
if '晴' in text:
|
||||
return text + '☀️'
|
||||
return text
|
||||
|
||||
url = 'https://devapi.heweather.net/v7/weather/3d'
|
||||
params = {
|
||||
'location': id,
|
||||
'key': HFWEATHERKEY,
|
||||
}
|
||||
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']}℃。"
|
||||
if float(tdw['precip']) > 0:
|
||||
weather += '\n记得收好衣服,出门带伞~'
|
||||
|
||||
return weather
|
||||
|
||||
|
||||
def calendar():
|
||||
|
||||
ymc = ["十一", "十二", "正", "二", "三", "四", "五", "六", "七", "八", "九", "十"]
|
||||
rmc = ["初一", "初二", "初三", "初四", "初五", "初六", "初七", "初八", "初九", "初十", "十一", "十二", "十三", "十四", "十五",
|
||||
"十六", "十七", "十八", "十九", "二十", "廿一", "廿二", "廿三", "廿四", "廿五", "廿六", "廿七", "廿八", "廿九", "三十", "卅一"]
|
||||
zmc = ["一", "二", "三", "四", "五", "六", "天"]
|
||||
nowdate = datetime.now()
|
||||
y = nowdate.year
|
||||
m = nowdate.month
|
||||
d = nowdate.day
|
||||
zc = int(nowdate.strftime("%W")) - 34
|
||||
|
||||
z = zmc[nowdate.weekday()]
|
||||
|
||||
lunar = sxtwl.Lunar()
|
||||
lunarday = lunar.getDayBySolar(y, m, d)
|
||||
|
||||
lunardaychinese = f"{ymc[lunarday.Lmc]}月{rmc[lunarday.Ldi]}日"
|
||||
if lunarday.Lleap:
|
||||
lunardaychinese = "闰" + lunardaychinese
|
||||
|
||||
cal = f"{m}月{d}日,农历{lunardaychinese},本学期第{zc}周,星期{z}"
|
||||
return cal
|
Loading…
Reference in a new issue