mc list up up

This commit is contained in:
SiHuan 2020-02-27 22:34:47 +08:00
parent 7b6fa53913
commit aa6117f5ba

View file

@ -1,14 +1,26 @@
from zzcore import StdAns
import re
from subprocess import getoutput
class Ans(StdAns):
def GETMSG(self):
if self.parms[1] == 'status':
cmd = self.parms[1]
if cmd == 'status':
return getoutput('spigot status')
AllowCmd = ['list','tps']
if self.parms[1] in AllowCmd:
cmd = 'spigot command '
cmd = cmd + self.parms[1]
return getoutput(cmd)
AllowCmd = ['list']
if cmd in AllowCmd:
if cmd == 'list':
output = getoutput('spigot status')
p = re.compile(r'There are (.*?)[ of a max]', re.S)
online = int(re.findall(p,a)[0])
if online == 0:
msg = '咱看着没有人在线哎\n_(-ω-`_)⌒)_'
else:
msg = '' + str(online) + '个小伙伴在线!'
p = re.compile(r'online: (.*?)[\n>]', re.S)
players = re.findall(p,a)[0].split(', ')
for player in players:
msg = msg + '\n' + player
return msg
else:
return self.parms[1] + ' 是暂时不被允许的命令!'