Giter Club home page Giter Club logo

dicebot's Introduction

DiceBot

DiceBot is a Slack app.

  • roll.go - The dice parsing logic.
  • oauth.go - The Slack specific authentication and parsing.

Installing

Click Add to Slack on this page to install into your own Slack.

Usage

The DiceBot app does a pretty forgiving parsing of the text passed to the /roll command, to figure out what sort of dice to roll and how to use them.

First, it scans the string for all the "roll expressions" it can find. Each roll expression consists of:

  1. An optional operation, either:

    • + for addition
    • - for subtraction
    • * or ร— for multiplication
    • / for division
    • ^ for maximum
    • v for minimum

    If there is no operation, addition is assumed. (So, 1d20 1d20 will roll two d20s and add the results.)

    There is no "order of operations" or grouping of roll expressions; each expression's operation applies its value to the result of all the preceding expressions. For example, 1d4 * 1d6 ^ 1d8 + 1d10 will roll 1d4, then roll 1d6 and multiply the previous result by that, then roll 1d8 and take either that value or the previous result, whichever is higher, then roll 1d10 and add it to the previous result. If the rolls were 1 5 3 8, the result would be (((1 * 5) ^ 3) + 8), totalling 13.

  2. A "dice expression", defined below.

  3. Optionally, a "for" value, like 2d6 for damage, which will print out in the results to help explain what was rolled. (The "for" value will consume all the text up to the next comma or semicolon.)

Any text other than the roll expressions is ignored, and won't have any effect on the result.

A "dice expression" instructs the bot how many and what kind of dice to roll, and what additional special actions to take. There are a few possible forms:

  1. Just a number, by itself, between 1 and 99999.
  2. Fudge dice, like 5f, which rolls 5 fudge dice (between 1 and 99999).
  3. A full standard notation dice expression, with the following pieces (in order):
    • Optionally, the number of dice to roll, between 1 and 999. If omitted, defaults to 1.
    • The type of dice to roll: either df for fudge dice, d% for percentile dice, or d6 (for any number between 1 and 1000) for dice with that many sides.
    • Optionally, a ! to indicate that the dice "explode", rolling an additional die of the same size when the max value is rolled.
    • Optionally, a <5 or >5 (for any number between 2 and the die size - 1) to indicate that you want to count up how many dice rolled below or above the value.
    • Optionally, a k5 or k-5 (for any number between -999 and 999) to indicate that only the best K (for positive values) or worst K (for negative values) rolls should be counted in the result.

If no dice expression is provided, the DiceBot app will default to 2d6 or two six-sided dice similar to //roll from AOL Instant Messenger.

Examples

D&D rolls can be written just like they are in text: 1d20 + 4, 8d6, etc. To roll with advantage or disadvantage, use the k modifier, like 2d20k1 + 2 for advantage, or 2d20k-1 + 2 for disadvantage. The "standard" stat-rolling method can be written as 4d6k3 for Str, etc., rolling 4 dice and dropping the lowest.

World of Darkness rolls should be written like 5d10!>7, which will roll 5 exploding d10s, and count how many exceed 7 (are 8 or higher).

