Archived
1
0
Fork 0
This repository has been archived on 2024-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
akari-bot/CommandGen.py

122 lines
4.2 KiB
Python
Raw Normal View History

2020-08-07 06:19:34 +00:00
import re
2020-08-12 16:01:34 +00:00
2020-08-18 13:12:38 +00:00
from modules.ab import ab
from modules.bug import bugtracker
from modules.checkuser import checkuser
2020-08-20 10:30:08 +00:00
from modules.help import help,credits
2020-08-18 13:12:38 +00:00
from modules.mcv import mcv, mcbv, mcdv
from modules.newbie import new
from modules.ping import ping
from modules.rc import rc
from modules.server import ser
from modules.user import Username
from modules.userp import Userp
from modules.wiki import wiki
2020-08-12 16:01:34 +00:00
def findcommand(str1, group=0):
2020-08-07 06:19:34 +00:00
print(group)
2020-08-12 16:01:34 +00:00
str1 = re.sub(r'^', '~', str1)
2020-08-07 06:19:34 +00:00
try:
2020-08-12 16:01:34 +00:00
q = re.match(r'^.*(: ~)(.*)', str1)
2020-08-07 06:19:34 +00:00
return q.group(2)
except Exception:
try:
2020-08-12 16:01:34 +00:00
q = re.match(r'^~(.*)', str1)
2020-08-07 06:19:34 +00:00
return q.group(1)
except Exception:
try:
2020-08-12 16:01:34 +00:00
q = re.match(r'^!(.*\-.*)', str1)
2020-08-07 06:19:34 +00:00
q = str.upper(q.group(1))
2020-08-20 10:30:08 +00:00
return 'bug ' + q
2020-08-07 06:19:34 +00:00
except Exception:
2020-08-11 15:49:14 +00:00
pass
2020-08-12 16:01:34 +00:00
async def command(text, group=0):
2020-08-07 06:19:34 +00:00
try:
2020-08-12 16:01:34 +00:00
result = findcommand(text, group)
2020-08-07 06:19:34 +00:00
c = result
try:
d = result.split(' ')
d = d[0]
except:
d = c
if d == 'echo':
2020-08-12 16:01:34 +00:00
echo = re.sub(r'^echo ', '', c)
2020-08-20 10:30:08 +00:00
return echo
2020-08-07 06:19:34 +00:00
if c == 'help':
2020-08-20 10:30:08 +00:00
return help()
2020-08-07 06:19:34 +00:00
elif d == 'paa':
2020-08-20 10:30:08 +00:00
return ''
2020-08-07 06:19:34 +00:00
elif d == 'mcv':
2020-08-20 10:30:08 +00:00
return await mcv()
2020-08-07 06:19:34 +00:00
elif d == 'mcbv':
2020-08-20 10:30:08 +00:00
return await mcbv()
2020-08-07 06:19:34 +00:00
elif d == 'mcdv':
2020-08-20 10:30:08 +00:00
return await mcdv()
2020-08-12 16:01:34 +00:00
elif d.find('新人') != -1 or d.find('new') != -1:
2020-08-20 10:30:08 +00:00
return await new()
2020-08-07 06:19:34 +00:00
elif d.find("wiki") != -1 or d.find("Wiki") != -1:
2020-08-20 10:30:08 +00:00
return await(wiki(c, group))
2020-08-12 16:01:34 +00:00
elif c.find("bug") != -1 or c.find("MC-") != -1 or c.find("BDS-") != -1 or c.find("MCPE-") != -1 or c.find(
"MCAPI-") != -1 or c.find("MCCE-") != -1 or c.find("MCD-") != -1 or c.find("MCL-") != -1 or c.find(
"REALMS-") != -1 or c.find("MCE-") != -1 or c.find("WEB-") != -1:
2020-08-20 10:30:08 +00:00
return await bugtracker(c)
2020-08-07 06:19:34 +00:00
elif d == 'server' or d == 'Server':
2020-08-20 10:30:08 +00:00
return await ser(c)
2020-08-07 06:19:34 +00:00
elif d.find("user") != -1 or d.find("User") != -1:
if c.find("-p") != -1:
f = re.sub(' -p', '', c)
print(f)
try:
2020-08-12 16:01:34 +00:00
z = re.sub(r'^User', 'user', f)
2020-08-07 06:19:34 +00:00
try:
2020-08-12 16:01:34 +00:00
g = re.match(r'^user ~(.*) (.*)', z)
2020-08-07 06:19:34 +00:00
h = g.group(1)
h2 = g.group(2)
2020-08-12 16:01:34 +00:00
h2 = re.sub('_', ' ', h2)
2020-08-07 06:19:34 +00:00
except Exception:
try:
2020-08-12 16:01:34 +00:00
g = re.match(r'^user-(.*?) (.*)', z)
h = 'minecraft-' + g.group(1)
2020-08-07 06:19:34 +00:00
h2 = g.group(2)
h2 = re.sub('_', ' ', h2)
except Exception:
try:
g = re.match(r'^user (.*?):(.*)', z)
h = 'minecraft-' + g.group(1)
h2 = g.group(2)
h2 = re.sub('_', ' ', h2)
except Exception:
try:
2020-08-12 16:01:34 +00:00
g = re.match(r'user (.*)', z)
2020-08-07 06:19:34 +00:00
h = 'minecraft'
h2 = g.group(1)
h2 = re.sub('_', ' ', h2)
except Exception as e:
print(str(e))
2020-08-12 16:01:34 +00:00
if checkuser(h, h2):
2020-08-15 06:35:23 +00:00
h2 = re.sub('User:','',h2)
2020-08-15 06:34:30 +00:00
print(h2)
2020-08-20 10:30:08 +00:00
return await Userp(h, h2) + "[[usn:" + h2 + "]]"
2020-08-07 06:19:34 +00:00
else:
2020-08-20 10:30:08 +00:00
return '没有找到此用户。'
2020-08-07 06:19:34 +00:00
except Exception as e:
print(str(e))
else:
2020-08-20 10:30:08 +00:00
return await Username(c)
2020-08-07 06:19:34 +00:00
elif d == 'rc':
2020-08-20 10:30:08 +00:00
return await rc()
2020-08-07 06:19:34 +00:00
elif d == 'ab':
2020-08-20 10:30:08 +00:00
return await ab()
2020-08-07 06:47:23 +00:00
elif d == 'ping':
2020-08-20 10:30:08 +00:00
return await ping()
elif d == 'credits':
return credits()
2020-08-07 06:19:34 +00:00
else:
pass
except:
2020-08-12 16:01:34 +00:00
pass