forked from git.klmp200.net/ALFRED
Merge branch 'features' of ALFRED/ALFRED into master
This commit is contained in:
commit
5ba31d37cb
@ -2,7 +2,7 @@
|
|||||||
* @Author: Bartuccio Antoine
|
* @Author: Bartuccio Antoine
|
||||||
* @Date: 2018-07-23 15:24:22
|
* @Date: 2018-07-23 15:24:22
|
||||||
* @Last Modified by: klmp200
|
* @Last Modified by: klmp200
|
||||||
* @Last Modified time: 2018-07-24 15:21:53
|
* @Last Modified time: 2018-07-24 20:55:53
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
@ -25,6 +25,7 @@ func main() {
|
|||||||
"/framapad": commands.Framapad,
|
"/framapad": commands.Framapad,
|
||||||
"/setgender": commands.SetGender,
|
"/setgender": commands.SetGender,
|
||||||
"/gender": commands.Gender,
|
"/gender": commands.Gender,
|
||||||
|
"/roll": commands.Dice,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := settings.LoadSettings("settings.json", "settings_custom.json"); err != nil {
|
if err := settings.LoadSettings("settings.json", "settings_custom.json"); err != nil {
|
||||||
|
30
commands/dice.go
Normal file
30
commands/dice.go
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* @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)))
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user