From ea39e55342b4a3449124bcf3ba4f683e18fa8107 Mon Sep 17 00:00:00 2001 From: lyx0 <66651385+lyx0@users.noreply.github.com> Date: Mon, 8 Aug 2022 13:17:42 +0200 Subject: [PATCH] add coinflip command --- cmd/bot/command.go | 17 +++++++++++++---- pkg/commands/coinflip.go | 26 ++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 pkg/commands/coinflip.go diff --git a/cmd/bot/command.go b/cmd/bot/command.go index e262782..5f820d9 100644 --- a/cmd/bot/command.go +++ b/cmd/bot/command.go @@ -55,7 +55,7 @@ func handleCommand(message twitch.PrivateMessage, tc *twitch.Client) { } case "bttv": if msgLen < 2 { - common.Send(target, "Not enough arguments provided. Usage: ()bttv [emote name]", tc) + common.Send(target, "Not enough arguments provided. Usage: ()bttv ", tc) return } else { commands.Bttv(target, cmdParams[1], tc) @@ -68,6 +68,15 @@ func handleCommand(message twitch.PrivateMessage, tc *twitch.Client) { } else { return } + case "coin": + commands.Coinflip(target, tc) + return + case "coinflip": + commands.Coinflip(target, tc) + return + case "cf": + commands.Coinflip(target, tc) + return case "currency": if msgLen < 4 { common.Send(target, "Not enough arguments provided. Usage: ()currency 10 USD to EUR", tc) @@ -105,7 +114,7 @@ func handleCommand(message twitch.PrivateMessage, tc *twitch.Client) { return case "preview": if msgLen < 2 { - common.Send(target, "Not enough arguments provided. Usage: ()preview forsen", tc) + common.Send(target, "Not enough arguments provided. Usage: ()preview ", tc) return } else { commands.Preview(target, cmdParams[1], tc) @@ -113,7 +122,7 @@ func handleCommand(message twitch.PrivateMessage, tc *twitch.Client) { } case "thumbnail": if msgLen < 2 { - common.Send(target, "Not enough arguments provided. Usage: ()thumbnail forsen", tc) + common.Send(target, "Not enough arguments provided. Usage: ()thumbnail ", tc) return } else { commands.Preview(target, cmdParams[1], tc) @@ -121,7 +130,7 @@ func handleCommand(message twitch.PrivateMessage, tc *twitch.Client) { } case "tweet": if msgLen < 2 { - common.Send(target, "Not enough arguments provided. Usage: ()tweet forsen", tc) + common.Send(target, "Not enough arguments provided. Usage: ()tweet ", tc) return } else { commands.Tweet(target, cmdParams[1], tc) diff --git a/pkg/commands/coinflip.go b/pkg/commands/coinflip.go new file mode 100644 index 0000000..4d30256 --- /dev/null +++ b/pkg/commands/coinflip.go @@ -0,0 +1,26 @@ +package commands + +import ( + "fmt" + + "github.com/gempir/go-twitch-irc/v3" + "github.com/lyx0/nourybot/pkg/common" +) + +func Coinflip(target string, tc *twitch.Client) { + flip := common.GenerateRandomNumber(2) + fmt.Println(flip) + + switch flip { + case 0: + common.Send(target, "Heads!", tc) + return + case 1: + common.Send(target, "Tails!", tc) + return + default: + common.Send(target, "Heads!", tc) + return + } + +}