#dev-log

1 messages · Page 79 of 1

odd spireBOT
regal archBOT
#

Relevant comment on this topic on the server: #community-meta message

Basically, while it definitely isn't a great option, there aren't really any better free options. So for people who are making a simple bot for them and a few friends in a small server, which they are happy just about working most of the time, and are happy to put up with a bit of extra setup work, it might be the best option for them - and I think that's ofte...

regal archBOT
regal archBOT
#

587e52e Add commands to turn automatic review posting o... - wookie184
3bdec8e Small code improvements and added 'ar' alias - wookie184
792c5a4 Rename commands from on/off to enable/disable - wookie184
5aa0022 Remove bot prefix from docstring and change sin... - wookie184
def62f6 Add check for redundant change - wookie184

odd spireBOT
regal archBOT
#

Sentry Issue: BOT-130

The response doesn't include an encoding in the headers, so aiohttp has to guess. It sometimes guesses incorrectly, leading to decoding errors. The API does not document what the encoding of responses is. Would it be safe to assume it's always UTF-8?

UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 1009: character maps to 
  File "discord/ext/comma...
oak estuaryBOT
odd spireBOT
regal archBOT
#
[python-discord/bot] New branch created: force\-utf\-8\-decoding\-for\-metabase
odd spireBOT
regal archBOT
#

Sentry Issue: BOT-135

If the cog is reloaded while there are less than the maximum amount of available channels, it makes some channels available until the limit is reached. When a channel is made available, it updates the available_help_channels set. The update_available_help_channels() function will not update this set if it sees that the set already contains elements. This results in onl...

#
#
[python-discord/bot] New branch created: bug/info/bot\-13b/code\-snippet\-msg\-404
#

In the examples they might have been called with self but the context was different. In case of silence for example it was called directly there (async def silence(...)) which in fact is not a staticmethod but a normal method. But in my case, I'm calling a staticmethod inside a staticmethod.(Which in fact is strange, but I could not put it into the helpers unfortunately, so I put it directly into the cog as a staticmethod.).
But if you prefer those staticmethod decorators to be removed...

#
[python-discord/bot] branch deleted: force\-utf\-8\-decoding\-for\-metabase
odd spireBOT
oak estuaryBOT
odd spireBOT
regal archBOT
regal archBOT
odd spireBOT
regal archBOT
night lilyBOT
#
Sir Lancebot

Connected!

odd spireBOT
regal archBOT
#
[python-discord/sir-lancebot] New branch created: add\_stackoverflow\_emojis
odd spireBOT
night lilyBOT
#
Sir Lancebot

Connected!

odd spireBOT
regal archBOT
#
[python-discord/bot] New branch created: enhance/backend/time\-util\-refactor
regal archBOT
#
[python-discord/bot] branch deleted: bug/mod/1706/infr\-append\-no\-reason
odd spireBOT
oak estuaryBOT
odd spireBOT
regal archBOT
regal archBOT
regal archBOT
#
  • What do you plan on eventually achieving with Python?
    • Was Python your first programming language? If not, what was?
    • What's your favourite aspect of Python development (e.g. backend, web dev, game dev, machine learning, ai)?
    • In what ways has Python Discord helped you with Python?
    • Are you currently using Python professionally, for education, or as a hobby?
    • What is your process when you decide to start a project in Python?
    • Have you ever been unable...
#

Wdym? They are not capitalized which is incorrect spelling, the others are capitalized because it is the correct spelling because it is a name. Unless I misunderstood you?

I was just unsure if there was some un-written rule of when to use "python" vs "Python". For example I could say I have a python script written in Python. When it is an adjective lower case seems fine, but as a noun it seems more proper to use the capitalization.

regal archBOT
#

I think this might be clearer as a multiline string constant defined at the top, then you can use actual newline characters instead of \n, making it more clear what the result will actually look like. Would also mean you don't have to use a mixture of single and double quoted strings.

Also not sure why there are 3 spaces, e.g. between **1** and for on line 310, seems to render with just 1 in discord though, not sure if i'm missing something

regal archBOT
regal archBOT
regal archBOT
#
[python-discord/bot] branch deleted: bug/mod/bot\-137/defcon\-reject\-dm\-403
odd spireBOT
oak estuaryBOT
odd spireBOT
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
oak estuaryBOT
odd spireBOT
regal archBOT
#
[python-discord/bot] branch deleted: bug/bot\-1jd/backend/wait\-for\-deletion\-404
odd spireBOT
regal archBOT
#

I don't like the debug mode being false as the config default as it should almost always be set for dev; what do you think about making it an env var with defaulting to enabled?

That's a decent idea. The downside is it goes against the concept of the default config being the default values for production, but I don't see a simple way around this.

We could have it as an env var that gets set in the compose file, since that isn't use in prod

oak estuaryBOT
odd spireBOT
regal archBOT
#

I don't like the debug mode being false as the config default as it should almost always be set for dev; what do you think about making it an env var with defaulting to enabled?

That's a decent idea. The downside is it goes against the concept of the default config being the default values for production, but I don't see a simple way around this.

We could have it as an env var that gets set in the compose file, since that isn't use in prod

It's a parti...

#

I don't like the debug mode being false as the config default as it should almost always be set for dev; what do you think about making it an env var with defaulting to enabled?

That's a decent idea. The downside is it goes against the concept of the default config being the default values for production, but I don't see a simple way around this.

We could have it as an env var that gets set in the compose file, since that isn't use in prod

...

#

