修改过滤条件

测试判断字符串开头

修复字符串开头判断

优化消息开头字符
This commit is contained in:
liyp 2024-04-20 12:49:16 +08:00
parent b521264877
commit ca02f5fcf1

View file

@ -21,8 +21,13 @@ func Router(data map[string]interface{}) {
sender := data["sender"].(map[string]interface{}) sender := data["sender"].(map[string]interface{})
role := sender["role"].(string) role := sender["role"].(string)
mid := data["message_id"].(float64) mid := data["message_id"].(float64)
raw_msg := data["raw_message"].(string)[1:]
//包含发送消息的'!'
raw_msg := data["raw_message"].(string)
// fmt.Println("raw_msg:", string(raw_msg[0]))
if len(raw_msg) > 1 && raw_msg[0] == '!' {
// 去除'!'
raw_msg = raw_msg[1:]
parms := strings.Fields(raw_msg) parms := strings.Fields(raw_msg)
worker := workers.NewWorker(parms, fmt.Sprintf("%d", int(uid)), fmt.Sprintf("%d", int(gid)), role, fmt.Sprintf("%d", int(mid)), raw_msg) worker := workers.NewWorker(parms, fmt.Sprintf("%d", int(uid)), fmt.Sprintf("%d", int(gid)), role, fmt.Sprintf("%d", int(mid)), raw_msg)
@ -36,5 +41,6 @@ func Router(data map[string]interface{}) {
worker.SendMsg(message) worker.SendMsg(message)
} }
}
} }