mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
add pyramid command
This commit is contained in:
parent
13252d3b0d
commit
0ff2b74239
2 changed files with 60 additions and 0 deletions
49
pkg/commands/pyramid.go
Normal file
49
pkg/commands/pyramid.go
Normal file
|
@ -0,0 +1,49 @@
|
|||
package commands
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/gempir/go-twitch-irc/v2"
|
||||
)
|
||||
|
||||
func Pyramid(channel string, size string, emote string, client *twitch.Client) {
|
||||
if size[0] == '.' || size[0] == '/' {
|
||||
client.Say(channel, ":tf:")
|
||||
return
|
||||
}
|
||||
|
||||
if emote[0] == '.' || emote[0] == '/' {
|
||||
client.Say(channel, ":tf:")
|
||||
return
|
||||
}
|
||||
|
||||
pyramidSize, err := strconv.Atoi(size)
|
||||
pyramidEmote := fmt.Sprint(emote + " ")
|
||||
|
||||
if err != nil {
|
||||
client.Say(channel, "Something went wrong")
|
||||
}
|
||||
|
||||
if pyramidSize == 1 {
|
||||
client.Say(channel, fmt.Sprint(pyramidEmote+"..."))
|
||||
return
|
||||
}
|
||||
|
||||
if pyramidSize > 20 {
|
||||
client.Say(channel, "Max pyramid size is 20")
|
||||
return
|
||||
}
|
||||
|
||||
for i := 0; i <= pyramidSize; i++ {
|
||||
pyramidMessageAsc := strings.Repeat(pyramidEmote, i)
|
||||
// fmt.Println(pyramidMessageAsc)
|
||||
client.Say(channel, pyramidMessageAsc)
|
||||
}
|
||||
for j := pyramidSize - 1; j >= 0; j-- {
|
||||
pyramidMessageDesc := strings.Repeat(pyramidEmote, j)
|
||||
// fmt.Println(pyramidMessageDesc)
|
||||
client.Say(channel, pyramidMessageDesc)
|
||||
}
|
||||
}
|
|
@ -108,5 +108,16 @@ func HandleCommand(message twitch.PrivateMessage, twitchClient *twitch.Client, u
|
|||
commands.Fill(message.Channel, message.Message[7:len(message.Message)], twitchClient)
|
||||
}
|
||||
|
||||
case "pyramid":
|
||||
if msgLen != 3 {
|
||||
twitchClient.Say(message.Channel, "Usage: ()pyramid [size] [emote]")
|
||||
return
|
||||
} else if utils.ElevatedPrivsMessage(message) {
|
||||
commands.Pyramid(message.Channel, cmdParams[1], cmdParams[2], twitchClient)
|
||||
return
|
||||
} else {
|
||||
twitchClient.Say(message.Channel, "Pleb's can't pyramid FeelsBadMan")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue