diff --git a/.gitignore b/.gitignore index 65d5e2c..dce0c1f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,8 @@ config.toml .vs .vscode -__pycache__ \ No newline at end of file +<<<<<<< HEAD +.idea +======= +__pycache__ +>>>>>>> 51011ec401ee07fe7446b24fad680a629e12ff56 diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..359bb53 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml diff --git a/.idea/icalingua-python-bot.iml b/.idea/icalingua-python-bot.iml new file mode 100644 index 0000000..7c91e7f --- /dev/null +++ b/.idea/icalingua-python-bot.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..1260ee9 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..ecc691b --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/connect.py b/connect.py index d4bf782..1455675 100644 --- a/connect.py +++ b/connect.py @@ -191,7 +191,6 @@ async def add_message(data: Dict[str, Any]): sender_id = data['message']['senderId'] content = data['message']['content'] room_id = data['roomId'] - reply = ReplyMessage(id=data['message']['_id']) if not is_self: if data.get('message').get('content') == '/bot': @@ -209,7 +208,7 @@ async def add_message(data: Dict[str, Any]): # else: # message = Message(content=f"此服务器空无一人",room_id=data['roomId']) - message = Message(content=f"此服务器有 {status.players.online} 个玩家在线",reply_to=reply,room_id=data['roomId']) + message = Message(content=f"此服务器有 {status.players.online} 个玩家在线",room_id=data['roomId']) await sio.emit('sendMessage', message.to_json()) @@ -217,7 +216,7 @@ async def add_message(data: Dict[str, Any]): server = JavaServer.lookup("192.168.1.6:25565") query = server.query() players = query.players.names - message = Message(content=f"此服务器当前在线玩家有 {players}",reply_to=reply,room_id=data['roomId']) + message = Message(content=f"此服务器当前在线玩家有 {players}",room_id=data['roomId']) await sio.emit('sendMessage', message.to_json()) @@ -225,20 +224,18 @@ async def add_message(data: Dict[str, Any]): ctypet = content[len("!!hitokoto "):] if content == "!!hitokoto": - result_code, result_data, result_type= hitokoto.hitokoto(None) + result_code, result_data = hitokoto.hitokoto("没有") else: - result_code, result_data, result_type= hitokoto.hitokoto(ctypet) + result_code, result_data = hitokoto.hitokoto(ctypet) if result_code == 3: - message = Message(content=f"参数不对哦!你可以输入!!hitokoto help查看帮助",reply_to=reply,room_id=data['roomId']) + message = Message(content=f"参数不对哦!",room_id=data['roomId']) elif result_code == 2: - message = Message(content=f"发生了不可描述的错误X_X,但可以肯定的是模块炸了(",reply_to=reply,room_id=data['roomId']) - elif result_code == 1: - message = Message(content=f"(参数)句子类型如下\na 动画\nb 漫画\nc 游戏\nd 文学\ne 原创\nf 来自网络\ng 其他\nh 影视\ni 诗词\nj 网易云\nk 哲学\nl 抖机灵",reply_to=reply,room_id=data['roomId']) + message = Message(content=f"发生了不可描述的错误X_X", room_id=data['roomId']) elif result_code == 0: - message = Message(content=f"“{result_data['hitokoto']}”\n来源:{result_data['from']}\n类型:{result_type}",reply_to=reply,room_id=data['roomId']) + message = Message(content=f"Hitokoto: {result_data['hitokoto']}", room_id=data['roomId']) else: - message = Message(content=f"你看到这条消息就代表有bug出炉,但肯定不是模块炸了(",reply_to=reply,room_id=data['roomId']) + message = Message(content=f"但你看到这条消息就代表有bug出炉", room_id=data['roomId']) await sio.emit('sendMessage', message.to_json()) @@ -280,6 +277,7 @@ async def add_message(data: Dict[str, Any]): randomer = random.Random(f'{sender_id}-{data["message"]["date"]}-jrrp-v2') result = randomer.randint(0, 50) + randomer.randint(0, 50) print(f'{sender_name} 今日人品值为 {result}') + reply = ReplyMessage(id=data['message']['_id']) message = Message(content=f'{sender_name} 今日人品值为 {result}', reply_to=reply, room_id=room_id) diff --git a/module/hitokoto/__init__.py b/module/hitokoto/__init__.py index a37f290..6118d00 100644 --- a/module/hitokoto/__init__.py +++ b/module/hitokoto/__init__.py @@ -1,6 +1,7 @@ import requests import random + def hitokoto(ctypet): result_type = None @@ -17,6 +18,7 @@ def hitokoto(ctypet): ctype = 'd' elif ctypet == '原创' or ctypet == 'e': ctype = 'e' + elif ctypet == '网络' or ctypet == 'f': elif ctypet == '来自网络' or ctypet == 'f': ctype = 'f' elif ctypet == '其他' or ctypet == 'g': @@ -31,6 +33,15 @@ def hitokoto(ctypet): ctype = 'k' elif ctypet == '抖机灵' or ctypet == 'l': ctype = 'l' + + elif ctypet == '没有': + ctype = random.choice('abcdefghijkl') + params_value = {'c': ctype} + hitokoto = requests.get('https://v1.hitokoto.cn', params=params_value) + + return 0, hitokoto.json() + else: + return 3, None elif ctypet == None: ctype = random.choice('abcdefghijkl') elif ctypet == 'help': @@ -41,6 +52,11 @@ def hitokoto(ctypet): params_value = {'c': ctype} hitokoto = requests.get('https://v1.hitokoto.cn', params=params_value) + return 0, hitokoto.json() + + except IOError: + return 2, None + htype=hitokoto.json()['type'] if htype=='a': result_type = '动画' diff --git a/module/hitokoto/__pycache__/__init__.cpython-311.pyc b/module/hitokoto/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..2ae9f3e Binary files /dev/null and b/module/hitokoto/__pycache__/__init__.cpython-311.pyc differ diff --git a/module/hitokoto/__pycache__/__init__.cpython-39.pyc b/module/hitokoto/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..68862f7 Binary files /dev/null and b/module/hitokoto/__pycache__/__init__.cpython-39.pyc differ diff --git a/module/hitokoto/test.py b/module/hitokoto/test.py new file mode 100644 index 0000000..e69de29 diff --git a/module/minecraft_server/__init__.py b/module/minecraft_server/__init__.py index e69de29..b0ed445 100644 --- a/module/minecraft_server/__init__.py +++ b/module/minecraft_server/__init__.py @@ -0,0 +1,15 @@ +import time +import random +import asyncio +import traceback + +from typing import Dict, List, Tuple, Any, Optional, Union, Literal + +import qtoml +import socketio +from colorama import Fore, Style +from nacl.signing import SigningKey +from lib_not_dr.types import Options +from mcstatus import JavaServer + +def mcstatus(): diff --git a/requirement.txt b/requirement.txt index 05ae1a4..2a79a74 100644 --- a/requirement.txt +++ b/requirement.txt @@ -3,5 +3,9 @@ colorama qtoml pynacl python-socketio[asyncio_client] +<<<<<<< HEAD mcstatus -requests \ No newline at end of file +======= +mcstatus +requests +>>>>>>> 51011ec401ee07fe7446b24fad680a629e12ff56