mirror of
https://git.klmp200.net/ALFRED/ALFRED.git
synced 2025-01-18 18:46:44 +01:00
31 lines
640 B
Go
31 lines
640 B
Go
/*
|
|
* @Author: Bartuccio Antoine
|
|
* @Date: 2018-07-24 20:50:04
|
|
* @Last Modified by: klmp200
|
|
* @Last Modified time: 2018-07-24 21:00:59
|
|
*/
|
|
|
|
package commands
|
|
|
|
import (
|
|
"../shared"
|
|
tb "gopkg.in/tucnak/telebot.v2"
|
|
"math/rand"
|
|
"strconv"
|
|
"strings"
|
|
)
|
|
|
|
func Dice(m *tb.Message) {
|
|
split := strings.Split(m.Text, " ")
|
|
if len(split) < 2 {
|
|
shared.Bot.Send(m.Chat, "Pour lancer un dé, il faut préciser combien de faces il a.")
|
|
return
|
|
}
|
|
up, err := strconv.Atoi(split[1])
|
|
if err != nil || up <= 0 {
|
|
shared.Bot.Send(m.Chat, split[1]+" n'est pas un nombre valide.")
|
|
return
|
|
}
|
|
shared.Bot.Send(m.Chat, strconv.Itoa(rand.Intn(up+1)))
|
|
}
|