Limit dice size and number of rolls.
parent
fe569360ae
commit
759edd3c5c
|
@ -427,6 +427,24 @@ var eventTests = []struct {
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "roll 1000000",
|
||||
in: irc.Message{
|
||||
Command: "PRIVMSG",
|
||||
Trailing: ":roll 2000000",
|
||||
Params: []string{"#testchan-1"},
|
||||
Prefix: &irc.Prefix{
|
||||
Name: "idontexist",
|
||||
},
|
||||
},
|
||||
expectedOut: []irc.Message{
|
||||
{
|
||||
Command: "PRIVMSG",
|
||||
Params: []string{"#testchan-1"},
|
||||
Trailing: "Number of rolls and dice size is limited to 1000000",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "roll 0",
|
||||
in: irc.Message{
|
||||
|
|
|
@ -42,6 +42,10 @@ func roll(output func(irc.Message), msg irc.Message) {
|
|||
output(reply(msg, "Usage: :roll <sides int> <rolls int>, each roll is [0, n)+1, size has to be >0"))
|
||||
return
|
||||
}
|
||||
if sides > 1000000 || rolls > 1000000 {
|
||||
output(reply(msg, "Number of rolls and dice size is limited to 1000000"))
|
||||
return
|
||||
}
|
||||
|
||||
sum := rolls
|
||||
for i := 0; i < rolls; i++ {
|
||||
|
|
Loading…
Reference in New Issue