项目作者: wireapp

项目描述 :
You know... for polls
高级语言: Kotlin
项目地址: git://github.com/wireapp/poll-bot.git
创建时间: 2020-02-26T08:27:45Z
项目社区:https://github.com/wireapp/poll-bot

开源协议:MIT License

下载


Wire Poll Bot

GitHub version
CI
Docker Latest build
Staging Deployment
Release Pipeline

Wire bot for the polls. This version is based on Roman therefore does not employ E2EE directly

Service code to enable Poll bot in your team:

  1. 3131a0af-89d4-4569-b36d-50bcced4b1fb:163a422b-c314-4e34-95af-10b6b36cde18

Commands

Basic usage

  • /poll "Question" "Option 1" "Option 2" will create poll
  • /stats will send result of the latest poll in the conversation
  • /help to show help
  • /version prints the current version of the poll bot

Technologies used

Bot is using webhooks coming from Roman, for that, the bot needs to have public URL or IP address.

Usage

  • The bot needs Postgres database up & running - we use one in docker-compose.yml, to start it up, you can use
    command make db.
  • To run the application execute make run or ./gradlew run.
  • To run the application inside the docker compose environment run make up.

For more details see Makefile.

Docker Images

Poll bot has public docker image.

  1. quay.io/wire/poll-bot

Tag latest is the latest release. Releases have then images with corresponding tag, so you
can always roll back. Tag staging is build from the latest commit in staging branch.

Bot configuration

Configuration is currently being loaded from the environment variables.

  1. /**
  2. * Username for the database.
  3. */
  4. const val DB_USER = "DB_USER"
  5. /**
  6. * Password for the database.
  7. */
  8. const val DB_PASSWORD = "DB_PASSWORD"
  9. /**
  10. * URL for the database.
  11. *
  12. * Example:
  13. * `jdbc:postgresql://localhost:5432/bot-database`
  14. */
  15. const val DB_URL = "DB_URL"
  16. /**
  17. * Token which is used for the auth of proxy.
  18. */
  19. const val SERVICE_TOKEN = "SERVICE_TOKEN"
  20. /**
  21. * Domain used for sending the messages from the bot to proxy eg. "https://proxy.services.zinfra.io/api"
  22. */
  23. const val PROXY_DOMAIN = "PROXY_DOMAIN"

Via the system variables - see complete list.

Docker Compose

To run bot inside docker compose environment with default PostgreSQL database,
please create .env file in the root directory with the following variables:

  1. # database
  2. POSTGRES_USER=
  3. POSTGRES_PASSWORD=
  4. POSTGRES_DB=
  5. # application
  6. DB_USER=
  7. DB_PASSWORD=
  8. DB_URL=
  9. SERVICE_TOKEN=
  10. PROXY_DOMAIN=

Such configuration can look for example like that:

  1. # database
  2. POSTGRES_USER=wire-poll-bot
  3. POSTGRES_PASSWORD=super-secret-wire-pwd
  4. POSTGRES_DB=poll-bot
  5. # application
  6. DB_USER=wire-poll-bot
  7. DB_PASSWORD=super-secret-wire-pwd
  8. DB_URL=jdbc:postgresql://db:5432/poll-bot
  9. SERVICE_TOKEN=x6jsd5vets967dsA01dz1cOl
  10. APP_KEY=eyJhbGciOiJIUzM4NCJ9.......
  11. PROXY_DOMAIN=https://proxy.services.zinfra.io/api