Skip to content

Commit

Permalink
add options for default question and votes
Browse files Browse the repository at this point in the history
  • Loading branch information
silberzwiebel authored and M-Mueller committed Apr 22, 2019
1 parent f54b820 commit e8a9b30
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
12 changes: 10 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
settings.BARS_BY_DEFAULT = True
if not hasattr(settings, 'BAR_IMG_URL'):
settings.BAR_IMG_URL = None
if not hasattr(settings, 'DEFAULT_QUESTION'):
settings.DEFAULT_QUESTION = None
if not hasattr(settings, 'DEFAULT_VOTES'):
settings.DEFAULT_VOTES = []


def parse_slash_command(command):
Expand All @@ -55,8 +59,12 @@ def parse_slash_command(command):
- locale: str
"""
args = [arg.strip() for arg in command.split('--')]
message = args[0]
vote_options = []
if not args[0]:
message = settings.DEFAULT_QUESTION
vote_options = settings.DEFAULT_VOTES
else:
message = args[0]
vote_options = []
progress = settings.PROGRESS_BY_DEFAULT
public = settings.PUBLIC_BY_DEFAULT
bars = settings.BARS_BY_DEFAULT
Expand Down
6 changes: 6 additions & 0 deletions settings.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ PUBLIC_BY_DEFAULT = False
PROGRESS_BY_DEFAULT = True
BARS_BY_DEFAULT = True

# Set default question and vote possibilities, if the user does not provide
# any of those (i.e., if the user just writes the slash command).
# If these options are not set, the default behavior is to show the help message.
# DEFAULT_QUESTION = "What is your favorite color?"
# DEFAULT_VOTES = ["Green", "Blue", "Red"]

# Uncomment the following lines to enable file logging:
#import logging
#logging.basicConfig(filename='poll.log', level=logging.DEBUG)
Expand Down

0 comments on commit e8a9b30

Please sign in to comment.