55 lines
No EOL
2.7 KiB
Python
55 lines
No EOL
2.7 KiB
Python
import re
|
||
from .m import m
|
||
from .wikilib import Wiki
|
||
import asyncio
|
||
async def wikim(str1):
|
||
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 == "cs" or w == "de" or w == "el" or w == "en" or w == "es" or w == "fr" or w == "hu" or w == "it" or w == "ja" or w == "ko" or w == "nl" or w == "pl" or w == "pt" or w == "ru" or w == "th" or w == "tr" or w == "uk" or w == "zh"):
|
||
return(await m(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 (Wiki(metaurl,s.group(2)))
|
||
except:
|
||
try:
|
||
d = re.sub(r':.*','',q.group(1))
|
||
x = re.sub(r'^'+d+':','',q.group(1))
|
||
w = d
|
||
if (w == "cs" or w == "de" or w == "el" or w == "en" or w == "es" or w == "fr" or w == "hu" or w == "it" or w == "ja" or w == "ko" or w == "nl" or w == "pl" or w == "pt" or w == "ru" or w == "th" or w == "tr" or w == "uk" or w == "zh"):
|
||
try:
|
||
metaurl = 'https://minecraft-' + w + '.gamepedia.com'
|
||
return (Wiki(metaurl, x))
|
||
except Exception as e:
|
||
return ('发生错误:' + str(e))
|
||
elif w == 'Wikipedia' or w == 'wikipedia':
|
||
return('暂不支持Wikipedia查询。')
|
||
elif w == 'Moegirl' or w == 'moegirl':
|
||
try:
|
||
metaurl = 'https://zh.moegirl.org'
|
||
return (Wiki(metaurl, x))
|
||
except Exception as e:
|
||
return ('发生错误:' + str(e))
|
||
else:
|
||
try:
|
||
metaurl = 'https://minecraft.gamepedia.com'
|
||
return (Wiki(metaurl, q.group(1)))
|
||
except Exception as e:
|
||
return ('发生错误:' + str(e))
|
||
except Exception:
|
||
return(await m('en',q.group(1))) |