Code Monkey home page Code Monkey logo

derekshaheen / paul-bot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from abrahammurciano/paul-bot

0.0 0.0 0.0 566 KB

Hi! I'm Paul; a teeny tiny bot who's good at one thing. Making polls. And when I say good, I mean really really good. Like the bestest best bot ever at making polls. I can make open polls, I can make closed polls, I can make dynamically editable polls, and I can make them any size. And all that with a simple, good-looking, and easy to use interface

License: GNU General Public License v3.0

Python 99.72% Dockerfile 0.28%

paul-bot's Introduction

Paul - The bestest polling bot ever

Hi! I'm Paul; a teeny tiny bot who's good at one thing. Making polls. And when I say good, I mean really really good. Like the bestest best bot ever at making polls. I can make open polls, I can make closed polls, I can make dynamically editable polls, and I can make them any size. And all that with a simple, good-looking, and easy to use interface! So come on and try me out in your server!

Table of Contents

Links

Features

Paul has many features. In fact I believe it has the most features out of any other poll bot I could find. After all, that's why I made him; because I couldn't find a feature rich poll bot with an easy and well designed interface.

  • Uses a slash command to create the poll.
  • Uses buttons to vote and interact with existing polls.
  • Polls are persistent (That means if the bot goes offline it will remember its old polls when it comes back online)
  • Highly customizable permissions for each action (voting, editing, viewing).
  • Set expiry dates on polls.
  • Option to allow multiple votes per person.
  • Option to allow certain people (or everyone) to view the votes.
  • Option to allow people to add options to the poll.
  • Option to restrict votes to certain roles and/or users.
  • Beautiful interface.
  • Button for the poll creator to close the poll at will.

Usage

This bot has a very simple interface. There is only one command. /poll. Below are the parameters it accepts.

question

Specify the question that the poll is asking. This parameter is required.

Example:

/poll question: Do you like potatoes?

question example

options

Choose which options will be available for people to vote for. This parameter is optional, and by default will be Yes/No.

When entering options, you must separate each option with a pipe character (|). (Trailing spaces around the pipe will be ignored.)

Example:

/poll question: How do you like your potatoes? options: boiled | mashed | in a stew

options example

expires

With this parameter, you can choose when the poll will expire. Once the poll is expired, the vote buttons will disappear. By default, polls expire 30 days from creation.

When entering the expiry date/time, you may be quite liberal in its format. You can enter a relative date/time, such as "in 2 minutes", "1h20m", "tomorrow", "next week", etc; or you can enter an absolute date/time, such as "5 PM", "26 oct 2022", etc.

When using an absolute time such as "5 PM", it will be treated as UTC time. To specify a time zone, just include it in your input, for example "5 PM GMT+3" or "5 PM EST"

Example:

/poll question: Do you like potatoes? expires: 1h20m

expires example

allow_multiple_votes

With this parameter you can control whether or not to allow people to vote on several different options. By default each voter may vote for only one option. If you set this to True, then each voter can vote for each option up to one time.

Example:

/poll question: Do you like potatoes? allow_multiple_votes: True

allow_multiple_votes example

allowed_vote_viewers

This parameter allows you to specify which users or roles are allowed to see who voted for each option. By default, votes are private and cannot be seen by anyone.

When specifying this parameter, you must mention all the roles and/or users you want to allow.

If this parameter is specified, then an additional button will appear underneath the poll which can be clicked by the allowed people for them to see the votes.

Example:

/poll question: Do you like potatoes? allowed_vote_viewers: @everyone

allowed_vote_viewers example

allowed_editors

With this parameter, you can specify who will be allowed to add options to the poll. By default, only you can add options.

People with permission may click the "Add Option" button, after which the bot will prompt them to enter a new option within a minute. When they do, the option will be added to the poll with a note saying who it was added by.

Example:

*Click "Add Option" button

allowed_editors example

allowed_voters

Use this parameter to restrict who may vote to a set of users and roles. By default everyone may vote.

Example:

/poll question: Do you like potatoes? allowed_voters: @Admin|๐Ÿ”ฑ @Abraham|๐Ÿ‘‘๐Ÿ”ฑ

allowed_voters example

Closing the poll

You can use the big red button to close the poll manually without waiting for it to expire. Once you do this, there's no turning back. Only the poll creator can do this.

Self Hosting

This bot is hosted on fly.io so these instructions are tailored to that platform. However, you can host it on any other platform, you'll just need to figure out how to do it yourself.

Create a bot

  1. Go to the Discord Developer Portal and create a new application.
  2. Go to the "Bot" tab and click "Add Bot".
  3. Copy the token and save it for later.

Create a fly.io app

  1. Install the fly.io CLI by following the instructions here.
  2. Use flyctl auth login or flyctl auth signup to (create and) log in to your fly.io account.
  3. Run flyctl create and follow the instructions to create a new app.

Create a PostgreSQL database

You can use any PostgreSQL hosting service you like. Here are instructions for hosting one on fly.io.

Run the following commands to create a new PostgreSQL app and attach it to your main app. When you attach it, a new user and database will be created for the main app.

flyctl postgres create --name <app-name>-db
flyctl postgres attach <app-name>-db

The output of the attach command will contain the connection string which has the username, password, host, etc. It will look something like this:

postgres://<app-name>:<password>@<app-name>-db.flycast:5432/<app-name>

It will be added as a secret (named DATABASE_URL) in the main app. Also, make a note of it as we'll need to create the initial schema on the database.

Initialize the database

You need to run the paul_bot/data/schema.psql file on the database to create the necessary schema.

First run the following command to make localhost:5432 act as a proxy to the fly.io database. It will block until you cancel with Ctrl+C, so run it in a different shell.

flyctl proxy 5432 -a <app-name>-db

Then run this command to import the schema:

psql postgres://<app-name>:<password>@localhost:5432/<app-name> -f paul_bot/data/schema.psql

Set fly.io secrets

Use the following command to set the secrets for the bot.

flyctl secrets set BOT_TOKEN=<your-bot-token> DBG_CHANNEL=<channel-id> ERR_CHANNEL=<channel-id>
  • BOT_TOKEN is the token you copied from the Discord Developer Portal.
  • DBG_CHANNEL (optional) is the channel ID where you want to receive debug messages.
  • ERR_CHANNEL (optional) is the channel ID where you want to receive error messages.

paul-bot's People

Contributors

abrahammurciano avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.