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

111 lines
3.4 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-09-10 14:29:33 +00:00
ignorelist = [250500369, 676942198]
2020-08-12 16:01:34 +00:00
2020-09-10 14:35:23 +00:00
2020-08-30 08:26:54 +00:00
async def findcommand(str1, group=0):
2020-08-12 16:01:34 +00:00
str1 = re.sub(r'^', '~', str1)
2020-09-10 14:29:33 +00:00
q = re.match(r'^.*(: ~)(.*)', str1)
if q:
2020-08-07 06:19:34 +00:00
return q.group(2)
2020-09-10 14:29:33 +00:00
q = re.match(r'^~(.*)', str1)
if q:
return q.group(1)
q = re.match(r'^!(.*\-.*)', str1)
if q:
q = str.upper(q.group(1))
return 'bug ' + q
w = re.findall(r'\[\[(.*?)\]\]', str1)
w2 = re.findall(r'\{\{(.*?)\}\}', str1)
z = []
c = '\n'
if w:
2020-09-11 15:03:01 +00:00
from modules.wiki import im, imarc
2020-09-10 14:29:33 +00:00
if str(w) != '['']' or str(w) != '[]':
for x in w:
if x == '':
2020-08-30 08:26:54 +00:00
pass
2020-09-10 14:29:33 +00:00
else:
if group in ignorelist:
z.append(await imarc(x))
2020-08-30 08:26:54 +00:00
else:
2020-09-10 14:29:33 +00:00
z.append(await im(x))
if w2:
2020-09-11 15:03:01 +00:00
from modules.wiki import imt
2020-09-10 14:29:33 +00:00
if str(w2) != '['']' or str(w2) != '[]':
for x in w2:
if x == '':
2020-08-30 08:26:54 +00:00
pass
else:
2020-09-10 14:29:33 +00:00
if group in ignorelist:
pass
else:
z.append(await imt(x))
2020-09-10 14:37:13 +00:00
if str(z):
2020-09-10 14:29:33 +00:00
v = c.join(z)
2020-09-10 14:39:23 +00:00
if v != '':
2020-09-10 14:37:13 +00:00
return 'echo ' + v
2020-08-12 16:01:34 +00:00
async def command(text, group=0):
2020-09-10 14:29:33 +00:00
result = await findcommand(text, group)
c = result
2020-09-10 14:32:02 +00:00
if c != None:
try:
d = result.split(' ')
d = d[0]
except Exception:
d = c
if d == 'echo':
echo = re.sub(r'^echo ', '', c)
return echo
if c == 'help':
2020-09-11 15:03:01 +00:00
from modules.help import help
2020-09-10 14:32:02 +00:00
return help()
if d == 'pa':
return ''
if d == 'mcv':
2020-09-11 15:03:01 +00:00
from modules.mcv import mcv
2020-09-10 14:32:02 +00:00
return await mcv()
if d == 'mcbv':
2020-09-11 15:03:01 +00:00
from modules.mcv import mcbv
2020-09-10 14:32:02 +00:00
return await mcbv()
if d == 'mcdv':
2020-09-11 15:03:01 +00:00
from modules.mcv import mcdv
2020-09-10 14:32:02 +00:00
return await mcdv()
if d.find('新人') != -1 or d.find('new') != -1:
2020-09-11 15:03:01 +00:00
from modules.newbie import new
2020-09-10 14:32:02 +00:00
return await new()
if d.find("wiki") != -1 or d.find("Wiki") != -1:
2020-09-11 15:03:01 +00:00
from modules.wiki import wmg
2020-09-10 14:32:02 +00:00
return await(wmg(c, group))
if 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-09-11 15:03:01 +00:00
from modules.bug import bugtracker
2020-09-10 14:32:02 +00:00
return await bugtracker(c)
if d == 'server' or d == 'Server':
2020-09-11 15:03:01 +00:00
from modules.server import ser
2020-09-10 14:32:02 +00:00
return await ser(c)
if d.find("user") != -1 or d.find("User") != -1:
if c.find("-p") != -1:
2020-09-11 15:03:01 +00:00
from modules.userp import userpic
2020-09-10 14:32:02 +00:00
return await userpic(c)
else:
2020-09-11 15:03:01 +00:00
from modules.user import Username
2020-09-10 14:32:02 +00:00
return await Username(c)
if d == 'rc':
2020-09-11 15:03:01 +00:00
from modules.rc import rc
2020-09-10 14:32:02 +00:00
return await rc()
if d == 'ab':
2020-09-11 15:03:01 +00:00
from modules.ab import ab
2020-09-10 14:32:02 +00:00
return await ab()
if d == 'ping':
2020-09-11 15:03:01 +00:00
from modules.ping import ping
2020-09-10 14:32:02 +00:00
return await ping()
if d == 'credits':
2020-09-11 15:03:01 +00:00
from modules.help import credits
2020-09-10 14:32:02 +00:00
return credits()
2020-09-10 14:35:23 +00:00
else:
pass