#dev-log
1 messages ยท Page 71 of 1
[python-discord/quackstack] New branch created: sane\-ci\-names
Reverts CI stage names to a bit of normalcy. Whilst duck puns are great, I don't think CI stages is a place for them, and it simply adds confusion (e.g. Build & Quack, what is Quack?).
As of #25 all assets have been moved into the repo so I'm closing this issue now
LGTM, tested locally in docker and looks to be working fine, can't see any issues with the code either, will wait to see if anyone else suggests changes soon but if not should be fine to merge soon
I quite like this implementation from the staff PyWeek submission
def make_color(hue: float, dark_variant: bool) -> tuple[float, float, float]:
saturation = 1
lightness = random.uniform(.7, .85)
# green and blue do not like high lightness, so we adjust this depending on how far from blue-green we are
# hue_fix is the square of the distance between the hue and cyan (0.5 hue)
hue_fix = (1 - abs(hue - 0.5))**2
# magic fudge factors
lightness -= hue_fi...
Closing this PR, as #642 includes this change.
f8e14d0 Issues: ignore bots - Akarys42
@kosayoda the requested changes have been addressed. I took the liberty of rewriting the cog in https://github.com/python-discord/sir-lancebot/pull/642/commits/08b1348b33d2d865987f2677a68ba62645db2abe because the old code base was too complicated to work with. Should be good to go now!
8276f8e Add a !tp get_review command to get the nominat... - Akarys42
[python-discord/bot] New branch created: tp\-get\_review\-command
This can be used when information should be added to the post, or someone wants to review the user.
Approved by our nomination overlord @wookie184.
It seems like if the permissions should be revoked while the bot is offline, the task will be removed from the cache without firing.
You should make sure that it gets removed either through the reschedule function or inside the scheduler directly.
From what I can tell an empty StringIO seems to be truthy, so this doesn't work as expected, and reviewing somebody who is not currently nominated sends an empty file. To fix this you could just create the stringio inside the if, so the condition is on the string directly
Just a small thing.
Also, Discord doesn't seem to display the emojis properly in the file preview, at least for me, I get something like this:

The actual file when downloaded seems fine though, seems it could be a discord bug? I guess we could make it display with the :thumbsup: format, but I don't really mind leaving it as-is.
Mostly looks good, one small suggestion.
review = "\n\n".join((opening, current_nominations, review_body, vote_request))
That's isn't my code :pensive: but thanks haha
cb87d95 Talentpool: loop style change - Akarys42
16ea7ae Forbid commands in DMs with in_whitelist_check - Akarys42
[python-discord/sir-lancebot] New branch created: reject\-dms\-default\-check
This will prevent most commands from running in DMs, which would break most commands and lead to moderation issues.
I don't think this parameter was used anywhere.
[sir-lancebot] Branch reject\-dms\-default\-check was force-pushed to `c0fb978`
play Jedi tricks you didn't see anything
Might make sense for line 273 in _review.py, to be changed to use :eyes: instead of ๐ since you've changed the other ones, but this looks good to me, thanks!
Might make sense for line 273 in
_review.py, to be changed to use:eyes:instead of๐since you've changed the other ones, but this looks good to me, thanks!
To be honest, if we were to do that they should be Unicode points because Git messes up encoding sometimes. But we can't use the emoji names everwhere, it will fail in some places. I don't mind switching everything though.
78f9fa7 Recruitment: Don't use emoji literals - Akarys42
Fake Redis was the culprit, let's go!
[python-discord/bot] branch deleted: stream\-and\-revokestream\-commands
Connected!
The unicode escape is not very clear, the bot has a Emojis.check_mark constant for this emoji
This should use Emojis.cross_mark or :x: if we're taking out emojis out of the code.
Same situation on L303
I think using "\N{THUMBS UP SIGN}" and "\N{THUMBS DOWN SIGN}" is a bit clearer for the emojis
384ac5f Reduce default duration of stream permission fr... - ChrisLovering
[python-discord/bot] New branch created: reduce\-default\-stream\-duration
[python-discord/bot] branch deleted: reduce\-default\-stream\-duration
Connected!
The YouTube Terms of Service have been updated a bit since March 14, 2020 when they were last edited in the ytdl tag. (They were last changed March 17, 2021 according to the site.)
Specifically, it looks like we need to fix the wording in restrictions 1 and 3.
I'm happy to tackle this one really quick once it's assigned to m...
If a user's streaming permission is removed via the revoke stream command, we want to stop any stream that may be in-progress.
If a user's video role drops off due to the normal schedule, then we don't need to do this.
discord.ActivityType.streaming shows whether a user is streaming.
This implementation should work even if the member don't have the video role anymore.
[python-discord/quackstack] branch deleted: sane\-ci\-names
This only checks the final node. It needs to ensure all nodes along the path are mapping nodes. In fact, the above loop will fail if one of the values it retrieves does not have a setdefault function.
Why is it a kw-only argument?
What if the path is an empty string i.e. the root? Is that even a possible case?
It's not clear that the referenced attribute need not exist in the config (in which case it'd use the default value of the class). Also, in this case, it should say overwritten not overwrote (though I find the entire "even if..." part to be confusing anyway).
We should try to come up with a way to explain it in terms of ConfigEntry attributes, since that is well documented above. If we just say it references the class's attribute, then they can refer to the above documentation for ho...
I didn't add any load_stream() function since this can be done through a StringIO, do you think that's really needed?
Yes, it would be useful because StringIO provides a file-like object while the load() function currently expects a path.
Furthermore, I still think an encoding parameter to forward to open() would be useful to have on load().
Should we have a special check to avoid registering that path then? I don't know of a better way to avoid it.
We may need to rely on subclassing the metaclass for our Discord stuff for all I know, but sure, we can save it for later.
I was leaning towards add_constructor anyway since it's more explicit. I don't like the idea of importing modules just for the sake of executing the code within them.
"""Independent YAML loader to add constructors on it."""
One of these is misaligned.
Why did you go for this approach instead of storing the path? Is disallowing references to paths which are also references not sufficient to prevent circular references? Looping to check each constructor for circular dependencies seems more complex and slower.
It shouldn't be possible afaik as the root node would just be the entry itself.
Oh, I missed that. I feel like a circular reference is more of a configuration error anyway so it probably doesn't need its own exception type.
I initially made it a default argument because of the two recursive calls, that's just my brain being smooth. I like the idea of having a default argument here though, this is a more general function that can be used elsewhere.
I suspect that the API for this function may often change, I think it is better practice to put less used parameters as keyword-only.
We could delete the node if it is empty, sure. But if we ever overwrote an attribute, we can't do that.
Yeah, good point. I think it'd be a bad idea to have inconsistent behaviour. What happens currently when there is a reference to an attribute with a configured value, but the corresponding class is not loaded?
This sounds a bit like premature optimisation. We don't rely on exceptions in our code except in case of actual failure, if they aren't optimised I don't think it is an issue.
You may be right, but I'll have to look into the flow of execution more since I don't remember now. In any case, we can leave this optimisation for another time.
Do we even want to avoid it? I don't find it problematic, it will just hold an empty dictionary in the global configuration.
Not sure if I agree with this being frequently changing, but I don't really mind it being kw-only so, whatever.
Is disallowing references to paths which are also references not sufficient to prevent circular references?
It would be, although we can't point a ref to another ref which would be pretty lame.
I haven't tested it yet but it should still resolve it since it is in the global configuration.
But can't someone set the path of a ConfigEntry to be the root node?
I'm not sure if that should be allowed, but I'm fine with leaving it as-is for now.
Okay, that's fine then. I wish it didn't need to have follow_descriptors forwarded like 4 times, but I don't have any better ideas. It's an implementation detail so we can come back and address it later if we want.
Why do these exceptions indicate that the end was reached?
I see your point, but I would've rather not have it added, especially considering it's a private utility function only used once. However, since you already did, I guess it can stay.
Connected!
Since snekbox does not run with a tty, stdout is technically raw bytes, and thus incomplete surrogate pairs can be printed without the client application erroring, and instead fail within _consume_stdout when we attempt to decode it to a str.
This commit sets the PYTHONIOENCODING environment variable to inform python to open the pipe in utf-8 mode.
However, clever use of execl and os.unsetenv() can unset this environment variable, so we add a safety check to _consume_stdout to fail out ...
[python-discord/quackstack] New branch created: time\-fix
I will go ahead and do this.
2b7b343 fix ducky saving after switch to new return type - vcokltfre
[python-discord/quackstack] New branch created: slash\-duck\-fix
The return type for duck building is now a named tuple with an image argument, rather than an image, causing the server to error when trying to save the duck (calling .save() on the namedtuple), this PR fixes that issue.
๐ฆ Looks ๐ฆ good ๐ฆto ๐ฆ me!
dd069c4 remove git submodule update from dockerfile - vcokltfre
[python-discord/quackstack] New branch created: docker\-update
As of #25 we no longer use the branding repo as a submodule and hence have no submodules, so this removed the submodule update step from the dockerfile
[python-discord/bot] New branch created: decorator\-tag
This PR adds a tag for creating custom decorators in discord.py for commands (different to the existing decorators tag in that it specifically shows how to make discord.py checks, a commonly required subject, rather than just decorators)
How the embed looks:

