|
|
@ -35,45 +35,42 @@ func (b *bot) chatHandler(m chat1.MsgSummary) { |
|
|
|
b.handlePayment(m) |
|
|
|
b.handlePayment(m) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
// Determine first if this is a command
|
|
|
|
|
|
|
|
|
|
|
|
// if its not a payment evaluate if this is a command at all
|
|
|
|
if strings.HasPrefix(m.Content.Text.Body, "!") || strings.HasPrefix(m.Content.Text.Body, "@") { |
|
|
|
if strings.HasPrefix(m.Content.Text.Body, "!") || strings.HasPrefix(m.Content.Text.Body, "@") { |
|
|
|
// determine the root command
|
|
|
|
// first return if its not a command for me
|
|
|
|
body := strings.ToLower(m.Content.Text.Body) |
|
|
|
if !strings.Contains(m.Content.Text.Body, b.cmd()) && !strings.Contains(m.Content.Text.Body, b.k.Username) { |
|
|
|
words := strings.Fields(body) |
|
|
|
return |
|
|
|
command := strings.Replace(words[0], "@", "", 1) |
|
|
|
} |
|
|
|
command = strings.Replace(command, "!", "", 1) |
|
|
|
// then check if this is the root command
|
|
|
|
command = strings.ToLower(command) |
|
|
|
if isRootCommand(m.Content.Text.Body, b.cmd(), b.k.Username) { |
|
|
|
// create the args
|
|
|
|
b.handleMeeting(m) |
|
|
|
args := words[1:] |
|
|
|
return |
|
|
|
nargs := len(args) |
|
|
|
} |
|
|
|
switch command { |
|
|
|
// then check sub-command variants
|
|
|
|
case b.k.Username: |
|
|
|
// feedback
|
|
|
|
if nargs > 0 { |
|
|
|
if hasCommandPrefix(m.Content.Text.Body, b.cmd(), b.k.Username, "feedback") { |
|
|
|
switch args[0] { |
|
|
|
b.handleFeedback(m) |
|
|
|
case "set": |
|
|
|
return |
|
|
|
b.handleSetCommand(m) |
|
|
|
} |
|
|
|
case "list": |
|
|
|
// help
|
|
|
|
b.handleListCommand(m) |
|
|
|
if hasCommandPrefix(m.Content.Text.Body, b.cmd(), b.k.Username, "help") { |
|
|
|
} |
|
|
|
b.handleWelcome(m.ConvID) |
|
|
|
} |
|
|
|
return |
|
|
|
case "jitsi": |
|
|
|
} |
|
|
|
if nargs == 0 { |
|
|
|
// hello
|
|
|
|
b.handleMeeting(m) |
|
|
|
if hasCommandPrefix(m.Content.Text.Body, b.cmd(), b.k.Username, "hello") { |
|
|
|
} else if nargs >= 1 { |
|
|
|
b.handleWelcome(m.ConvID) |
|
|
|
switch args[0] { |
|
|
|
return |
|
|
|
case "meet": |
|
|
|
} |
|
|
|
b.handleMeeting(m) |
|
|
|
// set commands
|
|
|
|
case "feedback": |
|
|
|
if hasCommandPrefix(m.Content.Text.Body, b.cmd(), b.k.Username, "set") { |
|
|
|
b.handleFeedback(m) |
|
|
|
b.handleSetCommand(m) |
|
|
|
case "hello": |
|
|
|
return |
|
|
|
fallthrough |
|
|
|
} |
|
|
|
case "help": |
|
|
|
// list commands
|
|
|
|
b.handleWelcome(m.ConvID) |
|
|
|
if hasCommandPrefix(m.Content.Text.Body, b.cmd(), b.k.Username, "list") { |
|
|
|
default: |
|
|
|
b.handleSetCommand(m) |
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|