mc list up up
This commit is contained in:
parent
7b6fa53913
commit
aa6117f5ba
1 changed files with 18 additions and 6 deletions
24
worker/mc.py
24
worker/mc.py
|
@ -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] + ' 是暂时不被允许的命令!'
|
Loading…
Reference in a new issue