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/wikim/__init__.py
2020-06-13 20:43:43 +08:00

55 lines
No EOL
2.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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)))