From 8dd599348152f74dfcef1b4deedd9cffba35ec4e Mon Sep 17 00:00:00 2001 From: Karmanyaah Malhotra Date: Sun, 7 Mar 2021 11:56:48 -0500 Subject: [PATCH] Fix panic --- real_time.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/real_time.go b/real_time.go index e9a9b3e..939acfd 100644 --- a/real_time.go +++ b/real_time.go @@ -134,8 +134,17 @@ func (r *PushSubscription) StartListening(context context.Context) { channel := msg.Channel() if strings.HasPrefix(channel, groupChannel) || strings.HasPrefix(channel, dmChannel) { - c := content.(map[string]interface{})["line"] - d, _ := json.Marshal(c) + c, ok := content.(map[string]interface{}) + if !ok { + fmt.Println(content, "err") + continue + } + e, ok := c["line"] + if !ok { + fmt.Println(content, "err") + continue + } + d, _ := json.Marshal(e) r.chatEvent(contentType, d) continue }