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/mcvbot.py

56 lines
2.3 KiB
Python
Raw Normal View History

2020-07-27 15:00:01 +00:00
from mirai import Mirai, Group, MessageChain, Member, Plain, At, Source, Image, Friend
qq = 2052142661 # 字段 qq 的值
authKey = '1145141919810' # 字段 authKey 的值
mirai_api_http_locate = 'localhost:11919/ws' # httpapi所在主机的地址端口,如果 setting.yml 文件里字段 "enableWebsocket" 的值为 "true" 则需要将 "/" 换成 "/ws", 否则将接收不到消息.
app = Mirai(f"mirai://{mirai_api_http_locate}?authKey={authKey}&qq={qq}",websocket=True)
@app.subroutine
async def ver(app: Mirai):
2020-07-30 14:44:17 +00:00
from mcvrss import mcvrss
for qqgroup in mcvrss():
try:
await app.sendGroupMessage(int(qqgroup),[Plain('已开启检测游戏版本。')])
except Exception as e:
print(str(e))
2020-07-27 15:00:01 +00:00
from mcversion import mcversion
import time
import requests
import json
url = 'http://launchermeta.mojang.com/mc/game/version_manifest.json'
while True:
2020-07-27 15:14:33 +00:00
try:
verlist = mcversion()
version_manifest = requests.get(url)
file = json.loads(version_manifest.text)
release = file['latest']['release']
snapshot = file['latest']['snapshot']
if release in verlist:
pass
else:
2020-07-30 14:44:17 +00:00
for qqgroup in mcvrss():
try:
await app.sendGroupMessage(int(qqgroup),[Plain('启动器已更新'+file['latest']['release']+'正式版。')])
except Exception as e:
print(str(e))
2020-07-27 15:14:33 +00:00
addversion = open('mcversion.txt','a')
addversion.write('\n'+release)
addversion.close()
if snapshot in verlist:
pass
else:
2020-07-30 14:44:17 +00:00
for qqgroup in mcvrss():
try:
await app.sendGroupMessage(int(qqgroup),[Plain('启动器已更新'+file['latest']['snapshot']+'快照。')])
except Exception as e:
print(str(e))
2020-07-27 15:14:33 +00:00
addversion = open('mcversion.txt','a')
addversion.write('\n'+snapshot)
addversion.close()
2020-07-30 14:44:17 +00:00
print('ping')
2020-07-27 15:14:33 +00:00
time.sleep(10)
except Exception as e:
print(str(e))
2020-07-27 15:15:06 +00:00
time.sleep(5)
2020-07-27 15:04:18 +00:00
if __name__ == "__main__":
app.run()