From c138f0ac7ed45f0f8da0453f3cf426983795b38f Mon Sep 17 00:00:00 2001 From: SharwOrange Date: Sat, 30 Dec 2023 15:16:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8D=8A=E6=88=90=E5=93=81?= =?UTF-8?q?=E7=9A=84=E4=B8=80=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 0 connect.py | 15 ++++++- module/hitokoto/__init__.py | 5 +++ .../__pycache__/__init__.cpython-311.pyc | Bin 0 -> 470 bytes module/hitokoto/test.py | 38 ++++++++++++++++++ module/minecraft_server/__init__.py | 0 6 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 .vscode/settings.json create mode 100644 module/hitokoto/__init__.py create mode 100644 module/hitokoto/__pycache__/__init__.cpython-311.pyc create mode 100644 module/hitokoto/test.py create mode 100644 module/minecraft_server/__init__.py diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..e69de29 diff --git a/connect.py b/connect.py index 4a57be3..6d785e7 100644 --- a/connect.py +++ b/connect.py @@ -12,6 +12,10 @@ from nacl.signing import SigningKey from lib_not_dr.types import Options from mcstatus import JavaServer +# 功能包引用处 +from module import hitokoto +# 功能包结束引用 + def get_config() -> Tuple[str, str, int]: with open('config.toml', 'r', encoding='utf-8') as f: config = qtoml.load(f) @@ -192,6 +196,7 @@ async def add_message(data: Dict[str, Any]): message = Message(content='icalingua bot test', room_id=data['roomId']) await sio.emit('sendMessage', message.to_json()) + elif content == '!!status': server = JavaServer.lookup("192.168.1.6:25565") status=server.status() @@ -213,7 +218,15 @@ async def add_message(data: Dict[str, Any]): message = Message(content=f"此服务器当前在线玩家有 {players}",room_id=data['roomId']) await sio.emit('sendMessage', message.to_json()) - + + elif content == f'!!hitokoto {stypet}': + hitokoto.hitokoto(stypet) + result_code, result_data = hitokoto.hitokoto() + if result_code == 3: + message= Message(content=f"输入参数无效,将随机选取一言句子类型",room_id=data['roomId']) + if result_code == 0: + message = Message(f"Hitokoto: {result_data['hitokoto']}") + elif data.get('message').get('content').startswith('=='): evals: str = data.get('message').get('content')[2:] diff --git a/module/hitokoto/__init__.py b/module/hitokoto/__init__.py new file mode 100644 index 0000000..cd88196 --- /dev/null +++ b/module/hitokoto/__init__.py @@ -0,0 +1,5 @@ +import requests + +def hitokoto(): + hitokoto = requests.get('https://v1.hitokoto.cn') + print(hitokoto.json) \ No newline at end of file diff --git a/module/hitokoto/__pycache__/__init__.cpython-311.pyc b/module/hitokoto/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2ae9f3e3ea77a5aa6ffe2fd3ce7ab2e76d740840 GIT binary patch literal 470 zcmZ3^%ge<81fMterxpY0#~=<2FhLogMSzUy3@HpLj5!QZ3@J=43{i|JjKK_=%r8Mo z{F0#x!4xx)1mVwNKw>&W2_sk(Ok}~?DU8d2?A367Ekg+_LR}3*7RUrJKvl;GbOq2} zCci4NjFOUqVk>?9GDE$L%#!@<{E~dVB(RziETVT^7y`jUL^L zED~2(Brd?vXP{c3ABtFj6xf873`L+=DB=VXzc_3lw%Qf(0J$JX7OMk^56p~=j5iqg S8^G`b3lpQ{2L?<6Y!Co)17*Sh literal 0 HcmV?d00001 diff --git a/module/hitokoto/test.py b/module/hitokoto/test.py new file mode 100644 index 0000000..1c419ff --- /dev/null +++ b/module/hitokoto/test.py @@ -0,0 +1,38 @@ +import requests +import random + +def hitokoto(ctypet): + + if ctypet == '动画' or ctypet == 'a': + ctype = 'a' + elif ctypet == '漫画' or ctypet == 'b': + ctype = 'b' + elif ctypet == '游戏' or ctypet == 'c': + ctype = 'c' + elif ctypet == '文学' or ctypet == 'd': + ctype = 'd' + elif ctypet == '原创' or ctypet == 'e': + ctype = 'e' + elif ctypet == '网络' or ctypet == 'f': + ctype = 'f' + elif ctypet == '其他' or ctypet == 'g': + ctype = 'g' + elif ctypet == '影视' or ctypet == 'h': + ctype = 'h' + elif ctypet == '诗词' or ctypet == 'i': + ctype = 'i' + elif ctypet == '网易云' or ctypet == 'j': + ctype = 'j' + elif ctypet == '哲学' or ctypet == 'k': + ctype = 'k' + elif ctypet == '抖机灵' or ctypet == 'l': + ctype = 'l' + else: + ctype= random.choice('abcdefghijkl') + return 3 + + params_value={'c':ctype} + hitokoto = requests.get('https://v1.hitokoto.cn',params=params_value) + return 0,(hitokoto.json()) + except Exception as e: + return 2, None \ No newline at end of file diff --git a/module/minecraft_server/__init__.py b/module/minecraft_server/__init__.py new file mode 100644 index 0000000..e69de29