2020-03-20 22:46:23 +08:00
|
|
|
|
from zzcore import StdAns
|
|
|
|
|
import requests, time
|
|
|
|
|
|
|
|
|
|
class Ans(StdAns):
|
|
|
|
|
def GETMSG(self):
|
|
|
|
|
if len(self.parms) < 2:
|
|
|
|
|
return '不加参数是坏文明!'
|
|
|
|
|
cmd = self.parms[1]
|
|
|
|
|
AllowCmd = ['start','stop']
|
|
|
|
|
|
|
|
|
|
if cmd in AllowCmd:
|
|
|
|
|
if cmd == 'stop':
|
|
|
|
|
self.DATASET({'status':'0'})
|
|
|
|
|
return '我已知晓你希望 inx 停止.'
|
|
|
|
|
if cmd == 'start':
|
|
|
|
|
self.DATASET({'status':'1'})
|
2020-03-24 20:55:50 +08:00
|
|
|
|
self.sendmsg('inx 启动!')
|
2020-03-24 20:48:05 +08:00
|
|
|
|
pinx = 0
|
|
|
|
|
pixic = 0
|
|
|
|
|
pdji = 0
|
2020-03-20 22:51:35 +08:00
|
|
|
|
while(self.DATAGET()['status'] == '1'):
|
2020-03-24 20:48:05 +08:00
|
|
|
|
inx, ixic, dji = getMG()
|
2020-03-24 20:58:31 +08:00
|
|
|
|
msg = '标普 500 : ' + inx + ' ' + emoji(pinx,inx) + '纳斯达克 : ' + ixic + ' ' + emoji(pixic,ixic) + '道琼斯 : ' + dji + ' ' + emoji(pdji,dji)
|
2020-03-24 20:55:50 +08:00
|
|
|
|
self.sendmsg(msg)
|
|
|
|
|
# print(msg)
|
2020-03-24 20:48:05 +08:00
|
|
|
|
pinx = inx
|
|
|
|
|
pixic = ixic
|
|
|
|
|
pdji = dji
|
|
|
|
|
time.sleep(16)
|
|
|
|
|
|
2020-03-20 22:46:23 +08:00
|
|
|
|
return "现在 inx 真的停了!"
|
|
|
|
|
|
|
|
|
|
else:
|
2020-03-24 20:48:05 +08:00
|
|
|
|
return '汝是不是在inx后面添加了奇怪的参数,咱可只知道 start 和 stop。'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def getMG():
|
2020-04-02 21:48:59 +08:00
|
|
|
|
req = requests.get("https://hq.sinajs.cn/etag.php?_=1584712625172&list=gb_$inx,gb_$ixic,gb_$dji").text.split(';')
|
|
|
|
|
inx = req[0].split(',')[2]
|
|
|
|
|
ixic = req[1].split(',')[2]
|
|
|
|
|
dji = req[2].split(',')[2]
|
|
|
|
|
return inx, ixic, dji
|
2020-03-24 20:48:05 +08:00
|
|
|
|
|
|
|
|
|
def emoji(p,n):
|
|
|
|
|
n = float(n)
|
|
|
|
|
p = float(p)
|
|
|
|
|
if n < p:
|
2020-03-24 20:53:49 +08:00
|
|
|
|
emoji = '📉📉📉🎉\n'
|
2020-03-24 20:48:05 +08:00
|
|
|
|
elif n > p:
|
2020-03-24 20:53:49 +08:00
|
|
|
|
emoji = '📈📈📈😢\n'
|
2020-03-24 20:48:05 +08:00
|
|
|
|
else :
|
|
|
|
|
emoji = '⬜⬜⬜🌚\n'
|
|
|
|
|
return emoji
|