Skip to content

Commit

Permalink
Fix bug with fortunes that we're always offensive. I tribute this to …
Browse files Browse the repository at this point in the history
…almost Mel.
  • Loading branch information
bahner committed Mar 17, 2024
1 parent 77a490e commit d12a91d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions config/mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ func PongFortuneMode() bool {
return viper.GetBool("mode.pong.fortune.enable") && PongMode()
}

func PongFortuneArgs() string {
return viper.GetString("mode.pong.fortune.args")
func PongFortuneArgs() []string {
args := viper.GetString("mode.pong.fortune.args")

return []string{args}
}
8 changes: 4 additions & 4 deletions mode/pong/reply.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@ import (
"github.com/spf13/viper"
)

var fortuneArgs = []string{"-o"}

func reply(m *msg.Message) []byte {

if string(m.Content) == string(replyBytes()) {
return angryBytes()
}

if config.PongFortuneMode() {
return getFortuneCookie(fortuneArgs)
return getFortuneCookie()
}

return replyBytes()
Expand All @@ -37,7 +35,9 @@ func angryBytes() []byte {
}

// Returns a fortune cookie if the pong-fortune mode is enabled, otherwise the default reply.
func getFortuneCookie(args []string) []byte {
func getFortuneCookie() []byte {

args := config.PongFortuneArgs()
// Check if the fortune command is available in the PATH
_, err := exec.LookPath("fortune")
if err != nil {
Expand Down

0 comments on commit d12a91d

Please sign in to comment.