diff --git a/cmd/stock/main.go b/cmd/stock/main.go index a1c164c..b4e7ad4 100644 --- a/cmd/stock/main.go +++ b/cmd/stock/main.go @@ -175,7 +175,7 @@ func main() { continue } - msg_ := st.Msg() + msg_ := st.Msg(false) if msg_ != "" { err = msg.Send(msg_) if err != nil { diff --git a/stock/stock.go b/stock/stock.go index d286681..a117942 100644 --- a/stock/stock.go +++ b/stock/stock.go @@ -272,12 +272,12 @@ func (sk *stocks) FinishSendAll() { } } -func (sk *stocks) Msg() string { +func (sk *stocks) Msg(all bool) string { sk.mx.RLock() defer sk.mx.RUnlock() var resp string for _, s := range sk.stkMap { - if s.needSend { + if all || s.needSend { msg := s.Msg() resp = resp + msg + "\n" } @@ -286,7 +286,7 @@ func (sk *stocks) Msg() string { } func (sk *stocks) Arg(openid string) map[string]interface{} { - msg := sk.Msg() + msg := sk.Msg(false) if msg == "" { return nil } diff --git a/stock/stock_test.go b/stock/stock_test.go index 87534e5..8e00a97 100644 --- a/stock/stock_test.go +++ b/stock/stock_test.go @@ -11,5 +11,5 @@ func Test_newStocks(t *testing.T) { fmt.Println(err) return } - fmt.Println(ss.Msg()) + fmt.Println(ss.Msg(true)) } diff --git a/wxgzh/wxgzh.go b/wxgzh/wxgzh.go index 31bf54a..6ba1070 100644 --- a/wxgzh/wxgzh.go +++ b/wxgzh/wxgzh.go @@ -192,7 +192,7 @@ func Handle(c *gin.Context) { if err != nil { wMsg.Content = "查询错误:\n" + err.Error() } else { - msg := stks.Msg() + msg := stks.Msg(true) if msg == "" { wMsg.Content = "您未订阅任何股票!" } else {