mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
add command counter
This commit is contained in:
parent
2ce5f432b5
commit
18363b0dee
2 changed files with 22 additions and 0 deletions
15
pkg/commands/ping.go
Normal file
15
pkg/commands/ping.go
Normal file
|
@ -0,0 +1,15 @@
|
|||
package commands
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gempir/go-twitch-irc/v2"
|
||||
"github.com/lyx0/nourybot/pkg/utils"
|
||||
)
|
||||
|
||||
func PingCommand(channel string, client *twitch.Client) {
|
||||
commandCount := fmt.Sprint(utils.GetCommandsUsed())
|
||||
|
||||
s := fmt.Sprintf("Pong! :) Commands used: %v", commandCount)
|
||||
client.Say(channel, s)
|
||||
}
|
|
@ -4,6 +4,8 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/gempir/go-twitch-irc/v2"
|
||||
"github.com/lyx0/nourybot/pkg/commands"
|
||||
"github.com/lyx0/nourybot/pkg/utils"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
|
@ -14,6 +16,9 @@ import (
|
|||
func HandleCommand(message twitch.PrivateMessage, twitchClient *twitch.Client) {
|
||||
log.Info("fn HandleCommand")
|
||||
|
||||
// Counter that increments on every command call.
|
||||
utils.CommandUsed()
|
||||
|
||||
// commandName is the actual command name without the prefix.
|
||||
commandName := strings.SplitN(message.Message, " ", 3)[0][2:]
|
||||
|
||||
|
@ -40,5 +45,7 @@ func HandleCommand(message twitch.PrivateMessage, twitchClient *twitch.Client) {
|
|||
case "echo":
|
||||
twitchClient.Say(message.Channel, cmdParams[1])
|
||||
return
|
||||
case "ping":
|
||||
commands.PingCommand(message.Channel, twitchClient)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue