allthingslinux / tux

Tux is an all in one bot for the All Things Linux discord server.
https://discord.gg/linux
GNU General Public License v3.0
79 stars 24 forks source link

565 add poll ban #567

Closed FluxC0 closed 1 day ago

FluxC0 commented 5 days ago

Description

Creates the pollban command, which can prevent someone from making polls using tux. Fixes #565 .

Guidelines

How Has This Been Tested? (if applicable)

I used pollban on myself to make sure the command processed, and then tested making a poll afterwards to ensure that the ban works. Then, i unbanned myself and tested making polls afterward.

Summary by Sourcery

Add new commands 'pollban' and 'pollunban' to manage user permissions for creating polls. Implement checks to enforce poll bans and update documentation to reflect these changes.

New Features:

Enhancements:

Documentation:

sourcery-ai[bot] commented 5 days ago

Reviewer's Guide by Sourcery

This pull request implements a new feature to ban users from creating polls using the Tux bot. It introduces new commands for poll banning and unbanning, adds checks to prevent poll-banned users from creating polls, and includes the necessary database interactions to manage these bans.

File-Level Changes

Change Details Files
Implement poll ban and unban functionality
  • Add PollBanFlags and PollUnbanFlags classes for command flags
  • Create PollBan cog with poll_ban command and is_pollbanned method
  • Create PollUnban cog with poll_unban command
  • Add database interactions for managing poll bans and unbans
tux/utils/flags.py
tux/cogs/moderation/pollban.py
tux/cogs/moderation/pollunban.py
Update Poll cog to check for poll bans
  • Add is_pollbanned method to Poll cog
  • Implement check for poll ban before allowing poll creation
  • Add CaseController to Poll cog initialization
tux/cogs/utility/poll.py

Sequence Diagrams

Poll Ban Process

sequenceDiagram
    participant User
    participant Tux
    participant Database
    User->>Tux: /pollban command
    Tux->>Database: Check if user is already banned
    Database-->>Tux: Ban status
    alt User not banned
        Tux->>Database: Insert POLLBAN case
        Tux->>User: Send confirmation
    else User already banned
        Tux->>User: Send 'already banned' message
    end

Poll Creation with Ban Check

sequenceDiagram
    participant User
    participant Tux
    participant Database
    User->>Tux: /poll command
    Tux->>Database: Check if user is poll banned
    Database-->>Tux: Ban status
    alt User not banned
        Tux->>Tux: Create poll
        Tux->>User: Send poll
    else User is banned
        Tux->>User: Send 'poll banned' message
    end

Tips - Trigger a new Sourcery review by commenting `@sourcery-ai review` on the pull request. - Continue your discussion with Sourcery by replying directly to review comments. - You can change your review settings at any time by accessing your [dashboard](https://app.sourcery.ai): - Enable or disable the Sourcery-generated pull request summary or reviewer's guide; - Change the review language; - You can always [contact us](mailto:support@sourcery.ai) if you have any questions or feedback.
FluxC0 commented 1 day ago

yeah, those changes make sense. i felt as if it was a little unprofessional, but i didnt know what to change it to. thank you for addressing my note.