Skip to content

Provides a slash command to create polls in Mattermost

License

Notifications You must be signed in to change notification settings

Alderaaan/mattermost-poll

 
 

Repository files navigation

Mattermost Poll

Build Status codecov

Provides a slash command to create polls in Mattermost.

Example

By default, a poll will only offer the options Yes and No. However, users can also specify an arbitrary number of choices:

Example

Choices are separated by --.

Additional options

  • --noprogress: Do not display the number of votes until the poll is ended
  • --public: Show who voted for what at the end of the poll
  • --votes=X: Allows users to place a total of X votes. Default is 1. Each individual option can still only be voted once.
  • --bars: Show results as a bar chart at the end of the poll.
  • --locale=X: Use a specific locale for the poll. Supported values are en and de. By default it's the users language.

Help

/poll help will display full usage options. Only visible to you.

Set the "Autocomplete Hint" in the Slash Command settings to See "/poll help" for full usage options

Requirements

  • Python >= 3.6
  • Flask
  • Tornado
  • Requests

Setup

Copy settings.py.example to settings.py and customise your settings.

Start the server:

python run.py
  1. In Mattermost go to Main Menu -> Integrations -> Slash Commands and add a new slash command with the URL of the server including the configured port number, e.g. http://localhost:5000.
  2. Choose POST for the request method.
    • Optionally add the generated token to your settings.py (requires server restart).
  3. Edit your Mattermost config.json to include "localhost" in the "AllowedUntrustedInternalConnections" setting, e.g. "AllowedUntrustedInternalConnections": "localhost"

To resolve usernames in --public polls and to provide localization, the server needs access to the Mattermost API. For this a personal access token must be provided in your settings.py. Which user provides the token doesn't matter, e.g. you can create a dummy account. If no token is provided --public polls will not be available and all texts will be english.

Docker

To integrate with mattermost-docker:

cd mattermost-docker
git submodule add [email protected]:M-Mueller/mattermost-poll.git poll

and add the following to the services section:

  poll:
    build:
      context: poll
      args:
        - mattermost_url="http://web"
        - mattermost_tokens=['<mattermost-token-1>', '<mattermost-token-2>']
        - mattermost_pa_token="<personal-access-token>"
    ports:
      - "5000:5000"
    restart: unless-stopped
    volumes:
      - ./volumes/poll:/app/volume:rw
  1. In Mattermost go to Main Menu -> Integrations -> Slash Commands and add a new slash command with the URL of the server including the configured port number, e.g. http://poll:5000.
  2. Choose POST for the request method.
  3. Edit your Mattermost config.json to include "poll" in the "AllowedUntrustedInternalConnections" setting, e.g. "AllowedUntrustedInternalConnections": "poll"

About

Provides a slash command to create polls in Mattermost

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.0%
  • Dockerfile 1.0%