2.0(?
This commit is contained in:
parent
2ce44ade5c
commit
e87b2546b2
27 changed files with 419 additions and 451 deletions
149
CommandGen.py
Normal file
149
CommandGen.py
Normal file
|
@ -0,0 +1,149 @@
|
|||
import re
|
||||
import string
|
||||
from blacklist import blacklist
|
||||
from mcv import mcv,mcbv,mcdv
|
||||
from ab import ab
|
||||
from bug import bug
|
||||
from newbie import new
|
||||
from rc import rc
|
||||
from server import ser
|
||||
from user import Username
|
||||
from userp import Userp
|
||||
from wiki import wiki,im,imt,imarc
|
||||
from help import help
|
||||
from checkuser import checkuser
|
||||
async def findcommand(str1,group=0):
|
||||
print(group)
|
||||
str1 = re.sub(r'^~','~',str1)
|
||||
try:
|
||||
q = re.match(r'^.*(: ~)(.*)',str1)
|
||||
return q.group(2)
|
||||
except Exception:
|
||||
try:
|
||||
q = re.match(r'^~(.*)',str1)
|
||||
return q.group(1)
|
||||
except Exception:
|
||||
try:
|
||||
q = re.match(r'^!(.*\-.*)',str1)
|
||||
q = str.upper(q.group(1))
|
||||
return ('bug '+q)
|
||||
except Exception:
|
||||
try:
|
||||
w = re.findall(r'\[\[(.*?)\]\]',str1)
|
||||
w2 = re.findall(r'\{\{(.*?)\}\}',str1)
|
||||
print(str(w),str(w2))
|
||||
z = []
|
||||
c = '\n'
|
||||
try:
|
||||
for x in w:
|
||||
if group == 250500369 or group == 676942198:
|
||||
if x == '':
|
||||
pass
|
||||
else:
|
||||
z.append(await imarc(x))
|
||||
else:
|
||||
if x == '':
|
||||
pass
|
||||
else:
|
||||
z.append(await im(x))
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
if str(w2) == '['']' or str(w2) == '[]':
|
||||
pass
|
||||
else:
|
||||
for x in w2:
|
||||
if group == 250500369 or group == 676942198:
|
||||
pass
|
||||
else:
|
||||
if x == '':
|
||||
pass
|
||||
else:
|
||||
z.append(await imt(x))
|
||||
except:
|
||||
pass
|
||||
if str(z) =='['']['']' or str(z) == '[][]' or str(z) == '[]':
|
||||
pass
|
||||
else:
|
||||
v = c.join(z)
|
||||
return('echo '+v)
|
||||
except Exception:
|
||||
pass
|
||||
async def command(text,group=0):
|
||||
try:
|
||||
result = await findcommand(text,group)
|
||||
c = result
|
||||
try:
|
||||
d = result.split(' ')
|
||||
d = d[0]
|
||||
except:
|
||||
d = c
|
||||
if d == 'echo':
|
||||
echo = re.sub(r'^echo ','',c)
|
||||
return(echo)
|
||||
if c == 'help':
|
||||
return(await help())
|
||||
elif d == 'paa':
|
||||
return('爬')
|
||||
elif d == 'mcv':
|
||||
return(await mcv())
|
||||
elif d == 'mcbv':
|
||||
return(await mcbv())
|
||||
elif d == 'mcdv':
|
||||
return(await mcdv())
|
||||
elif d.find('新人')!= -1 or d.find('new')!=-1:
|
||||
return (await new())
|
||||
elif d.find("wiki") != -1 or d.find("Wiki") != -1:
|
||||
return(await(wiki(c,group)))
|
||||
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:
|
||||
return(await bugtracker(c))
|
||||
elif d == 'server' or d == 'Server':
|
||||
return(await ser(c))
|
||||
elif d.find("user") != -1 or d.find("User") != -1:
|
||||
if c.find("-p") != -1:
|
||||
f = re.sub(' -p', '', c)
|
||||
print(f)
|
||||
try:
|
||||
z = re.sub(r'^User','user',f)
|
||||
try:
|
||||
g = re.match(r'^user ~(.*) (.*)',z)
|
||||
h = g.group(1)
|
||||
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:
|
||||
g = re.match(r'^user (.*?):(.*)', z)
|
||||
h = 'minecraft-' + g.group(1)
|
||||
h2 = g.group(2)
|
||||
h2 = re.sub('_', ' ', h2)
|
||||
except Exception:
|
||||
try:
|
||||
g = re.match(r'user (.*)',z)
|
||||
h = 'minecraft'
|
||||
h2 = g.group(1)
|
||||
h2 = re.sub('_', ' ', h2)
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
if checkuser(h,h2):
|
||||
return(await Userp(h,h2)+"[[usn:"+h2+"]]")
|
||||
else:
|
||||
return ('没有找到此用户。')
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
|
||||
else:
|
||||
return(await Username(c))
|
||||
elif d == 'rc':
|
||||
return(await rc())
|
||||
elif d == 'ab':
|
||||
return(await ab())
|
||||
else:
|
||||
pass
|
||||
except:
|
||||
pass
|
56
MessageGen.py
Normal file
56
MessageGen.py
Normal file
|
@ -0,0 +1,56 @@
|
|||
from graia.application.message.elements.internal import Plain,At,Image,UploadMethods,Quote
|
||||
from graia.application import GraiaMiraiApplication, Session
|
||||
from graia.application.message.chain import MessageChain
|
||||
from graia.application.event.messages import TempMessage
|
||||
from os.path import abspath
|
||||
from CommandGen import command
|
||||
import re
|
||||
async def gen(app, message, friend):
|
||||
run = await command(message.asDisplay())
|
||||
print(run)
|
||||
if run != None:
|
||||
if run.find('[[usn:') != -1:
|
||||
user = re.sub(r'.*\[\[usn:','',run)
|
||||
user = re.sub(r'\]\]','',user)
|
||||
msg = re.sub(r'\[\[.*\]\]','',run)
|
||||
await app.sendFriendMessage(friend,MessageChain.create(\
|
||||
[Plain(msg),\
|
||||
Image.fromLocalFile(filepath=abspath(f"./assests/usercard/{user}.png"),method=UploadMethods.Friend)]).asSendable())
|
||||
else:
|
||||
await app.sendFriendMessage(friend,MessageChain.create(\
|
||||
[Plain(run)]).asSendable())
|
||||
async def geng(app, message, group, member):
|
||||
run = await command(message.asDisplay(),group.id)
|
||||
print(run)
|
||||
if run != None:
|
||||
if run.find('[[usn:') != -1:
|
||||
user = re.sub(r'.*\[\[usn:','',run)
|
||||
user = re.sub(r'\]\]','',user)
|
||||
msg = re.sub(r'\[\[.*\]\]','',run)
|
||||
await app.sendGroupMessage(group,MessageChain.create(\
|
||||
[Plain(msg),\
|
||||
Image.fromLocalFile(filepath=abspath(f"./assests/usercard/{user}.png"),method=UploadMethods.Group)]).asSendable())
|
||||
else:
|
||||
await app.sendGroupMessage(group,MessageChain.create(\
|
||||
[Plain(run)]).asSendable())
|
||||
async def gent(app, message, group, member):
|
||||
run = await command(message.asDisplay())
|
||||
print(run)
|
||||
if run != None:
|
||||
if run.find('[[usn:') != -1:
|
||||
user = re.sub(r'.*\[\[usn:','',run)
|
||||
user = re.sub(r'\]\]','',user)
|
||||
msg = re.sub(r'\[\[.*\]\]','',run)
|
||||
await app.sendTempMessage(group=group,target=member,message=MessageChain.create(\
|
||||
[Plain(msg),\
|
||||
Image.fromLocalFile(filepath=abspath(f"./assests/usercard/{user}.png"),method=UploadMethods.Temp)]).asSendable())
|
||||
else:
|
||||
await app.sendTempMessage(group=group,target=member,message=MessageChain.create(\
|
||||
[Plain(run)]).asSendable())
|
||||
|
||||
|
||||
"""
|
||||
await app.sendGroupMessage(group,MessageChain.create(\
|
||||
[At(member.id),Plain(msg),\
|
||||
Image.fromLocalFile(filepath=abspath("./assests/usercard/Lightyzhh.png"),method=UploadMethods.Group)]).asSendable())
|
||||
"""
|
223
bot2.py
223
bot2.py
|
@ -1,215 +1,36 @@
|
|||
from graia.broadcast import Broadcast
|
||||
import asyncio
|
||||
from graia.application.message.elements.internal import Plain,At,Image,UploadMethods,Quote
|
||||
from graia.application import GraiaMiraiApplication, Session
|
||||
from graia.application.message.chain import MessageChain
|
||||
import asyncio
|
||||
|
||||
from graia.application.message.elements.internal import Plain
|
||||
from graia.application.group import Group,Member
|
||||
from graia.application.friend import Friend
|
||||
from graia.application.group import Group
|
||||
|
||||
from command import command
|
||||
from mcv import mcv
|
||||
from wikim import wikim
|
||||
from bug import bugtracker
|
||||
from user import Username
|
||||
import re
|
||||
from userp import Userp
|
||||
from pathexist import pathexist,pathexist2
|
||||
import urllib
|
||||
from server import ser
|
||||
from wikil import im
|
||||
from rc import rc
|
||||
from ab import ab
|
||||
from help import help
|
||||
from newbie import new
|
||||
from mcbv import mcbv
|
||||
from mcdv import mcdv
|
||||
from checkuser import checkuser
|
||||
import mcvrss
|
||||
|
||||
from graia.application.event.messages import TempMessage
|
||||
from graia.broadcast import Broadcast
|
||||
from os.path import abspath
|
||||
from MessageGen import gen,geng,gent
|
||||
loop = asyncio.get_event_loop()
|
||||
|
||||
bcc = Broadcast(loop=loop)
|
||||
bcc = Broadcast(loop=loop,debug_flag=True)
|
||||
app = GraiaMiraiApplication(
|
||||
broadcast=bcc,
|
||||
connect_info=Session(
|
||||
host="http://localhost:11919/ws", # 填入 httpapi 服务运行的地址
|
||||
authKey='1145141919810', # 填入 authKey
|
||||
account=2052142661, # 你的机器人的 qq 号
|
||||
host="http://localhost:11451", # 填入 httpapi 服务运行的地址
|
||||
authKey=41919810, # 填入 authKey
|
||||
account=2926887640, # 你的机器人的 qq 号
|
||||
websocket=True # Graia 已经可以根据所配置的消息接收的方式来保证消息接收部分的正常运作.
|
||||
)
|
||||
)
|
||||
|
||||
@bcc.receiver("GroupMessage")
|
||||
async def msg(app: GraiaMiraiApplication, group: Group, message: MessageChain):
|
||||
try:
|
||||
print (await command(message.asDisplay(),str(member.id),str(group.id)))
|
||||
c = await command(message.asDisplay(),str(member.id),str(group.id))
|
||||
try:
|
||||
d = c.split(' ')
|
||||
d = d[0]
|
||||
except:
|
||||
d = c
|
||||
print(d)
|
||||
if d == 'echo':
|
||||
echo = re.sub(r'^echo ','',c)
|
||||
await app.sendGroupMessage(group, MessageChain.create([Plain(echo)]))
|
||||
elif d == 'paa':
|
||||
await app.sendGroupMessage(group, MessageChain.create([At(member.id),Plain('爬')]))
|
||||
elif d == 'help':
|
||||
await app.sendGroupMessage(group, MessageChain.create([Plain((await help()))]))
|
||||
elif d == 'mcv':
|
||||
await app.sendGroupMessage(group, MessageChain.create([Plain((await mcv()))]))
|
||||
elif d == 'mcbv':
|
||||
await app.sendGroupMessage(group, MessageChain.create([Plain((await mcbv()))]))
|
||||
elif d == 'mcdv':
|
||||
await app.sendGroupMessage(group, MessageChain.create([Plain((await mcdv()))]))
|
||||
elif d.find('新人')!= -1 or d.find('new')!=-1:
|
||||
await app.sendGroupMessage(group, MessageChain.create([Plain((await new()))]))
|
||||
elif d.find('xrrrlei')!= -1:
|
||||
await app.sendGroupMessage(group, MessageChain.create([Plain((await new()))]))
|
||||
elif d.find("wiki") != -1 or d.find("Wiki") != -1:
|
||||
await app.sendGroupMessage(group, MessageChain.create([Plain('⏳')]))
|
||||
await app.sendGroupMessage(group, MessageChain.create([Plain((await wikim(c)))]))
|
||||
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:
|
||||
await app.sendGroupMessage(group, MessageChain.create([Plain('⏳')]))
|
||||
await app.sendGroupMessage(group, MessageChain.create([Plain((await bugtracker(c)))]))
|
||||
elif d == 'server' or d == 'Server':
|
||||
await app.sendGroupMessage(group,MessageChain.create([plain((await ser(c)))]))
|
||||
elif d.find("user") != -1 or d.find("User") != -1:
|
||||
if c.find("-p") != -1:
|
||||
f = re.sub(' -p', '', c)
|
||||
print(f)
|
||||
try:
|
||||
z = re.sub(r'^User','user',f)
|
||||
try:
|
||||
g = re.match(r'^user ~(.*) (.*)',z)
|
||||
h = g.group(1)
|
||||
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:
|
||||
g = re.match(r'^user (.*?):(.*)', z)
|
||||
h = 'minecraft-' + g.group(1)
|
||||
h2 = g.group(2)
|
||||
h2 = re.sub('_', ' ', h2)
|
||||
except Exception:
|
||||
try:
|
||||
g = re.match(r'user (.*)',z)
|
||||
h = 'minecraft'
|
||||
h2 = g.group(1)
|
||||
h2 = re.sub('_', ' ', h2)
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
if checkuser(h,h2):
|
||||
if pathexist(h):
|
||||
await app.sendGroupMessage(group,MessageChain.create([plain(Userp(h,h2)),Image.fromFileSystem("/home/wdljt/oasisakari/bot/assests/usercard/"+h2+".png")]))
|
||||
else:
|
||||
await app.sendGroupMessage(group,MessageChain.create([plain('检测到此次为第一次访问该Wiki,下载资源可能会耗费一定的时间,请耐心等待。')]))
|
||||
await app.sendGroupMessage(group,MessageChain.create([plain(Userp(h,h2)),Image.fromFileSystem("/home/wdljt/oasisakari/bot/assests/usercard/"+h2+".png")]))
|
||||
else:
|
||||
await app.sendGroupMessage(group,MessageChain.create([plain('没有找到此用户。')]))
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
|
||||
else:
|
||||
await app.sendGroupMessage(group,MessageChain.create([plain((await Username(c)))]))
|
||||
elif d == 'rc':
|
||||
await app.sendGroupMessage(group,MessageChain.create([plain((await rc()))]))
|
||||
elif d == 'ab':
|
||||
await app.sendGroupMessage(group,MessageChain.create([plain((await ab()))]))
|
||||
if c == 'rss add mcv':
|
||||
await app.sendGroupMessage(group,MessageChain.create([plain((mcvrss.mcvrssa(str(group.id))))]))
|
||||
if c == 'rss remove mcv':
|
||||
await app.sendGroupMessage(group,MessageChain.create([plain((mcvrss.mcvrssr(str(group.id))))]))
|
||||
else:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
async def group_message_handler(app: GraiaMiraiApplication, message: MessageChain, group: Group, member:Member):
|
||||
print(message)
|
||||
await geng(app,message,group,member)
|
||||
@bcc.receiver("FriendMessage")
|
||||
async def msg(app: GraiaMiraiApplication, friend: Friend, message: MessageChain):
|
||||
try:
|
||||
print (await command(message.asDisplay(),'0'))
|
||||
c = await command(message.asDisplay(),'0')
|
||||
try:
|
||||
d = c.split(' ')
|
||||
d = d[0]
|
||||
except:
|
||||
d = c
|
||||
print(d)
|
||||
if d == 'echo':
|
||||
echo = re.sub(r'^echo ','',c)
|
||||
await app.sendFriendMessage(friend,MessageChain.create([plain(echo)]))
|
||||
if d == 'help':
|
||||
await app.sendFriendMessage(friend,MessageChain.create([plain((await help()))]))
|
||||
if d == 'mcv':
|
||||
await app.sendFriendMessage(friend,MessageChain.create([plain((await mcv()))]))
|
||||
elif d == 'mcbv':
|
||||
await app.sendFriendMessage(friend,MessageChain.create([plain((await mcbv()))]))
|
||||
elif d == 'mcdv':
|
||||
await app.sendFriendMessage(friend,MessageChain.create([plain((await mcdv()))]))
|
||||
elif c.find("wiki") !=-1 or c.find("Wiki") !=-1:
|
||||
await app.sendFriendMessage(friend,MessageChain.create([plain((await wikim(c)))]))
|
||||
elif d.find('新人')!= -1 or d.find('new')!=-1:
|
||||
await app.sendFriendMessage(friend,MessageChain.create([plain((await new()))]))
|
||||
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:
|
||||
await app.sendFriendMessage(friend,MessageChain.create([plain((await bugtracker(c)))]))
|
||||
elif d == 'server' or d == 'Server':
|
||||
await app.sendFriendMessage(friend,MessageChain.create([plain((await ser(c)))]))
|
||||
elif d.find("user") != -1 or d.find("User") != -1:
|
||||
if c.find("-p") != -1:
|
||||
f = re.sub(' -p', '', c)
|
||||
print(f)
|
||||
try:
|
||||
z = re.sub(r'^User','user',f)
|
||||
try:
|
||||
g = re.match(r'^user ~(.*) (.*)',z)
|
||||
h = g.group(1)
|
||||
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:
|
||||
g = re.match(r'^user (.*?):(.*)', z)
|
||||
h = 'minecraft-' + g.group(1)
|
||||
h2 = g.group(2)
|
||||
h2 = re.sub('_', ' ', h2)
|
||||
except Exception:
|
||||
try:
|
||||
g = re.match(r'user (.*)',z)
|
||||
h = 'minecraft'
|
||||
h2 = g.group(1)
|
||||
h2 = re.sub('_', ' ', h2)
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
if checkuser(h,h2):
|
||||
if pathexist(h):
|
||||
await app.sendFriendMessage(friend,MessageChain.create([plain(Userp(h,h2)),Image.fromFileSystem("/home/wdljt/oasisakari/bot/assests/usercard/"+h2+".png")]))
|
||||
else:
|
||||
await app.sendFriendMessage(friend,MessageChain.create([plain('检测到此次为第一次访问该Wiki,下载资源可能会耗费一定的时间,请耐心等待。')]))
|
||||
await app.sendFriendMessage(friend,MessageChain.create([plain(Userp(h,h2)),Image.fromFileSystem("/home/wdljt/oasisakari/bot/assests/usercard/"+h2+".png")]))
|
||||
else:
|
||||
await app.sendFriendMessage(friend,MessageChain.create([plain('没有找到此用户。')]))
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
|
||||
else:
|
||||
await app.sendFriendMessage(friend,MessageChain.create([plain((await Username(c)))]))
|
||||
elif d == 'rc':
|
||||
await app.sendFriendMessage(friend,MessageChain.create([plain((await rc()))]))
|
||||
elif d == 'ab':
|
||||
await app.sendFriendMessage(friend,MessageChain.create([plain((await ab()))]))
|
||||
except Exception:
|
||||
pass
|
||||
app.launch_blocking()
|
||||
async def friend_message_handler(app: GraiaMiraiApplication, message: MessageChain, friend:Friend):
|
||||
print(message)
|
||||
await gen(app,message,friend)
|
||||
@bcc.receiver("TempMessage")
|
||||
async def temp_message_handler(app: GraiaMiraiApplication, message: MessageChain, group: Group, member: Member):
|
||||
print(group.id, member.id, message.asDisplay())
|
||||
await gent(app,message,group,member)
|
||||
app.launch_blocking()
|
66
command.py
66
command.py
|
@ -1,66 +0,0 @@
|
|||
import re
|
||||
import string
|
||||
from blacklist import blacklist
|
||||
from wikil import im,imarc,imt
|
||||
async def command(str1,member,group = '0'):
|
||||
str1 = re.sub(r'^~','~',str1)
|
||||
try:
|
||||
q = re.match(r'^.*(: ~)(.*)',str1)
|
||||
return q.group(2)
|
||||
except Exception:
|
||||
try:
|
||||
q = re.match(r'^~(.*)',str1)
|
||||
if q.group(1).find('爬') != -1:
|
||||
if member in blacklist():
|
||||
return ('paa')
|
||||
else:
|
||||
return q.group(1)
|
||||
else:
|
||||
return q.group(1)
|
||||
except Exception:
|
||||
try:
|
||||
q = re.match(r'^!(.*\-.*)',str1)
|
||||
q = str.upper(q.group(1))
|
||||
return ('bug '+q)
|
||||
except Exception:
|
||||
try:
|
||||
w = re.findall(r'\[\[(.*?)\]\]',str1)
|
||||
w2 = re.findall(r'\{\{(.*?)\}\}',str1)
|
||||
print(str(w),str(w2))
|
||||
z = []
|
||||
c = '\n'
|
||||
try:
|
||||
for x in w:
|
||||
if group == '250500369' or group == '676942198':
|
||||
if x == '':
|
||||
pass
|
||||
else:
|
||||
z.append(await imarc(x))
|
||||
else:
|
||||
if x == '':
|
||||
pass
|
||||
else:
|
||||
z.append(await im(x))
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
if str(w2) == '['']' or str(w2) == '[]':
|
||||
pass
|
||||
else:
|
||||
for x in w2:
|
||||
if group == '250500369' or group == '676942198':
|
||||
pass
|
||||
else:
|
||||
if x == '':
|
||||
pass
|
||||
else:
|
||||
z.append(await imt(x))
|
||||
except:
|
||||
pass
|
||||
if str(z) =='['']['']' or str(z) == '[][]' or str(z) == '[]':
|
||||
pass
|
||||
else:
|
||||
v = c.join(z)
|
||||
return('echo '+v)
|
||||
except Exception:
|
||||
pass
|
32
help.py
32
help.py
|
@ -1,10 +1,24 @@
|
|||
path = '~'
|
||||
async def help():
|
||||
return('''~ab
|
||||
~bug -h
|
||||
~mcv
|
||||
~rc
|
||||
~server -h
|
||||
~user -h
|
||||
~wiki -h
|
||||
!
|
||||
[[]]''')
|
||||
return(f'''{path}ab - 查看Minecraft Wiki过滤器日志。
|
||||
{path}bug -h
|
||||
{path}mcv - 获取当前Minecraft Java版最新版本。
|
||||
{path}mcbv - 获取当前Minecraft基岩版最新版本。
|
||||
{path}mcdv - 获取当前Minecraft Dungeons最新版本。
|
||||
{path}rc - 查看Minecraft Wiki最近更改。
|
||||
{path}server -h
|
||||
{path}user -h
|
||||
{path}wiki -h
|
||||
! - 用于快捷查bug,如!mc-4
|
||||
[[]] - 用于快捷查wiki,如[[海晶石]]
|
||||
{{{{}}}} - 用于快捷查wiki模板,如{{{{v}}}}''')
|
||||
async def wikihelp():
|
||||
return(f'''{path}wiki ~<site> <pagename> - 从指定Gamepedia站点中输出条目链接。
|
||||
{path}wiki <lang>:<pagename>, {path}wiki-<lang> <pagename> - 从指定语言中的Minecraft Wiki中输出条目链接。
|
||||
{path}wiki <pagename> - 从Minecraft Wiki(英文)中输出条目链接。''')
|
||||
async def userhelp():
|
||||
return(f'''{path}user ~<site> <pagename> - 从指定Gamepedia站点中输出用户信息。
|
||||
{path}user <lang>:<pagename>, {path}user-<lang> <pagename> - 从指定语言中的Minecraft Wiki中输出用户信息。
|
||||
{path}user <pagename> - 从Minecraft Wiki(英文)中输出用户信息。
|
||||
[-r] - 输出详细信息。
|
||||
[-p] - 输出一张用户信息的图片(不包含用户组)。''')
|
|
@ -1,22 +0,0 @@
|
|||
import json
|
||||
import requests
|
||||
import re
|
||||
async def mcbv():
|
||||
url = 'https://bugs.mojang.com/rest/api/2/project/10200/versions'
|
||||
q = requests.get(url)
|
||||
w = json.loads(q.text)
|
||||
f = []
|
||||
z = []
|
||||
for x in w[:]:
|
||||
if x['archived'] == False:
|
||||
try:
|
||||
e = re.match(r'(.*)Beta$',x['name'])
|
||||
f.append(e.group(1))
|
||||
except Exception:
|
||||
z.append(x['name'])
|
||||
else:
|
||||
pass
|
||||
h = '| '
|
||||
d = h.join(f)
|
||||
u = h.join(z)
|
||||
return('Beta: '+str(d)+'\nRelease: '+u+'\n(数据来源于MoJira,可能会比官方发布要早一段时间。信息仅供参考。)')
|
Binary file not shown.
|
@ -1,2 +0,0 @@
|
|||
from .mcbv import mcbv
|
||||
mcbv()
|
|
@ -1,14 +0,0 @@
|
|||
import json
|
||||
import requests
|
||||
import re
|
||||
async def mcdv():
|
||||
url = 'https://bugs.mojang.com/rest/api/2/project/11901/versions'
|
||||
q = requests.get(url)
|
||||
w = json.loads(q.text)
|
||||
f = []
|
||||
for x in w[:]:
|
||||
if x['archived'] == False:
|
||||
s = x['name']
|
||||
else:
|
||||
pass
|
||||
return('最新版:'+s+'\n(数据来源于MoJira,可能会比官方发布要早一段时间。信息仅供参考。)')
|
Binary file not shown.
|
@ -1,2 +0,0 @@
|
|||
from .mcdv import mcdv
|
||||
mcdv()
|
|
@ -1,7 +1,7 @@
|
|||
import requests
|
||||
import json
|
||||
import asyncio
|
||||
|
||||
import re
|
||||
async def mcv():
|
||||
url = 'http://launchermeta.mojang.com/mc/game/version_manifest.json'
|
||||
try:
|
||||
|
@ -9,4 +9,36 @@ async def mcv():
|
|||
file = json.loads(version_manifest.text)
|
||||
return("最新版:" + file['latest']['release'] + ",最新快照:" + file['latest']['snapshot'])
|
||||
except Exception:
|
||||
return("发生错误:土豆熟了。")
|
||||
return("发生错误:土豆熟了。")
|
||||
|
||||
async def mcbv():
|
||||
url = 'https://bugs.mojang.com/rest/api/2/project/10200/versions'
|
||||
q = requests.get(url)
|
||||
w = json.loads(q.text)
|
||||
f = []
|
||||
z = []
|
||||
for x in w[:]:
|
||||
if x['archived'] == False:
|
||||
try:
|
||||
e = re.match(r'(.*)Beta$',x['name'])
|
||||
f.append(e.group(1))
|
||||
except Exception:
|
||||
z.append(x['name'])
|
||||
else:
|
||||
pass
|
||||
h = '| '
|
||||
d = h.join(f)
|
||||
u = h.join(z)
|
||||
return('Beta: '+str(d)+'\nRelease: '+u+'\n(数据来源于MoJira,可能会比官方发布要早一段时间。信息仅供参考。)')
|
||||
|
||||
async def mcdv():
|
||||
url = 'https://bugs.mojang.com/rest/api/2/project/11901/versions'
|
||||
q = requests.get(url)
|
||||
w = json.loads(q.text)
|
||||
f = []
|
||||
for x in w[:]:
|
||||
if x['archived'] == False:
|
||||
s = x['name']
|
||||
else:
|
||||
pass
|
||||
return('最新版:'+s+'\n(数据来源于MoJira,可能会比官方发布要早一段时间。信息仅供参考。)')
|
Binary file not shown.
4
pbc.py
4
pbc.py
|
@ -10,7 +10,9 @@ from time import gmtime, strftime
|
|||
from urllib.parse import urlencode
|
||||
import aiohttp
|
||||
import os
|
||||
|
||||
from dotenv import find_dotenv,load_dotenv
|
||||
from os.path import abspath
|
||||
load_dotenv(find_dotenv(abspath('.env')))
|
||||
def hash_hmac(key, code, sha1):
|
||||
hmac_code = hmac.new(key.encode(), code.encode(), sha1)
|
||||
return base64.b64encode(hmac_code.digest()).decode('utf-8')
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
import re
|
||||
from .user import User1
|
||||
from .ruserlib import rUser1
|
||||
from help import userhelp
|
||||
async def Username(name):
|
||||
name = re.sub(r'^User', 'user', name)
|
||||
if name.find(" -h")!= -1:
|
||||
return ('''~user ~<site> <pagename> - 从指定Gamepedia站点中输出用户信息。
|
||||
~user <lang>:<pagename>, ~user-<lang> <pagename> - 从指定语言中的Minecraft Wiki中输出用户信息。
|
||||
~user <pagename> - 从Minecraft Wiki(英文)中输出用户信息。
|
||||
[-r] - 输出详细信息。
|
||||
[-p] - 输出一张用户信息的图片(不包含用户组)。''')
|
||||
return (await userhelp())
|
||||
elif name.find(" -r")!=-1:
|
||||
m = re.sub(r' -r', '', name)
|
||||
try:
|
||||
|
|
|
@ -7,7 +7,7 @@ from .gender import gender
|
|||
from .UTC8V import UTC8V
|
||||
import urllib
|
||||
|
||||
def Userp(path,Username):
|
||||
async def Userp(path,Username):
|
||||
try:
|
||||
q = re.sub('User:', '', Username)
|
||||
q = re.sub('_', ' ', q)
|
||||
|
|
127
wiki/__init__.py
Normal file
127
wiki/__init__.py
Normal file
|
@ -0,0 +1,127 @@
|
|||
import re
|
||||
from .wikilib import wiki1,wiki2
|
||||
import asyncio
|
||||
import traceback
|
||||
from interwikilist import iwlist,iwlink
|
||||
from help import wikihelp
|
||||
async def wiki(str1,group = 0):
|
||||
if str1.find(' -h')!=-1:
|
||||
return(await wikihelp())
|
||||
else:
|
||||
try:
|
||||
b = re.sub(r'^Wiki','wiki',str1)
|
||||
except:
|
||||
b = str1
|
||||
try:
|
||||
q = re.match(r'^wiki-(.*?) (.*)',b)
|
||||
w = q.group(1)
|
||||
print(w)
|
||||
if w in iwlist():
|
||||
return(await wiki2(q.group(1),q.group(2)))
|
||||
else:
|
||||
return('未知语言,请使用~wiki -h查看帮助。')
|
||||
except:
|
||||
q = re.match(r'^wiki (.*)',b)
|
||||
try:
|
||||
s = re.match(r'~(.*?) (.*)',q.group(1))
|
||||
metaurl = 'https://' + s.group(1) + '.gamepedia.com'
|
||||
return (await Wiki(metaurl,s.group(2)))
|
||||
except:
|
||||
try:
|
||||
if group == 250500369 or group == 676942198:
|
||||
x = q.group(1)
|
||||
metaurl = 'https://wiki.arcaea.cn/'
|
||||
return (await wiki1(metaurl, x))
|
||||
else:
|
||||
d = re.match(r'(.*?):(.*)',q.group(1))
|
||||
x = d.group(2)
|
||||
w = str.lower(d.group(1))
|
||||
if w in iwlist():
|
||||
try:
|
||||
metaurl = iwlink(w)
|
||||
return (await wiki1(metaurl, x))
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
return ('发生错误:' + str(e))
|
||||
elif w == 'Wikipedia' or w == 'wikipedia':
|
||||
return('暂不支持Wikipedia查询。')
|
||||
else:
|
||||
try:
|
||||
metaurl = 'https://minecraft.gamepedia.com'
|
||||
return (await wiki1(metaurl, x))
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
return ('发生错误:' + str(e))
|
||||
except Exception:
|
||||
return(await wiki2('en',q.group(1)))
|
||||
|
||||
|
||||
|
||||
from .wikitextlib import wi
|
||||
async def im(str1):
|
||||
try:
|
||||
pipe = re.match(r'(.*?)\|.*',str1)
|
||||
str1 = pipe.group(1)
|
||||
except Exception:
|
||||
str1 = str1
|
||||
str1 = re.sub(r'^:','',str1)
|
||||
try:
|
||||
d = re.match(r'(.*?):(.*)',str1)
|
||||
w = d.group(1)
|
||||
w = str.lower(w)
|
||||
if w in iwlist():
|
||||
c = iwlink(w)
|
||||
pagename = d.group(2)
|
||||
itw = 't'
|
||||
else:
|
||||
c = iwlink('zh')
|
||||
pagename = str1
|
||||
itw = 'f'
|
||||
except Exception:
|
||||
c = iwlink('zh')
|
||||
pagename = str1
|
||||
itw = 'f'
|
||||
w = '.'
|
||||
return(await wi(c,w,pagename,itw,ignoremessage='f'))
|
||||
|
||||
async def imarc(str1):
|
||||
try:
|
||||
pipe = re.match(r'(.*?)\|.*',str1)
|
||||
str1 = pipe.group(1)
|
||||
except Exception:
|
||||
str1 = str1
|
||||
str1 = re.sub(r'^:','',str1)
|
||||
c = 'https://wiki.arcaea.cn/'
|
||||
itw = 'f'
|
||||
w = '.'
|
||||
return(await wi(c,w,str1,itw,ignoremessage='t'))
|
||||
|
||||
async def imt(str1):
|
||||
try:
|
||||
pipe = re.match(r'(.*?)\|.*',str1)
|
||||
str1 = pipe.group(1)
|
||||
except Exception:
|
||||
str1 = str1
|
||||
str1 = re.sub(r'^:','',str1)
|
||||
try:
|
||||
d = re.match(r'(.*?):(.*)',str1)
|
||||
w = d.group(1)
|
||||
w = str.lower(w)
|
||||
if w in iwlist():
|
||||
c = iwlink(w)
|
||||
pagename = 'Template:'+d.group(2)
|
||||
itw = 't'
|
||||
else:
|
||||
c = iwlink('zh')
|
||||
pagename = 'Template:'+str1
|
||||
itw = 'f'
|
||||
except Exception:
|
||||
c = iwlink('zh')
|
||||
pagename = 'Template:'+str1
|
||||
itw = 'f'
|
||||
w = '.'
|
||||
return(await wi(c,w,pagename,itw,ignoremessage='f',template = 't'))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(asyncio.run(wiki('wiki Netherite')))
|
|
@ -4,7 +4,7 @@ import requests
|
|||
import urllib
|
||||
import traceback
|
||||
from interwikilist import iwlist,iwlink
|
||||
async def Wiki(path1,pagename):
|
||||
async def wiki1(path1,pagename):
|
||||
print(pagename)
|
||||
metaurl = path1 +'api.php?action=query&format=json&prop=info&inprop=url&redirects&titles=' + pagename
|
||||
print(metaurl)
|
||||
|
@ -83,7 +83,7 @@ async def Wiki(path1,pagename):
|
|||
async def wiki2(lang,str1):
|
||||
try:
|
||||
metaurl = iwlink(lang)
|
||||
return(await Wiki(metaurl,str1))
|
||||
return(await wiki1(metaurl,str1))
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
return (str(e))
|
|
@ -1,67 +0,0 @@
|
|||
import re
|
||||
import traceback
|
||||
from .wikitextlib import wi
|
||||
from interwikilist import iwlist,iwlink
|
||||
async def im(str1):
|
||||
try:
|
||||
pipe = re.match(r'(.*?)\|.*',str1)
|
||||
str1 = pipe.group(1)
|
||||
except Exception:
|
||||
str1 = str1
|
||||
str1 = re.sub(r'^:','',str1)
|
||||
try:
|
||||
d = re.match(r'(.*?):(.*)',str1)
|
||||
w = d.group(1)
|
||||
w = str.lower(w)
|
||||
if w in iwlist():
|
||||
c = iwlink(w)
|
||||
pagename = d.group(2)
|
||||
itw = 't'
|
||||
else:
|
||||
c = iwlink('zh')
|
||||
pagename = str1
|
||||
itw = 'f'
|
||||
except Exception:
|
||||
c = iwlink('zh')
|
||||
pagename = str1
|
||||
itw = 'f'
|
||||
w = '.'
|
||||
return(await wi(c,w,pagename,itw,ignoremessage='f'))
|
||||
|
||||
async def imarc(str1):
|
||||
try:
|
||||
pipe = re.match(r'(.*?)\|.*',str1)
|
||||
str1 = pipe.group(1)
|
||||
except Exception:
|
||||
str1 = str1
|
||||
str1 = re.sub(r'^:','',str1)
|
||||
c = 'wiki.arcaea.cn'
|
||||
itw = 'f'
|
||||
w = '.'
|
||||
return(await wi(c,w,str1,itw,ignoremessage='t'))
|
||||
|
||||
async def imt(str1):
|
||||
try:
|
||||
pipe = re.match(r'(.*?)\|.*',str1)
|
||||
str1 = pipe.group(1)
|
||||
except Exception:
|
||||
str1 = str1
|
||||
str1 = re.sub(r'^:','',str1)
|
||||
try:
|
||||
d = re.match(r'(.*?):(.*)',str1)
|
||||
w = d.group(1)
|
||||
w = str.lower(w)
|
||||
if w in iwlist():
|
||||
c = iwlink(w)
|
||||
pagename = 'Template:'+d.group(2)
|
||||
itw = 't'
|
||||
else:
|
||||
c = iwlink('zh')
|
||||
pagename = 'Template:'+str1
|
||||
itw = 'f'
|
||||
except Exception:
|
||||
c = iwlink('zh')
|
||||
pagename = 'Template:'+str1
|
||||
itw = 'f'
|
||||
w = '.'
|
||||
return(await wi(c,w,pagename,itw,ignoremessage='f',template = 't'))
|
Binary file not shown.
Binary file not shown.
|
@ -1,57 +0,0 @@
|
|||
import re
|
||||
from .wikilib import Wiki,wiki2
|
||||
import asyncio
|
||||
import traceback
|
||||
from interwikilist import iwlist,iwlink
|
||||
async def wikim(str1,group = 0):
|
||||
if str1.find(' -h')!=-1:
|
||||
return('''~wiki ~<site> <pagename> - 从指定Gamepedia站点中输出条目链接。
|
||||
~wiki <lang>:<pagename>, ~wiki-<lang> <pagename> - 从指定语言中的Minecraft Wiki中输出条目链接。
|
||||
~wiki <pagename> - 从Minecraft Wiki(英文)中输出条目链接。''')
|
||||
else:
|
||||
try:
|
||||
b = re.sub(r'^Wiki','wiki',str1)
|
||||
except:
|
||||
b = str1
|
||||
try:
|
||||
q = re.match(r'^wiki-(.*?) (.*)',b)
|
||||
w = q.group(1)
|
||||
print(w)
|
||||
if w in iwlist():
|
||||
return(await wiki2(q.group(1),q.group(2)))
|
||||
else:
|
||||
return('未知语言,请使用~wiki -h查看帮助。')
|
||||
except:
|
||||
q = re.match(r'^wiki (.*)',b)
|
||||
try:
|
||||
s = re.match(r'~(.*?) (.*)',q.group(1))
|
||||
metaurl = 'https://' + s.group(1) + '.gamepedia.com'
|
||||
return (await Wiki(metaurl,s.group(2)))
|
||||
except:
|
||||
try:
|
||||
if group == 250500369:
|
||||
x = q.group(1)
|
||||
metaurl = 'https://wiki.arcaea.cn'
|
||||
return (await Wiki(metaurl, x))
|
||||
else:
|
||||
d = re.match(r'(.*?):(.*)',q.group(1))
|
||||
x = d.group(2)
|
||||
w = str.lower(d.group(1))
|
||||
if w in iwlist():
|
||||
try:
|
||||
metaurl = iwlink(w)
|
||||
return (await Wiki(metaurl, x))
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
return ('发生错误:' + str(e))
|
||||
elif w == 'Wikipedia' or w == 'wikipedia':
|
||||
return('暂不支持Wikipedia查询。')
|
||||
else:
|
||||
try:
|
||||
metaurl = 'https://minecraft.gamepedia.com'
|
||||
return (await Wiki(metaurl, x))
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
return ('发生错误:' + str(e))
|
||||
except Exception:
|
||||
return(await wiki2('en',q.group(1)))
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in a new issue