commit
d10532656c
5 changed files with 111 additions and 6 deletions
54
worker/bbc.py
Normal file
54
worker/bbc.py
Normal file
|
@ -0,0 +1,54 @@
|
|||
from zzcore import StdAns
|
||||
|
||||
class Ans(StdAns):
|
||||
def GETMSG(self):
|
||||
if len(self.parms) < 2:
|
||||
return '不加参数是坏文明!'
|
||||
try:
|
||||
msg = str(bc(self.raw_msg['message'][5:]))
|
||||
except Exception as e:
|
||||
msg = str(e)
|
||||
return msg
|
||||
|
||||
def bc(formula):
|
||||
formula = pure(formula)
|
||||
try:
|
||||
return float(formula)
|
||||
except ValueError:
|
||||
print(subFormula(formula))
|
||||
subLift,subRight,flag = subFormula(formula)
|
||||
return cal(bc(subLift),bc(subRight),flag)
|
||||
|
||||
def pure(formula):
|
||||
while(formula[0] == '(' or (formula[0] == '-' and formula[1] == '-')):
|
||||
if formula[0] == '(':
|
||||
formula = formula[1:]
|
||||
else:
|
||||
formula = formula[2:]
|
||||
while(formula[len(formula) - 1] == ')'):
|
||||
formula = formula[:len(formula) - 1]
|
||||
|
||||
return formula
|
||||
|
||||
def subFormula(formula):
|
||||
start = 0
|
||||
if formula[0]=='-':
|
||||
start = 1
|
||||
for index in range(start,len(formula)):
|
||||
if formula[index] in ['*','/']:
|
||||
lastxx = index
|
||||
elif formula[index] == '+':
|
||||
return formula[:index],formula[index+1:],'+'
|
||||
elif formula[index] == '-' and formula[index-1] not in ['*','/']:
|
||||
return formula[:index],formula[index:],'+'
|
||||
elif formula[index] == '(':
|
||||
return formula[:index-1],formula[index:],formula[index-1]
|
||||
return formula[:lastxx],formula[lastxx+1:],formula[lastxx]
|
||||
|
||||
def cal(f1,f2,flag):
|
||||
do = {
|
||||
'+':lambda x,y: x+y,
|
||||
'*':lambda x,y: x*y,
|
||||
'/':lambda x,y: x/y
|
||||
}
|
||||
return do[flag](f1,f2)
|
32
worker/ip.py
Normal file
32
worker/ip.py
Normal file
|
@ -0,0 +1,32 @@
|
|||
from zzcore import StdAns
|
||||
import requests
|
||||
|
||||
class Ans(StdAns):
|
||||
def GETMSG(self):
|
||||
try:
|
||||
ip = self.parms[1]
|
||||
except:
|
||||
ip = ''
|
||||
url = 'https://api.ip.sb/geoip/'
|
||||
if ip == '' or ip == 'help':
|
||||
ret = '您可以使用 "/ip ip地址" 进行查找'
|
||||
else:
|
||||
res = requests.get(url + ip)
|
||||
rsc = res.status_code
|
||||
rem = res.json()
|
||||
if rsc == 400:
|
||||
ret = '不是正确的ip地址,您可以使用 "/ip ip地址" 进行查找'
|
||||
else:
|
||||
rlt = []
|
||||
try:
|
||||
rlt.append('IP: ' + ip)
|
||||
rlt.append('国家/地区: ' + rem['country'])
|
||||
rlt.append('ISP: ' + rem['isp'])
|
||||
rlt.append('ASN: ' + str(rem['asn']))
|
||||
rlt.append('ASN组织: ' + rem['asn_organization'])
|
||||
rlt[1] += ', ' + rem['region']
|
||||
rlt[1] += ', ' + rem['city']
|
||||
except:
|
||||
pass
|
||||
ret = '\n'.join(rlt)
|
||||
return ret
|
9
worker/ns.py
Normal file
9
worker/ns.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
from zzcore import StdAns
|
||||
from subprocess import run
|
||||
|
||||
class Ans(StdAns):
|
||||
def GETMSG(self):
|
||||
domain = self.raw_msg['message'][4:]
|
||||
r = run(["nslookup",domain],capture_output=True)
|
||||
msg = bytes.decode(r.stdout)
|
||||
return msg
|
11
worker/pull.py
Normal file
11
worker/pull.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
from zzcore import StdAns
|
||||
|
||||
from subprocess import getoutput
|
||||
|
||||
class Ans(StdAns):
|
||||
AllowUser = [1318000868]
|
||||
UserNotAllow = '汝不是咱的Master!'
|
||||
|
||||
def GETMSG(self):
|
||||
output = getoutput('git pull')
|
||||
return output
|
|
@ -12,11 +12,10 @@ class Ans(StdAns):
|
|||
cmd = ''
|
||||
if cmd == '帮助':
|
||||
msg = '您可以使用以下参数:\n 动画,漫画,游戏,文学,原创,来自网络,其他,影视,诗词,网易云,哲学,抖机灵'
|
||||
elif cmd == '':
|
||||
msg = requests.get(url).text
|
||||
elif cmd in cmdlst:
|
||||
msg = requests.get(url+cmdlst[cmd]).text
|
||||
else:
|
||||
if cmd == '':
|
||||
msg = requests.get(url).text
|
||||
elif cmd in cmdlst:
|
||||
msg = requests.get(url+cmdlst[cmd]).text
|
||||
else:
|
||||
msg = '我不知道 ' + cmd + ' 这个参数,你可以使用"/yiyan 帮助"来获取帮助'
|
||||
msg = '我不知道 ' + cmd + ' 这个参数,你可以使用"/yiyan 帮助"来获取帮助'
|
||||
return msg
|
Loading…
Reference in a new issue