"For" values can make a result easier to read, like 1d8+1 for sword, +1d6 for fire which will print out something like "@dm rolled 5 + 1 for sword + 1 for fire = 7". (Note the comma after the first "for" value - it'll parse wrong if you leave that off.)

Running Locally

  • git clone https://github.com/idkclub/dicebot.git, followed by cd dicebot
  • go run .

dicebot's People

Contributors

arkie avatar katre avatar tabatkins avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dicebot's Issues

Avatar is broken

S3 isn't delivering the avatar for the bot in Slack.

This XML file does not appear to have any style information associated with it. The document tree is shown below.

AccessDenied
Access Denied
991E6B1381134625

d2KtzU8AI8eFZWK8otd6PwpU+FZPCdUOps2FmDqGsthh/aWDAZ3TZzSJHPkHbmpsqjmoFNUKwdE=

parsing words with number

Is this intentional behavior? Here, I have not written 'for test1' by omitting the 'for'.
/roll d6+6 test1
and dicebot gives me
@xxxx rolled 6 + 6 + 1 = 13

Dicebot has parsed the string 'test1' and interpreted it as intent to add 1.

Rerolls?

Hey,

I was wondering if there was an option I didn't find, or maybe a plan to add reroll supports?
Something like:
/roll 4d6r<2
Which would roll 4d6 and reroll all 1s and 2s.
And maybe something like /roll 4d6r1r4 to reroll 1s and 4s ?

Thanks!

rolling 2 dice types

One can roll 2d4+1 correctly but the 3d4+3d6 will interpreted as (3d4+3)+(1d6)

rolled d0

Yes, Installed this on a slack instance and a user tried to roll a d0, because geeks.

Anyways.. this should probably return an error instead of a value. ie:

User [8:48 AM]
/roll 10d0
Dicebot APP [8:48 AM]
@user rolled 10

User [8:49 AM]
/roll 0d0
Dicebot APP [8:49 AM]
@user rolled 1

[Feature Request] Addition to dice rolls

This is a small annoyance if anything, but it would be cool if we could do something like 2d10+3 and have the dice roll add the 3 automatically. Obviously this is easy to do ourselves, but would be cooler if the app took care of that was well.

Would you accept some documentation?

Heya, I've been using dicebot for a while and loving it, but I've been forced to gradually discover the functionality from usage, as there is effectively no documentation for the project. I write specs for a living, and would be happy to write up some docs for the syntaxes - would you accept a PR to your README?

Add Support for Modifiers

This slack app is pretty sweet, but it would be even sweeter if you could specify a modifier to be added to the roll. I added this to a D&D team that I started and the modifier would make it perfect for playing out scenarios.

Example: /roll 1d20+3 would get the random roll for a 20-sided die and add 3 to it.

Cannot divide

I noticed we can do some math operations ( /roll 2*2 return 4) but when i do /roll 1/2 i get 0 in return.

Savage Worlds exploding dice +wild die

Is it possible to have dice explode (if the result is the highest number on the die roll it again and add them together)? right now when you type explode it adds a d6 which doesn't explode and adds it to your total.

I would also like to see an option to roll two dice, 1d8 and 1d6 for example, and take the higher result for the Savage Worlds wild die mechanic.

Allow for multi-roll.

I have been giving this a go and love it so far, but was curious if this supported something like multi-roll? This would look something like:

/roll 6 4d6k3

Rolling 6 iterations...
4d6kh3 (4, 2, 5, 2) = 11
4d6kh3 (6, 3, 6, 2) = 15
4d6kh3 (3, 1, 2, 2) = 7
4d6kh3 (3, 2, 1, 3) = 8
4d6kh3 (6, 1, 3, 3) = 12
4d6kh3 (3, 2, 1, 1) = 6

This could be pretty useful for something like rolling stats for D&D or rolling for a bunch of enemies at once.

Stopped working today.

We kept getting a failure message. I don't recall the exact text. I uninstalled with the intent to reinstall; however, we can't get it to install now. It worked fine yesterday.

Certain rolls no longer work

Currently certain rolls, at least '/roll 1d6' and all rolls with no die number ('/roll d20'), are broken. However, '/roll 1 d6' works. Maybe something wrong with the regexp?

Dicebot misunderstands capitalized dice rolls

When telling Dicebot to roll dice like "1D20", it instead rolls 2 6-sided dice, instead of 1 20-sided.

scarius [9:28 PM]
/roll 1D20+4 perception

Dicebot BOT [9:28 PM]
@Scarius rolled โ€‹_8_โ€‹

Dice

2d6

Rolls

3 5

Support for multiple dice

Could you add support for multiple independent dice? The Savage World mechanic is a good example where a players rolls on dice(which explodes) and a secondary dice(named wild dice, typically a d6 which could also explode and takes the higher result of the two.

DiceTool has this mechanic in incorporated via a ";" separator(if I recall correctly)

So a possible implementation example might be:

/roll 1d8!;1d6!

Foo rolled 11 & 5
Dice Rolls
1d8 8 3
1d6 5

a "for" flag would be cool

We're playing a game with multiple characters. It would be cool if you could pass a flag like "for:Lothar"
or something along those lines so you could tag which roll was for which character.

/roll 3d6 for:Lothar

the output would something like:

@kelmerp rolls a 12 for Lothar
Dice                       Rolls
3d6                        2 6 4

or

/roll mini 1d20 for:Lothar

the output would be something:

@kelmerp rolls 10 for Lothar

Support not sending the /roll chat to the channel

Right now if you type in "/roll", it sends that text to the channel. Can we have an option to not send it to the channel like a normal slash command or is that a limitation of the permissions that the bot has been granted?

Only unique rolls

Hi. My team uses this great bot to decide on who is going to do assigned tasks. For example, on my team of 6 we /roll 3d6 to choose three people to do some task.

Unfortunately, we often get roll results like 5 5 1, so we have to re-roll to get a set of three numbers.

It would be great if the bot could support something like /roll 3du6 (3 unique d6 rolls).

Thanks

Dice rolling in slack threads

I hope this is the right place to make requests. Me and my friends use the dice rolling app in slack for a D&D game we are playing and it is a great app. It would be extremely helpful to be able to use the dice rolling app in the slack threads you can start when someone posts something. Currently you can only use /roll in the main chat channel. Is this possible? Sorry to bother you about it but I don't know the first thing about coding.

Feature Request: Aliases

First off, thanks for making dicebot!

It would be great if roll instructions could be saved to an alias, scoped to a user.

As a suggestion, the syntax could be extended with a = character to define an alias.

/roll d20+3 for perception =perception

would then get a reply such as

@you rolled 8 + 3 = 11 for perception. In the future, you may say just "/roll perception".

I realize this would necessarily add some kind of data storage, but I think it'd add quite some value for people who use dicebot for complicated games, especially on mobile devices.

`1 - 1 = -2`

This input /roll -1d-1 results in:

[user] rolled *1* - *1* = *-2*

Yes, it's a nonsense input, but it's a bit silly that the output can be a mathematically invalid expression.

Afford use of all operators in conjunction with `for`?

When I do:

/roll 1d3 for foo, + 1d3 for bar

I get the both results added.

When I do:

/roll 1d3 for foo, + 1d3 for bar

I get the both results subtracted.

But when I do:

/roll 1d3 for foo, ^ 1d3 for bar

I get the both results added. I would like to see the maximum. Is it possible to do this?

Add support for Fate Dice

/roll dFate - roll four fate dice
/roll dfate, /roll dFate, /roll df, /roll dF - alternate calls for above

/roll XdFate - roll X fate dice
/roll Xdfate, /roll XdFate, /roll Xdf, /roll XdF - alternate calls for above

Compact Version or way to hide

Hello,

When my workspace uses dicebot for public stat rolling, it really clogs up our channel (see below image). While I love the breakout, it adds quite a lot of clutter and I can't figure out how to remove or hide the dicebot messages (maybe there are ways but FYI I'm not an admin).

Anyway, I was wondering if there were a way for rolls like this to be compacted.

For instance, maybe running the command from the pic below (with an additional keyword)...

/roll compact 4d6k3 for Stat1, 4d6k3 for Stat2, 4d6k3 for Stat3, 4d6k3 for Stat4, 4d6k3 for Stat45, 4d6k3 for Stat6

...has the following result:

@.Person rolled 12 for Stat1 +7 for Stat2 +13 for Stat3 +11 for Stat4 16 for Stat5 +14 for Stat6 = 73
(Dice: 4d6)(Keep: 3)(Rolls: 3 4 5)(Removed: 1) Total = 12
(Dice: 4d6)(Keep: 3)(Rolls: 1 1 5)(Removed: 1) Total = 7
(Dice: 4d6)(Keep: 3)(Rolls: 4 4 5)(Removed: 3) Total = 13
(Dice: 4d6)(Keep: 3)(Rolls: 2 3 6)(Removed: 2) Total = 11
(Dice: 4d6)(Keep: 3)(Rolls: 4 6 6)(Removed: 2) Total = 16
(Dice: 4d6)(Keep: 3)(Rolls: 2 6 6)(Removed: 1) Total = 14

Currently this is the result, imagine 6-8 of these in your channel ๐Ÿ˜ฑ
image

Updating to GCP

I am trying to run this on my own since I have some changes I'd like that is not worth pushing (setting mini to default)

I am having a lot of errors getting this going. Has this been updated to support the latest GCP?
Examples are:

  • No more api_version
  • runtime should be changed to a specific go version like go111

Thread roll

Could the dicer bot make the roll in threads ? This would allow for clean sub-conversation rolls as well .

ie.

in a thread, /roll 2d6

Numbers overflow

/roll 15123d123123

Dicebot APP [6:34 PM]
@vegi rolled 15123 + 908 + 23 = 16054
Dice
1d1000
Rolls
908

It seems that the numbers overflow.

Channel integration

Hey,
Nice app, it is a lot of fun. Would you be able to add integration to allow it to only deployed to a specific channel like many other apps?

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.