Do we really need to find a fix? We can just tell people to set the value like we do for most other values. The biggest downside I see is that it’ll leave a possible security vulnerability if the user doesn’t set it, and nothing will tell them so. That being said, I imagine most people are already running these bots in their own test servers, or with people they trust.

regal archBOT
#

Description

The proposal is that we allow tags to be specified as another argument for the stackoverflow command. Stack Exchange API allows filtering by tags with the query, so if the user would like to specify the tags for a certain query, i,e. .so JSON [tags], the stackoverflow command would add the additional tagged parameter with the Stack Exchange API with the query 'JSON'.

Reasoning

The current stackoverflow command will search for the top 5 results, but it can't ...

regal archBOT
#
[python-discord/sir-lancebot] New branch created: ChrisLovering\-patch\-1
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
#
[python-discord/bot] New branch created: add\-codeql\-workflow
odd spireBOT
regal archBOT
#
[python-discord/bot] branch deleted: add\-codeql\-workflow
#
[python-discord/sir-lancebot] branch deleted: ChrisLovering\-patch\-1
regal archBOT
#
[python-discord/forms-frontend] New branch created: remove\-return\-home
regal archBOT
regal archBOT
regal archBOT
#

This is my first shot at it, definitely could clean up the string combination as well as having an embedded error message for more than 5 tags.

    async def stackoverflow(self, ctx: commands.Context, *, search_query: str, ) -> None:
        """Sends the top 5 results of a search query from stackoverflow."""
        def tag_parse(query: str) -> str:

            list_query = query.split()
            if "-t" in list_query:
                stop_index = list_query.index("-t")
...
regal archBOT
regal archBOT
#

The implementations had some redundancies. Furthermore, the functions were commonly being used with either datetimes or ISO 8601 strings, but some functions only accepted one of them rather than both types. This resulted in ugly call sites because callers had to perform conversions themselves. Lastly, some functions were more tightly coupled (mostly naming-wise since the switch to Discord timestamps) to infractions than they needed to be.

The changes are described well by the commit hist...

odd spireBOT
regal archBOT
regal archBOT
#

In an event the server icon will only update every 3 days (iirc we had it lower at one point but it caused strange cache problems). I think that means we'll only see one of the icons (chosen randomly) in the event. This is fine, just wanted to make sure you were aware of this.

If you had a favourite and wanted to make sure that appears, you could remove the other two, or you could also replace them with a gif cycling through them all, although either of those ideas should probably be discu...

odd spireBOT
odd spireBOT
regal archBOT
#

Description:
The tag informs why YouTube or any tutorials are not good to be followed.
Motivation:
There are a lot of users asking for help on code that they were spoonfeeded or simply do not understand and I think this is a good way to tell them to stop and try and understand since all information you want about making a command can be found in docs.
Tag content: (can of course be shortened since this is fairly long)
Tutorials are fundamentally flawed in concept when it com...

#

Description:
The tag informs why YouTube or any tutorials are not good to be followed.
Motivation:
There are a lot of users asking for help on code that they were spoonfeeded or simply do not understand and I think this is a good way to tell them to stop and try and understand since all information you want about making a command can be found in docs.
Tag content: (can of course be shortened since this is fairly long)
Tutorials are fundamentally flawed in concept when it com...

regal archBOT
#

I have to strongly disagree on this one. I don't see it helpful in any way to say "hey, the way you prefer to learn is not good". I see this as injecting a personal opinion on tutorials/videos and passing it off as canonically accepted. At worst, it's a harmful opinion. In terms of benefits, I don't see this being as constructive in any way. I believe content of specific tutorials or other works, if to be addressed, must be addressed on a case-by-case basis.

Instead, we should encourage ...

regal archBOT
#

Resource name
ExplorePython

Resource location
https://explorepython.org

Payment type
Free

Why it should be included
As opposed to some other python courses and tutorials, it gives the lessons in bite sized pieces with comprehension tests at the end of each lesson to test their learning. This helps with retention, as well as makes it more fun and entertaining to do.
Also, Kat said it should be here.

Potential limitations
It is missing some vital content ...

regal archBOT
#

When you type in an invalid argument for the docs command and it says "No documentation found for the requested symbol.", it also lists down the closest matches to what you type so you can see what the name of the argument is. Or could take this a step further and make the bot list the closest matches with corresponding number beside it to which the user can write the number/react to the emote showing that number and it would show the docs for that argument

odd spireBOT
regal archBOT
#
[python-discord/sir-lancebot] New branch created: remove\-gpl\-deps
#

Closes #794

I'm not sure why aspecific scorer was specified in the old code here, https://github.com/python-discord/sir-lancebot/commit/8e653f4f6fc64ad78809e5ec1943ee38865bf221#diff-2b56425c5b483af73a4eaf13d49e54eca49dd8338d3b3f6cad5201ecad8d0366L162. The default seems fine, although I can change to use fuzz.ratio if necessary.

Did you:

odd spireBOT
regal archBOT
#

Description

A user command to search Real Python for a relevant article. The command would take user input and return a short list of articles with the search terms in the title of the Real Python articles. This is heavily inspired by the recent Stackoverflow search command.

Reasoning

Similar to the Stackoverflow command, this would give a shortcut to the information existing on the Real Python website from within the Python Discord server.

Proposed Implementation

N/...

regal archBOT
regal archBOT
odd spireBOT
oak estuaryBOT
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
#

Explanation

It's like SQL injection, but for URLs. Carelessly formatting user input into a URL template can allow attackers construct a specific string to do something nasty.

