Skip to content

Commit

Permalink
Add best of flag to choose
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinMcKechney committed Aug 9, 2024
1 parent 6e5d392 commit edc63e1
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/bobbit/modules/choose.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,28 @@

NAME = 'choose'
ENABLE = True
PATTERN = '^!choose (?P<options>.*)'
USAGE = '''Usage: !choose <options>
PATTERN = '^!choose (?:-b (?P<best_of>[0-9]) )?(?P<options>.*)'
USAGE = '''Usage: !choose [FLAG] <options>
Given a list of options separated by "or", this chooses one of them.
-b <best_of>
choose <best_of> times
Example:
> !choose stay or go
stay
'''

# Command

async def choose(bot, message, options=None):
async def choose(bot, message, options=None, best_of=None):
options = options.split(' or ')
return message.with_body(random.choice(options))
if best_of is None:
return message.with_body(random.choice(options))
else:
choices = ''
for i in range(0, int(best_of)):
choices += random.choice(options) + '\n'
return message.with_body(choices.strip())


# Register

Expand Down

0 comments on commit edc63e1

Please sign in to comment.