2020-08-07 06:19:34 +00:00
|
|
|
|
import re
|
2020-08-12 16:01:34 +00:00
|
|
|
|
|
2020-09-19 06:21:06 +00:00
|
|
|
|
ignorelist = []
|
2020-08-12 16:01:34 +00:00
|
|
|
|
|
2020-09-19 06:21:06 +00:00
|
|
|
|
from commandlist import commandlist
|
|
|
|
|
|
|
|
|
|
clist = commandlist()
|
2020-09-10 14:35:23 +00:00
|
|
|
|
|
2020-09-24 14:09:02 +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
|
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':
|
2020-09-19 10:35:13 +00:00
|
|
|
|
echo = re.sub('echo ', '', c)
|
2020-09-19 06:21:06 +00:00
|
|
|
|
if echo != '':
|
|
|
|
|
return echo
|
|
|
|
|
if d in clist:
|
2020-09-19 10:30:27 +00:00
|
|
|
|
k = clist.get(d)
|
2020-09-23 05:21:34 +00:00
|
|
|
|
k1 = re.match(r'from (.*) import (.*)\|(.*)', k)
|
|
|
|
|
if k1:
|
2020-09-24 14:09:02 +00:00
|
|
|
|
cmd = eval(
|
|
|
|
|
f'__import__("modules.{k1.group(1)}", fromlist=["{k1.group(1)}"]).{k1.group(2)}().{k1.group(3)}')
|
2020-09-22 15:44:05 +00:00
|
|
|
|
if d == c:
|
|
|
|
|
return await cmd()
|
|
|
|
|
else:
|
2020-09-24 14:09:02 +00:00
|
|
|
|
c = re.sub(r'^'+d+' ','',c)
|
2020-09-22 15:44:05 +00:00
|
|
|
|
return await cmd(c)
|
|
|
|
|
else:
|
2020-09-23 05:21:34 +00:00
|
|
|
|
k2 = re.match(r'from (.*) import (.*)', k)
|
|
|
|
|
if k2:
|
|
|
|
|
cmd = eval(f'__import__("modules.{k2.group(1)}", fromlist=["{k2.group(1)}"]).{k2.group(2)}')
|
|
|
|
|
if d == c:
|
|
|
|
|
return await cmd()
|
|
|
|
|
else:
|
2020-09-24 14:09:02 +00:00
|
|
|
|
c = re.sub(r'^' + d + ' ', '', c)
|
2020-09-23 05:21:34 +00:00
|
|
|
|
return await cmd(c)
|
2020-09-22 15:44:05 +00:00
|
|
|
|
else:
|
2020-09-23 05:21:34 +00:00
|
|
|
|
a = __import__('modules.' + k, fromlist=[k])
|
|
|
|
|
if d == c:
|
|
|
|
|
return await a.main()
|
|
|
|
|
else:
|
2020-09-24 14:09:02 +00:00
|
|
|
|
c = re.sub(r'^' + d + ' ', '', c)
|
2020-09-23 05:21:34 +00:00
|
|
|
|
return await a.main(c)
|
2020-10-09 11:13:19 +00:00
|
|
|
|
|
2020-09-26 05:37:55 +00:00
|
|
|
|
|
2020-10-01 03:30:11 +00:00
|
|
|
|
async def ttext(text, group=0):
|
2020-11-06 09:37:53 +00:00
|
|
|
|
if text.find('[Webhook]') != -1:
|
|
|
|
|
pass
|
|
|
|
|
else:
|
|
|
|
|
w = re.findall(r'\[\[(.*?)\]\]', text, re.I)
|
|
|
|
|
w2 = re.findall(r'\{\{(.*?)\}\}', text, re.I)
|
|
|
|
|
z = []
|
|
|
|
|
c = '\n'
|
|
|
|
|
if w:
|
|
|
|
|
from modules.wiki import im
|
|
|
|
|
wi1 = []
|
|
|
|
|
if str(w) != '['']' or str(w) != '[]':
|
|
|
|
|
for x in w:
|
|
|
|
|
if x == '' or x in wi1:
|
|
|
|
|
pass
|
|
|
|
|
else:
|
|
|
|
|
wi1.append(x)
|
|
|
|
|
if wi1 != []:
|
|
|
|
|
z.append(await im(wi1))
|
|
|
|
|
if w2:
|
|
|
|
|
from modules.wiki import imt
|
|
|
|
|
wi2 = []
|
|
|
|
|
if str(w2) != '['']' or str(w2) != '[]':
|
|
|
|
|
for x in w2:
|
|
|
|
|
if x == '' or x in wi2:
|
|
|
|
|
pass
|
|
|
|
|
else:
|
|
|
|
|
wi2.append(x)
|
|
|
|
|
if wi2 != []:
|
|
|
|
|
z.append(await imt(wi2))
|
|
|
|
|
w3 = re.findall(r'(https://bugs.mojang.com/browse/.*?-\d*)', text)
|
|
|
|
|
for link in w3:
|
|
|
|
|
matchbug = re.match(r'https://bugs.mojang.com/browse/(.*?-\d*)',link)
|
|
|
|
|
if matchbug:
|
|
|
|
|
import modules.bug
|
|
|
|
|
z.append(await modules.bug.main(matchbug.group(1)))
|
|
|
|
|
if str(z):
|
|
|
|
|
v = c.join(z)
|
|
|
|
|
if v != '':
|
|
|
|
|
return v
|