2020-02-27 21:47:36 +08:00
|
|
|
from zzcore import StdAns
|
2020-02-27 22:34:47 +08:00
|
|
|
import re
|
2020-02-27 21:47:36 +08:00
|
|
|
from subprocess import getoutput
|
|
|
|
|
|
|
|
class Ans(StdAns):
|
|
|
|
def GETMSG(self):
|
2020-02-27 22:34:47 +08:00
|
|
|
cmd = self.parms[1]
|
|
|
|
if cmd == 'status':
|
2020-02-27 21:47:36 +08:00
|
|
|
return getoutput('spigot status')
|
2020-02-27 22:34:47 +08:00
|
|
|
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
|
2020-02-27 21:47:36 +08:00
|
|
|
else:
|
|
|
|
return self.parms[1] + ' 是暂时不被允许的命令!'
|