To fix

https://github.com/python-discord/sir-lancebot/blob/main/bot/exts/evergreen/movie.py
URL formatting partially using f-strings (line 145). I wasn't able to find a vulnerability, but no check is made to ensure that the substitution is safe

https://github.com/python-discord/sir-lancebot/blob/main/bot...

regal archBOT
#
[python-discord/sir-lancebot] New branch created: decorator\-factory/typehints\-fix
odd spireBOT
regal archBOT
regal archBOT
#

Several users have expressed a desire to interact with files with their executed code. I believe such feature is in scope and that it would be a great feature. Supporting it would require a way to mount an isolated, size-capped r/w directory for each NsJail instance. Implementation details need to be investigated to determine the feasability of this feature.

regal archBOT
regal archBOT
regal archBOT
regal archBOT
regal archBOT
regal archBOT
#
jb3

Is it really a new one or is it just mounting the same directory over and over?

https://github.com/python-discord/snekbox/blob/e6cf1c4dce96e45313f125473dc30582f4d443ef/config/snekbox.cfg#L107-L113

If this works the same way that it would in the equivalent fstab, it will be a new tmpfs instance for each execution. I'm having trouble reading through how nsjail actually allocates this though, I can't tell if it is doing something special or just mounting a filesystem in the typical way.
...

regal archBOT
regal archBOT
odd spireBOT
regal archBOT
#

That's a good approach. In in favour.

From what I remember, the package does sometimes produce table classes instead of models (for non-trivial situations). Still, it should get us 90% of the way there, and we probably convert those tables manually.

The end goal was always to have a solid base migration that we can then use as the basis for future migrations. This means that @jb3 doesn't have to be our human migration manager.

regal archBOT
odd spireBOT
regal archBOT
regal archBOT
regal archBOT
#

Relevant Issues

Closes #801
<!-- Link the issue by typing: "Closes #" (Closes #0 to close issue 0 for example). -->

Description

I applied the built in tools from aiohttp wherever I could to properly sanitize the inputs, in case of the GithubInfo Cog, because of the API architecture I had to use a different approach, but by switching to quote_plus I managed to fix the issue.
The cogs fixed:

  • Movie
  • Githubinfo
  • Wikipedia
  • Hacktoberstats (get_october_prs function in...
odd spireBOT
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
#

I'm not very familiar with URL injections, but you may have missed some:

There are three different places in the wolfram cog; this is just one of them
https://github.com/python-discord/sir-lancebot/blob/32b6d0e386350ea12ab9e745e2bede844d289d07/bot/exts/evergreen/wolfram.py#L111-L122


This one might be okay since there's no user input, but it could still be passed via the params kwarg
https://github.com/python-discord/sir-lancebot/blob/32b6d0e386350ea12ab9e745e2bede844d289d07/bot...

odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
#

As for expired or inactive infractions, I think replacing the expiry value with Expired should be enough. This has the disadvantage of not telling the user when their infraction expired, but this isn't really a case we're planning to use the command in.

Can we defer this to after #1721 is merged? I think it would make this slightly easier.


I realised that the advisory may get truncated if the reason is too long. I might have to add a separate parameter for an advisory than ap...

oak estuaryBOT
#

Doc item doc_item.symbol_id='environment-variables' present in loaded documentation inventories not found on site, inventories may need to be refreshed.

regal archBOT
odd spireBOT
regal archBOT
#
[python-discord/bot] New branch created: bug/message\-404
odd spireBOT
regal archBOT
#

What alternative to tutorials do you propose? Make people learn the tools they need using the reference? That is not effective teaching, and that's not how we teach anything else.

In elementary school, you didn't learn addition from first principles, that would be ridiculous. You started off with doing simple examples by help, and only then you learned "how it actually works".

People learn by recognizing patterns and doing things in practice...

regal archBOT
odd spireBOT
regal archBOT
night lilyBOT
#
Sir Lancebot

Connected!

odd spireBOT
regal archBOT
regal archBOT
regal archBOT
regal archBOT
regal archBOT
#

This can be paired up with the above log into a single log, also the language this has sounds a bit like user forward, where it is telling them to try it again.

Maybe something like this, (add a := to if statement, if error:=raw_data.get("errors"):)

                    log.info(f"Got an error while communicating with Wikipedia API: {error}.")

And this doesn't follow the python discord style guide, [this section](https://pythondiscord.com/pages/guides/pydis-guid...

regal archBOT
odd spireBOT
oak estuaryBOT
odd spireBOT
regal archBOT
#

Tag Name- VPS
The tag covers what is a VPS and some examples of good ones
Tag content:
If you need to run your bot 24/7 (with no downtime), you should consider one a cheap VPS.
The following is a list of recommended services that many people on the server have used.
They are reliable and good value for money. Their specs should be sufficient for running Discord bots.

https://www.scaleway.com/

  • Cheap VPS
  • Based in Europe.

https://www.digitalocean.com/

  • Cheap V...
odd spireBOT
regal archBOT
#
[python-discord/bot] New branch created: swfarnsworth/tags
odd spireBOT
regal archBOT
#

I am following the holy PEP 8

Be consistent in return statements. Either all return statements in a function should return an expression, or none of them should. If any return statement returns an expression, any return statements where no value is returned should explicitly state this as return None, and an explicit return statement should be present at the end of the function (if reachable)

odd spireBOT
regal archBOT
#

Looks LGTM to me, good changes overall.

The notion of imposing better validation on data coming from external sources is attractive, though on the other hand Lancebot is primarily aimed at beginners. I don't know whether it'd make sense to put in the effort of making existing features more resilient if the same level of resilience isn't required from new contributions.

regal archBOT
regal archBOT
odd spireBOT
regal archBOT
#

To be honest i'm not quite sure of the use of this tag, in many online tutorials array and list are used interchangeably, and I don't see the benefit of making this distinction.

I would probably say most of the time when people say array in PyDis they're referring to a Python list, unless they've already explicitly said they're working with numpy.

The code example there is also a bit confusing imo as it suggests the different multiplication behaviour is a feature of a list vs an a...

regal archBOT
odd spireBOT
regal archBOT
#
[python-discord/bot] branch deleted: swfarnsworth/tags
regal archBOT
odd spireBOT
regal archBOT
#

Hey, thanks for the suggestion! I will have to shoot this proposal (as well as other translations) for a few reasons:

  • A translation is a lot of work, from finding people to do the initial translation, to finding reviewers so people don’t slip in their own “thoughts” in there.
  • Maintenance is going to be very hard, because each change would require the same requirements as the initial conversion.

Translation and providing people with good content is a good cause, but it isn’t feasibl...

#

The project currently enforces typehinting, but discord.py uses annotations for its own purposes which makes some annotations on command callbacks invalid typehints.

@MarkKoz proposed in #dev-contrib that converters could inherit from the type they return to alleviate this issue, but this is more limited than normal typehinting (although still better than the current hints which are just wrong and cause warnings during development).

The typing.Annotated type allows us to attach metada...

#

I know that when I help, I go back and see if the other user still needs help, and if the user closed the channel, I will kinda have to search for the channel.

But won't they receive a notification for the new message? Receive a DM for a new message = this person still needs help. Don't receive a DM = they probably don't need any more help.

if you didn't really care, you can just turn DM help off in a simple command

What if the helper cares about the current notifications but not...

#

Very cool; I like this approach. I'm fine with patching discord.py since the precedent has already been set (implementing root aliases). This patch isn't that bad anyway because it's not really dealing with any internal/private APIs. That being said, we would have to ensure the setter is in sync for all the special cases (like the greedy converter).

How do you think we should name the typing.Annotated aliases and the converters? I'm thinking that call converters should be named like `Dat...

#

Wdym for the new message? And what current notifications? Isn't help dms only for when you write the first message to help in a channel?

You're right. I misread the code.

Still, I don't see this as particularly useful for helpers but then again I never though the helpdm command was that useful to begin with. I think you should shove aside by opinion and instead gather thoughts from people who actually use that feature.

#

A) Not related, but how do you respond to a specific line?
B) The same thing could be said about if we did the channel closed instead of the initial message, which is why both seem to be same importance level because they both keep you tracking the help channels. Personally, the channel closed is a much important feature, because you know when you type a message in a certain channel.

