remove debug log
This commit is contained in:
parent
906b7be381
commit
203cc30867
@ -1,12 +1,9 @@
|
|||||||
package msgcmd
|
package msgcmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.trj.tw/golang/mtfosbot/module/utils"
|
|
||||||
|
|
||||||
"git.trj.tw/golang/mtfosbot/model"
|
"git.trj.tw/golang/mtfosbot/model"
|
||||||
|
|
||||||
"git.trj.tw/golang/mtfosbot/module/apis/line"
|
"git.trj.tw/golang/mtfosbot/module/apis/line"
|
||||||
@ -26,12 +23,11 @@ func parseCMD(in string) (c [][]string) {
|
|||||||
|
|
||||||
// ParseLineMsg -
|
// ParseLineMsg -
|
||||||
func ParseLineMsg(txt, replyToken string, source *lineobj.SourceObject) {
|
func ParseLineMsg(txt, replyToken string, source *lineobj.SourceObject) {
|
||||||
fmt.Println("parse Line msg ;::: ", txt, utils.ToMap(source))
|
|
||||||
if source.Type != "group" {
|
if source.Type != "group" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
strs := strings.Split(strings.Trim(txt, " "), " ")
|
strs := strings.Split(strings.Trim(txt, " "), " ")
|
||||||
fmt.Println(strs)
|
|
||||||
// skip empty string
|
// skip empty string
|
||||||
if len(strs[0]) == 0 {
|
if len(strs[0]) == 0 {
|
||||||
return
|
return
|
||||||
@ -40,36 +36,27 @@ func ParseLineMsg(txt, replyToken string, source *lineobj.SourceObject) {
|
|||||||
if strings.HasPrefix(strs[0], "!") || strings.HasPrefix(strs[0], "!") {
|
if strings.HasPrefix(strs[0], "!") || strings.HasPrefix(strs[0], "!") {
|
||||||
// nor cmd
|
// nor cmd
|
||||||
cmd := strs[0][1:]
|
cmd := strs[0][1:]
|
||||||
fmt.Println(cmd)
|
|
||||||
if len(cmd) == 0 {
|
if len(cmd) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c, err := model.GetGroupCommand(strings.ToLower(cmd), source.GroupID)
|
c, err := model.GetGroupCommand(strings.ToLower(cmd), source.GroupID)
|
||||||
if err != nil || c == nil {
|
if err != nil || c == nil {
|
||||||
fmt.Println("get command fail ", err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Println("get command ::::", utils.ToMap(c))
|
|
||||||
|
|
||||||
str := runCMD(strings.Join(strs[1:], " "), c.Message, source)
|
str := runCMD(strings.Join(strs[1:], " "), c.Message, source)
|
||||||
fmt.Println("cmd result ::::::", str)
|
|
||||||
m := parseResult(str)
|
m := parseResult(str)
|
||||||
fmt.Println("parsed cmd result :::::", m)
|
|
||||||
line.ReplyMessage(replyToken, m)
|
line.ReplyMessage(replyToken, m)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// key cmd
|
// key cmd
|
||||||
c, err := model.GetGroupKeyCommand(strings.ToLower(strs[0]), source.GroupID)
|
c, err := model.GetGroupKeyCommand(strings.ToLower(strs[0]), source.GroupID)
|
||||||
if err != nil || c == nil {
|
if err != nil || c == nil {
|
||||||
fmt.Println("get command fail::::", err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Println("get command ::::", utils.ToMap(c))
|
|
||||||
|
|
||||||
str := runCMD(strings.Join(strs[1:], " "), c.Message, source)
|
str := runCMD(strings.Join(strs[1:], " "), c.Message, source)
|
||||||
fmt.Println("cmd result ::::", str)
|
|
||||||
m := parseResult(str)
|
m := parseResult(str)
|
||||||
fmt.Println("parsed cmd result :::::", m)
|
|
||||||
line.ReplyMessage(replyToken, m)
|
line.ReplyMessage(replyToken, m)
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -95,7 +82,6 @@ func parseResult(str string) interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runCMD(txt, c string, s *lineobj.SourceObject) (res string) {
|
func runCMD(txt, c string, s *lineobj.SourceObject) (res string) {
|
||||||
fmt.Println("run run run::::::", txt, c, s)
|
|
||||||
cmdAct := parseCMD(c)
|
cmdAct := parseCMD(c)
|
||||||
if len(cmdAct) == 0 {
|
if len(cmdAct) == 0 {
|
||||||
return c
|
return c
|
||||||
@ -109,7 +95,6 @@ func runCMD(txt, c string, s *lineobj.SourceObject) (res string) {
|
|||||||
if len(m) > 1 {
|
if len(m) > 1 {
|
||||||
sub = strings.Join(m[1:], " ")
|
sub = strings.Join(m[1:], " ")
|
||||||
}
|
}
|
||||||
fmt.Println("run ::::::::", m[0], sub, txt)
|
|
||||||
cmdRes := selectAct(m[0], sub, txt, s)
|
cmdRes := selectAct(m[0], sub, txt, s)
|
||||||
res = strings.Replace(res, v[0], cmdRes, 1)
|
res = strings.Replace(res, v[0], cmdRes, 1)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user