Skip to content

Commit 9b33d53

Browse files
committed
feat: nombre
1 parent 4931729 commit 9b33d53

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

chaos-bot/commands.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ func init() {
4242
"!histoire-pour-enfant": doHistoirePourEnfant,
4343
"!moulsay": doMoulsay,
4444
"!roulette": doRoulette,
45+
"!nombre": doNombre,
4546
"!ntw": doNtw,
4647
}
4748
// FIXME: !pause 5min
@@ -150,6 +151,25 @@ func doRecettator(s *discordgo.Session, m *discordgo.MessageCreate) error {
150151
return nil
151152
}
152153

154+
func doNombre(s *discordgo.Session, m *discordgo.MessageCreate) error {
155+
content := strings.Split(m.Content, " ")
156+
if len(content) < 3 {
157+
s.ChannelMessageSend(m.ChannelID, "exemple: !nombre 1 100")
158+
return nil
159+
}
160+
a, err := strconv.Atoi(content[1])
161+
if err != nil {
162+
return err
163+
}
164+
b, err := strconv.Atoi(content[2])
165+
if err != nil {
166+
return err
167+
}
168+
nbr := rand.Intn(b) + a
169+
s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("%d", nbr))
170+
return nil
171+
}
172+
153173
func doRoulette(s *discordgo.Session, m *discordgo.MessageCreate) error {
154174
os.MkdirAll("data", 0777)
155175
db, err := gorm.Open("sqlite3", "data/roulette.db")

chaos-bot/go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ require (
1313
github.com/imdario/mergo v0.3.9 // indirect
1414
github.com/jinzhu/gorm v1.9.12
1515
github.com/karrick/godirwalk v1.15.6 // indirect
16+
github.com/mattn/go-sqlite3 v2.0.3+incompatible // indirect
1617
github.com/oklog/run v1.1.0
1718
github.com/peterbourgon/ff/v3 v3.0.0
1819
github.com/sirupsen/logrus v1.5.0 // indirect
@@ -24,7 +25,7 @@ require (
2425
moul.io/godev v1.6.0
2526
moul.io/moulsay v1.3.0
2627
moul.io/number-to-words v0.6.0
27-
moul.io/pipotron v1.8.1-0.20200416220341-8aa407f4150c
28+
moul.io/pipotron v1.9.0
2829
ultre.me/recettator v0.4.0
2930
)
3031

chaos-bot/go.sum

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzp
275275
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
276276
github.com/mattn/go-sqlite3 v2.0.1+incompatible h1:xQ15muvnzGBHpIpdrNi1DA5x0+TcBZzsIDwmw9uTHzw=
277277
github.com/mattn/go-sqlite3 v2.0.1+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
278+
github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U=
279+
github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
278280
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
279281
github.com/miekg/mmark v1.3.6/go.mod h1:w7r9mkTvpS55jlfyn22qJ618itLryxXBhA7Jp3FIlkw=
280282
github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ=
@@ -587,8 +589,8 @@ moul.io/moulsay v1.3.0 h1:7ZV4d2oQRuBH0M7NWKx41gG5edwXotMIgzZ2e1wgMMg=
587589
moul.io/moulsay v1.3.0/go.mod h1:m1Bd/M8JhWrsEaBBIRqwW0jgNPLectvU1vfHAv4WhFg=
588590
moul.io/number-to-words v0.6.0 h1:w5ZaDTFASB0v9SI6fedlwLs5DXnMl9Q7cMlMsatnIKg=
589591
moul.io/number-to-words v0.6.0/go.mod h1:y2h2Dy3ksovv3n7oHDypgxqCNc4X9COF0zM3jABnrnA=
590-
moul.io/pipotron v1.8.1-0.20200416220341-8aa407f4150c h1:nfTQCDOPsvI5jrhyUMh/UqZ9UOzB66wJHxeGCAmQZhk=
591-
moul.io/pipotron v1.8.1-0.20200416220341-8aa407f4150c/go.mod h1:rJ2583VCJpb/uHiSB7VzGoSnrDw1m0Erd8PGgdJmDYc=
592+
moul.io/pipotron v1.9.0 h1:T1IeRiTCAUhxnASVMGfLiDGe8FIarxQuvRsbUtV4hIk=
593+
moul.io/pipotron v1.9.0/go.mod h1:rJ2583VCJpb/uHiSB7VzGoSnrDw1m0Erd8PGgdJmDYc=
592594
moul.io/srand v1.4.0 h1:r5ZMiWDN0ni0lTV7KzJR/jx0K7GivJYW5WaXmufgeik=
593595
moul.io/srand v1.4.0/go.mod h1:P2uaZB+GFstFNo8sEj6/U8FRV1n25kD0LLckFpJ+qvc=
594596
pack.ag/amqp v0.8.0/go.mod h1:4/cbmt4EJXSKlG6LCfWHoqmN0uFdy5i/+YFz+fTfhV4=

0 commit comments

Comments
 (0)