summaryrefslogtreecommitdiff
path: root/ATRIbot/plugins/mojang.py
diff options
context:
space:
mode:
authorKyomotoi <[email protected]>2020-07-17 21:36:55 +0800
committerKyomotoi <[email protected]>2020-07-17 21:36:55 +0800
commit77514e99f0308ed90dc031810f71c67771971878 (patch)
tree1611339c44a607dc313c11500c5b0284431fb623 /ATRIbot/plugins/mojang.py
parent0efc5d2b0f3d7395715c30bd453d0c4a78d6101d (diff)
downloadATRI-77514e99f0308ed90dc031810f71c67771971878.tar.gz
ATRI-77514e99f0308ed90dc031810f71c67771971878.tar.bz2
ATRI-77514e99f0308ed90dc031810f71c67771971878.zip
[FIX]
Diffstat (limited to 'ATRIbot/plugins/mojang.py')
-rw-r--r--ATRIbot/plugins/mojang.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/ATRIbot/plugins/mojang.py b/ATRIbot/plugins/mojang.py
new file mode 100644
index 0000000..f134e90
--- /dev/null
+++ b/ATRIbot/plugins/mojang.py
@@ -0,0 +1,59 @@
+import json
+import requests
+from mcstatus import MinecraftServer
+from nonebot import on_command, CommandSession
+
+
+@on_command('mc_server_status', aliases=['服务器状态查询'], only_to_me=False)
+async def _(session: CommandSession):
+ ip = session.current_arg.strip()
+ if not ip:
+ ip = session.get('server', prompt='请告诉吾辈服务器ip,或输入服务器名(如需添加请联系作者)')
+
+ if ip == '南外手艺':
+ ip = str('mc.nflsedition.com:26164')
+
+ elif ip == 'hypixel':
+ ip = str('mc.hypixel.net')
+
+ elif ip == 'shotbow':
+ ip = str('us.shotbow.net')
+
+ elif ip == 'potterworld':
+ ip = str('potterworldmc.com')
+
+ else:
+ pass
+
+ server = MinecraftServer.lookup(ip)
+ status = server.status()
+ await session.send(f'IP:{ip}\nPlayers: {0}\nms: {1}'.format(status.players.online, status.latency))
+
+
+@on_command('check_mc_id', aliases=['mc正版查询', 'MC正版查询'], only_to_me=False)
+async def check_mc_id(session: CommandSession):
+ player = session.current_arg.strip()
+ if not player:
+ player = session.get('player', prompt='请告诉吾辈需要查询的id')
+
+ url = f'https://api.mojang.com/users/profiles/minecraft/{player}'
+ print(url)
+
+ try:
+ response = requests.request("GET", url)
+
+ try:
+ html = response.text
+ ms = json.loads(html)
+
+ name = ms["name"]
+ uuid = ms["id"]
+
+ await session.send(f'status: success!\nPlayer: {name}\nuuid: {uuid}\nNamemc: https://mine.ly/{name}.1')
+
+ except:
+ await session.send(f'{player}可能为非正版玩家,无法查询到其信息')
+
+ except:
+ print('error')
+ await session.send('mojang似乎炸了...等一会吧')