Make sure there are enough args before getting args

This commit is contained in:
Tulir Asokan 2018-12-08 01:30:15 +02:00
parent 88483fc61f
commit c6d33d8bba

View file

@ -134,13 +134,18 @@ func (handler *CommandHandler) CommandHelp(ce *CommandEvent) {
}, "\n")) }, "\n"))
} }
const cmdImportHelp = `import JID|contacts - Open up a room for JID or for each WhatsApp contact` const cmdImportHelp = `import <jid>|contacts - Open up a room for JID or for each WhatsApp contact`
// CommandImport handles import command // CommandImport handles import command
func (handler *CommandHandler) CommandImport(ce *CommandEvent) { func (handler *CommandHandler) CommandImport(ce *CommandEvent) {
// ensure all messages go to the management room // ensure all messages go to the management room
ce.RoomID = ce.User.ManagementRoom ce.RoomID = ce.User.ManagementRoom
if len(ce.Args) == 0 {
ce.Reply("Usage: import <jid>|contacts")
return
}
user := ce.User user := ce.User
if ce.Args[0] == "contacts" { if ce.Args[0] == "contacts" {