将部分消息添加回复功能
This commit is contained in:
parent
48867b8cf9
commit
6a3a31ab18
15
connect.py
15
connect.py
|
@ -191,6 +191,7 @@ async def add_message(data: Dict[str, Any]):
|
||||||
sender_id = data['message']['senderId']
|
sender_id = data['message']['senderId']
|
||||||
content = data['message']['content']
|
content = data['message']['content']
|
||||||
room_id = data['roomId']
|
room_id = data['roomId']
|
||||||
|
reply = ReplyMessage(id=data['message']['_id'])
|
||||||
|
|
||||||
if not is_self:
|
if not is_self:
|
||||||
if data.get('message').get('content') == '/bot':
|
if data.get('message').get('content') == '/bot':
|
||||||
|
@ -208,7 +209,7 @@ async def add_message(data: Dict[str, Any]):
|
||||||
# else:
|
# else:
|
||||||
# message = Message(content=f"此服务器空无一人",room_id=data['roomId'])
|
# message = Message(content=f"此服务器空无一人",room_id=data['roomId'])
|
||||||
|
|
||||||
message = Message(content=f"此服务器有 {status.players.online} 个玩家在线",room_id=data['roomId'])
|
message = Message(content=f"此服务器有 {status.players.online} 个玩家在线",reply_to=reply,room_id=data['roomId'])
|
||||||
|
|
||||||
await sio.emit('sendMessage', message.to_json())
|
await sio.emit('sendMessage', message.to_json())
|
||||||
|
|
||||||
|
@ -216,7 +217,7 @@ async def add_message(data: Dict[str, Any]):
|
||||||
server = JavaServer.lookup("192.168.1.6:25565")
|
server = JavaServer.lookup("192.168.1.6:25565")
|
||||||
query = server.query()
|
query = server.query()
|
||||||
players = query.players.names
|
players = query.players.names
|
||||||
message = Message(content=f"此服务器当前在线玩家有 {players}",room_id=data['roomId'])
|
message = Message(content=f"此服务器当前在线玩家有 {players}",reply_to=reply,room_id=data['roomId'])
|
||||||
|
|
||||||
await sio.emit('sendMessage', message.to_json())
|
await sio.emit('sendMessage', message.to_json())
|
||||||
|
|
||||||
|
@ -229,15 +230,15 @@ async def add_message(data: Dict[str, Any]):
|
||||||
result_code, result_data, result_type= hitokoto.hitokoto(ctypet)
|
result_code, result_data, result_type= hitokoto.hitokoto(ctypet)
|
||||||
|
|
||||||
if result_code == 3:
|
if result_code == 3:
|
||||||
message = Message(content=f"参数不对哦!你可以输入!!hitokoto help查看帮助",room_id=data['roomId'])
|
message = Message(content=f"参数不对哦!你可以输入!!hitokoto help查看帮助",reply_to=reply,room_id=data['roomId'])
|
||||||
elif result_code == 2:
|
elif result_code == 2:
|
||||||
message = Message(content=f"发生了不可描述的错误X_X,但可以肯定的是模块炸了(", room_id=data['roomId'])
|
message = Message(content=f"发生了不可描述的错误X_X,但可以肯定的是模块炸了(",reply_to=reply,room_id=data['roomId'])
|
||||||
elif result_code == 1:
|
elif result_code == 1:
|
||||||
message = Message(content=f"(参数)句子类型如下\na 动画\nb 漫画\nc 游戏\nd 文学\ne 原创\nf 来自网络\ng 其他\nh 影视\ni 诗词\nj 网易云\nk 哲学\nl 抖机灵", room_id=data['roomId'])
|
message = Message(content=f"(参数)句子类型如下\na 动画\nb 漫画\nc 游戏\nd 文学\ne 原创\nf 来自网络\ng 其他\nh 影视\ni 诗词\nj 网易云\nk 哲学\nl 抖机灵",reply_to=reply,room_id=data['roomId'])
|
||||||
elif result_code == 0:
|
elif result_code == 0:
|
||||||
message = Message(content=f"“{result_data['hitokoto']}”\n来源:{result_data['from']}\n类型:{result_type}", room_id=data['roomId'])
|
message = Message(content=f"“{result_data['hitokoto']}”\n来源:{result_data['from']}\n类型:{result_type}",reply_to=reply,room_id=data['roomId'])
|
||||||
else:
|
else:
|
||||||
message = Message(content=f"你看到这条消息就代表有bug出炉,但肯定不是模块炸了(", room_id=data['roomId'])
|
message = Message(content=f"你看到这条消息就代表有bug出炉,但肯定不是模块炸了(",reply_to=reply,room_id=data['roomId'])
|
||||||
|
|
||||||
await sio.emit('sendMessage', message.to_json())
|
await sio.emit('sendMessage', message.to_json())
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user