From 8e1b0c1ef64646f34002732772e1123d2ff5ab0e Mon Sep 17 00:00:00 2001 From: Jay Date: Wed, 10 Oct 2018 00:52:40 +0800 Subject: [PATCH] add command prefix check --- main.go | 5 ++++- module/message-command/message-command.go | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 897f5eb..6fa0fab 100644 --- a/main.go +++ b/main.go @@ -84,7 +84,7 @@ func main() { go func() { for { PrintMemUsage() - time.Sleep(time.Second * 10) + time.Sleep(time.Second * 20) } }() @@ -100,6 +100,9 @@ func PrintMemUsage() { fmt.Printf("\tTotalAlloc = %v MiB", bToMb(m.TotalAlloc)) fmt.Printf("\tSys = %v MiB", bToMb(m.Sys)) fmt.Printf("\tNumGC = %v\n", m.NumGC) + fmt.Printf("HeapAlloc = %v MiB", bToMb(m.HeapAlloc)) + fmt.Printf("\t HeapSys = %v MiB", bToMb(m.HeapSys)) + fmt.Printf("\t NextGC = %v MiB\n", bToMb(m.NextGC)) } func bToMb(b uint64) uint64 { return b / 1024 / 1024 diff --git a/module/message-command/message-command.go b/module/message-command/message-command.go index 89b585a..038c201 100644 --- a/module/message-command/message-command.go +++ b/module/message-command/message-command.go @@ -33,7 +33,8 @@ func ParseLineMsg(txt, replyToken string, source *lineobj.SourceObject) { return } - if strings.HasPrefix(strs[0], "!") || strings.HasPrefix(strs[0], "!") { + firstNum := []rune(strs[0])[0] + if firstNum == 33 || firstNum == 65281 { // nor cmd cmd := strs[0][1:] if len(cmd) == 0 {