Coder Social home page Coder Social logo

podaboutlist / santa Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 3.0 110 KB

Discord bot for sending and collecting gifts

Home Page: https://podaboutli.st/discord

License: GNU Affero General Public License v3.0

Python 98.25% Shell 1.23% Dockerfile 0.52%
discord-bot discord-py postgresql ponyorm sql discord agpl holidays santa docker

santa's Introduction

santa's People

Contributors

propane-accessories avatar ralphorama avatar theelk801 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

santa's Issues

[docker] Update docker-compose.yml to log SantaBot container output to file

Description of the New Feature

Add logging to file to make it easier to inspect exceptions and fix bugs. Easier than scrolling through docker logs.

Added Functionality

This feature changes or adds functionality to:

  • The Discord Bot
  • The Database or API
  • Other program functionality (.env, scripts, etc.)
  • Documentation
  • Containerization
  • CI
  • Other:

New/Additional Dependencies

  • My feature request does not add any external dependencies

[cog] implement @santa stats [me|@user|global]

Description of the New Feature

Replacing the @santa my and @santa global commands is the @santa stats command.

Added Functionality

This feature changes or adds functionality to: report various statistics about gift-giving through the bot. Ideally I'd like these wrapped in an Embed to give them some snazz.

Commands would function as follows:

  • @santa stats: prints a message asking for me, a @mention, or global
  • @santa stats me: displays the following statistics for a user:
    • Current present count
    • Stolen present count
    • Gifted present count
    • Grinch visit count
    • Max owned presents at any time (already stored as max_present_count in santabot/db/models/user.py
    • Possibly more - leave your ideas in the comments

Affected Components

  • The Discord Bot
  • The Database or API
  • Other program functionality (.env, scripts, etc.)
  • Documentation
  • Containerization
  • CI
  • Other:

New/Additional Dependencies

  • My feature request does not add any external dependencies

[db] Bot appears online even when not connected to the database

Description of the Bug

When using Postgres as a database provider, cooldowns on gifting times don't work.

Steps to Reproduce the Bug

  1. Set up docker-compose.yml using the one from docs/
  2. run docker-compose up
  3. In Discord, ask for gifts multiple times rapidly
  4. No cooldown is enforced

The Bug Affects

  • The Discord Bot
  • The Database or API
  • Other program functionality (.env, scripts, etc.)
  • Documentation
  • Containerization
  • CI
  • Other:

Replace config.json with environment variables

What the title says. Move the data we're currently storing in config/config.json to environment variables so we can use .env files and easily deploy Docker images.

There is still some code in santabot/cogs/grinch.py that fetches the webhook avatar URL which was going to use data from config.json. See line #23. Shouldn't be missed when working on this issue.

[CI] Unit Tests

We need to configure unit tests. These should include:

  • Testing bot commands
  • Testing helper classes (i.e. GrinchManager)
  • Testing the database
    • Populating data
    • Modifying data
    • Testing queries

[bot] Add stats to channel topic

Having channel stats/leaderboard in the #christmas channel topic seems like a good idea, then it can auto update on an interval rather than having to be summoned. Need to investigate how to edit a topic and how to implement recurring processes.

This feature changes or adds functionality to:

  • The Discord Bot
  • The Database or API
  • Other program functionality (.env, scripts, etc.)
  • Documentation
  • Containerization
  • CI
  • Other:

New/Additional Dependencies

  • My feature request does not add any external dependencies

[bot] Add @santabot debug

Description of the New Feature

Add @santabot debug command that displays:

  • current commit hash
  • database connection status
  • uptime
  • python version

Only allow the command to run if the user is a server admin.

Added Functionality

This feature changes or adds functionality to:

  • The Discord Bot
  • The Database or API
  • Other program functionality (.env, scripts, etc.)
  • Documentation
  • Containerization
  • CI
  • Other:

New/Additional Dependencies

  • My feature request does not add any external dependencies

[bot] Make sure gift names aren't empty

Description of the Bug

Discord already strips white space from the end of messages, but sometimes present names are still blank?

Screen Shot 2020-12-15 at 11 45 55 AM

Steps to Reproduce the Bug

  1. Run @SantaBot (beta) please give me
  2. Santa gives you a present with an empty name

The Bug Affects

  • The Discord Bot
  • The Database or API
  • Other program functionality (.env, scripts, etc.)
  • Documentation
  • Containerization
  • CI
  • Other:

[cog] Implement @santa help

Description of the New Feature

Implement a help page for SantaBot. This could be achieved through customizing Discord.py's built in HelpCommand, or by writing a GitHub Gist, markdown file in this repo, GitHub Wiki page, custom web page, or any other method of effectively showing the user how to use the bot.

More user testing is also needed to figure out what the best way to display functionality is.

Added Functionality

The @santa help command should effectively communicate how to use SantaBot to users.

Affected Components

  • The Discord Bot
  • The Database or API
  • Other program functionality (.env, scripts, etc.)
  • Documentation
  • Containerization
  • CI
  • Other:

New/Additional Dependencies

  • My feature request does not add any external dependencies*

* Unless we create a new website lol

[db] Stretch goal: change perspective in present names from first to second person

Description of the Bug

If you say, for example, @santa give me my own item, you get the response check... for my own item. A stretch goal is implementing changing perspective to second person, where we would see something like:

@santa give me my own item -> check... for your own item

The Bug Affects

  • The Discord Bot
  • The Database or API
  • Other program functionality (.env, scripts, etc.)
  • Documentation
  • Containerization
  • CI
  • Other:

[cog] Admin Commands

Didn't include these in the design doc, but these should get some consideration: commands for administrative action.

Functionality should include but isn't limited to:

  • deleting presents by ID
  • deleting all of a user's presents
  • banning a user from using the system

[bot] Add word filter for present names

Description of the New Feature

Implementation with the wordfilter package would be very simple. We can use the default list and simply reject the present if it has a bad word in the name.

Added Functionality

This feature changes or adds functionality to:

  • The Discord Bot
  • The Database or API
  • Other program functionality (.env, scripts, etc.)
  • Documentation
  • Containerization
  • CI
  • Other:

New/Additional Dependencies

  • My feature request does not add any external dependencies

Adds wordfilter, which will speed up development time without adding too large a dependency.

[bot] Setting status message to git commit hash doesn't work in Docker container

Description of the Bug

docker build doesn't include the .git directory, so git rev-parse --short HEAD fails when trying to set the bot's status message. One possible solution is to move Docker builds to Travis, then use docker push so we can use Travis to set default environment variables for the image

Steps to Reproduce the Bug

  1. Launch the bot using the Docker container (ralphorama/santabot)
  2. Watch log output

The Bug Affects

  • The Discord Bot
  • The Database or API
  • Other program functionality (.env, scripts, etc.)
  • Documentation
  • Containerization
  • CI
  • Other:

[docker] Set up Docker support

Description of the New Feature

Docker kicks ass. Gotta add it to this repo.

We'd need to add:

  • Dockerfile
  • .dockerignore
  • docs/docker/docker-compose.yml example configuration file

And:

  • Enable image builds on Docker Hub

Added Functionality

This feature changes or adds functionality to:

  • The Discord Bot
  • The Database or API
  • Other program functionality (.env, scripts, etc.)
  • Documentation
  • Containerization
  • CI
  • Other:

New/Additional Dependencies

  • My feature request does not add any external dependencies

Adds optional dependencies on Docker, but not required.

[feat] Database Integration

The limiting factor for this project right now is getting database integration up and running.

The DB functionality should be accessible from individual cogs so database logic can be abstracted out to its respective functions.

We need tables to store data for:

  • users
  • presents
  • servers

Functionality that we still need to add:

  • Bot interactions with the database
  • PostgreSQL integration (instead of sqlite in memory)
  • A real test suite (see #6)

[bot] @santa give cooldowns not being respected

Description of the Bug

When using @santabot give, after a while, the cooldown stops being enforced. I'm sure this is some logical blunder on my part.

Steps to Reproduce the Bug

  1. Run SantaBot for a while and issue multiple give commands
  2. After some time, cooldowns stop being enforced

The Bug Affects

  • The Discord Bot
  • The Database or API
  • Other program functionality (.env, scripts, etc.)
  • Documentation
  • Containerization
  • CI
  • Other:

[bot] @santabot stats should default to @santabot stats global functionality

Description of the Bug

Currently, @santabot stats doesn't display anything. It should display the same information as @santabot stats global.

Steps to Reproduce the Bug

  1. Issue the @santabot stats command
  2. Nothing happens.

The Bug Affects

  • The Discord Bot
  • The Database or API
  • Other program functionality (.env, scripts, etc.)
  • Documentation
  • Containerization
  • CI
  • Other:

[docs] Update README.md

Description of the New Feature

README.md needs some updates to documentation. It could use:

  • Links to PAL socials
  • "About" section
  • "Contributing" section with details about workspace setup, testing, CI, and code style
  • More badges lol (AGPL, Python 3, whatever)

If I think of more stuff I'll add it to the list.

Added Functionality

This feature changes or adds functionality to:

  • The Discord Bot
  • The Database or API
  • Other program functionality (.env, scripts, etc.)
  • Documentation
  • Containerization
  • CI
  • Other:

External Dependencies

  • My feature request does not add any external dependencies

Persist and re-use webhook information

Depends on #2.

The current implementation of santabot/cogs/grinch.py contains the class GrinchManager which caches a discord.Webhook object, but doesn't save the details for when the bot is restarted. This leads to a lot of webhooks getting created when testing the grinch commands that one needs to delete by hand.

Once database support is functional, we should cache these values in the db. See docs/DESIGN.md for more info.

[bot] Rewrite "Grinch Chance" algorithm

Description of the Bug

The current algorithm for predicting the chance of the Grinch visiting the user seems to result in a very high visit rate (only tested at a lower number of gifts). See the current implementation here

My current implementation for the Grinch Visit algorithm is:

def calc_steal_chance() -> bool:
    # Generate a number between 0 and the # of presents the User currently owns
    rand_int = random.randint(0, current_present_count)
    # Take the cube root of the User's present count
    threshold = int(present_count ** (1 / 3))
    # If the user said 'Please', give them a 5% better chance at not failing the check
    threshold = threshold * 1.05 if please else threshold
    # If rand_int > threshold, steal presents
    return rand_int > threshold

The logic behind this was to use cube root falloff so as a user's present count gets higher, the threshold determined via cube root levels off (see graph).

Cube root vs y=x

However, this dropoff is way too fast. Gotta rewrite the algo.

Steps to Reproduce the Bug

n/a

The Bug Affects

  • The Discord Bot
  • The Database or API
  • Other program functionality (.env, scripts, etc.)
  • Documentation
  • Containerization
  • CI
  • Other:

[bot] Add status message to bot

Description of the New Feature

Discord users can set arbitrary status messages. The bot should have one that, ideally, would rotate through several messages on a timer:
- ''Use @santa help for help"
- "Sent {0} presents to {1} users"
- "Christmas (EST) is in days_left days"

For now, a static message that just displays the first help message is fine.

Added Functionality

This feature changes or adds functionality to:

  • The Discord Bot
  • The Database or API
  • Other program functionality (.env, scripts, etc.)
  • Documentation
  • Containerization
  • CI
  • Other:

New/Additional Features

  • My feature request does not add any external dependencies

[docs] Add typing hints and docstrings to cogs

Some cogs have functions to which I didn't add type hints or docstrings. Adding these will definitely help new contributors to this project.

Please keep in mind you should add documentation like this to your own code before submitting PRs. Don't be lazy like me!

Implement Command Cogs

The following command cogs need implementation:

  • global.py (depends on #2)
  • help.py (good first cog)
  • invite.py (good first cog)
  • my.py (depends on #2)

See docs/DESIGN.md for more information involving command implementation if you would like to help.

[bot] Add @santabot top [all] command

Description of the New Feature

Adds leader boards, sorted by gift count. @santa top displays the users with the most presents in the server. @santa top all displays users with the most presents from all servers.

Added Functionality

This feature changes or adds functionality to:

  • The Discord Bot
  • The Database or API
  • Other program functionality (.env, scripts, etc.)
  • Documentation
  • Containerization
  • CI
  • Other:

New/Additional Dependencies

  • My feature request does not add any external dependencies

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.