添加半成品的一言

This commit is contained in:
SharwOrange橙夜 2023-12-30 15:16:50 +08:00
parent 43dc6deaea
commit c138f0ac7e
6 changed files with 57 additions and 1 deletions

0
.vscode/settings.json vendored Normal file
View File

View File

@ -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:]

View File

@ -0,0 +1,5 @@
import requests
def hitokoto():
hitokoto = requests.get('https://v1.hitokoto.cn')
print(hitokoto.json)

Binary file not shown.

38
module/hitokoto/test.py Normal file
View File

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

View File