add command 'ping'

This commit is contained in:
zhaoYangguang 2020-10-16 20:42:32 +08:00
parent 5b122411ae
commit 55c32bfba7
1 changed files with 20 additions and 28 deletions

View File

@ -99,8 +99,8 @@ func (handler *CommandHandler) CommandMux(ce *CommandEvent) {
// handler.CommandReconnect(ce) // handler.CommandReconnect(ce)
//case "disconnect": //case "disconnect":
// handler.CommandDisconnect(ce) // handler.CommandDisconnect(ce)
//case "ping": case "ping":
// handler.CommandPing(ce) handler.CommandPing(ce)
//case "delete-connection": //case "delete-connection":
// handler.CommandDeleteConnection(ce) // handler.CommandDeleteConnection(ce)
//case "delete-session": //case "delete-session":
@ -421,31 +421,23 @@ const cmdDisconnectHelp = `disconnect - Disconnect from WhatsApp (without loggin
const cmdPingHelp = `ping - Check your connection to WhatsApp.` const cmdPingHelp = `ping - Check your connection to WhatsApp.`
//func (handler *CommandHandler) CommandPing(ce *CommandEvent) { func (handler *CommandHandler) CommandPing(ce *CommandEvent) {
// if ce.User.Session == nil { if ce.User.Session == nil || ce.User.Session.SkypeToken == "" {
// if ce.User.IsLoginInProgress() { if ce.User.IsLoginInProgress() {
// ce.Reply("You're not logged into WhatsApp, but there's a login in progress.") ce.Reply("You're not logged into Skype, but there's a login in progress.")
// } else { } else {
// ce.Reply("You're not logged into WhatsApp.") ce.Reply("You're not logged into Skype.")
// } }
// } else if ce.User.Conn == nil { } else if ce.User.Conn.LoggedIn == false {
// ce.Reply("You don't have a WhatsApp connection.") ce.Reply("You're not logged into Skype.")
// } else if ok, err := ce.User.Conn.AdminTest(); err != nil { } else {
// if ce.User.IsLoginInProgress() { username := ce.User.Conn.UserProfile.FirstName
// ce.Reply("Connection not OK: %v, but login in progress", err) if len(ce.User.Conn.UserProfile.LastName) > 0 {
// } else { username = username + ce.User.Conn.UserProfile.LastName
// ce.Reply("Connection not OK: %v", err) }
// } ce.Reply("You are logged in as @" + username)
// } else if !ok { }
// if ce.User.IsLoginInProgress() { }
// ce.Reply("Connection not OK, but no error received and login in progress")
// } else {
// ce.Reply("Connection not OK, but no error received")
// }
// } else {
// ce.Reply("Connection to WhatsApp OK")
// }
//}
const cmdHelpHelp = `help - Prints this help` const cmdHelpHelp = `help - Prints this help`
@ -464,7 +456,7 @@ func (handler *CommandHandler) CommandHelp(ce *CommandEvent) {
//cmdPrefix + cmdReconnectHelp, //cmdPrefix + cmdReconnectHelp,
//cmdPrefix + cmdDisconnectHelp, //cmdPrefix + cmdDisconnectHelp,
//cmdPrefix + cmdDeleteConnectionHelp, //cmdPrefix + cmdDeleteConnectionHelp,
//cmdPrefix + cmdPingHelp, cmdPrefix + cmdPingHelp,
//cmdPrefix + cmdLoginMatrixHelp, //cmdPrefix + cmdLoginMatrixHelp,
//cmdPrefix + cmdLogoutMatrixHelp, //cmdPrefix + cmdLogoutMatrixHelp,
cmdPrefix + cmdSyncHelp, cmdPrefix + cmdSyncHelp,