From d9c94b8e4ce6e6b748ce65eedd3d9d8309809ad8 Mon Sep 17 00:00:00 2001 From: Riley Date: Tue, 10 May 2022 19:01:29 +0200 Subject: [PATCH] chat exec pluginapi --- chat.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/chat.go b/chat.go index 6257c8b..db4dc8b 100644 --- a/chat.go +++ b/chat.go @@ -13,6 +13,25 @@ import ( // about a chat command that's taking long to execute. var ChatCmdTimeout = 10 * time.Second +// Exec handles a string as if it where send by a client. +// string is imediate returnvalue of chatcommand (if applicable) +// bool is if msg is getting forwarded to the minetest server +func (cc *ClientConn) Exec(msg string) (string, bool) { + pkt := &mt.ToSrvChatMsg{ + Msg: msg, + } + + str, fwd := onChatMsg(cc, pkt) + + if fwd { + cc.server().Send(*&mt.Pkt{ + Cmd: pkt, + }) + } + + return str, fwd +} + // SendChatMsg sends a chat message to the ClientConn. func (cc *ClientConn) SendChatMsg(msg ...string) { cc.SendCmd(&mt.ToCltChatMsg{