Catch up
Relevant Issues
Description
Reasoning
Screenshots
Additional Details
Did you:
- [ ] Join the Python Discord Community?
- [ ] If dependencies have been added or updated, run
pipenv lock? - [ ] Lint your code (
pipenv run lint)? - [ ] Set the PR to allow edits from contributors?
Because it is pointing to a non-existing attribute, we can't continue further.
Nope, it will default to the module name if an empty string is passed.
Sounds good @bsoyka, thanks!
We currently have the !ext command to list, unload and load cogs.

It would be useful to have a similar command to lower the log level to DEBUG or TRACE during runtime.
Do note that some cog relies on other files like HelpChannel is actually made of four files. We need to find a way to detect those additional files and also change their logging level.
Do note that some cog relies on other files like
HelpChannelis actually made of four files. We need to find a way to detect those additional files and also change their logging level.
Setting the level on the parent logger of the package will make all the children inherit it so we don't need to discover those manually.
But I'm not sure how util logs should be handled with changing levels, for example the utils.lock will continue logging with the previous level even for informati...
Setting the level on the parent logger of the package will make all the children inherit it so we don't need to discover those manually.
Cool, that should work then.
But I'm not sure how util logs should be handled with changing levels, for example the
utils.lockwill continue logging with the previous level even for information that is relevant to the ext where the level was changed, but then changing it will also cause logs from locks from all the other exts to change.
I th...
Connected!
Connected!
Connected!
The Terms of Service seem to be different in different countries, the UK version seems to be the one that was used previously, and the relevant info for that one hasn't changed as far as I can tell, see https://www.youtube.com/static?gl=GB&template=terms. It's just that the US version seems to have slightly different wording. I guess it doesn't really matter which one we use though
Ah, that would make sense. Does the link in the tag automatically redirect to the UK version if that's where you're at? If so, we should probably just change the link instead, but if not, the wording should be the US version so it matches up.
[python-discord/sir-lancebot] New review comment on pull request #583: Add the stackoverflow command
@Shivansh-007 I have implemented that.
Description
Currently, the .issue | .pr command uses a green open pull request emoji when showing open pull requests. Although, when pull requests are drafts in Github, then the colour of the sign will be grey. For example, #623 is a draft PR, and doing .pr 623 currently looks like this:

However, it really should look like this:
 and I'm gonna switch the wording back to the UK version and fix the link, then it should be all good to go.
Please use dedent like the rest of the tests.
I'm not sure if asserting the exact traceback is the right approach to testing this. The way I see it, we don't care how Python deals with it as long as our program doesn't crash trying to get the output. In fact, do we even care if the exit code is 1?
Also, this would need to be updated https://github.com/python-discord/snekbox/blob/main/snekbox/api/resources/eval.py#L43-L44
All of these fuctions are slow, and blocking, so they should be ran in executors.
@pfp_modify.command(aliases=["easterify"], root_aliases=("easterify", "avatareasterify"))
pass_context is no longer a valid kwarg, as it's passed automatically,
await ctx.send(f"{Emojis.cross_mark} Could not get member info.")
elif data["url"].endswith(("jpg", "png", "gif")):
str.endswith can take a tuple.
Because our help command isn't a commands.HelpCommand, this should use utils.extensions.invoke_help_command.
if data["is_video"] or {"youtube", "youtu.be"}.issubset(set(data["url"].split("."))):
if r.headers.get("X-RateLimit-Remaining") == "0":
await message.channel.send(embed=embed, delete_after=5)
Returns IssueState on success, FetchError on failure.
WTF_PYTHON_RAW_URL = "http://raw.githubusercontent.com/satwikkansal/wtfpython/master/"
mster seems to give a 404 response, causing the extension to be unloaded right when the bot starts.
LOAD = Bot.load_extension
UNLOAD = Bot.unload_extension
In __init__, self.game_owner is an int object, yet when play is called, self.game_owner is a Member object.
LOAD, and UNLOAD needs to partials as they would be considered as function definitions which is not what we want, if we remove the partials.
Uses implementation of the staff PyWeek submission
-
Adds colors.py which contains all util functions i.e.
make_color,make_duck_colors,make_man_duck_colors. -
Get rid of random RGB generator and validator.
to be fair. as people are getting to know about discord recently. i have seen this happening a quite bit
i don't think there is any precious we are losing by adding a single line to help command.
[python-discord/quackstack] branch deleted: slash\-duck\-fix
[python-discord/quackstack] branch deleted: docker\-update
fd2ff1d increase the number of repos per page we fetch ... - vcokltfre
[python-discord/sir-lancebot] New branch created: issues\-more\-repos
Description
Currently repos such as quackstack don't work with the issues cog when typing, for example, quackstack#29 into discord, since by default GitHub paginates repos to 30 per page, and we only fetch one page.
Reasoning
Reasoning is to make the functionality work for repos beyond the 30 repo pagination limit, by adding a per_page query string to get 100 per page. This is not a permanent fix, but it should certainly suffice for a long time - another 64 repos.
Did you...
50cd34e fix: use get_user in 8bitify to avoid events is... - vcokltfre
30756d4 fix: use api fetch not cache get - vcokltfre
41f0661 Merge branch 'main' into vcokltfre-avatar - Xithrius
7901267 Merge pull request #657 from python-discord/vco... - Xithrius
3ed1270 Merge branch 'main' into akarys/630/automatic-l... - Akarys42
I think we do care that it exits with 1, as that indicates the python process has successfully thrown an error message like we've expected. I was trying to find good ways of asserting that it simply returned a UnicodeEncodeError, as that's really what I wanted to check.
That sounds better, committed in b436dcf
Which commands do we want moved?
Looking at it there's the site home/about and site help commands, which don't looks like they'd fit a tag, at least if the names are kept. But I don't think they get much use, what do the usage stats look like for them?
422f6d5 Refactor pfp cog to remove unnecessary params a... - ChrisLovering
c9e4916 Ensure to await ctx.send() calls - ChrisLovering
Description
It would be great to have Sir Lancebot spot latex syntax in messages and send an image rendering it.
Reasoning
There are math-related questions in the off-topic channels fairly frequently, and writing equations in plain text is quite, uh, painful.
Proposed Implementation
We could use matplotlib for rendering the latex, it seems to do the job pretty well.
Messages with text enclosed in $ symbols would be identified, said text would be rendered, and its image ...
Connected!
icon_url is conveying the wrong meaning here, it is not a "icon url", but rather an emoji.
You can also mention issue #643 in this PR. As the original contributor who was interested has un-assigned himself and looks no more interested.
You can add a :x: emoji, ahead of the return code to match the pattern.
description_list.append(f":x: [{result.return_code}] {result.message}")
Connected!
It is ignored on purpose, we shouldn't send automatic error embeds. It is part of the original specs of #566.
That was the original name, I don't mind changing it.
@MarkKoz I'm going to go ahead and leave the channel "checking" as it is.
As for missing messages, we receive a discord.errors.NotFound: 404 Not Found (error code: 10008): Unknown Message (tested with random IDs). I haven't seen an instance of where the return code is a 400.
This seems to give a NameError here.
@Xithrius I'd like to take this.
[python-discord/site] Pull request opened: #474 Added a Favicon, and changed the 404\-support text\.
Added the PyDis logo as the favicon, and altered the error text slightly.
Shouldnโt this be part of python-discord/snekbox rather than breaking into the user code and appending few lines to it or making two calls?
Either way is fine as far as I am concerned. There was an idea to support supplying arbitrary Python arguments to the API (rather than adding a new endpoint specifically for timeit).
On second thought, it's useful to assert the exit code to distinguish this case from the case of snekbox catching the error and handling it. Asserting the traceback is needed cause the exit code on its own would be too broad of an assertion. That being said, do you think simplifying it to assert "UnicodeEncodeError" in output would be sufficient?
[python-discord/sir-lancebot] Issue opened: #664 Remove/edit a topic which is impossible to answer\.
Description
There is never anyone to the right. Remove that line from the topic command.
Reasoning
Every time this topic comes up, people tend to hate it or make fun of it.
Proposed Implementation
Remove the topic from /bot/resources/evergreen/starter.yaml#L9
Would you like to implement this yourself?
- [x ] I'd like to impl...
Relevant Issues
Closes #661
Description
In this PR, I changed the url for getting the pull info to https://api.github.com/repos/{user}/{repository}/pulls/{number}, and check if pull_data["draft"] is true, and if so, use the :PRDraft: emoji.
Reasoning
It makes more sense when the PR is a draft that the bot will show the draft PR icon/
Screenshots
? - [x] Set the PR to **allow edits fro...
Description
It'll just emulate the cowsay program.
Reasoning
This would be useful because it would be funny.
Proposed Implementation
It would have the flags of the original cowsay, such as tux, except maybe the head in ass one.
Would you like to implement this yourself?
- [ ] I'd like to implement this feature myself
- [x] Anyone can implement this feature
Thank god this one is gone, thanks! :shipit:
Is anybody working on this anymore?
This constant no longer exists.
Okay, thanks for looking into it.
Relevant Issues
Closes #663
Description
Uses matplotlib's default parser for rendering tex.
Reasoning
matplotlib's subset of tex allows nothing more than symbols and alphanumeric characters, eliminating the need for sandboxing.
It also does not require a local installation of LaTeX.
Screenshots

