add dice module, give it a !choose

This commit is contained in:
Brian S. Stephan 2018-01-08 10:21:30 -06:00
parent ef29f9f3e2
commit 3850595b14
3 changed files with 17 additions and 0 deletions

9
dice/__init__.py Normal file
View File

@ -0,0 +1,9 @@
"""Roll dice and do other randomization type operations."""
from bot import hitomi
from dice import lib
@hitomi.command()
async def choose(*choices: str):
"""Randomly select one item from multiple choices."""
await hitomi.say(lib.choose(*choices))

7
dice/lib.py Normal file
View File

@ -0,0 +1,7 @@
"""Functions for use in the dice module."""
import random
def choose(*choices: str):
"""Randomly choose an item from the provided multiple choices."""
return random.choice(choices)

View File

@ -38,6 +38,7 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'bot',
'dice',
]
MIDDLEWARE = [