36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
import betterproto
|
|
from game_server.net.session import PlayerSession
|
|
from game_server.game.chat.command_handler import handler
|
|
from rail_proto.lib import (
|
|
SendMsgCsReq,
|
|
SendMsgScRsp,
|
|
RevcMsgScNotify,
|
|
MsgType,
|
|
ChatType
|
|
)
|
|
|
|
async def handle(session: PlayerSession, msg: SendMsgCsReq) -> betterproto.Message:
|
|
if msg.message_type == MsgType.MSG_TYPE_CUSTOM_TEXT:
|
|
session.pending_notify(
|
|
RevcMsgScNotify(
|
|
message_type=MsgType.MSG_TYPE_CUSTOM_TEXT.value,
|
|
chat_type=ChatType.CHAT_TYPE_PRIVATE.value,
|
|
message_text=msg.message_text,
|
|
target_uid=69,
|
|
source_uid=session.player.data.uid
|
|
)
|
|
)
|
|
text = await handler.handle_command(session, msg.message_text)
|
|
if text:
|
|
session.pending_notify(
|
|
RevcMsgScNotify(
|
|
message_type=MsgType.MSG_TYPE_CUSTOM_TEXT.value,
|
|
chat_type=ChatType.CHAT_TYPE_PRIVATE.value,
|
|
message_text=text,
|
|
target_uid=session.player.data.uid,
|
|
source_uid=69
|
|
)
|
|
)
|
|
return SendMsgScRsp(
|
|
retcode=0
|
|
) |