From 4747d6999b4930a34fa1c372961b7a5d011d6f17 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 30 Aug 2019 21:32:47 +0300 Subject: [PATCH] Add different error message in ping if user has no session --- commands.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/commands.go b/commands.go index 0f65000..413ba9f 100644 --- a/commands.go +++ b/commands.go @@ -267,12 +267,11 @@ func (handler *CommandHandler) CommandDisconnect(ce *CommandEvent) { const cmdPingHelp = `ping - Check your connection to WhatsApp.` func (handler *CommandHandler) CommandPing(ce *CommandEvent) { - if ce.User.Conn == nil { + if ce.User.Session == nil { + ce.Reply("You're not logged into WhatsApp.") + } else if ce.User.Conn == nil { ce.Reply("You don't have a WhatsApp connection.") - return - } - ok, err := ce.User.Conn.AdminTest() - if err != nil { + } else if ok, err := ce.User.Conn.AdminTest(); err != nil { ce.Reply("Connection not OK: %v", err) } else if !ok { ce.Reply("Connection not OK, but no error received")