regal archBOT
#

That being said, we would have to ensure the setter is in sync for all the special cases (like the greedy converter).

I don't anticipate any more cases like that as we're really just modifying what's in the loaded params, with the greedy being some kind of an early fail according to a comment in the source. When I looked at the current master branch it looked like it was still the only piece that immediately acts on the changed annotation. But if something does pop up it shouldn't be har...

odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
regal archBOT
odd spireBOT
regal archBOT
regal archBOT
#

Yeah, that's where the other patch is., though some are not fans of having significant amounts of code in init. You could consider creating a patch module and defining functions like "apply_x_patch" that get called from init. We used to have a similar system to patch a bug in d.py, but it was all removed once it got fixed upstream. You could also try to find that for inspiration. I don't have a concrete idea of the best approach.

regal archBOT
#

The format of the templates was discussed a long time ago in python-discord/organisation#268 but never actioned. I don't think we really came to a conclusion. I personally think some templates need changes. We should also invest in https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/configuring-issue-templates-for-your-repository as Chris mentioned in that issue.

odd spireBOT
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
#
[python-discord/quackstack] New branch created: feat/vcokltfre/cors
#
[python-discord/quackstack] branch deleted: feat/vcokltfre/cors
regal archBOT
#
[python-discord/sir-lancebot] branch deleted: remove\-gpl\-deps
odd spireBOT
night lilyBOT
#
Sir Lancebot

Connected!

odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
#
[python-discord/site] branch deleted: mbaruh/cj\-links
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
regal archBOT
odd spireBOT
regal archBOT
regal archBOT
odd spireBOT
regal archBOT
regal archBOT
#

Hey are you still planning on working on this? Someone sent me this link for Discord Flags: https://pypi.org/project/discord-flags/might be helpful to use these for all of the parameters? Could default most of them to None.

Hey @brad90four, I was thinking that there is no need for using flagged arguments, as I have mentioned here. This would even add functionalityfor more filters.

So I presume we...

odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
oak estuaryBOT
odd spireBOT
regal archBOT
#
[python-discord/sir-lancebot] New branch created: love\-command\-checks
#

After some research I found a library SQLAcodegen that works just like reflecting the current database in SQLAlchemy, except it actually generates the models. (As an additional bonus, it produces a PEP 8 compliant code). This way the API doesn't have to reflect the database every time the it starts up.
Naturally, it would still require a review to make sure everything's generated properly, but it would make a whole lot easier to setup an alembic pr...

#

Description

This makes a few changes to the .love command to make it slightly less creepy, more consistent with other lovefest commands and also makes it give consistent output, regardless of input order.