? - [ ] Set the PR to allow edits from contributors?
I'm not sure. It may be strange to see if something external needs access to the config, like for introspection. I suppose we can remove it later if it becomes a problem.
[python-discord/sir-lancebot] branch deleted: word\-boundaries\-in\-issues\-regex
Last 6 months:
site_resources 4 K
site_rules 4 K
site_tools 84
site_home 72
site_faq 43
site_help 10
I don't see why they all can't be tags (except rules). I guess the names should be like sitefaq, sitehome, etc.
Description
Simple addition to remove the connect permission from the everyone role and restore it when done.
Reasoning
Keep people from joining voice channels during a raid, making the entire server as read only as it can get.
Did you:
- [x] Join the Python Discord Community?
- [x] If dependencies have been added or updated, run
pipenv lock? - [x] Lint your code (
pipenv run lint)? - [x] Set the PR to **allow edits from c...
If we're going for shutting down voice channels, should we also set speak to False too?
If we're going for shutting down voice channels, should we also set
speakto False too?
No, because if you can't connect to a voice channel, you can't talk in them.
If we're going for shutting down voice channels, should we also set
speakto False too?No, because if you can't connect to a voice channel, you can't talk in them.
I'm referring to users who are already in voice channels.
If we're going for shutting down voice channels, should we also set
speakto False too?No, because if you can't connect to a voice channel, you can't talk in them.
I'm referring to users who are already in voice channels.
If they're already in voice channel, permissions aren't applied until one leaves and rejoins. To fix this, the bot would need to recurse through everyone in the voice channels and disconnect them from the channels.
If we're going for shutting down voice channels, should we also set
speakto False too?No, because if you can't connect to a voice channel, you can't talk in them.
I'm referring to users who are already in voice channels.
If they're already in voice channel, permissions aren't applied until one leaves and rejoins. To fix this, the bot would need to recurse through everyone in the voice channels and disconnect them from the channels.
...
If we're going for shutting down voice channels, should we also set
speakto False too?No, because if you can't connect to a voice channel, you can't talk in them.
I'm referring to users who are already in voice channels.
If they're already in voice channel, permissions aren't applied until one leaves and rejoins. To fix this, the bot would need to recurse through everyone in the voice channels and disconnect them from the channels.
...
My main concern here is site-help, as a tag I don't think the name really fits it and it may be used in a fashion similar to how the ask tag was used.
Connected!
The NsJail process failed to launch or the output was invalid Unicode
3072fff Use PYTHONIOENCODING to enable utf-8 stdout for... - bast0006
cf1cb44 Match new unicode eval tests and output to the ... - bast0006
802441b Note new return case in eval api file - bast0006
4b3a226 Clarify documentation of None return code - MarkKoz
93f99fb Merge PR #100 - avoid decoding of invalid Unico... - MarkKoz
Thanks @bast0006! Were you interested in working on adding support for byte output too?
Currently, only CPU and memory parent cgroups are created. While this works fine for the default config, it doesn't account for custom configs which may use additional cgroups. It should either create all possible parents or try to read the config and determine which cgroups are needed. If the latter is possible and not complicated to implement, then it would be preferable to the former.
Special cases, similar to disabling swap for the memory cgroup, should be investigated when creating th...
NsJail supports v2 and ideally snekbox should too.
I am, although I think we needed some bikeshedding on what exactly we were going to do there. I'll open an issue?
Currently, all output is interpreted as Unicode text. Supporting byte output would allow a much more diverse range of things that could be returned e.g. images and sound. I think it makes sense to maintain a single endpoint and simply add a parameter to change from text to byte mode, but I'm still open to discussion on making it a separate endpoint.
Since the API uses JSON, the bytes would have to be base64-encoded, unless someone has a better alternative (which could perhaps also be a goo...
Currently, the limit is hard-capped at 1 MB here
These should read from environment variables to enable users to customise the values when launching the container.
Custom arguments to the Python subprocess would enable execution of other modules e.g. timeit. These arguments should be appended after the arguments in the nsjail config. In other words, they should replace the implicit -c argument
The arguments should be supplied as an array of strings in the JSON body of the POST request.
For example, given the current default configuration, passing ["-m", "timeit"] should result in /usr/local/bin/python -Squ -m timeit "the code here". Notice...
A long time ago I made a rough draft of a filter:
seccomp_string: "KILL {"
seccomp_string: " execve,"
seccomp_string: " execveat,"
seccomp_string: " shmget,"
seccomp_string: " shmat,"
seccomp_string: " shmdt,"
seccomp_string: " shmctl,"
seccomp_string: " fork,"
seccomp_string: " clone"
seccomp_string: "}"
seccomp_string: "DEFAULT ALLOW"
However, because nsjail applies the filter to the forked process before it changes from nsjail to Python, blocking s...
Connected!
While Docker's defaults are supposedly pretty good, maybe we could do better. Specific areas of focus are likely seccomp and capabilities. @Akarys42 borugh up a whitepaper, which, while relatively old, may still offer some insights.
gvisor also sounds great, but it's unclear whether it implements the kernel features necessary for nsjail to work. Furthe...
Re: gVisor.
The limitations for gVisor means that we would likely have to subject the entire snekbox deployment to gVisor filters, since the Kubernetes guide[1] is for placing entire pods into the gVisor realm.
As of now, they only provide instructions for running with containerd, and even then it's unclear whether this would be compatible with the managed Kubernetes instances hosted by Linode (as of now it's unclear whether Linode will switch to containerd or CRI-O for subsequent Kub...
Description
Some of the requests to the github api aren't authenticated, specifically in the github cog
Proposed Implementation
I have two different ideas here. The one and simple idea would be to copy code from the issues cog that does authenticate requests, but the other idea would be to m...
To maintain consistency could you switch this to use soft_red
colour=Colours.soft_red
Include the message ID here, otherwise this statement is of no use.
1f4fa2d Remove opt_out column - jb3
8c93760 Remove opt_out from bot logic and opt out commands - jb3
f6cf6d0 Various version upgrades for discord.py - jb3
This PR removes the opt out data from the database and the related opt out commands from the bot.
Data gathered from Metricity is used in various places around the community now, including but not limited to:
- Voice verification
- Nomination information
- Channel usage measurements
The opt-out functionality is somewhat misleading since the only data it opts out from is from collection of message counters, all data collected prior is retained as well as user information. There is no ...
Note to self: this should be changelogged when merged, with some of the above explanation included.
Code looks good. And after talking in #dev-contrib today, I agree that removing the opt-out makes it much clearer.
I agree with DawnOfMidnight - code looks good and after a short interrogation discussion with Joe, this definitely makes things clearer.
Much easier to say you can't opt out at all than to allow opting out of one small aspect of Metricity.
This hasn't gone anywhere, and I don't feel it's the direction the eval feature on the bot, let alone snekbox, should go in anyway.
Connected!
Hey @onerandomusername, thanks for the PR! It seems like you don't say why those changes were made. Chris pointed me to the discussion in #dev-contrib from last time, if you could mention it on your next PRs that'd be perfect!
The changes looks good, I'm going to trust you for the privacy policy part :+1:
Connected!
This is just a trace statement, it was just for me to understand what this variable would contain. It will only be shown in development it is pretty trivial to know which message triggered it.
AFAIK aiohttp will follow the 301 and either yield a 200 or 404.
Is anybody working on this anymore?
Hi, sorry, I got sidetracked by my school exams and then my laptop broke and is now under repair. If you would like to contribute to this, feel free!
We can skip overriding the __init__ as you don't end up using the Bot instance anywhere
Nitpicking but I think you'll want to rearrange those imports according to alphabetical order as well
Thanks for the PR! Just a small suggestion:
I think instead of returning a Union[BytesIO, str] after a try-except, it'd be better if we catch that error within latex instead. You could raise a commands.BadArgument instead of sending the exception message directly as well. So possibly something like:
@commands.command()
async def latex(self, ctx: commands.Context, *, text: str) -> None:
"""Renders the text in latex and sends the image."""
async with ...
the imports are pretty much in the order for which flake8 doesn't complain, probably because import...s should go before from ... import ...s
Alright, once I do that would I have to change anything in the error_handler.py?
Also, I think if the rendering fails, the users might want to see where the syntax error is in their latex
Not entirely sure on the former, but assuming e has the information for that, you could interpolate it
https://github.com/python-discord/sir-lancebot/blob/964112352809bcec5b13fe5da93b15b4ade1b196/bot/exts/evergreen/error_handler.py#L94 catches BadArguments. The string that you pass when raising will be included in the output, so you could include what you want to output in that there.
Finishes #453.
In issue #453, it was proposed that the 100k banner be removed and that the timeline was added to the navbar. Lemon removed the 100k banner, so this pr finishes the second part of that. It adds the timeline to the navbar for easy access from anywhere on the website.
Image:

This doesn't need to be a partial since text is a normal arg, you'd only need a partial if using kwargs.
I'm not sure if we want to output the full traceback here. What does e look like in this case?
Yea, that's fine then. Wasn't sure if it would have a huge traceback.
Which line is actually going to raise this ValueError? Ideally we would only wrap that individual line in the try/except, rather than all of this.
Just one minor gripe which doesn't need to be done.
Rest looks good to me :)
Looks good to me, tested locally too.
I also tested the WonderTwins and ConvoStarters cogs since those are the only ones that use PyYAML (Since this PR upgrades the version to latest)
Do we want to specify the type=public query param here to ensure we never pull private repos? Just in case the token given to lancebot gets given read access to them.
Just a small comment, rest looks fine.
I think a filter can be configured from the Sentry website. See https://sentry.io/settings/python-discord/projects/bot/filters/data-filters/
0c78edf Log exception info for unhandled exceptions fro... - MarkKoz
[python-discord/bot] New branch created: bug/backend/log\-event\-exc\-info
It's pretty difficult to debug without this information.
Actually, since d.py calls this from an except block, it should already have the exception info implicitly. However, for some reason, it doesn't exist for this issue.
8f1294a Filtering: remove invisible characters before c... - MarkKoz
[python-discord/bot] New branch created: bug/filters/1469/invis\-chars
Fixes #1469
Invisible characters are removed for the following filters:
- names
- urls
- invites
- regex
#1346 should have addressed any outstanding race conditions.
I've ignored it in Sentry. Unless I've done something incorrect, this shouldn't show up in the dev-core channel ever again.
FORMATTED_CODE_REGEX = re.compile(
r"(?P<delim>(?P<block>```)|``?)" # code delimiter: 1-3 backticks; (?P=block) only matches if it's a block
r"(?(block)(?:(?P<lang>[a-z]+)\n)?)" # if we're in a block, match optional language (only letters plus newline)
r"(?:[ \t]*\n)*" # any blank (empty or tabs/spaces only) lines before the code
r"(?P<code>.*?)" # extract all code inside the markup
r"\s*" ...
"figure.facecolor": "36393F", # matches Discord's dark mode background color
Nitpicking, but this is the exact colour code for dark mode, can be found in discord.colour.Colour.dark_theme
You would need to import time to run this code.
text = self._prepare_input(text)
async with ctx.typing():
with ThreadPoolExecutor() as pool:
start = time.time()
image = await asyncio.get_running_loop().run_in_executor(
pool, self._render, text
)
end = time.time()
time_taken = end - start
embed = discord.Embed(name="Latex O...
Thanks! Looks Good To Me! :shipit:
[python-discord/bot] New branch created: bug/filters/902/antispam\-punish\-once
Fixes #902
A user may manage to send multiple message that violate filters before the mute is applied. Because of a race condition, subsequent punish attempts did not detect the mute role exists and therefore proceeded to apply another mute.
To avoid the race condition, abort any subsequent punish attempts while one is already ongoing for a given user. It could be possible to wait instead of abort, but the first attempt failing very likely means subsequent attempts would fail too.
Description
Quite simply, the ability to use .timed (.t as an alias), to be able to time the execution time of a command.
Reasoning
Considering a conversation in dev-contrib about having time displayed in a latex rendering command, I figured why not have the best of both worlds; by default don't display the time since it can be considered bloat, but have the ability to time the execution of a command should you wish for the extra technical details, if it's of interest to you.
...
0e9ea17 add timed command for timed execution of commands - vcokltfre
[python-discord/sir-lancebot] New branch created: feature/timed\-execution
Relevant Issues
Implements and closes #671
Description
The changes have been implemented by creating a new execution context for the command by taking the message content, updating a copy of the message with that content, and using bot.get_context() to get a new context for execution. The invokation of that context is then timed by perf_counter() and displayed to the user upon the command finishing with the time in seconds to .4f precision.
Reasoning
It's been impleme...
Per discussion in #dev-contrib I'm not implementing this
Is that from an internal eval?
@MarkKoz this specific issue is indeed coming from an int e
Do we only want to handle the common chars here?
There's a bunch more of chars which don't render to anything noticeable, I'm haven't checked them all for how they look on discord but the tags for example don't show up as anything https://paste.fuelrats.com/oguvesutip.py
Could avoid the docstring commenting on the character names if named escapes would be used here
Context
The !superstar command currently requires a duration to be specified when invoked.
Often we want to change someone's nickname from something very noisy or that takes up a lot of room until the user can respond and change it themselves. The duration in these cases is not usually that important as we want it to be a quick change.
Proposal
It would be useful if there was a short default duration for this command. Something like 5 or 15 minutes. It would function similarl...
msg.content = f"{ctx.prefix}{command}"
Do we need this here? self.bot hasn't been used at all.
Do we only want to handle the common chars here?
There's a bunch more of chars which don't render to anything noticeable, I haven't checked them all for how they look on discord but the tags for example don't show up as anything https://paste.fuelrats.com/oguvesutip.py
I'll try to make it more thorough. Thanks for the tip about the Unicode category. Only some Arabic characters at the start render, but I think it's fine to strip them out anyway cause it seems more likely th...
Problem
Currently a user can run as many time commands as he wants, which would then lead to spamming in the channel, i.e.

Solution
add commands.max_concurrency(2) decorator would solve this issue by allowing only two time calls.
 should be fixed, although I disagree with the proposed solution. Using this wouldn't allow more than two users to use the command at the same time which doesn't make sense. The timed command should just make sure that it isn't executing itself.
The problem pointed out by @Shivansh-007 (#672 (review)) should be fixed, although I disagree with the proposed solution. Using this wouldn't allow more than two users to use the command at the same time which doesn't make sense. The
timedcommand should just make sure that it isn't executing itself.
I think that's only because it's using the [global bucket type](https://discordpy.readthedocs.io/en/l...
Cool, let's use the user bucket then and call it a day.
b11d68c AntiSpam: use a more thorough regex for zalgo &... - MarkKoz
In that case, I'll close this.
[python-discord/bot] branch deleted: bug/backend/log\-event\-exc\-info
I think redis is good enough, but a more robust approach would be to use message history to find the message when the cog is initialised. It would only need to get the most recent message and make sure the author is the bot (and optionally check the start of the message is "Currently available help channel").
discord.py doesn't appreciate when we directly set attributes of things like messages, which is why i'm using the update function made specifically for that
A better solution would just be to check that new_ctx.command is not timed which is my intended solution to the problem
d726323 removed unused cog init and fixed timing timed ... - vcokltfre
I don't like that we're using a private method here, plus, the only thing _update does is set message.content = value. So this is the same thing here.
The return annotation is None, but you're returning a Message object.
await ctx.send("You are not allowed to time the execution of the `timed` command.")
return
Relevant Issues
Closes #653
Description
This internal eval comes from rattlesnake primarily. It was ripped out of rattlesnack whole sale and subsequently modified to fit Sir Lancebot's structure. Additionaly, the codeblock regex from snekbox was stolen used for more robust code markdown usage. The image below shows it quite nicely.

Rattlesnake's internal eval imp...
Tested it out. It's pretty nice and locking deps didn't take 5 years. So +1 for a basic Windows user.
Alright, this command works pretty nicely. However, when the command isn't found, there isn't any handling for an AttributeError:
Traceback (most recent call last):
File "sir-lancebot\bot\exts\evergreen\timed.py", line 29, in timed
await new_ctx.command.invoke(new_ctx)
AttributeError: 'NoneType' object has no attribute 'invoke'
This all looks fine and works great locally, however discussion in #dev-contrib pointed towards this task taking multiple seconds, so I'm wondering whether some sort of caching should be implemented.
My suggestion would be to generate a hash of some sort of the query and then store to a _latex_cache directory in the current folder or something (therefore allowing it to work in Docker & on Host). The directory would not be persistent at all and should of course be gitignored.
What's th...
7c7c6dd fix: use ctx.prefix when suggesting the help co... - vcokltfre
Relevant Issues
Closes python-discord#622
Description
self.match = re.fullmatch("([A-J]|[a-j]) ?((10)|[1-9])", message.content.strip())
Reasoning
Screenshots
Additional Details
Did you:
- [ ] Join the Python Discord Community?
- [ ] If dependencies have been added or updated, run
pipenv lock? - [ ] Lint your code (
pipenv run lint)? - [ ] Set the PR to allow edits from contributors?
@rijusougata13 Thanks for your contribution! Please fill pull request template fully and give why and what you changed. Thanks.
INVISIBLE_RE = regex.compile(rf"[{VARIATION_SELECTORS}\p{{UNASSIGNED}}\p{{FORMAT}}\p{{CONTROL}}--\s]", regex.V1)
For something that may not be noticed in testing: poetry does not support automatic selection of python interpreter (even though it claims it does). This is something that has bitten us in the staff pyweek project for some people, and something I've dealt with on my own projects.
Poetry claims to be able to select the correct python version from your path, like pipenv does, but that doesn't seem to work (from my testing on windows, and...
The PR looks pretty good overall, thanks! Just a few comments.
This docstring should be updated to use Sir Lancebot's prefix. Technically it should use the constants but you can't really use variables in docstrings.
clear the context, use the `.internal clear` command.
This is already handled by the .int reset command defined below. Besides this doesn't allow for things like exit() to restart the container.
Same as above
log = logging.getLogger(__name__)
Connected!
Could we move this into the _render function, since it's blocking? Could be worth renaming the function or updating the docstring after too, to reflect it also saves the file.
Following the discussion in #dev-contrib I think we want to add a max_concurrency to this command. I'd suggest with 1 concurrent, the guild bucket, and wait=True.
This could just be CACHE_DIRECTORY.mkdir(exist_ok=True)
This comment can be ignored here, as there is no defining of Redis Cache instances in this cog.
Quick review, need to look into ast and mess around with it, before I can do a full review.
"<internal eval>" can be made a file constant.
This is not getting used anywhere, and hence can be removed.
51d9b54 Issues: add type=public - Akarys42
Added it in 51d9b54 as a safety measure
Looks good to me. Only limitation is that it doesn't work with commands that use wait_fors, such as anything using the LinePaginator, as the invoked command doesn't "finish" until the wait_for ends.
It could be worth adding a time alias, but I don't mind either way.
@commands.command(name="timed", aliases=["time", "t"])
17cf2b3 Add env var for trashcan eomji override - ChrisLovering
[python-discord/sir-lancebot] New branch created: trashcan\-can\-now\-be\-overwritten\-with\-an\-env\-var
Description
Added an environ.get with a default value
Reasoning
Allows users to override the default emoji to their own, which will avoid errors in dev testing.
Did you:
- [ ] Join the Python Discord Community?
- [ ] If dependencies have been added or updated, run
pipenv lock? - [ ] Lint your code (
pipenv run lint)? - [ ] Set the PR to allow edits from contributors?
Thanks! Looks Good To Me! :shipit:
Looking at the logs with this change, I don't think this adds anything beneficial to the logs.
[python-discord/sir-lancebot] branch deleted: trashcan\-can\-now\-be\-overwritten\-with\-an\-env\-var
Connected!
I think it's fine as is since the codeblock we spit back out is formatted with the py language detection. It makes sense that the hastebin output of it would match as well.
The RedisCache instance is an example of why you should import the Cog at runtime, not saying that is for sure what will happen.
log.trace(f"Updating locals {self._locals} with {locals_}")
I agree with joeโs suggestion here.
Use bot.utils.extensions.invoke_help_command instead, ctx.send_help sends the default help command.
Great PR, just one change.
In fact there is no way to escape triple backticks and this function really isn't what we want. Please ignore my comment, sorry about that.
This line should have a \n before the second set of ``` because discord markdown won't always give the output highlighting if that \n isn't there. It also will display as if it was only single ticked on android.
- await ctx.send(f"```py\n{output}```{upload_message}")
+ await ctx.send(f"```py\n{output}\n```{upload_message}")
@Vthechamp22 Greetings. I hope your exams went well.
Are you still willing to finish off this feature, or should I hand it off to someone else?
22ba746 Remove topic that doesn't make sense in discord - onerandomusername
9641123 Merge pull request #666 from onerandomusername/... - ks129
17cf2b3 Add env var for trashcan eomji override - ChrisLovering
5134635 Merge pull request #675 from python-discord/tra... - Akarys42
b1bfea4 Merge branch 'main' into akarys/630/automatic-l... - Xithrius
I'd like to see some issues that came up during a cursory test addressed:
-
Duplicates

-
No limit on the number of issues grepped from a message

-
No ratelimit handling:
fetch_issuesreturnst.Union[FetchIssueErrors, str, list], two of which are error mess...
Could you explain a bit more about the exit() to restart the container? I believe the functionality is so you can do a quick .int e exit to reset the context to mimic a REPL environment.
b8e8be4 fix: put april fools video links in correct cha... - vcokltfre
[python-discord/sir-lancebot] New branch created: fix/april\-fools\-video\-categories
Description
A simple fix to put videos in their correct channel names to avoid this:

Did you:
- [x] Join the Python Discord Community?
- [x] If dependencies have been added or updated, run
pipenv lock? - [x] Lint your code (
pipenv run lint)? - [x] Set the PR to allow edits from contributors?
652e306 chore: add time as alias of timed - vcokltfre
We can stick with the Redis cache for now since I think we'll probably want to shove more information in the dynamic message in the future.
0e9ea17 add timed command for timed execution of commands - vcokltfre
d726323 removed unused cog init and fixed timing timed ... - vcokltfre
bf1cd68 fix message updating and return types - vcokltfre
b0892e5 return and send message if command isnt found w... - vcokltfre
7c7c6dd fix: use ctx.prefix when suggesting the help co... - vcokltfre
[python-discord/sir-lancebot] branch deleted: feature/timed\-execution
Connected!
Everything looks good, fingers crossed everything goes as expected this time.
2aa7e74 Add a !tp get_review command to get the nominat... - Akarys42
75af5ef Use emoji names in nomination body - Akarys42
ae9afac Properly handle the lack of nomination of a user - Akarys42
cb87d95 Talentpool: loop style change - Akarys42
f79b7c8 Close voice channels with defcon shutdown - onerandomusername
Looking at how Python does it and other areas of Lancebot, I'm not sure if this should be made a constant. What's the benefit for it?
Haven't tested yet, but I noticed that we're defining caches in bot/exts/help_channels/_caches.py, so it would be a good idea to have that there too.
Going by convention then, the namespace could be HelpChannels.dynamic_message? I'd also suggest simplifying the redis key, maybe message_id or just id
[python-discord/bot] branch deleted: dynamic\-available\-message\-patch
c07b211 Added Redis caching. - Xithrius
32922b4 Merge branch 'master' into dynamic-available-me... - Xithrius
71ea5a6 Removed extra newline at end of _cog.py. - Xithrius
016614c Using http methods to edit/send messages. - Xithrius
7896894 Moved cache, reworked logic so message sends on... - Xithrius
Connected!
c07b211 Added Redis caching. - Xithrius
32922b4 Merge branch 'master' into dynamic-available-me... - Xithrius
71ea5a6 Removed extra newline at end of _cog.py. - Xithrius
016614c Using http methods to edit/send messages. - Xithrius
7896894 Moved cache, reworked logic so message sends on... - Xithrius
Tested the new regex locally, looks good to me
Currently the dynamic message in #how-to-get-help doesn't sort the available help channels, so this PR sorts the channel by position.
[python-discord/bot] branch deleted: bug/filters/1469/invis\-chars
0e9ea17 add timed command for timed execution of commands - vcokltfre
d726323 removed unused cog init and fixed timing timed ... - vcokltfre
bf1cd68 fix message updating and return types - vcokltfre
b0892e5 return and send message if command isnt found w... - vcokltfre
7c7c6dd fix: use ctx.prefix when suggesting the help co... - vcokltfre
Connected!
In case in future if the message limit gets increased it would be easier to change it, and I think such data is kept as a constant on Bot and Sir Lancebot.
This can possibly done with the help of Wolfram Alpha
-
The domain:

-
In the 3rd section, click Subdomains

Would it make sense to implement this throughout the entire bot for all commands?
This can possibly done with the help of Wolfram Alpha
1. The domain:  2. In the 3rd section, click **Subdomains** 
This actually can be done with dns lookup on a domain to see all domains ...
Privacy policy amendments and announcement have been made. This PR can be merged any time after 12 UTC on Sunday April 18th.
Description
TL;DR add a command to get info on a color supplied by rgb, hex, possibly fuzzy matching by name, and possibly hsv or hsl. All of this would be local and no api usage whatsoever.
More details are below in the Proposed Implementation section.
Reasoning
Say one was in #media and were trying to show a color for everyone, or were in offtopic and wanted to get color ...
I took a look at how Python handles these types of things and unless it's a common changing value it's not a constant.
so then we can merge and close the issue
@Xithrius, Yes my exams went well, thanks for asking. Yes, I think I will finish off this feature, hopefully by this week.
This can possibly done with the help of Wolfram Alpha
- The domain:
- In the 3rd section, click Subdomains
Using our wolfram alpha credits for this sounds really silly. It isn't something that we need an exte...
Sure, I will go ahead and implement this.
[python-discord/bot] New branch created: is\-vs\-==
Tag to demonstrate the difference between is and ==.
[python-discord/bot] New branch created: str\-join\-tag
For those curious here's what the tag looks like:

I'm not a fan of the use of the word "thing". Maybe "object" would be a good replacement?
This empty line should be removed
Would a PR be good, which would edit the Available Help Channel Embed to also include the user ID of the person who claimed that channel? This seems a useful feature, cz some people (many tbh), delete the message after claiming the channel, resulting in that being a useless channel...
e187a3c Allow automatic linking of issues outside of th... - Akarys42
Automatic linking has been extended to other organisation! Closes python-discord/organisation#345.
Indeed, solved in 4ff6d5a!
Description
Its impossible to get the source for the HelpChannel cog.
Steps to Reproduce
!src HelpChannel
Due to the logic of the command, all that needs to be said is !src help followed by anything.
Expected Behaviour
Source link to the HelpChannel cog is shown.
Actual Behaviour
Help command source link is shown.
Known Impacted Platforms
- [x] Web
- [x] Desktop
- [x] Android App
- [x] iOS App
Possible Solutions
These lines are the ...
Create a tag to showcase str.join
Hey @SavagePastaMan, can you please add a bit more content to the PR body? right now it isn't saying much about the PR either how it looks inside the server. Also, don't forget to lint!
i'm just using the github editor :pensive:. I also don't have a local instance of the bot so I can't get screenshots ๐ฌ.
Connected!
Connected!
375c247 Remove inappropriate riddle - ChrisLovering
[python-discord/sir-lancebot] New branch created: remove\-inappropriate\-riddle
Description
Deleted a riddle from the resource file
Reasoning
This riddle isn't the best, and one of the hints is inappropriate for our server.
Did you:
- [x] Join the Python Discord Community?
- [x] If dependencies have been added or updated, run
pipenv lock? - [x] Lint your code (
pipenv run lint)? - [x] Set the PR to allow edits from contributors?
Currently, when you do !source HelpChannels (or any command/cog/tag that starts with help), it shows the source for the help command. This is because we check if the lowered string starts with help, and not checking if it is equal to help.
Relevant Issues
Closes #1519
This all looks fine and works great locally, however discussion in #dev-contrib pointed towards this task taking multiple seconds, so I'm wondering whether some sort of caching should be implemented.
My suggestion would be to generate a hash of some sort of the query and then store to a _latex_cache directory in the current folder or something (therefore allowing it to work in Docker & on Host). The directory would not be persistent at all and should of course be gitignored.
What's th...
6b6e2bd Add latex cog - Shakya Majumdar
3e09dd8 add markdown support - Shakya Majumdar
e095a4f run _render in executor, raise BadArgument for ... - Shakya Majumdar
29c77d6 remove redundant use of functools.partial - Shakya Majumdar
4675123 exclude non error-causing lines from try-except - Shakya Majumdar
Connected!
Connected!
6b6e2bd Add latex cog - Shakya Majumdar
3e09dd8 add markdown support - Shakya Majumdar
e095a4f run _render in executor, raise BadArgument for ... - Shakya Majumdar
29c77d6 remove redundant use of functools.partial - Shakya Majumdar
4675123 exclude non error-causing lines from try-except - Shakya Majumdar
[python-discord/sir-lancebot] branch deleted: akarys/630/automatic\-linking\-everywhere
Connected!
Connected!
Connected!
Connected!
We want deleted messages to remain in the cache so that the bot can account for them when applying spam rules.
One way of doing that is monkey-patching this part https://github.com/Rapptz/discord.py/blob/master/discord/state.py#L483-L504 but it should be accompanied by proper tests to prevent any funny business on version bumps.
Another way is to cache deleted messages in a separate cache, but well.. it was already cached.
Connected!
Connected!
This line should have a \n before the second set of ``` because discord markdown won't always give the output highlighting if that \n isn't there. It also will display as if it was only single ticked on at least android, can't confirm on other OSes.
- await ctx.send(f"```py\n{output}```{upload_message}")
+ await ctx.send(f"```py\n{output}\n```{upload_message}")
c230761 fix: display help for the correct command when ... - vcokltfre
[python-discord/sir-lancebot] New branch created: vcokltfre/fix/timed\-error\-help
Description
When a new execution context is created in the timed command it's now added as the subcontext attribute of the parent context. When the error handler deals with the error the context is set to the subcontext if available, else the normal context. This means the command displays correctly.
Reasoning
It's been implemented this way since I believe it to be the cleanest and simplest way to do this. If this turns out not to be the case I'm more than happy to change the i...
LGTM. :shipit: :shipit: :shipit:
b8e8be4 fix: put april fools video links in correct cha... - vcokltfre
83245fa feat: rewrite portion of fool command to allow ... - vcokltfre
607e83b chore: remove unnecessary utility function and ... - vcokltfre
c811a75 Merge branch 'main' into fix/april-fools-video-... - ChrisLovering
eb999d1 Merge pull request #676 from python-discord/fix... - HassanAbouelela
[python-discord/sir-lancebot] branch deleted: fix/april\-fools\-video\-categories
Connected!
Connected!
Overview
Here are some features we should include:
- [ ] Colour information
- [ ] Random RGB or HSV colours
- [ ] Colour conversions
- [ ] Colour naming
These should all be implemented in the same command, but can be implemented separately, the above order is my recommendation for tackling them one by one.
Details
Colour information
Given a colour in one of the supported colour models (RGB/HSV/HSL/CMYK) we should return an embed with information on that colour.
...
@onerandomusername Which parts of this are you interested in doing, since this is a rather large task.
Thanks! Looks Good To Me! :shipit:
I would be working on this along with @DawnOfMidnight
Connected!
Connected!
Can I request that we upgrade to 3.9.4, rather than 3.9.1 as this issue title suggests.
I'll be working on this along with ToxicKidz and Shivansh-007. Also, I agree that 3.9.4 is better since it's more stable (assuming I understand versioning right).
ccdf1c9 Update issue matching regex - laundmo
[python-discord/sir-lancebot] New branch created: laundmo\-regex\-isssue\-patch
a3ce39f Linebreak to hopefully not run into linter issues - laundmo
fixes it being unable to get issue numbers larger than 9
limits it somewhat length-wise and character-wise to the actual github limits
Description
Changed the regex to match numbers at the end greedily
Changed the regex to only match allowed characters
Additional Details
regex used: https://regex101.com/r/V2ji8M/6
Did you:
- [x] Join the Python Discord Community?
- [x] If dependencies have been added or updated, run
pipenv lock?...
LGTM regex is tested and working, more than can be said for the current one lol
The regEx works. :shipit:
[python-discord/sir-lancebot] branch deleted: laundmo\-regex\-isssue\-patch
Connected!
7d9cf84 feat: add ping command - vcokltfre
[python-discord/sir-lancebot] New branch created: vcokltfre/feat/ping
Relevant Issues
No github issues, but the relevant conversation in pydis/dev-contrib is around here #dev-contrib message
Description
A simple command that sends an embed showing the bot's websocket latency. It is simple as was discussed; it has no need to be complex, just provide basic information and more importantly show that the bot is online.
Screenshots
}ms",
897d892 chore: use discord terminology - vcokltfre
Description
Switched from matplotlib.pyplot.figure to matplotlib.figure.Figure.
Memory cleared manually with del and gc.collect().
Cooldown added to the .latex command
Reasoning
matplotlib.pyplot.figure isn't properly reference counted.
With these changes in place, memory usage doesn't increase without bound, plateaus out at ~110MB.
Did you:
- [x] Join the Python Discord Community?
- [x] If dependencies have been added or ...
| Dependency Name | Upgraded | Tested | |
|---|---|---|---|
| aiodns | <ul><li>- [ ] </li></ul> | <ul><li>- [ ] </li></ul> | |
| arrow | <ul><li>- [ ] </li></ul> | <ul><li>- [ ] </li></ul> | |
| beautifulsoup4 | <ul><li>- [ ] </li></ul> | <ul><li>- [ ] </li></ul> | |
| fuzzywuzzy | <ul><li>- [ ] </li></ul> | <ul><li>- [ ] </li></ul> | |
| pillow | ... |
Any reason why you went with this, rather than something like
with open("bot/resources/evergreen/trivia_quiz.json", encoding="utf8") as json_data:
QUESTIONS = json.load(json_data)
This removes the need to import pathlib too
Hi, I started to review the code, but found it harder than I should to follow it, mostly due to the lack of comments. Could you add some useful comments around this new cog that explains why you chose to do things in certain ways?
Also, could you update the reason section of your PR description? This section is supposed to be used to explain why you made the implementation decisions you did. This is not a place to describe the whole reason for the cog, or who approved it.
Connected!
Everything checks out! It's a ping command all right :shipit:
So when Phil Karlton said ~
There are only two hard things in Computer Science: cache invalidation and naming things.
~ I think he forgot about timezones.
Branding
The new branding manager [#1463] is storing UTC timestamps incorrectly, and this PR amends that. The bug isn't critical, in fact it doesn't even do anything, as I'll explain shortly, but it is still a bug. Additionally this PR adds a small cosmetic fix for 1 day events.
1. Datetime sucks
The branding manage...
Added the Py-Dis Logo As A Favicon For The 404 Page
475bd21 Use a paginated embed to output multiple snowfl... - ChrisLovering
[python-discord/bot] New branch created: output\-snowflakes\-in\-one\-embed
Previously each snowflake passed to the command would have their own embed, which may cause the bot to send many embeds if a staff unknowingly passed it a bunch of snowflakes. This change makes sure that we don't run into rate limits on the bot by sending all of the snowflakes in one embed.
Connected!
Connected!
Connected!
Connected!
Connected!
Connected!
Connected!
Does this update the help command? I might just be blind, but I don't see where it does. Unless that's a plan for a separate pr.
Connected!
Connected!
Connected!
Connected!
Tested, it works well.
[python-discord/sir-lancebot] branch deleted: vcokltfre/feat/ping
Is there a way of having the bot send something like .timed uwu ?
I'll see what I can do, but I get the feeling the solution may end up being quite ugly, anyway, will see :P
@RohanJnr are you planning on finishing this up?
58e747d chore: show parent command in error message - vcokltfre
Why don't we do this?
if not ctx.subcontext.command:
386e178 chore: use ctx.subcontext in if rather than new... - vcokltfre
[sir-lancebot] Branch vcokltfre/fix/timed\-error\-help was force-pushed to `fbe8e0a`
[python-discord/sir-lancebot] branch deleted: vcokltfre/fix/timed\-error\-help
Connected!
@RohanJnr are you planning on finishing this up?
Yes, I will, sorry for the delay
Changed the exception type used in 56ed6b4
Resolved by 454ad1c and 2ecf31b
This code no longer exists, so this is resolved.
Resolved by 191f19e401861aff709f7e486bff8dd503583bd5
Resolved by c71e0ede5cbc9175d3c14f08f9ea903f8b3b3479
Resolved by 20f3e2b05982ee0afb98c87d353cdf09c2751abd
Resolved by 120349f2ae51325e8a60e02a76140b7c5a622bda
This incorrectly assumes that attributes cannot be mappings, resulting in configured values being incorrectly removed when an entry class is unloaded.
It's also interpreting keys of such mapping attributes as attributes, but that shouldn't cause any problems.
The cache is still something that needs to be looked into in the future. It seems safe to not delete dicts from the cache since _update_mapping is careful to actually update existing dicts rather than overwriting them. It's important that the cache does not end up out of sync with what's in the global config.
That being said, keeping values in cache means more memory is used. Keeping or deleting the cache is a matter of a time vs. space trade-off. Deleting manually wouldn't be straight f...
Except for the request change above, this looks complete to me. However, I'm not entirely confident all bugs have been found, as exemplified by the one above which I caught at the last minute. Furthermore, I'm not sure how the public API that's been set up will play out once we start using it to try to implement the Discord stuff; more access to internals may need to be provided.
Some things to address in the future:
- Test suite
- Set up pre-commit to lint this code (black? ๐ค)
- Doc ...
Is it intentional for _check_undefined_entries to complain about default values not existing if the class is defined before a config file is loaded? I'm not sure how it could distinguish between missing values and config not being loaded yet anyway.
Another possibly strange thing is something like this:
from smartconfig import ConfigEntry, load_stream
content = """
package_a:
module_a:
ref_2: !REF package_a.module_d.integer_8
"""
load_stream(content)
class A(ConfigEntry, path="package_a.module_a"):
ref_2: int = 0
class D(ConfigEntry, path="package_a.module_d"):
integer_8: int = 8888
This fails because A, which references D, is defined before D and D doesn't have any overwritte...
Thank you for this excellent write up and the fix PR! It is just wonderful to read through, I didn't think such a bug could exist. :shipit:
33c0bac Add confusables for dealing with raids - ChrisLovering
[python-discord/bot] New branch created: Add\-confusables\-for\-dealing\-with\-raids
[python-discord/bot] branch deleted: Add\-confusables\-for\-dealing\-with\-raids
347927c Catch NotFound errors when trying to delete the... - ChrisLovering
[python-discord/bot] New branch created: catch\-invocation\-not\-found\-error
This often happens during a raid, when an int e script is added to ban & clean messages. Since the invocation
message will be deleted on the first run, we should except subsequent NotFound errors.
[python-discord/bot] branch deleted: catch\-invocation\-not\-found\-error
Connected!
People deleting their first message is indeed an issue, but it's addressed by shortening the duration before the channel is automatically closed (from 30 minutes to 5 minutes). I don't see how knowing the person's name would be useful. If they deleted the message then they probably don't need help any more and don't want to be bothered. In fact, knowing the name may encourage others to send messages in the channel thus extending the duration before closing from 5 minutes back to 10 or even 30...
Can you provide more context on this? AntiSpam uses an API call to get message history; it doesn't rely on a cache. Are you also proposing to change it to use a cache?
I don't think the readability is poor as a single line.
Resolved by python-discord/metricity#3. We no longer have opt-out functionality.
Resolved by python-discord/metricity#3. We no longer have opt-out functionality.
Does this update the help command? I might just be blind, but I don't see where it does. Unless that's a plan for a separate pr.
When you remove a command, it automatically updates the help command.
56ff78a Refactor embed to use just one line - ChrisLovering
Agreed, this was a copy-paste oversight from when we also set the description here.
Does this update the help command? I might just be blind, but I don't see where it does. Unless that's a plan for a separate pr.
When you remove a command, it automatically updates the help command.
But since there will no longer be any commands, it would make sense to either remove or edit the m!help command to reflect what the bot is, perhaps be an about command instead.
I think it's fairly fine, you'd have to know m!help even existed to try it. If we want then a subsequent PR can implement that.
475bd21 Use a paginated embed to output multiple snowfl... - ChrisLovering
f9fb863 Require at least one snowflake to be provided. - ChrisLovering
56ff78a Refactor embed to use just one line - ChrisLovering
056191d Merge branch 'main' into output-snowflakes-in-o... - ks129
a8daa2c Merge pull request #1524 from python-discord/ou... - ks129
[python-discord/bot] branch deleted: output\-snowflakes\-in\-one\-embed
Connected!
[python-discord/bot] New branch created: mbaruh/offduty
Added a cog to allow moderators to go off and on duty.
The off-duty state is cached via a redis cache, and its expiry is scheduled via the Scheduler.
Additionally changes which roles are pinged on mod alerts to the new role + here.

[python-discord/bot] New comment on issue #1366: The paginator should properly handle too long lines
This is using the default paginator rather than our LinePaginator, which does properly handle lines that are too long. As mentioned, this is a duplicate anyway, so I'm closing it.
set would fit here better.
log = logging.getLogger(__name__)
Let's include how long in reason
Seems like I misremembered. Then yes, we should use the cache, unless there is some reason against.
That's basically a race condition. See https://github.com/python-discord/bot/issues/1018
If you only care about solving the race condition, then there's possibly a better way than to cache deleted messages. However, if you want to also account for messages that users delete themselves, then caching them is likely the only option.
I don't think we should be manually messing with memory, especially the global python GC. Scaleios is working on a mutliprocessing version of this cog, so that we can limit the memory of the spawned process.
This can be removed until that is ready.
I'm not sure this is needed, since the issue isn't with too many people using it quickly, but 1 bad actor giving it really long input. I don't think this cooldown is needed, but I'm not completely against it if someone else disagrees.
I'm not sure this is needed, since the issue isn't with too many people using it quickly, but 1 bad actor giving it really long input. I don't think this cooldown is needed, but I'm not completely against it if someone else disagrees.
I think in addition to a cooldown a limit of how many times the command can be executing at once would also help.
We're already limiting how many times the command can be executing at once with the max_concurrency decorator. That's my point, I don't think the cooldown adds anything on top of that.
Connected!
e6485c3 Adds Resource Limits To The Latex Command - HassanAbouelela
[python-discord/sir-lancebot] New branch created: latex\-limits
Connected!
Is there a specific reason? in terms of functionality it seems to work just fine.
Closes #549
This PR upgrades the Python version we use for the bot to Python 3.9.4. One of the major upgrades this offers for us is that we can now use list[dict[str, str]] rather than importing typing module and then doing those ugly typing.List[Typing.Dict[str, str]] annotations.
Changes to be aware of
- Bumps Python to 3.9 in Pipfile & lock and Docker.
- Bumps all dependencies to the latest version, which support
python3.9and solve the breaking changes only - Ad...
[python-discord/bot] branch deleted: bug/filters/902/antispam\-punish\-once
Connected!
First sentence is unnecessary. If someone wants to know how to create a check then they already have a reason for why they want to do it. In any case, the notion of having to create something because it doesn't already exist is pretty obvious and doesn't need to be explained.
I've elected to keep the sentence, but I've made it more matter of fact. The reasoning behind this is that I don't want it to sound too robotic or boring for those reading since this is a tag generally for beginners...






