mirror-nourybot/pkg/commands/pyramid.go

53 lines
991 B
Go
Raw Normal View History

2021-10-19 23:53:41 +02:00
package commands
import (
"fmt"
"strconv"
"strings"
"github.com/lyx0/nourybot/cmd/bot"
)
func Pyramid(channel string, size string, emote string, nb *bot.Bot) {
if size[0] == '.' || size[0] == '/' {
nb.Send(channel, ":tf:")
return
}
if emote[0] == '.' || emote[0] == '/' {
nb.Send(channel, ":tf:")
return
}
pyramidSize, err := strconv.Atoi(size)
pyramidEmote := fmt.Sprint(emote + " ")
if err != nil {
nb.Send(channel, "Something went wrong")
}
if pyramidSize == 1 {
nb.Send(channel, fmt.Sprint(pyramidEmote+"..."))
return
}
if pyramidSize > 20 {
nb.Send(channel, "Max pyramid size is 20")
return
}
for i := 0; i <= pyramidSize; i++ {
pyramidMessageAsc := strings.Repeat(pyramidEmote, i)
// fmt.Println(pyramidMessageAsc)
2021-10-20 23:54:34 +02:00
2021-10-19 23:53:41 +02:00
nb.Send(channel, pyramidMessageAsc)
}
2021-10-20 23:54:34 +02:00
2021-10-19 23:53:41 +02:00
for j := pyramidSize - 1; j >= 0; j-- {
pyramidMessageDesc := strings.Repeat(pyramidEmote, j)
// fmt.Println(pyramidMessageDesc)
2021-10-20 23:54:34 +02:00
2021-10-19 23:53:41 +02:00
nb.Send(channel, pyramidMessageDesc)
}
}