The changes I have made are:

  • Added and in_month check, to ensure the command can only run during February (valentine season)
  • Require that both members have opted into the love fest event (by checking roles)
  • Sort the members to be checked before hashing, to ensure sym...
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
#
[python-discord/bot] New branch created: chore/vcokltfre/blocking\-tag\-newlines
odd spireBOT
regal archBOT
#

To be honest, I quite like this idea.
My way of implementing this is using the on_message_edit tag to get the message
and use bot.process_commands (Not tested yet I'm not sure will it work or not)
to run the message.

Note that this will also run other edited commands. not just !eval if you want it to only run on !eval or !e
you can check if the message starts with !e (!eval contains !e so it should work on both alias).

#
[python-discord/bot] branch deleted: chore/vcokltfre/blocking\-tag\-newlines
oak estuaryBOT
regal archBOT
regal archBOT
regal archBOT
regal archBOT
regal archBOT
regal archBOT
#
[python-discord/bot] New branch created: dynamic\-dormant\-message
#

Could a tag which describes how to use custom/default emotes in embeds or in messages by a bot be made? It can include that if you want to put a default discord emoji, you can use the charinfo command and otherwise, it shows how to get the emoji ID and use:
Static custom emote -
Animated custom emote -
Or it shows how to use the bot.get_emoji(id) function
I've seen many users ask how to make the bot display a emote whether in embeds or normal messages, and think this can be useful

odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
regal archBOT
odd spireBOT
regal archBOT
#

10c3b34 Update DORMANT_MSG to be compatible with str.fo... - TizzySaurus
f038479 Update DORMANT_MSG to allow kwargs in str.format() - TizzySaurus
ae0d725 Update embed sent when channel moves to dormant... - TizzySaurus
d6c92ad Make DORMANT_MSG a string instead of f-string - TizzySaurus
e77a0d9 Change bot.get_channel to utils.channels.try_ge... - TizzySaurus

#
[python-discord/bot] branch deleted: dynamic\-dormant\-message
oak estuaryBOT
odd spireBOT
regal archBOT
regal archBOT
#
[python-discord/site] New branch created: smarter\-resources
odd spireBOT
regal archBOT
#

I don't have much experience with the file previews, but they sound like the perfect solution for this feature. It gives a lot more headroom compared to the message length limit. I know they work on Desktop, Web, and Android.

I don't have file previews on Android at the moment, tried on latest stable and also alpha build (88202). Not sure if it might be a partial rollout, or maybe older devices aren't supported?

Personally I still wouldn't mind using file previews for this, as...

#

I believe discord.Object was how you infracted users who weren't in a guild before discord.py V1.6, however 1.6 introduced lazy-fetching which will get the discord.User object even when the user isn't in the server.

If I'm wrong and it is still possible for user to be a discord.Object we should change user.mention to <@user.id>, since discord.Object does have an id attribute, and this is what user.mention would return.

On the other hand, if I'm correct and the user will ...

regal archBOT
regal archBOT
#
[python-discord/bot] New branch created: TizzySaurus\-patch\-1
odd spireBOT
regal archBOT
regal archBOT
#
[python-discord/bot] New branch created: remove\-redundant\-converters
#
[python-discord/bot] branch deleted: TizzySaurus\-patch\-1
oak estuaryBOT
odd spireBOT
regal archBOT
#

I believe, replying to the original message where the reminder was invoked is more consistent than using a jump url.
For that we would have to modify jump_url to be message_id instead

        reminder = await self.bot.api_client.post(
            'bot/reminders',
            json={
                'author': ctx.author.id,
                'channel_id': ctx.message.channel.id,
                'jump_url': ctx.message.jump_url,
                'content': content,
         ...
#

Sounds like a great idea! But notice, if the message was deleted, and you try to reference it, you will get discord.HTTPException error saying Unkown Message. The best way I can think about handling it is:

partial_message = TextChannel.get_partial_message(message_id)
try:
  await channel.send(content=content, embed=embed, reference=partial_message)
except discord.HTTPException:
  await channel.send(content=content, embed=embed)```
While the variables `message_id` is the message i...
regal archBOT
regal archBOT
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
odd spireBOT
odd spireBOT
regal archBOT
odd spireBOT
odd spireBOT
odd spireBOT
regal archBOT
regal archBOT
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
#
[python-discord/bot] New branch created: dawnofmidnight/site\-urls
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
odd spireBOT
sullen whaleBOT
#
Thread Bot

Connected!

odd spireBOT
regal archBOT
#
[python-discord/bot] New branch created: Remove\-role\-pings\-on\-nomination\-votes
odd spireBOT
regal archBOT
#
[python-discord/bot] branch deleted: bug/message\-404
#

5fc4b67 Incidents: catch 404s - MarkKoz
b8d959c Code block: catch 404s when editing or deleting... - MarkKoz
dde617e Duck pond: abort if reaction's message or autho... - MarkKoz
e88df8f Merge branch 'main' into bug/message-404 - MarkKoz
6bfc7a9 Merge #1726 - catch various 404s from message o... - MarkKoz

odd spireBOT
oak estuaryBOT
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
#
[python-discord/bot] branch deleted: Remove\-role\-pings\-on\-nomination\-votes
odd spireBOT
oak estuaryBOT
odd spireBOT
regal archBOT
#

I created a calculator using python ( i learned python in a week). please do add this as this would be a big achievement and I hope the users will also benefit from this. ( my discord id: 762215365446598666 )

Relevant Issues

<!-- Link the issue by typing: "Closes #" (Closes #0 to close issue 0 for example). -->

Description

Did you:

#

Hello @imranshaji7, thank you for your interest in our projects.

Congratulation on finishing your first project! Our bot uses the discord.py library though, and can't be used to add various unneeded scripts. Please make sure to be assigned to an issue before submitting a PR, or come discuss this with us in the #dev-contrib channel.

Since your pull request doesn't fill the various requirements for this project, I'll be closing this PR.

regal archBOT
odd spireBOT
sullen whaleBOT
#
Thread Bot

Connected!

regal archBOT
#

It is what you would think it to be: A calculator . 2 numbers, 5 operations

Relevant Issues

<!-- Link the issue by typing: "Closes #" (Closes #0 to close issue 0 for example). -->

Description

Did you:

  • [ ] Join the Python Discord Community?
  • [ ] Read all the comments in this template?
  • [ ] Ensure there is an issue open, or link relevant discord discussions?
  • [ ] Read and agree to the [contributing guidelines](https://...
odd spireBOT
regal archBOT
odd spireBOT
sullen whaleBOT
#
Thread Bot

Connected!

odd spireBOT
regal archBOT
odd spireBOT
odd spireBOT
odd spireBOT
regal archBOT
#
[python-discord/bot] New branch created: fix\-nomination\-archive\-check
#

Previously nomination messages had role pings in them, now they don't as we moved them into a thread.
Due to this, we need to detect both in the interim of historic nominations existing.

A 'proper' fix for this is to store the nomination message IDs when we post them against the
nomination object in the site api. We are planing to work on this soon, this commit is a
short term fix.

odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
#

Ok, false alarm. The issue was caused due to me copying the text from another nomination to test, rather than using post_review or get_review. Due to this, the message contained a bunch of spaces that caused the regex to fail. This would also happen with the current system, so the proper fix is to upgrade to storing the message IDs, rather than use regex. This will do for now though.

regal archBOT
#

Updates to nomination review system posting conditions

There are a few changes we'd like to make to the nominations review system.

Features we want:

  1. A limit to the maximum number of reviews active in the channel at once.
  2. A limit on the frequency reviews are posted (e.g. one a day).
  3. A check to ensure the user has been active recently, to hold off the review if they haven't and possibly unnominate after a while.

Implementation:

General Idea:

These changes do...

regal archBOT
odd spireBOT
regal archBOT
#

First, thank you all for suggesting this idea and implementations!

I'm afraid we decided to reject it. The main reason being if a command gets edited and ran half a minute after the original message has been sent, it is hard to get who used what command. We break this immediate process of invocating a command and getting the answer.

We thought about using replies, but this isn't possible unless a major refactoring is done to add that to every command, which doesn't sound worth it. We ...

night lilyBOT
#
Sir Lancebot

Connected!

regal archBOT
#

Hey buddy, did you read through these and check that they were done?

Did you:

[ ] Join the Python Discord Community?
[ ] Read all the comments in this template?
[ ] Ensure there is an issue open, or link relevant discord discussions?
[ ] Read and agree to the contributing guidelines?

regal archBOT
#

A github search for pythondiscord.com brings up another case of a redirect link (not in the site cog): https://github.com/python-discord/bot/blob/d5ee28133f8e792526716b07d25cbf6e4faba3a1/bot/exts/help_channels/_message.py#L15

There are also a few other locations where pythondiscord.com is used rather than the constant e.g. https://github.com/python-discord/bot/blob/c1c6286fb2225a463533ba17d823b2e6a393f8ad/bot/exts/moderation/infraction/superstarify.py#L21
Do you think these would be w...

regal archBOT
#

Duplicate of #807.

Hey! Once again thanks for your suggestions, but these projects are not something we can integrate into our bots.

The bots are discord.py bots which interact with discord, with no real place for standalone scripts such as this one.

Im going to close this issue, as well as #808 which has the same problem. Please do not open any more PRs without talking to the core devs about your ideas on server.

Thanks!

regal archBOT
#

I propose that when we detect a webhook that's been posted in the guild, we call DELETE on that URL, so that the webhook is deleted.

This is to protect users against themselves, since there is the chance that their message was scraped before we deleted it, and someone now has that webhook url.

Implementing this would be as simple as calling DELETE on any webhook URLs that we detect.

#

Our channels are often rather crowded, if we send a message with the webhook they can read the message clearly themselves without scrolling.

It can also prove as a better lesson, "Look, we were able to send this message because you leaked the url!", rather than talking hypothetically.

I'm going to be very against anything other than deleting the webhook and adding information in our normal DM/in-channel message. It's not our responsibility to provide lessons to users about...

#

The NICKNAME_POLICY_URL seems to be correct already, but I can fix the other.

Yeah that one is the correct URL, just not using the site's name constants. There were a few others like that but I think the ASKING_GUIDE_URL is the only one with a redirect url. Just changing that one is fine if you think the others are out of scope, replacing the text with constants isn't particularly important.

regal archBOT
odd spireBOT
regal archBOT
#

On top of what's in the original issue description, we should also change the alert that's posted in mod-alerts to include whether the DELETE was successful or not.

i am not sure if this is current behaviour, but we should also run this filter against staff posting webhooks, since a mod may want to delete a webhook found in a grabber script.

odd spireBOT
sullen whaleBOT
#
Thread Bot

Connected!

odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
regal archBOT
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
regal archBOT
#

This pull request means that refresh tokes now refresh when generating new access tokens.

Currently I have set the lifetime of a refresh token to be the lifetime of 6 access tokens (6 hours). This means that 6 hours after a refresh token has been generated, it will be refresh when trying to generate a new access token. When this happens the old is invalidated, but this is not done automatically. So you can wait several days, and the refresh token won't be invalidated until you try to gener...

odd spireBOT
odd spireBOT
regal archBOT
#

I suppose it's okay to move these over for consistency's sake, but we should eventually have a discussion on this. I don't think it makes sense to define converters here which are unlikely to be used in multiple places. For example, Duration is generic and is indeed used in many places. But OffTopicName? That isn't used in more than one place nor will it likely ever be. We don't move cog-specific utlities to the utils directory, so why move such converters?

regal archBOT
regal archBOT
regal archBOT
regal archBOT
#

I agree we should remove the current scheduler entirely. The hourly task you mention can then run the two checks you mention, and if they pass it should just make an API request to the site api to get the next one to review, which then does the required calcs to work out which user to return (as the site has all the message history & nomination details). No need for a scheduler at all then.

regal archBOT
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
#

I like this enhancement. An API changing can be avoided by making the bot parse the message ID from the URL

You mean because it is in that format:
https://discord.com/channels/guild id/channel id/message-id
And than somehow jump_url.split('/')[-1]? Tho I think that we should just store the message-id so it'll be more clear for other users who look at the source.

odd spireBOT
odd spireBOT
regal archBOT
regal archBOT
regal archBOT
#

@TizzySaurus You misunderstood me. The lines I commented were only used when a discord.Object was passed. In that case, all it has is an ID, and it sucks to only display an ID. Instead, it relies on the last known information in the database, if it exists. If not, then it can fall back to just an ID.

Furthermore, what you had previously was sufficient when it's a Member or User. They have already have a __str__ which does exactly what you changed it to.

regal archBOT
#

I suppose we'd want something like

        if isinstance(user, (discord.Member, discord.User)):
            user_str = escape_markdown(user.name) + user.discriminator
        else:  # is discord.Object instance
            if infraction_list:  # can get the name#discrim from DB
                user = infraction_list[0]["user"]
                user_str = escape_markdown(user["name"]) + f"#{user['discriminator']:04}"
            else:  # can't get name from DB so just use the id
...
#

Right yes, escape_markdown(str(user)) would be easier so I'll go with that.

        if isinstance(user, (discord.Member, discord.User)):
            user_str = escape_markdown(str(user))
        else:  # is discord.Object instance
            if infraction_list:  # can get the name#discrim from DB
                user = infraction_list[0]["user"]
                user_str = escape_markdown(user["name"]) + f"#{user['discriminator']:04}"
            else:  # can't get name from D...
odd spireBOT
odd spireBOT
regal archBOT
#
[python-discord/site] branch deleted: dawnofmidnight/smarter\-resources/filtering\-system
regal archBOT
#

Currently the reminder feature is restricted to #bot-commands for non-staff which makes it a bit less convenient to use quickly and be able to jump back to the conversation itself without copying the message link manually.

We can allow them everywhere with reminders being sent in #bot-commands instead of the channel the reminder was set in, to prevent unnecessary out of context messages from popping up (which already happens to some degree from remainders by staff)
An additional staff onl...

#

Yeah, I'd like to go with our "allow everywhere until proven problematic" policy. The only channel I might be iffy about enabling it is in python-general, but I can be convinced otherwise.

I frequently see people trying to set themselves reminders to check in on an issue, or come back to some resource, or whatever else only to get told by the bot to go to bot-commands. I think having reminders available in non-py-gen channels will be a better experience for people.

I'm not even that so...

odd spireBOT
regal archBOT
#

The remind command is used quite functionally, at least within staff and contribution channels from my experience. If you check the git history for the latest change to that decorator, you’d see we were enabling it for open source channels.

I’d like to see it be global, though in slower channels (topical, open source, development, staff, etc), I think I don’t mind having it show up in channel.

odd spireBOT
regal archBOT
#

The reminders display the relative time when the reminder is scheduled, but the relative duration was already given by the user when they scheduled the reminder. It's also unlikely that someone will look at the reminder scheduled message in the past (apart from jumping to it when the reminder is sent) so in most cases the relative timestamp only restates what the user already knows; I think using the DAY_TIME (F) or DATE_TIME (f) would make more sense in this case

regal archBOT
#

This is a good suggestion as it will really improve the usability of the command for the masses. A few points which are open to discussion:

  1. In cases where it's not sending it to the same channel, is it feasible to first try to DM before resorting to sending it in #bot-commands? This might get complicated when multiple roles/users are mentioned in the reminder, but note that the feature is limited to Helpers+.
  2. It should never send a reminder in a help channel, even if invoked by st...
#

I guess we could try and detect if the pinned message was deleted and try and pin the next message from the author if it was

It'd be fairly simple to make it pin the next message it receives. However, this doesn't necessarily mean the first extant message will be pinned, since a message can be deleted after more are sent. A compromise could be reached where it only pins the next message if it's going to be the first extant message for that help session. However, that would require lookin...

regal archBOT
odd spireBOT
regal archBOT
#

This may seem like an innocent thing to add, but how do you propose to actually track user activity. Doesn't that also get into privacy issues?

By user activity I mean something like "has at least 10 messages in the past week", which we already track through metricity, which is integrated with site https://github.com/python-discord/site/blob/d038076b5034d14ce2b8dabcb929eacb0e837540/pydis_site/apps/api/models/bot/metricity.py, so would just r...

regal archBOT
odd spireBOT
regal archBOT
#

Some places re-annotate the argument to avoid warnings from type checkers. This is no longer necessary. Ideally, all these should be removed.
For example:
https://github.com/python-discord/bot/blob/main/bot/exts/moderation/modpings.py#L90

Do you think you can go through the code base and remove these? Otherwise, this PR looks good to me.

did a regex search with ^ *\w+: [\.\[\]\w]+$, removed the two it found in the last commit but it seems a bit low so let me know if ...

odd spireBOT
regal archBOT
regal archBOT
regal archBOT
#

It just occurred to me why this didn't originally use the normal converter. The problem is that discord.py's converters also support username and nickname strings (without a discriminator). This makes it impossible to search a reason for a string which happens to be a user's name. In practice, users are rarely, if ever specified this way, so it's preferable to prioritise the reason search.

regal archBOT
#
[python-discord/branding] New branch created: Archive\-hacktoberfest\-branding
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
#

As part of https://github.com/python-discord/branding/pull/161 we removed the Hacktoberfest branding, as we will not be taking part in Hacktoberfest this year.

As such, some generic Halloween branding should be made for our events calendar.

There are some assets in halloween/assets/ that you are free to use for this.

A PR for this issue should include a new Halloween event in events/ and should also remove the halloween/ directory.

#
[python-discord/branding] branch deleted: Archive\-hacktoberfest\-branding
odd spireBOT
odd spireBOT
regal archBOT
#

I think we should specifically handle a few cases here that have been missed:

  • if a message has been deleted, the converter will raise NotFound. We should have a special message for this case
  • When it's deleted, we can search through #message-change-log in our message cache looking for the appropriate message id: {id} string, to link there and extract content from there instead.
  • since incidents is within helper view, we should at the very least restrict this converter from accessing me...
regal archBOT
regal archBOT
#

That makes sense.

Would it be more logical to instead use UserMentionOrId here, since then that will remove the need of the Snowflake converter? We'd likely have to add a try/except around the call to the UserConverter though -- so UserMentionOrId becoming something like

    async def convert(self, ctx: Context, argument: str) -> t.Union[discord.User, int]:
        """Convert the `arg` to a `discord.User` or `int` in the case of a deleted account."""
        match = self._g...
odd spireBOT
odd spireBOT
odd spireBOT
regal archBOT
regal archBOT
#

Try not adjusting code if there are tests failing and you can't figure out how to reproduce the test failure with manual code. message.id should never be non-int, so if you're having to cast there you're having other problems (such as with the test). Otherwise the tests become part of your code, and are not really suitable as tests any longer.

This issue is because the Mock being used isn't having .id set appropriately. Try using breakpoint() or another debugger when this errors to fi...

regal archBOT
regal archBOT
#

Sending a new message when a channel is closed has no use, but if we could keep the DM message in cache and then edit when a channel is closed that would be the best.

Sending a new message will trigger a notification, which would get the person helping's attention, just to tell them that their help is no longer needed.

Editing the message will allow someone to look back over all channels they've helped in, and quickly get a nice status of who still needs help.

#

The discord Markdown timestamps introduced in #1666 are invalid in some embed fields like footers where they will render as plaintext leading ton on human readable data being sent.
The watchchannel send_header method tries to use a timestamp in the footer
https://github.com/python-discord/bot/blob/4d62dadc4d19f0c17d5cda8748c3fc520f2adccf/bot/exts/moderation/watchchannels/_watchchannel.py#L285-L296

And a reminder that's late tries to use a timestamp as ...

odd spireBOT
regal archBOT
#
[python-discord/bot] branch deleted: fix\-nomination\-archive\-check
oak estuaryBOT
odd spireBOT
regal archBOT
odd spireBOT
regal archBOT
regal archBOT
#

Would it be more logical to instead use UserMentionOrId here, since that will remove the need of the Snowflake converter? We'd likely have to add a try/except around the call to the UserConverter though to still allow for searching of deleted accounts etc. -- so UserMentionOrId would become something like:

The Snowflake converter has some code that improves the likelihood of a converted input actually being a snowflake. This would further disambiguate snowflakes from reasons that look ...

odd spireBOT
regal archBOT
#

There's a similar issue with this log message

https://github.com/python-discord/bot/blob/ad163c41e097c95bda033007b7422b129cdbbcf1/bot/exts/moderation/stream.py#L140-L141

From this and my experience with #1721, it's become evident that #1666 was not thoroughly reviewed and tested. It's a bit concerning that several obvious errors were missed, but that might just be me having the power of hindsight. I think it's worth reviewing all uses of these Discord timestamp utility functions to make...

odd spireBOT
regal archBOT
#
[python-discord/bot] branch deleted: mbaruh/jam\-management
oak estuaryBOT
odd spireBOT
regal archBOT
regal archBOT
#

Description

The current unittests fail on windows, when using the default test command:

python manage.py test --no-input

Cause

The following is the failing test: pydis_site.apps.content.tests.test_views.test_get_context_data_breadcrumbs
https://github.com/python-discord/site/blob/512bd175cffbc3463679f3e165bea6d0a486f6fa/pydis_site/apps/content/tests/test_views.py#L163-L177

The reason is in the following line:
https://github.com/python-discord/site/blob/512bd175cffbc346367...

regal archBOT
odd spireBOT
regal archBOT
regal archBOT
#
[python-discord/bot] New branch created: bug/help/1715/avail\-set\-init