mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
remove unused comments and clean up
This commit is contained in:
parent
edae669bee
commit
c5d9804c21
|
@ -13,14 +13,9 @@ func handleCommand(message twitch.PrivateMessage, tc *twitch.Client) {
|
|||
sugar := zap.NewExample().Sugar()
|
||||
defer sugar.Sync()
|
||||
|
||||
//sugar.Infow("Command received",
|
||||
// "message", message)
|
||||
|
||||
// commandName is the actual name of the command without the prefix.
|
||||
// e.g. `()ping` would be `ping`.
|
||||
commandName := strings.ToLower(strings.SplitN(message.Message, " ", 3)[0][2:])
|
||||
sugar.Infow("[handleCommand]",
|
||||
"commandName", commandName)
|
||||
|
||||
// cmdParams are additional command parameters.
|
||||
// e.g. `()weather san antonio`
|
||||
|
@ -35,13 +30,20 @@ func handleCommand(message twitch.PrivateMessage, tc *twitch.Client) {
|
|||
// msgLen is the amount of words in a message without the prefix.
|
||||
// Useful to check if enough cmdParams are provided.
|
||||
msgLen := len(strings.SplitN(message.Message, " ", -2))
|
||||
// sugar.Infow("handleCommand",
|
||||
// "msgLen:", msgLen)
|
||||
|
||||
// target is the channelname the message originated from and
|
||||
// where we are responding.
|
||||
target := message.Channel
|
||||
|
||||
sugar.Infow("Command received",
|
||||
// "message", message,
|
||||
"message.Message", message.Message,
|
||||
"target", target,
|
||||
"commandName", commandName,
|
||||
"cmdParams", cmdParams,
|
||||
"msgLen", msgLen,
|
||||
)
|
||||
|
||||
switch commandName {
|
||||
case "":
|
||||
if msgLen == 1 {
|
||||
|
|
|
@ -24,10 +24,10 @@ func main() {
|
|||
TwitchClient: tc,
|
||||
Logger: sugar,
|
||||
}
|
||||
|
||||
// Received a PrivateMessage (normal chat message), pass it to
|
||||
// the handler who checks for further action.
|
||||
app.TwitchClient.OnPrivateMessage(func(message twitch.PrivateMessage) {
|
||||
//app.Logger.Infof("%s", message)
|
||||
app.handlePrivateMessage(message)
|
||||
})
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@ import (
|
|||
func (app *Application) handlePrivateMessage(message twitch.PrivateMessage) {
|
||||
sugar := zap.NewExample().Sugar()
|
||||
defer sugar.Sync()
|
||||
// roomId is the Twitch UserID of the channel the
|
||||
// message originated from.
|
||||
|
||||
// roomId is the Twitch UserID of the channel the message originated from.
|
||||
roomId := message.Tags["room-id"]
|
||||
|
||||
// If there is no roomId something went wrong.
|
||||
|
@ -19,11 +19,9 @@ func (app *Application) handlePrivateMessage(message twitch.PrivateMessage) {
|
|||
return
|
||||
}
|
||||
|
||||
// Message was shorter than our prefix is therefore it's irrelevant for us.
|
||||
if len(message.Message) >= 2 {
|
||||
if message.Message[:2] == "()" {
|
||||
// app.Logger.Infow("handlePrivateMessage",
|
||||
// "message.Message", message.Message)
|
||||
|
||||
handleCommand(message, app.TwitchClient)
|
||||
return
|
||||
}
|
||||
|
@ -31,8 +29,10 @@ func (app *Application) handlePrivateMessage(message twitch.PrivateMessage) {
|
|||
|
||||
// Message was no command so we just print it.
|
||||
app.Logger.Infow("Private Message received",
|
||||
"message", message,
|
||||
"message.Channel", message.Channel,
|
||||
"message.User", message.User.DisplayName,
|
||||
"message.Message", message.Message)
|
||||
"message.Message", message.Message,
|
||||
)
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ func (app *Application) handleWhisperMessage(message twitch.WhisperMessage) {
|
|||
// Print the whisper message for now.
|
||||
// TODO: Implement a basic whisper handler.
|
||||
app.Logger.Infow("Whisper Message received",
|
||||
"message", message,
|
||||
"message.User.DisplayName", message.User.DisplayName,
|
||||
"message.Message", message.Message)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue