The community bot for the Python Discord community

Overview

Python Utility Bot

Discord Lint & Test Build Deploy Coverage Status License

This project is a Discord bot specifically for use with the Python Discord server. It provides numerous utilities and other tools to help keep the server running like a well-oiled machine.

Read the Contributing Guide on our website if you're interested in helping out.

Comments
  • [Meta] Bot Core Refactor

    [Meta] Bot Core Refactor

    Wanted to open up a discussion related to some of the things we've been chatting about in the developer channels recently. All put together I think it ends up being a significant effort & rearchitecting that will need a lot of feedback & planning (https://github.com/orgs/python-discord/projects/2).

    TLDR: There seems to be a good amount of technical debt building up as Python's features have expanded. It hasn't gone unrecognized, as proposals have already been made for multiple bots (fun bot, seasonal bot, recruitment bot) to handle some of the more distinct functionality and take some burden off of the singular bot (see: #161). I don't think the current architecture well supports such a distribution.

    A couple starting points for discussion, in no particular order:

    1. Refactor and thoroughly document shared utility functionality (e.g. authentication, constants, API links, logging, etc.) into a core codebase that can be used by all bots. This alleviates a lot of the copy+paste that would be necessary to unify core functionality across bots, and also eliminate the need for certain functionality (e.g. warning embeds, command role restriction) to be recreated in multiple cogs. This should help with some of the things brought up in #160.
    2. Related to #132, a more developer-friendly testing framework so issues can be caught before the MR. While self-hosted testing can catch a good amount of development issues, it's a bit of large task to test new features within our current framework.
    s: planning 
    opened by sco1 41
  • Further doc improvements

    Further doc improvements

    Sort of a continuation to #546 to get feedback before getting to it.

    Before (trying to) implementing #447, duplicate items will be needed to be removed from the inventories dict to get only the relevant results. These were mentioned in comments of the aforementioned issues.

    That will drastically decrease the amount of items and their used space so I thought we can also up the cache max_size in here https://github.com/python-discord/bot/blob/3d25c790a69421e0ed9c7c7a29ca1d5833322169/bot/cogs/doc.py#L283-L286 as we got some additional space and can save requests on the few additional items that may be there; although the chance of hitting the cache decreases with the size.


    Another thing to look into is the markdown converter that's used on the contents Discord handles embeds a bit differently on desktop and mobile (android) | desktop | mobile | | ---------------------------------------- | ----------------------------------------- |

    Where the internal references don't show up as inline codeblock


    And then the last one I goton my mind; we collect all the signatures of functions but some have aliases and others group them by category. How should this be handled if at all? As examples here for the first one, everything under the fetched signature is included but also relevant to how the contents are written, but in the second one we just get an alias that's mostly unneeded. | lt | width | | ---------------------------------------- | ----------------------------------------- |

    t: feature p: 2 - normal a: information 
    opened by Numerlor 30
  • Introduce subfolders into the cog folder so that we can organize the cogs better.

    Introduce subfolders into the cog folder so that we can organize the cogs better.

    Originally posted by Leon Sandøy:

    We should consider either consolidating similar cogs into a single cog with more features (like an Admin cog that had big brother, clean features, and defcon), or to create subfolders in the cogs folder so we can at least group the similar cogs together. The folder is growing unruly.

    t: feature a: backend s: planning p: 2 - normal 
    opened by pydis-bot 30
  • Cog for code snippet links

    Cog for code snippet links

    I thought that it would be pretty cool if Discord could show the contents of a snippet link instead of just the link to the snippet, so I made a bot for that.

    However, since adding third-party bots to the Python server was out of the question, I decided to add that functionality to the official server bot instead.

    Proof

    t: feature a: backend p: 2 - normal a: information 
    opened by dolphingarlic 26
  • Restricting/redirecting output of commands to bot-commands for regular users

    Restricting/redirecting output of commands to bot-commands for regular users

    Edit: I've decided to make this a general issue, since the !free command turns out to be a bit disruptive as well. In python-discussions, there have just been four consecutive calls to !free and it looks very disruptive (see below).

    My idea would be to create an easy way to redirect the output of certain commands, free and help, to bot commands for regular users, with the bot sending a temporary message to the user in channel redirecting them there. The bot could then delete that message (and, maybe, the invoking message as well) after a certain amount of time has passed.

    Four times !free in python-discussion: 2019-01-18_17-38-32

    Old message for context: Now the !help command works outside of bot-commands again, we may want to think about restricting the use/output to bot-commands for regular users. The help-embeds are quite sizeable and, therefore, quite disruptive in on-topic channels.

    I want to propose to redirect the output of help (the help-embed) to bot-commands for non-staff members, prepended by a mention of the user invoking the command. In addition, we could display a small, non-disruptive embed in the original context channel redirecting the user to bot commands. I think this should also be the case for help-calls on specific commands, as the embeds for those can be quite sizeable as well (e.g., !help site).

    Personally, I'd like this restriction to only apply to regular users, so staff can pull up help on a command quickly in channel and use help in the staff channels.

    t: feature a: frontend s: planning 
    opened by SebastiaanZ 24
  • Help Channel DM's For The Person Who Is Helping.

    Help Channel DM's For The Person Who Is Helping.

    So we already have the help channel DM's that sends the user a DM whenever they claim a help channel. But why not also send a DM to the person who is helping in the channel as well. We could also make this toggleable just incase someone doesn't want to receive the DM's.

    t: feature a: help channels 
    opened by JacobMonck 22
  • Tag Suggestions

    Tag Suggestions

    PyDis' Python bot uses !tags to provide brief, canonical explanations for common questions, programming pitfalls, and other Python related topics.

    Use this issue to suggest additional tags, bonus points if you help out with the body of the tag as well!

    edit: Since there's often an overlap between what's desired for a tag vs. the ability for a wiki article to be more comprehensive, I've expanded the scope of this to also include suggestions for Wiki articles (implemented soon) so you don't have to decide whether or not this belongs as a tag or as a Wiki article.

    t: feature a: information 
    opened by sco1 22
  • Doc improvements

    Doc improvements

    Improves the doc command to have more consistent outputs and speeds it up with a bit of caching

    Visual

    |old|new| |-|-| |||

    • relative urls are now resolved to absolute, allowing them to be used from discord
    • embed title urls now aren't encased in codeblock to enable their highlight on android clients

    |old|new| |-|-| |||

    • Only information strictly related to the symbol is fetched, skipping various attributes which we may not be able to construct proper markdown from
    • Signature params are collapsed when too long
    • More proper handling of description truncation, ensuring valid markdown and limiting the amount of newlines
    • text in bullet lists is more compact
    • Moved: prefix added to the footer to better explain the purpose of the symbol names in it closes: #990

    Behaviour

    Command

    • doc get is now greedy to allow a few symbols like not in to be fetched
    • to prevent issues from the greedy behaviour, the command tries to look up only the first word of the requested symbol name if it fails at first
    • backticks are stripped from symbol input
    • doc suffix added to long commands names to avoid shadowing doc symbols
    • when an inventory is added through the set command, only that inventory is fetched instead of refreshing all inventories

    Misc

    • symbols with certain groups that we overwrite in case of duplicates are no longer lost but moved to a different symbol name in case the symbol that overwrites them comes after they were included
    • stats for packages of fetched symbols
    • all symbols from a page are parsed on request to avoid multiple web requests
    • package names restricted to simple alphabetic names to be used by stats
    • all reachable symbols are attempted to be parsed
    • inventory fetches are rescheduled on fails
    • Symbol markdown results are cached in redis for a week
    • intersphinx inventory parsing replaced with custom async implementation

    Other

    • The source command now works properly for commands that had their functions wrapped
    • The send_denial helper now returns the message object after sending it
    • A new command_wraps decorator which preserves the globals of the wrapped function to replace wraps for functions used with discordpy commands closes: #1067 closes: #908 closes: #878
    t: bug t: feature help wanted p: 1 - high a: information 
    opened by Numerlor 21
  • Enhancing information within the incidents channel.

    Enhancing information within the incidents channel.

    Relevant Issues

    Closes #1226

    Description

    Whenever a staff member would post a message in #incidents channel, it would be searched through a regex and all the message links in it would be extracted.

    Then the bot would send this the messages the link point towards in embeds.

    The Embed would contain the following information -->
            Author: @Jason Terror ♦ (736234578745884682)
            Channel: Special/#bot-commands (814190307980607493)
            Content: This is a very important message!
    

    These embeds would be sent in groups of 10 using a webhook.

    Once the incident is actioned/rejected (using reactions), the bot would delete these webhook messages (NOT send them to #incidents-archive)

    Screenshots

    Has a link and doesn't has a link message

    Screenshot from 2021-03-04 13-57-32

    On putting ✅ reaction on message with link

    Screenshot from 2021-03-04 13-57-44

    In Incidents-Archive Channel (the message link embeds are not sent)

    Screenshot from 2021-03-04 13-57-50

    Additional Details

    Adds a webhook to channel #incidents with id 816650601844572212 (Thanks joe)

    Did you:

    • [x] Join the Python Discord Community?
    • [x] Lint your code (pipenv run lint)?
    • [x] Set the PR to allow edits from contributors?
    t: feature a: backend p: 2 - normal 
    opened by Shivansh-007 20
  • Gitlab Cog

    Gitlab Cog

    Originally posted by Wim De Clercq:

    A gitlab cog should be created to replace the clickup cog.

    It should (at least) have the same functionality as the existing clickup cog:

    • [x] Listing all issues
    • [x] Get detailed info about an issue
    • [x] Get a list of every member of the team
    • [x] Get all projects
    • [x] Create a new issue under a specific project
    • [x] Update the status of an issue

    Additionally, the following additional functionality should be implemented:

    • [ ] GitLab OAuth logins, so that tasks can be created by the people that submitted them
    • [ ] Short-hand for referring to issues/MRs, eg site#12, bot!3, etc
    t: feature a: utility 
    opened by pydis-bot 20
  • Replace Rowboat

    Replace Rowboat

    Originally posted by Gareth Coles:

    Rowboat is being shut down. We will need to bring its moderation features over to our bot. This should include an import mechanism for the Rowboat infractions archive, and integration with the site.

    • [x] clean commands - !31 and https://gitlab.com/python-discord/projects/site/merge_requests/26
      • [x] clean all [amount:int]: delete amount messages in the current channel, default?
      • [x] clean user <user:member> [amount:int] delete amount messages sent by user in the current channel, default amount?
      • [x] clean bots [amount:int]: delete amount messages by bots in the current channel, default?
      • [x] clean word <regex:str> [amount:int]: look through amount messages and delete any that match the provided regular expression.
      • [x] Must upload a log of all the messages that were removed.
      • Reference: http://rowboat.party/plugins/admin.html
    • [ ] Infractions - https://gitlab.com/python-discord/projects/site/merge_requests/23 and !28
      • [x] warn <user:member> <reason:str...>: warns the given user for the given reason, create an infraction with reason
      • [x] mute <user:member> <reason:str...>: mutes the given user for the given reason (applies a configured mute role), create an infraction with reason
      • [x] unmute <user:member>: unmutes the previously muted user (removes a configured mute role)
      • [x] tempmute <user:member> <duration:duration> [reason:str...]: apply the configured mute role to the given user, create an infraction with reason, remove it after duration
      • [x] kick <user:member> [reason:str...]: kick the given user, create an infraction with reason
      • [x] ban <user:snowflake|member> [reason:str...]: ban the given user, create an infraction with reason
      • [x] unban <user:snowflake> [reason:str...]: unban the given user
      • ~~softban <user:snowflake> [reason:str...]: ban the given user, deleting messages from the past 7 days, and unban the user again. create an infraction with reason~~
      • [x] tempban <user:snowflake|member> <duration:duration> [reason:str...]: ban the given user, create an infraction with reason, unban after duration
      • [x] infr search <query:snowflake|member|str>: search the infraction database for the given query. query can be a snowflake or a member to search by actor or user, or a string to search by reason
      • [x] infr duration <id:int> <duration:duration>: update the duration of the infraction with the given id to duration, relative to the start
      • [x] infr reason <id:int> [new_reason:str...]: update the reason of the infraction with the given id to new_reason
      • [x] infr search should be less strict. we should be able to search for id's, reasons, usernames, mentions, whatever. Right now it only works some of the time. !47
      • [x] !forceban <id:int> ban a user based on id, even if they're not on the server.
      • [ ] Send the user a DM when they suffer an infraction. As long as they don't have DMs disabled, this ensures they are let know of the reason they've been punished. !49
      • Reference: http://rowboat.party/plugins/infractions.html
    • [x] Filtering plugin !41
      • Reference: http://rowboat.party/plugins/censor.html
    • [x] Spam plugin - !35
      • [x] Spam bugfix MR - !40
      • Reference: http://rowboat.party/plugins/spam.html
    • [x] Mod log plugin
      • [x] Adding mod-log embeds for all discord events. - !30
      • [x] Still got a couple of icons missing for these. - #41
      • [x] Adding mod-log embeds for all relevant commands, like infractions, hiphopify, defcon, bigbrother, etc. Although most infractions will trigger an event, it will be beneficial to modlog from the command itself in some cases so that we can log information like ban reason and duration of tempbans. - !45
      • Reference: http://rowboat.party/plugins/modlog.html
    • [x] Configurable role persistence - !37
      • [x] Automatically persist temproles including mutes across member rejoins
      • [x] ~~̃Feature configurability~~
    • [x] Misc commands
      • [x] !server - !32
      • [x] !user / !userinfo - !42
      • [x] !roles - !32
      • [x] !remind {duration} {content}
    • [x] Reddit features - !23
      • [x] Relay new posts to the #reddit channel
      • [x] Generate weekly top 5 reports and keep them pinned in the channel
    t: feature p: 0 - critical a: frontend 
    opened by pydis-bot 20
  • Allow passing ful channel objects to check if the channel is ignored

    Allow passing ful channel objects to check if the channel is ignored

    This means that the is_channel_ignored fucntion can be used with on_*_delete events that have the channel object, but can't be retreived fromthe cache by the is_channel_ignored function

    opened by ChrisLovering 0
  • Make the infraction message mention @ModMail

    Make the infraction message mention @ModMail

    Previously, the footer for non-ban infraction messages would say to DM the ModMail bot. This commit makes "ModMail" a clickable mention of the bot.

    image

    When this footer was introduced, we decided not to make it a mention, in case the recipient did not have the ModMail bot account in their user cache (which would cause it to render as the account ID, ie "send a message to 683001325440860340"). Chris has determined that because the bot is at the top of the user list, it seems to always be in the cache for any guild member, even without visiting the guild or viewing the user list.

    opened by swfarnsworth 0
  • Print output implicitly for one line evals

    Print output implicitly for one line evals

    Link to discussion Should the eval command !e with an inline codeblock or no codeblock at all be ran and the output printed by default? (This is similar to how the Python REPL functions:

    python
    Python 3.10.1 (tags/v3.10.1:2cd268a, Dec  6 2021, 19:10:37) [MSC v.1929 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> "Hello, world"
    'Hello, world'
    >>>
    

    Similarly,

    !e "Hello, world!"
    'Hello, world!'
    
    s: planning p: 3 - low a: utility t: enhancement 
    opened by Robin5605 2
  • Add an IPython mode to eval

    Add an IPython mode to eval

    Current working command schemes:

    • !eval -ipython
    • !e -i

    Support IPython mode for eval with code blocks as "cells". Matplotlib will use a custom backend for show() which writes a png file to the output folder for upload.

    This will use the ipykernel backend with full support for ipython magic commands like %%time

    We can also inject custom exec tasks, imports, or custom ipython macros and magic commands via the ipython api.

    Most of the runtime wrapper can be sent from the bot side, we will just require snekbox to add the ipython package to deployment.

    Depends on

    • https://github.com/python-discord/snekbox/pull/159
    • https://github.com/python-discord/bot/pull/2326
    • Add ipython to our snekbox deployment venv

    Proof of concept

    image

    • Since IPython errors are colored with ANSI codes, we can use an ansi codeblock to render them

    image

    s: planning p: 2 - normal a: utility t: enhancement 
    opened by ionite34 0
  • Add a !mypy command

    Add a !mypy command

    Proposal to add a !mypy command

    Works like !eval or !timeit but instead of running the file, run a mypy type check on the file using snekbox and return the stdout results.

    Discussions on mypy results and inferrable types are pretty common, and usually means copying the output of mypy to paste with code in a discussion, having a command would encourage reproducible examples (like eval does)

    Depends on

    • https://github.com/python-discord/snekbox/pull/159
    • https://github.com/python-discord/bot/pull/2326
    • Add mypy to our snekbox deployment venv
    opened by ionite34 3
Owner
Python Discord
The hottest Python community on the planet!
Python Discord
Satoshi is a discord bot template in python using discord.py that allow you to track some live crypto prices with your own discord bot.

Satoshi ~ DiscordCryptoBot Satoshi is a simple python discord bot using discord.py that allow you to track your favorites cryptos prices with your own

Théo 2 Sep 15, 2022
WallAlley.bot is an open source and free to use financial discord bot originaly build for WallAlley server's community

WallAlley.bot About WallAlley.bot is an open source and free to use financial discord bot originaly build for WallAlley server's community. All data a

Mohammad KHADDAN 1 Jan 22, 2022
A discord bot made by the community (uses python)

discord community bot context: this is a discord bot made by the community by community i mean people adding commands to the bot or changing the bot b

TR ASH 0 Oct 11, 2022
A community made discord bot coded in Python and running on AWS.

Pogbot Project Open Group Discord This is an open source community ran project. Join the discord for more information on how to participate. Coded in

Project Open Group 2 Jul 27, 2022
A small and fun Discord Bot that is written in Python and discord-interactions (with discord.py)

Articuno (discord-interactions) A small and fun Discord Bot that is written in Python and discord-interactions (with discord.py) Get started If you wa

Blue 8 Dec 26, 2022
🤖 A discord bot for Dota2 community

BOTA BOT-A is a free Discord Dota 2 bot which provides comprehensive Information of every Dota 2 characters and exciting features for the community. P

Bendang 23 Jun 29, 2022
Simple Discord bot for the Collectez community.

Harvey - Discord Bot Simple Discord bot for the Collectez community. Features Ping the current status of Collectez's Teztools node. Steal emojis from

delintkhaum 1 Dec 26, 2021
Discord bot developed by Delhi University Student Community!

DUSC-Bot Discord bot developed by Delhi University Student Community! Libraries Used Pycord - Documentation Features Can purge messages in bulk Drop-D

professor 1 Jan 29, 2022
It's a Discord bot to control your PC using your Discord Channel or using Reco: Discord PC Remote Controller App.

Reco PC Server Reco PC Server is a cross platform PC Controller Discord Bot which is a modified and improved version of Chimera for Reco-Discord PC Re

Arvinth Krishna 12 Aug 31, 2022
Discord bot script for sending multiple media files to a discord channel according to discord limitations.

Discord Bulk Image Sending Bot Send bulk images to Discord channel. This is a bot script that will allow you to send multiple images to Discord channe

Nikola Arbov 1 Jan 13, 2022
Discord.py-Bot-Template - Discord Bot Template with Python 3.x

Discord Bot Template with Python 3.x This is a template for creating a custom Di

Keagan Landfried 3 Jul 17, 2022
An Open-Source Discord bot created to provide basic functionality which should be in every discord guild. We use this same bot with additional configurations for our guilds.

A Discord bot completely written to be taken from the source and built according to your own custom needs. This bot supports some core features and is

Tesseract Coding 14 Jan 11, 2022
Discord ToolBox is a discord bot developed by DJD320 created for the purpose of having some convenient tools in the form of a single bot.

Discord ToolBox Discord ToolBox is a discord bot developed by DJD320 created for the purpose of having some convenient tools in the form of a single b

null 3 Aug 7, 2021
Linky bot, A open-source discord bot that allows you to add links to ur website, youtube url, etc for the people all around discord to see!

LinkyBot Linky bot, An open-source discord bot that allows you to add links to ur website, youtube url, etc for the people all around discord to see!

AlexyDaCoder 1 Sep 20, 2022
Image-Bot-Discord - This Is a discord bot that shows the specific image you search from Google

Advanced Discord.py Image Bot CREDITS Made by RLX and Mathiscool README by Milrato Installation Guide in .env Adjust the TOKEN python main.py to start

RLX 3 Jan 16, 2022
Example-bot-discord - Example bot discord xD

example-python-bot-discord Clone this repository Grab a token on Discord's devel

Amitminer 1 Mar 14, 2022
YouTube-Discord-Bot - Discord Bot to Search YouTube

YouTube Bot Info YouTube Bot is a discord bot where you can search for anything

Riceblades11 10 Mar 5, 2022
SongLink Discord Bot - Discord bot to share music links easily

SongLink_Discord_Bot Discord bot to share music links easily. Take a link from y

Edgar Lefevre 4 Feb 18, 2022
Kevin L. 3 Jul 14, 2022