#dev-contrib
1 messages Β· Page 151 of 1
yeah ik
I'm just thinking it makes sense to add it there
Since the whole purpose of that function is to check whether we want to run the filters or not
Which is exactly what the code I'm adding does
It's a helper function which takes the common actions that need to be made to check whether a filter should be run on a particular message. The change you're suggesting changes the purpose of the function, a purpose which doesn't fit any of the other places which use it aside from that particular event.
That function is also invoked from _filter_message, so you'd need to add the before there as well
I don't think it's necessary to propagate the before through several functions just for this
Then what about moving _check_filter?
Still doesn't resolve this ^
I don't see how I'm changing the purpose of the function. The purpose is currently, as you said, "to check whether a filter should be run on a particular message". The code I'm adding is a part of that
The code you're addresses two states of a messages, instead of taking one message and checking it
This seems like a whole load of refactoring just for this
I don't think this alone should be a factor though. If you're refactoring to improve the code, then that's a good thing
You're making the function deal with something that most other places don't need. I don't think that improves the code
It's still a part of the underlying "do I want to run filters?"
What do you mean by "most other places"?
Any other place which needs to run this check
The only other call is in filter_eval
And on_message
Which runs check_filter
The only place that runs _check_filter is _filter_message (where _filter_message is called from on_message_edit and on_message) and filter_eval (where filter_eval is called after !e)
And on_message
Look, I'm not really hellbent on stopping you, but this seems a little excessive to me. That function is not even going to exist in the new system
I mean given that it's used elsewhere and would break those cases I guess it shouldn't be done
On its own I think it's fine though
On its own yes
But that function is used in multiple places which don't fit this use case
Yeah
I'll leave it as-is
So I put the code I'm adding before the _filter_message call in on_message_edit?
That's what I'd do
Could also do it right at the start
Since if you're exiting early you don't need the delta
Yeah, true
Is the .wiki issue yet merged?
So```py
@Cog.listener()
async def on_message_edit(self, before: Message, after: Message) -> None:
"""
Invoke message filter for message edits.
If there have been multiple edits, calculate the time delta from the previous edit.
"""
# We only care about changes to the message contents/attachments
if before.content == after.content and before.attachments == after.attachments:
return
if not before.edited_at:
delta = relativedelta(after.edited_at, before.created_at).microseconds
else:
delta = relativedelta(after.edited_at, before.edited_at).microseconds
await self._filter_message(after, delta)```?
Should I update the docstring or is the comment enough?
Something like that yeah.. would need testing ofc
Either is fine I think
You could add a comment saying you want to do this because you don't want to re-run on pin and embed removal
That's a good idea yeah
# We only care about changes to the message contents/attachments, not pin status or embeds etc.```something like that?
seems good enough
π
Somehow I get all notifications from github either 2-18 hours late
@cold island how do I go about testing when the test server doesn't have mod-logs?
If you mean sir-lancebot#936 then no; Chris requested some changes
alerts goes to #admin-mods and mod-log to #all-logs, I just got told
I just saw it, but just a 5 minutes ago I got the notification
It's because I've not blacklisted stuff I think
oh yeah, the default config has a few chat blacklisted
I remember it took him like 15mins to figure it out, heh
I've blacklisted bit.ly but it's not triggering a log
The only thing that does is sending a discord invite but I can't use that for testing since it deletes the message
And the whole point is that I need to be able to edit to see if it re-sends the log
Ah, figured out a way
And of course the code doesn't work lol
It is working, it's someone else's bot sending the log π€¦
Is it mine? I bet it's mine
what is the branch name for sir-lancebot#933 I don't seem to find it for some reason
yep, sorry
You can unload the ext, the prefix is ~ @static canyon
ehh wrong one, I mean the pr #936 π sorry
wikipedia/933/lock-paginator-to-author
You can see it just under the PR title
Nipa-Code wants to merge 1 commit into python-discord:main from Nipa-Code:wikipedia/933/lock-paginator-to-author
oh...
Thanks π
what was the command to set branch x to upstream or what ever it's called to push changes there
git push -u origin $branchname
so for example git push -u origin wikipedia/933/lock-paginator-to-author
if you ran it with -u once you can go ahead and just type git push
thx
.bm Make changes to specific branch
and if I do git add before that command, where will the changes be pushed? Still to the one specified?
you need to code, add, commit (potentially repeat from the start), then push
I see
uhm
it seems to have made pushes to wrong branch
it didn't update the pr, instead it made this
is it now pushed to bot or something?
yes, it should be live now
now I have some how successfully made 2 prs to the bot
Congrats!
Congrats!
@cold island have created bot#1937; would appreciate review when you're free π
bot#1926 also needs a re-review (have addressed your prior review)
Would appreciate reviews on https://github.com/python-discord/sir-lancebot/pull/930 π
So.. something interesting about this line https://github.com/python-discord/bot/blob/main/bot/exts/backend/error_handler.py#L245
bot/exts/backend/error_handler.py line 245
elif isinstance(e, errors.ArgumentParsingError):```
We don't raise it anywhere
So I just tried to do that
And it didn't reach the error handler
Oh wait
Nothing like rubber duck debugging
Hey! Is there a consensus on whether we should use a test DB or a mocked DB for API tests? I'm a bit lost as to which I should implement and the project in the future. π
Both have their advantages and disadvantages
A proper db will always give more accurate results, at the expense of a more complicated setup
This is the part that I'm still not convinced about. Why would the DB return more accurate results
Maybe, the relationships and similar database features. (Though, the should be working as expected. )
(I'm literally working against myself π)
Again, that's not something that we should be testing with our unit tests for routes...
If we want to, we can set up a separate integration test suite
But, anyways, I'm not sure what you even mean fully tbh
If there's a problem with the modeling, won't that be reflected in the pydantic models when you go to use them
I don't think so, no.
If something's wrong with the relationships (although, in theory, and practice it should be fine) and you perform like a DELETE operation and something goes wrong, pydantic will be of no use.
However, I accept your view, I was just curious if you have decided which method to implement in the end.
Don't take my view as fact, let's wait for volcy
Sure, I'm gonna implement the method you decide on. π
Also, the rest of the PR should be fine. (regarding the endpoints overall)
It is minor so I don't think there's any point in PRing it, but @cold island should existing filtering bugs/oversights be discussed in new issues (bot#1938) or in the filter rework pr?
If these kinds of bugs can be fixed now, then they should be
Anything that isn't a major design change is fine
Alright, thanks
Ok, it's ready for review.
I think the result looks cool, but I didn't enjoy writing this lol
https://github.com/python-discord/bot/pull/1939
I refactored everything at least three times
I'm not sure how relevant it is to make unfurling happen on the CF edge (CC @gritty wind), I don't see the added value other than not exposing our IP to bit.ly and stuff
It just makes it easier to have it be a blackbox we throw URLs into it with minimal concern for safety and resources
Partly why I was asking about execution limits on workers
Why put a depth limit when we can just have CF hammer it
But either would work
I guess we do have CF unlimited, so it isn't that bad
Hey! Can I get a few reviews on site#572? It should be fine as isβ’οΈ π
on it
oh i already did
if we really wanted to go-nuts we could probably do that delete in a single statement
but hell do i know how that would look in django orm lol
besides, this is more understandable for most people
Yeah, it's pretty straightforward that way. π
(btw. thank you for reviving the PR, I totally forgot about it π )
hahaha no problem
Here's your reminder: life got busy
[Jump back to when you created the reminder](#dev-contrib message)
!remind 14h life got busier
Your reminder will arrive on <t:1636199653:F>!
Lol
@austere hornet You really shouldn't be committing code with linting errors
Have you set up precommit?
That would stop this from happening
precommit honestly helps make the commits much nicer
It seems 7/32 of your commits are linting, and 9/32 are just merging main (so arguably half of the commits weren't needed / could be avoided). You only need to merge main at the end of the project, rather than as-you-go because otherwise it just clutters the commit history which is a bad thing to do when it can be avoided
@clever wraith for bot#1937, would a check for len(before.embeds) < len(after.embeds) # embed(s) added suffice? I don't want to be rerunning when an embed is removed since there's no way it will make the message now trigger (it would've already done so)
mm, while I don't think we would hit a case where a self-bot starts off with an auto-generated embed and changes it into an actual embed - checking if the after state is a subset of the before case would cover all cases (assuming embeds are hashable)
checking if the after state is a subset of the before case would cover all cases
So do you meanpy all(( embed in before.embeds for embed in after.embeds ))?
That seems wrong actually
The before and after would need to be the other way round
"If everything in before is in after"
what you've written seems fine
That won't work for the case I gave though
Because if after has more items than before then it's impossible for everything in after to be in before
So they'd have to be swapped, no?
i was referring to this
if not all((embed in before.embeds for embed in after.embeds)):
run_filter
what does all do for an empty iterable?
What do you mean?
!e print(all(()))
@clever wraith :white_check_mark: Your eval job has completed with return code 0.
True
!e py print( all(( number in [1,2,3] for number in [] )) )
@static canyon :white_check_mark: Your eval job has completed with return code 0.
True
Yeah, that's an issue I guess
well if we have no embeds in the after state then the embed was removed
len(embeds) will at most be 1
To be honest I don't see how this is different to just checking len(embeds)
I don't know what you mean by that
right
Seems a bit of a niche but fair enough
its quite niche, yeah, like I said I don't expect us to encounter this
I mean, they can just not send a rich embed
And use whatever type the link previews are
# We only care about changes to the message contents/attachments and embed additions, not pin status etc.
if all((
before.content == after.content, # content hasn't changed
before.attachments == after.attachments, # attachments haven't changed
all(embed in before.embeds for embed in after.embeds) # new embeds haven't been added
)):
return
```So like this? @clever wraith
It sounds pointless
The only filter we run right now is rich embed
If we did filter embed texts maybe it would be worth doing
This would catch rich embeds?
I mean, I really doubt a rich embed will appear after an edit
And even if it does we would get a ping for a user seeing it
And if no one saw it?
Based on that logic you could just completely remove the filter system and rely on other users reporting if/when they see
I think we have to take into account the probability of that happening
And here it is so slim that I don't think we should care
I'm making changes to the file anyway, I might as well account for all cases whilst I'm adjusting things π€·
Embed equality is also pretty jank
I agree it seems unlikely, which is why I originally didn't bother, but if I'm improving the logic anyway it should include all improvements, however minor
it's less of an improvement and more of a "retaining a feature we already have", since in its current state we'd get a ping for that case. its just one additional line, so i think its fine to add
anyway, i dont have a strong opinion but @static canyon that looks good to me
If you can make sure it works, I am fine with it
But it will probably be a little bit of a pain to test
time to selfbot 
time to setup a selfbot
I can't be bothered to test so I guess I'll just leave it as-is
Should I do my len(embeds) approach so that it still semi-accounts for embeds @clever wraith
Honestly, why do we even re-run messages that already pinged in the last, say, 30 secs
thats kinda niche too, but its simple and somethings better than nothing - i'd leave that in yep
The len thing will retrigger if the embeds are removed
if all((
before.content == after.content, # content hasn't changed
before.attachments == after.attachments, # attachments haven't changed
len(before.embeds) < len(after.embeds) # new embeds haven't been added
)):
``` this'd work, no?
That won't trigger for embeds being removed
You comparison is wrong way round
Wait
Yeah
You're saying a new embed has been added
Since there's more embeds after than before
if not before.edited_at:
delta = relativedelta(after.edited_at, before.created_at).microseconds
else:
delta = relativedelta(after.edited_at, before.edited_at).microseconds
await self._filter_message(after, delta)
```we do get the `delta` of how long ago the message was sent, so should I add something to not run if it's < x seconds?
Ah wait no that wouldn't go there
Since you don't know if it pinged or not
So I guess the reason we don't is we don't track the messages that pinged and therefore can't
Do we not?
Well, I guess we could be tracking that in a short deque
Like a tuple message ID, timestamp
Doesn't look like it
# If the message is classed as offensive, we store it in the site db and
# it will be deleted it after one week.
if _filter["schedule_deletion"] and not is_private:
delete_date = (msg.created_at + OFFENSIVE_MSG_DELETE_TIME).isoformat()
data = {
'id': msg.id,
'channel_id': msg.channel.id,
'delete_date': delete_date
}
try:
await self.bot.api_client.post('bot/offensive-messages', json=data)```
That's the closest thing
Andpy self.bot.stats.incr(f"filters.{name}")
I'd rather the filters ran again but without a mod ping
To be honest I think the only case this currently happens is the pinning/unpinning anyway
Eh, editing I guess
yeah, that
So I've now got```py
@Cog.listener()
async def on_message_edit(self, before: Message, after: Message) -> None:
"""
Invoke message filter for message edits.
Also calculates the time delta from the previous edit or when message was sent if there's no prior edits.
"""
# We only care about changes to the message contents/attachments and embed additions, not pin status etc.
if all((
before.content == after.content, # content hasn't changed
before.attachments == after.attachments, # attachments haven't changed
len(before.embeds) >= len(after.embeds) # embeds haven't been added
)):
return
if not before.edited_at:
delta = relativedelta(after.edited_at, before.created_at).microseconds
else:
delta = relativedelta(after.edited_at, before.edited_at).microseconds
await self._filter_message(after, delta)```
Does that look good? @clever wraith @green oriole
What do you do with delta?
It's used in _filter_message in the embed detection
If it's < 0.1 secs or something then it ignores since it's a double-fire
if filter_name == "watch_rich_embeds":
# If the edit delta is less than 0.001 seconds, then we're probably dealing
# with a double filter trigger.
if delta is not None and delta < 100:
continue```
That's the only place I think
CC @green oriole
Hmm alright
So should I commit this?
lgtm
boolean logic sucks tho, took me a while to get why it wasn't len(before.embeds) < len(after.embeds)
Pushed to bot#1937 π
Lul the most recent commits that failed are my fault
We'll just squash it down at the end though
Ideally we shouldn't have to squash though
It's not a big deal, just makes lives a bit easier
Although I suppose in this PR we'll have to squash anyway
Also, I expect better from a verified PyDis Contributorβ’οΈ smh
lol
Here's your reminder: life got busier
[Jump back to when you created the reminder](#dev-contrib message)
Re: .challenge @dim pelican #dev-log message
We might wanna .lower() the language in case users use upper cases:
#sir-lancebot-playground message
@trail pilot
On it
It wasn't really my fault, Bluenix commited something with linting errors. I'll try to fix them later today. I do have pre-commit set up.
I understand, yeah
Oh he already said that lol
Need to read better smh
Fixed!
@brisk brook zig left a few comments on your review on the Enhanced incidents PR, could you look and comment on them?
Sure hold on
Cool thanks
Is this fine for thread channels? @brisk brook
Maybe check how the styling looks for the embeds that get sent when someone opens a thread?
this, (modlog has no support for thread message edits/delets/etc yet)
Also there is no handling for no message content now, so should i just show this i.e. [No Message Content]
Just don't add the field
Oh, maybe instead of a / you can have a - or some other form of separation?
Bot Commands/#bot-commands - 'test'?
Yeah that works π
That seems nice to me
Better be explicit
;-; choose one lol - even I like [No Message COntent] personally
I like the [No Message Content] just reading it
@brisk brook pushed π
Hey! Could someone take a look at api#25 or site#572 ? I'd appreciate it. 
~~I wrote "site #572" first then edited :/ ~~
Yeah was gonna ask the same thing
@gritty wind can I submit it a pr to channel unlock the github command?
I have no idea what the permissions are meant to be
Basically keep it locked in #python-discussion
No, that was the issue and pr commands of it which were removed
I think there's a PR that removes it
The whole command was not removed
But two parts of it were
.issue
That is the command that is being removed IIRC
.help issue
There's a PR which removes .issue, but not .github (afaik)
Ah yeah
Sir-lancebot#778
Yeah, that's it
Lmao @timid sentinel you're one of the reviews that still needs to pass on that pr
Say
Meta#93
Nice it just fails on discussions
Well, not needs to, just requested
O, I thought you gave a requested changes review 
@rapid igloo Committed changes for sir-lancebot#909
https://nvd.nist.gov/vuln/detail/CVE-2021-41250 really π
~~Anybody else have every bot test fail due to permission errors when running the poetry task in WSL? ~~
EDIT: Solved it, for some reason the bot log was owned by root instead of my user and the tests couldn't write to it.
hey, looks like the lint task failed: bot/exts/utilities/challenges.py:267:1: D202 No blank lines allowed after function docstring. Just need to remove the blank line and should be good to go
(perhaps you should squash it with the last commit if you can, since it's a little unclean to add something in a commit only to remove it in the next π)
Agh, this is why I shouldn't edit code on my phone
Committed
Since site#618 is merged, can I open a corresponding PR on the API repo, so that we won't forget adding it?
@brisk brook git mv doesn't do anything different from renaming and moving files.
Hey @static canyon, https://github.com/python-discord/sir-lancebot/pull/732 no longer seems to be active, are (or the other user) planning on doing anything?
Huh?
Hold on let me do a test
So do you know how git blame attempts to follow renames and files moving?
Git does seem to actually track it. Here's my git status right now
On branch main
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
renamed: README.md -> README.rst
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: README.rst
PS C:\Users\%username%\Projects\git-mv-test> git blame README.rst
408e35e0 README.rst (Bluenix 2021-11-07 19:51:36 +0100 1) Git mv test
408e35e0 README.rst (Bluenix 2021-11-07 19:51:36 +0100 2) ===========
^0fc5ba2 README.md (Bluenix 2021-11-07 19:49:34 +0100 3)
^0fc5ba2 README.md (Bluenix 2021-11-07 19:49:34 +0100 4) This is a simple repository testing how Git's `git mv` command works.
^0fc5ba2 README.md (Bluenix 2021-11-07 19:49:34 +0100 5)
^0fc5ba2 README.md (Bluenix 2021-11-07 19:49:34 +0100 6) The questions is whether it helps `git blame`, which this repository attempts
^0fc5ba2 README.md (Bluenix 2021-11-07 19:49:34 +0100 7) to demonstrate.
See?
If you don't use git mv, git blame will just try to guess whenever it is a move or not
If you do use git mv then it knows for sure you moved it
Yeah now in my test it seems to have "guessed" like that
If you look at the blame on Tizzy's PR though, it has not guessed correctly: https://github.com/python-discord/sir-lancebot/blame/872185c7ad1597c54c748feaf8cd2d1772100c69/bot/exts/events/hacktoberfest/_cog.py
But yeah they're all separate cogs that have been merged, so it might be a little harder than what I have done in my test
The best way to have the history follow is to just rename in a single commit, then move stuff around
Suppose you have two files that you want to combine into one. Letβs set up a scratch repo to demonstrate. Iβve omitted the command prompts so you can copy-paste this into your shell of choice and play along at home. (The timestamps and commit hashes will naturally be different.) git init >fruits echo apple git add fruits git commit --author="Al...
Yeah this blog post explains how to rename two files into one
If we can't really get this to work I'd say we close the PR. I don't think it truly is worth it
From what I've read in the wikis and stuff, it boils down to:
Git has a rename command git mv, but that is just for convenience. The effect is indistinguishable from removing the file and adding another with different name and the same content.
It helps a bit because of how it does its staging, but ultimately trying to preserve git blame when doing a reorg is always a bit of a toss up.
git tries its best to track files by comparing the content in a file and seeing how similar it is. If you remove a file and add a file in the same commit it tends to do better, but it doesn't do anything special.
I don't think closing the PR because we can't perfectly preserve the git blame is a good move. At the end of the day that cog is a bit of a mess and I do want .timeleft to not be a top level command.
There's nothing else I can do. It's all down to the other user for the final bits that remain
the other user doesn't seem to be active, hasn't responded to ping for a while
pretty sure I pinged them here as well
π€·
hmm
Yeah, editing code on phone is not a great idea π
Hey! Could someone take a look at api#27? It's literally a one-liner and a migration. (That is autogenerated, and still pretty straightforward)
@gritty wind can i make a pr to add pip as an alias to pypi?
Sure
thanks
bot#1942 thanks
.ping
Gateway Latency: 115ms
those ids are this message and the one above it
If you stage the removal of the old file and addition of the new file with the same content, it will be the same as renaming with "git mv". If you want to up your chances of git understanding it was a rename, make a separate commit the does the rename without changing the contents of the file.
^
you can see the effect with making a commit of just a rename, and then amending the commit with many edits to that file, git will no longer think it was a rename
Yup yup. I was telling Bluenix that git mv doesn't do anything special apart from that. If you're drastically changing file names and content there isn't a nice way to preserve the git blame
imo a nice way is two seperate commits, do the rename and then make the edits
That isn't always possible unless you're doing a clean rename and move. Sometimes a file is going to get split up into multiple or moved and fundamentally changed. Especially if you're contending with multiple files that need to be somewhat combined and shifted.
Yeah it can get hairy. I might sometimes rename to the name of one of the new files and then move the code out of it
And didn't fully follow the conversation, sorry
@vale ibex there's a mistake in one of the commands in patsy, I have a commit ready to make a pr with
poetry run precommit -> poetry run task precommit
merged, neat
Ah didn't see this, feel free to open a PR
huh I don't see that in main
ah well, I didn't expect anyone else to be working on this
let alone merging PRs lol
I'm gonna change that setting actually
alertmanager is great i would use alertmanager as my health monitor dude i'm telling you all alertmanager is geat
did you force pushed to main chris lmfao
I was fixing a crashbackoff lol
smh smh mh smh
git pull/ git rebase
lmfao
what even is this pasta thing for again
No description, website, or topics provided.
lol
lol nice
!otn a message pasta
it's in the readme
it's the help channel message thingy
right
why is it about pastas though
I mean as PyDis' official Italian I approve, but why
it makes me hungry
have you read the readme?
anyways, IIRC Co-authored-by: onerandomusername <genericusername414@gmail.com> @vale ibex, or i think you can pull down commit ce78440cf1c028b184339cf817a4f11d9feb4f30
ooh, that's the name of the coconut guy
chris should i make a new pr?
Sure!
oh
before i do, do you want to add patsy to #dev-log ?
since we aren't getting anything except checks in #dev-log
imagine having admin perms on patsy
lmk when you have it, and i'll submit the pr π
done
i know, i just want it to be in #dev-log π
lol it didn't go to dev-log
lol
wdym?
none of the pr events have gone to #dev-log
the only thing that has gone is the workflow that sends to that channel
yea but i opened the page again to add the events and someone did lol
replica of GH-3 since Chris force pushed to main and lost the merge commit.
perfect description
yea was just doing it with the branch protection
ah
didn't have anything setup since I wasn't expecting others to contribute yet...
probs chris
lol
yeah it's not a simple rename -- not even a "merge multiple files into one" because tizzy did modify some of the logic a bit. we could possibly not have it all in a single _cogs.py and make it look like a rename (and still have them under one hacktober command), but after doing that if we ever merge them into a single file again the history would still have to be lost.
See the post I sent, I might try that out and open a PR that supersedes Tizzy's
oh! it's just above, I didn't see
. gl, it'd be amazing if we could preserve histories from the merge files but the blame and changes for the preserved commits might look a bit weird for someone in the future if they didn't know about this, as they change different parts of a merged file.
(cc @static canyon)
Git mv is notoriously a pain in the ass. The git blame would be ideal to have, but it's not necessary, and definitely not a blocker. We probably don't care that much about digging into the history of that cog.
It's a nice PR, I like nice PRs and would hate to see it die over something like this.
@gritty wind which pr is this referencing?
@patent pivot site#364 <- Is this still relevant?
sir-lancebot#919
Tbh I'd never even heard about git mv / git blame before yesterday so I'd have no clue where to start in trying to keep the commit history.
I wouldn't worry about it
git blame is very useful, though.
I don't usually use it from the CLI, but there are IDE integrations that are super nice.
Yeah, github integration too
Pycharm has it by default and with VSCode I've been using GitLens.
But it isn't a blocker for this PR to lose a bit of history
Yeah, no big deal if it's just one file.
But I'd hesitate to wipe history for large numbers of files.
git blame is nice, but I think it's fine to lose blame for a single fine due to refactoring.
but I agree with dementati that it sucks to do stuff like.. run black over the entire codebase and ruin blame for like 80% of the files.
still, this isn't that.
There is a special metadata you can add to such commits to have them ignored by the blame
maybe. I've never seen anyone actually open a blackify a shitton of code PR that did that, though.
added that metadata, I mean
I feel like the best approach for improving styling is to just apply a "leave the campsite in a better condition than you found it" principle as part of working on other issues.
Yep, that's probably the wisest choice
Oh yeah, that's what it was called.
and The Pragmatic Programmer uses the term Kaizen to refer to little unrelated cleanups and improvements you make as you work on different parts of the codebase
which is a nice term
π
I had a talk about kaizen at a show and tell at Dignio a few years ago, and now most of the engineers make these clearly labeled "kaizen commits" or "kaizen PRs" every now and then, it's nice.
One of the main problem with the boy scout principle is automated linting
how do you mean
You can't add a flake8-plugin or something similar to test for your new styling rule until the whole database uses this style
sure you can, just lint only new code
hmm, but full codebase lints will fail, I guess you need a proper CI setup that will only lint the diff between your branch and main then
yes
which sounds reasonable
it's pretty common
it's really the only non-disruptive way to introduce new linting tools into your toolchain in a large codebase
that old code has been running in production for years, your customers are happy, there's probably no real benefit to making huge, sweeping changes to it in some sort of mega-PR that adds new linting and cleans stuff up
engineers love to do that because it's satisfying to clean up clutter
but it's often risky
and the point of linting toolchains is to reduce risk
so usually you'll introduce CI that only looks at the diff, both for test coverage and code style.
the only thing I'd run the entire codebase through would be SAST
Isn't this valid for the API migration also? 
Probably not, what history are you trying to keep
what is SAST?
white box testing, like bandit in Python.
finding security vulnerabilities
like.. passwords in plaintext in the code, or compromised dependencies
short for static application security testing
All the past changes?
Most of the past changes from what I could tell are already formatted with black, so they do not apply to this
And if you're already at a stage where you can comfortably add it all in one go, then there is no reason to do it piecemeal as described
aah, bandit does some weird stuff sometimes
like STATIC_ROOT = "/tmp/static" was considered as an hardcoded password
yeah that's a bit weird. but no static analysis tool is perfect
better to get one more alert than you need than one too few
I was referring to the actual api, I don't see how site is related to that
Presumably we'd remove the api from site once the migration is done
Also, site doesn't follow black
Yep! A noqa never killed anyone
plus we got to write a little "wtf?" in the codebase which is an accomplishement
Ah, yeah according to discussions we will be removing the API from the site once the migration is complete but after removing it from the site we will lose all the git history associated with it.
I think it is fine, the whole codebase is getting rewritten anyway, right?
Yeah since it is being ported to FastAPI
Yeah it is, but things like why is the permissions model a BigIntegerField and not a simple integer field aren't answered, if we look at the git blame, it would be easier.
Note, I am not against having it or not having it, just saying it as the topic came up above
Cc @green oriole
Tldr the metadata isn't supported by github, but still exists on the commits. So if you look at it locally it would have the metadata
doesn't it render in GitHub?
@gritty wind interesting way to supply urls
why don't you use a POST instead?
A get made more sense as the method:
The POST method submits an entity to the specified resource, often causing a change in state or side effects on the server.
The GET method requests a representation of the specified resource. Requests using GET should only retrieve data.
At the end of the day, it really shouldn't matter much
don't you call issuing a request by the origin to a web server a side effect?
Well, either way I think url encoded urls is a much more reliable way to pass urls, heh
I really didn't give it as much thought as you did, because for the most part it doesn't matter
If you'd like to modify it to something else, feel free
hmm I can't really suggest changes since I use Ak's GH account
function parseURL(url: string): string {
const params = new URL(url).searchParams
return params.get("url") || throw Error('InputError')
}```
I believe it should be as simple as that
https://paste.pythondiscord.com/komocinire.ts?noredirect @gritty wind (untested)
That's so weird
Is throw an expression?!
Pretty sure that's a thing you can do, yeah
Okay maybe not
it isn't in the TS paste anyway
Isn't this why we have comments
Comments work, but they have downsides, like they tend not to get updated when the code they comment gets updated. That's less likely to be an issue with git blame.
But for something like a field being a bigint rather than an int, they work pretty well
And given the general standards of review here I'm fairly sure the comment would get updated with the code, even if it was during pr review
The trick is to keep the comment as close to the code as possible
Yes comments do work for most of the cases, but git blame is still important - why is this here? / when was this introduced? / who should I contact if I have a question regarding this code? / etc
Itβs generally a bad idea for single individuals to be responsible for remembering specifics like that
Because people forget, and people leave
Comments are forever π€‘
nope
GitHub doesn't look at .git-blame-ignore-revs
In Git 2.23+, you can specify a list of commits to skip during git blame: https://git-scm.com/docs/git-blame#Documentation/git-blame.txtβignore-revs-fileltfilegt This is very useful for hiding non-essential commits such as bulk code formatting. A lot of projects are already using this format, e.g.: https://github.com/nodejs/node/blob/master/...
how sad
I really like this idea. So the commit title/message would just look like: kaizen: do the thing?
That's how I've seen it be done
You can often infer useful information from commit messages and when a given commit was made, though. And even if you can't always rely on the original author being around, if they are, it tends to make figuring something out much much faster. I'm not saying comments aren't also useful, but git blame has just been so freaking useful in my career that I don't want people to discount it.
I use it frequently too, it's how we got the history for our CVE, but in this case I don't think it really matters, and in no case do I think it's worth blocking a project over
Javascript; the language where try/catch apparently doesn't try and catch shit
try {
body = await request.json<any>();
} catch (error) {
return new Response(
`Could not parse body, error: ${error.message}`,
{"status": 200}
);
}
No idea what's up with this lol
Despite catching the error, and returning the response, it still outputs an error in console
Who love JS'
lol never seen <any> in JS in that context.
TS requires type annotations if you're explicitly converting to any
Oh, so TS. π
request.json<any>().then((body) => {
console.log(body);
}).catch((error) => {
console.error(error);
});
``` does this work?
ah yea,
wait what about this https://stackoverflow.com/a/49311904
helper util
Oh right
Still not working, seems to be logging to console directly
I wonder if the json method does that
Regardless, the SO presents it as an alternative to try/catch, for performance reasons, not because one method doesn't work
Like my try/catch is working to return the correct response, but its still outputting an exception in console
Tbh I should probably just use the builtin JSON parser, it's what's done under the hood anyways
Yeah that's fixed it
Hey! Sorry, for keep asking to review some of my PRs but api#25, could use some reviews. (Apart from the tests, of course, it's still dubious)
Anyone know what's happening here? async sqlalchemy ```
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/dialects/postgresql/asyncpg.py", line 359, in _handle_exception
patsy-patsy-1 | self._adapt_connection._handle_exception(error)
patsy-patsy-1 | File "/usr/local/lib/python3.9/site-packages/sqlalchemy/dialects/postgresql/asyncpg.py", line 652, in _handle_exception
patsy-patsy-1 | raise translated_error from error
patsy-patsy-1 | sqlalchemy.exc.DBAPIError: (sqlalchemy.dialects.postgresql.asyncpg.Error) <class 'asyncpg.exceptions.DataError'>: invalid input for query argument $1: 126811506632294400 (value out of int32 range)
patsy-patsy-1 | [SQL: INSERT INTO users (user_id, opted_out) VALUES (%s, %s)]
patsy-patsy-1 | [parameters: (126811506632294400, False)]
patsy-patsy-1 | (Background on this error at: https://sqlalche.me/e/14/dbapi)
and yes, I'm using BitInteger
I've even checked in the psql DB, it's a BIGINT
I'd expect this error if using a normal integer type, but not sure where this is coming from
Could it be trying to do that validation outside of the DB for some reason?
Also why store ints when strings do the job π€‘
lol yea, thought I was being smart, since dealing with ints is easier
But I mean, the error is accurate. It's way outside int32 limit
2,147,483,648 <<<< 126,811,506,632,294,400
That's why i'm wondering if it's using int 32 internally
Need some of that spicy source code plz
Not your source
asyncpg source
For some reason the sqlalchemy site isn't loading for me π
sqlalchemy >=1.4.17,<1.5.0 asyncpg 0.24.0
Which model is this, if I may ask?
(I'm browsing the repo right now)
Seems version x.x.24 has that
from typing import Optional
from sqlmodel import BigInteger, Field, SQLModel
class UserBase(SQLModel):
"""A base model for storing information about users."""
user_id: int
opted_out: Optional[bool]
class UsersTable(UserBase, table=True):
"""A table for storing information about users."""
__tablename__ = "users"
user_id: int = Field(sa_column=BigInteger, primary_key=True)
opted_out: bool = Field(default=False, nullable=False)
It's not API
it's for patsy
I know. π
alr cool, it's all still local atm
This is raised by an execute?
@router.post("/users/", response_model=UserRead)
async def create_user(*, session: AsyncSession = Depends(get_session), user: UserUpsert):
"""Creates a new user."""
db_user = UsersTable.from_orm(user)
session.add(db_user)
await session.commit()
await session.refresh(db_user)
return db_user
both UserUpsert and UserRead are direct children of UserBase
Could you try to sort of "bundle" BigInteger into a Column(from sqlmodel)?
Like: [...] = Field(sa_column=Column("user_id", BigInteger, primary_key=True)
I might not be right, but it's possible that it can't recognize it and just simply goes with int, or something? π
No worries π
Wait did IDs get another digit?
yeah nvm I was just interacting with those extremely old Discord users holy shit
127499098990444545 <- like wut
Yeah haha
LP's is the lowest I've seen so far
I am so used to interacting with super new accounts lol
But mine is pretty low, yeah
Oh btw. @vale ibex the rest of the models might need to be patched as well. I'm not sure if the project is open for contributions, but I can take care of it if you haven't already.
Yea I've patched them all now π
Just going through and adding crud endpoints
i quite like async sqlalchemy
@router.get("/users/", response_model=list[UserRead])
async def get_users(
*,
session: AsyncSession = Depends(get_session),
offset: int = 0,
limit: int = Query(default=100, lte=100),
):
"""Get a list of all users."""
result = await session.execute(select(UsersTable).offset(offset).limit(limit))
users = result.scalars().all()
return users
very nice code
I am trying to test the tags PR by numerlor but the bot seems to be in a crash loop because of this: ```python
python-discord-bot-bot-1 | The above exception was the direct cause of the following exception:
python-discord-bot-bot-1 |
python-discord-bot-bot-1 | Traceback (most recent call last):
python-discord-bot-bot-1 | File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
python-discord-bot-bot-1 | return _run_code(code, main_globals, None,
python-discord-bot-bot-1 | File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
python-discord-bot-bot-1 | exec(code, run_globals)
python-discord-bot-bot-1 | File "/bot/bot/main.py", line 14, in <module>
python-discord-bot-bot-1 | bot.instance.load_extensions()
python-discord-bot-bot-1 | File "/bot/bot/bot.py", line 143, in load_extensions
python-discord-bot-bot-1 | self.load_extension(extension)
python-discord-bot-bot-1 | File "/usr/local/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 732, in load_extension
python-discord-bot-bot-1 | self._load_from_module_spec(spec, name)
python-discord-bot-bot-1 | File "/usr/local/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 663, in _load_from_module_spec
python-discord-bot-bot-1 | raise errors.ExtensionFailed(key, e) from e
python-discord-bot-bot-1 | discord.ext.commands.errors.ExtensionFailed: Extension 'bot.exts.info.information' raised an error: TypeError: init() takes 3 positional arguments but 4 were given
can you link the pr?
Noticed the slash command suggestion in #community-meta, can I point you guys towards enhanced-discord.py, a fork that implements slash commands ontop of ext.commands
Could be used as a temp solution
Thanks, we're currently waiting for a bit until we decide to migrate/introduce a new lib to our bots
we're not in a rush for slash commands, so want to make sure that the one we do pick will have good maintainers
Maybe I should run docker-compose build to make sure the internal state is doing okay
inb4 said maintainers: python discord\β’οΈ
yea might be a good idea
maybe a docker-compose pull first
since this PR doesn't seem to edit the information cog
also check if you have untracked files
relatable
The only untracked files is the different tags I've been creating (why I've been procrastinating testing this PR π¬)
I maintain it
oh I think I know, did you mean to help @clever wraith do her homeworks, @vale ibex ?
Do we have a strong use case yet for slash commands?
The only thing I can maybe think of is the new roles subscribing thing, but even that is slightly better suited to components
the only very nice use case I can see currently is the blacklist and whitelist commands
so you don't have to remember list names
They're ingrained into our minds by now anyway
Or at least for me
but...but...my beautiful PR
hey! I said components was a better option anyhow
how is that PR coming along?
I tried asking Ak what is the name of the list for domains is, he doesn't remember, neither I can find that info lmao
waiting for review lol
domain_name maybe?
haven't had any comments yet
#?
domain_name yeah
ay
filter_token, guild_invite, domain_name are the main three
bot#1868
Is it normal for channel to close in 12 minute in activity?
Which channel are you referring to?
filter_token is so weird, for me it would sound like Discord tokens or whatever
It's a regex token
If the claiment wasn't typing, then it'll close sooner
heh
We need to figure out what to do
Pixels ain't happening til Q3
I'll see if I can review today!
Q3?
Quarter 3
I operate on quarters
Oh- okay that's good. Then we have nice time
Oh ok
Aka Jul-Septish I think
ahhhhhhhhh
now alembic isn't detecting the BigInteger change for migrations
how annoying
I mean Pixels is open source look at our k8s cluster
Lol was that why you came here in the first place maybe
I came here to copy my ID lol
was testing
and it worked fine
until I tried create a new db from migrations
and I don't want to hand craft a migration, since it'll just try to revert it next time I generate one
How long should it take for help channel to close?
30mins by default iirc
45?
Depends on the scenario. 30 minutes after the OP has said anything and 10 minutes after non-OP has said something, when both of those conditions are met
If a person opens a help channel and the message is deleted, it'll close in 5-ish
Oh
it closes after 10 minutes of inactivity if the claimant hasn't typed in 30
Where'd I get 45 minutes from? Did it change somewhat recently?
nah, it's been consistent for awhile now
Damn
The new thing is that we reduced it from 30 minutes since anyone has typed, to 10 minutes if not OP has typed.
Probably bias then
Ah yeah
I'm just waiting for ping-pocalypse to hit us again
Thats somehow good
? hm
The duration change
Are you saying it's a good thing or asking how it's a good thing?
Saying that it's a good thing
π All pushed
Just a quick question since you used Async SQLAlchemy, do we also want to use it on the API? (It's still in beta, that's why I refrained from using it)
That's @hardy gorge's call, I know he's used async alch quite a bit
not sure if he has strong opinions
I would keep it sync for now, tbh. Later on we can migrate to it. It's not a big deal.
(Also, I'm having problems with making pydantic accept postgresql+asyncpg π )
The API of async sqla should be pretty stable
Ah, yeah, it probably expects a traditional ORM to map its attributes to
I like the opposite design more (domain models, where the ORM depends on the domain models via a mapper, instead of the domain models relying on the ORM), but I guess that's not easy here
So, the final conclusion is to use async? I'm in the middle of the migration, I can still change it. (2 hours, tops π )
I know someone who made a good talk about it, hehe
I can't seem to get it to use the async driver.
sqlalchemy.exc.InvalidRequestError: The asyncio extension requires an async driver to be used. The loaded 'psycopg2' is not async.
Any ideas? The SQLAlchemy url is in the right form. (postgresql+asyncpg)
is this from the env.py?
Unfortunately, no.
It's from the database module, that's supposed to create the async engine.
Are you using sqlalchemy.ext.asyncio.create_async_engine?
hmm
I'm guessing you switched to ```py
connectable = AsyncEngine(
engine_from_config(
config.get_section(config.config_ini_section),
prefix="sqlalchemy.",
poolclass=pool.NullPool,
future=True,
)
)
What's that No, I accidentally forgot.
I'll try.
This is the async template https://github.com/sqlalchemy/alembic/blob/rel_1_7_1/alembic/templates/async/env.py
Thank you! π
No, actually it seems to have a problem with this piece of code, but I fail to understand what's the problem here.
engine = create_async_engine(settings.database_url)
session_factory = sessionmaker(bind=engine, class_=AsyncSession)
and if you print settings.database_url just before that?
I tested out before, with an interactive session, and it worked.
(I switched to str in Pydantic temporarily, instead of PostgresDsn so that's not the source of the problem.. hopefully)
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine
from sqlalchemy.future import Engine
from sqlalchemy.orm import sessionmaker
from patsy.settings import CONFIG, DATABASE
engine: Engine = create_async_engine(DATABASE.database_url, echo=CONFIG.debug, future=True)
async def get_session():
"""Yield an engine session, should used as a dependency."""
async_session = sessionmaker(
engine, class_=AsyncSession, expire_on_commit=False
)
async with async_session() as session:
yield session
this is what I have currently
Yeah, it's almost the same. I wonder if it's a problem that psycopg2 is installed in the env.
hmmm possible, not too sure
if you remove it, it might make it more obvious where the issue is
since it'll error sooner saying it can't find psycopg
Okay, now.. it's looking for pyscopg2,
File "/app/./api/core/database/__init__.py", line 20, in <module> engine: Engine = create_async_engine(settings.database_url, future=True)
And that's the source.. π
Nevermind, I'll try to work out something, thank you for the help! π
uhhhhh that's odd
Problem, is that sometimes I need to just open a session when validating a model, so it's quite hard to do async there.
So, I'm not sure about that. It has to be discussed. π
But I'm not sure how that could work for model validations. π
RE bot#1864 is there someone that can give me a vague sort of step-by-step of what exactly needs to be done to fully implement this?
I know I'm going to need to edit the site and api repo as well, but not really sure where to start. Also, how would I go about testing as it's code from across 3 different repos.
As for the API:
you gotta edit https://github.com/python-discord/api/blob/main/api/core/database/models/api/bot/infraction.py (Basic SQLAlchemy)
and then generate an alembic migration using alembic revision --autogenerate - m "Add DM Sent..." like a commit, then push the changes.
(you might have to edit the migration file, because of flake8, sorry for that)
If you have any questions, let me know.
(You can follow this https://github.com/python-discord/api/pull/27, basically the same thing, adding a field)
.bm api changes required
Perfect, thanks π
I noticed site has a similar thing for the database stuff
So would it be the same there?
I'm not familiar with SQLAlchemy so not sure what the kwargs would be
yes, on the site it would be a BooleanField? Or something similar to that.
And what about the different args&kwargs? User, on_delete=, related_name=, related_name=, null= etc?
It seems they're all documented under https://docs.djangoproject.com/en/3.2/ref/models/fields/#django.db.models so I guess I'll just browse and try to figure out which ones I need
It seems like I wantpy dm_sent = BooleanField( null=True, help_text="Whether a DM was sent to the user when infraction was applied." )
@molten perch How would I generate the migrations code? E.g. https://github.com/python-discord/site/pull/618/files#diff-e942db86bcaa00ecf50ca948b4a8f42ae16de841f5370a6e2cb78384349632af
https://paste.pythondiscord.com/obofiwocur.md @static canyon π
Have left a comment with a few suggestions π
Alright, I hope that was all PRs. If there's more needing my review feel free to request it in GitHub
On that note GitHub's notification system is very nice!
not mine π¦ also i don't think i can request reviews lol
Oh you can't? I thought anyone was able to if they're the owner of the PR
i don't think i can 
Is yours the tag one or should I be looking on site or API (I usually don't review there though)
tag on bot, yeah, https://github.com/python-discord/bot/pull/1943
All messages in mod logs channel contains an embed right?
Yep.
So I could ignore this #dev-log message ?
How is it related?
It fails because the log message doesn't have an embed, but since all messages in the mod logs channel have an embed, this could be ignored.
Sorry for the late answer, you run βmanage.py makemigrationsβ then βmigrateβ
Why does it depend on mod log channel having embeds? Maybe I'm missing something here
I havenβt checked the code, but we do send non-embed text messages in there too
For the deleted message link functionality, it would go through the latest 100 messages to find the linked message (by checking in the embed description and matching the embed format to be of deleted message). If there is no embeds then this would fail as there is error handling for this.
Don't make assumptions about the contents of the channel, just look for the right format
doesn't look like that according to the code for me, hence I asked 6 messages above for confirmation
in #incidents-archive ?
in #mod-logs
All our log channels
Even if it's a bot message, if it's not in the right format you should be able to ignore it
nope, it doesn't... I will add the check for embeds
Tbh it can be the most rare thing and not matter
yep
Checking the format shouldnβt be too difficult
π , Will add a try...except on https://github.com/python-discord/bot/blob/32381cdfebd33b39bb69019f174b070beb32c44a/bot/exts/moderation/incidents.py#L189
bot/exts/moderation/incidents.py line 189
log_embed: discord.Embed = log_entry.embeds[0]```
Make sure to validate the embed content too before you use it
yeah I do
An API endpoint for finding the mod log message for x(message ID, author ID) and action y (nickname change, message delete) can be added, it would be useful for such cases.
Not sure it's info we want to store. We discussed using our own message cache with persistency a while back
Hmm, what's the reason for not wanting to store that info?
it will grow considerably large, and we have some issues on the site P99, so the less we hammer it, the better it is
ΡΡΡ Π΅ΡΡΡ Π ΡΡΡΠΊΠΈΠ΅? ΠΏΠΎΠΌΠΎΠ³ΠΈΡΠ΅ ΠΏΠΆ Ρ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ΠΌ
ΠΡΠΎ ΡΠ΅ΡΠ²Π΅Ρ ΡΠΎΠ»ΡΠΊΠΎ Π½Π° Π°Π½Π³Π»ΠΈΠΉΡΠΊΠΎΠΌ ΡΠ·ΡΠΊΠ΅.
ΠΏΠΎΠΌΠΎΠ³ΠΈ Ρ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ΠΌ ΠΏΠΆ ΡΠΎΡΠΈ
You can check out #βο½how-to-get-help on how to open your own help channel, but you'll have to write in English
Ok sory
.bm site changes
Just do if not log_entry.embeds: continue
hey does the forms project accept outside contributions? The notion setup page isn't set to publicly visible: https://github.com/python-discord/forms-frontend#setup--troubleshooting
CC @gritty wind @patent pivot ^
Hey Hedy, thanks for your interest, but currently we arenβt accepting outside contributions to it while we work on rewriting the docs, and opening it up
Iβve been meaning to do that for a while, but havenβt gotten around to it
Weβll put an announcement at least in #dev-announcements when itβs ready though
open source but not open to contributions, got it π
Just temporarily.
np, it's quite common afaik
This looks a bit fishy. It seems like some ZWC or a special char is inserted here which makes it not render as a proper heading. Is it intentional?
https://github.com/hedyhli/workers/commit/6df049db57b94c10eb0d3cc73d799ae0f4c9505f?short_path=30c8c65#diff-30c8c6524b8e512b3efa201ab14555f8703c84cb45a39d150e581644d13ea189
Toggle the rich diff if you have no idea what I'm talking about
!charinfo ## Deployment
\u0023 : NUMBER SIGN - #
\u0023 : NUMBER SIGN - #
\u0020 : SPACE -
\u0044 : LATIN CAPITAL LETTER D - D
\u0065 : LATIN SMALL LETTER E - e
\u0070 : LATIN SMALL LETTER P - p
\u006c : LATIN SMALL LETTER L - l
\u006f : LATIN SMALL LETTER O - o
\u0079 : LATIN SMALL LETTER Y - y
\u006d : LATIN SMALL LETTER M - m
\u0023\u0023\u0020\u0044\u0065\u0070\u006c\u006f\u0079\u006d\u0065\u006e\u0074
!charinfo
Deployment
\u0023 : NUMBER SIGN - #
\u0023 : NUMBER SIGN - #
\u0020 : SPACE -
\u0044 : LATIN CAPITAL LETTER D - D
\u0065 : LATIN SMALL LETTER E - e
\u0070 : LATIN SMALL LETTER P - p
\u006c : LATIN SMALL LETTER L - l
\u006f : LATIN SMALL LETTER O - o
\u0079 : LATIN SMALL LETTER Y - y
\u006d : LATIN SMALL LETTER M - m
\u0023\u0023\u0020\u0044\u0065\u0070\u006c\u006f\u0079\u006d\u0065\u006e\u0074
odd, can't see any special chars in the raw
\u0023 : NUMBER SIGN - #
\u0023 : NUMBER SIGN - #
\u00a0 : NO-BREAK SPACE - Β
\u0044 : LATIN CAPITAL LETTER D - D
\u0065 : LATIN SMALL LETTER E - e
\u0070 : LATIN SMALL LETTER P - p
\u006c : LATIN SMALL LETTER L - l
\u006f : LATIN SMALL LETTER O - o
\u0079 : LATIN SMALL LETTER Y - y
\u006d : LATIN SMALL LETTER M - m
\u0023\u0023\u00a0\u0044\u0065\u0070\u006c\u006f\u0079\u006d\u0065\u006e\u0074
ah yea, it's a non-breaking space
github renders it as a normal space char when viewing the raw
had to check it out locally to get the actual raw
it doesn't seem intentional, feel free to PR that π
i mean I can't think of a reason why it would ever be intentional
Whats bot-core needed for?
Preventing code duplication between the bots iirc
Ah π
@dim pelican Do you need a hand with matching the colors to names from the json?
If that is the direction we are going it should be pretty easy to write a snippet and create the RGB: color name mapping. Just want to avoid redundant work on it
sir-lancebot#842 how to handle the color name matching
Any opinions on this?
Would it be a problem to swap the hex in the json for rgb? And from there we can do as wookie suggested and get the nearest neighbor
Or, accept that there won't be a color name for every user input, even if it is close
I think it's a nice utility
And if the closest match doesn't look like the original color?
We can find how close it is and filter them out if it's too far
say 80 percent match for example
I would probably prefer the color name only show up if it's an exact match and if it isn't exact, don't show the name
The problem is that an exact match will almost never happen
I think that's probably fine, I'm not sure how crucial having the name of a color is
I would personally like to have the closest approximation
I have that on another bot I use for color manipulation, I find it quite useful
If you feel like implementing it, please do
Unless anyone has a strong argument against
I'm tired of working on it to be honest. Is it something that needs to be in the original PR? I feel like I've gotten the command to a "working" level about 4 times now to just have more and more things added to it.
No that's fine, you don't need to add any more if it's already working
Follow up PRs can be made
Have you had a look at my latest comment about the hex edit i suggested yesterday? I'm not sure I explained well what I added
Yeah, let's just merge it
Yeah it makes sense, remove the alpha and send a message along with the embed that it isn't supported right?
Please test before merging though, I've done a fair bit on my own but don't want to miss something
yes. I'm not sure that including the A for alpha belongs in the error message as the "required format" but I included it in there so we could decide
Its a range from A-F is what I was trying to say
Yeah, I will say I think the PR has crept quite out of its original scope with a lot of these small features piling up
tldr feature freeze the pr
Mmm gotta love these docs
BucketType.default
The default bucket operates on a global basis.
???? wtf is a global basis lol
Thanks y'all, for your infinite wisdom
i think so it means that its bucketed as one resource. Eg 3 people run the command in different servers, or dms, and they are all in the same bucket
its not very descriptive
!d discord.ext.commands.BucketType.default
The default bucket operates on a global basis.
That makes sense, thanks
!remind 5h add alpha handling to hex codes
Your reminder will arrive on <t:1636497663:F>!
discord/ext/commands/cooldowns.py lines 240 to 242
def get_bucket(self, message: Message, current: Optional[float] = None) -> Cooldown:
if self._type is BucketType.default:
return self._cooldown # type: ignore```
You are welcome. My office as a good French worker is opened from 2pm to 3pm from Monday to Wednesday, feel free to reach out anytime.
So I just booted a local instance of the bot, and it screamed an error at me. Going up the trace, I wound up at this code snippet:
https://github.com/python-discord/bot/blob/main/bot/exts/help_channels/_cog.py#L429-L438
bot/exts/help_channels/_cog.py lines 429 to 438
claimant_id = await _caches.claimants.get(channel.id)
_unclaim_channel = self._unclaim_channel
# It could be possible that there is no claimant cached. In such case, it'd be useless and
# possibly incorrect to lock on None. Therefore, the lock is applied conditionally.
if claimant_id is not None:
decorator = lock.lock_arg(f"{NAMESPACE}.unclaim", "claimant_id", wait=True)
_unclaim_channel = decorator(_unclaim_channel)
return await _unclaim_channel(channel, claimant_id, closed_on)```
I'm having trouble understanding what's going on here. The comment says "It could be possible that there is no claimant cached", but the condition is is not None
And the error I got is that claimant_id ended up being None
Ah I see, if it's not None, then apply the lock
But the error still happens down the line if it's None
Ah I see. @vale ibex in get_or_fetch_member if member_id is None it causes a malformed API request
So it needs a guard before using that function
I'd argue that's up to the caller
yeah
ahhh i read that as in the function for some reason
IG ```py
guild = self.bot.get_guild(constants.Guild.id)
if claimant_id and claimant := await members.get_or_fetch_member(guild, claimant_id):
await self._handle_role_change(claimant, claimant.remove_roles)
else:
log.info(f"{claimant_id} left the guild during their help session; the cooldown role won't be removed")
yea
Maybe even typehint the variable outside the function where it's defined
Since it's not really obvious from the name
just add the #6000
also depends what versions you are referring to. If it's things like bot, site, etc. then they're pinned to latest, so will update everytime we roll them
things like pg or modmail we update as needed
I think we're still on 8.1
I think there's an 8.2 now
afaik 8.2 doesn't add anything we need so we haven't gone out of the way to update
but there's also nothing stopping us
you can pr sure, but i don't think we'll commit to merging any time soon
so by the time we do, it'll likely be out of date
Lol wrong Joe
yeah I wouldn't make a habit out of it though, we bump for security or meaningful features
would appreciate a review or two on bot#1663
Here's your reminder: add alpha handling to hex codes
[Jump back to when you created the reminder](#dev-contrib message)
I feel like this colour pr is dragging on a bit due to scope creep
How do we feel about drawing a line on features we add for now and raising issues for them?
So we can focus on getting some core functionality released
Will make reviewing additions far easier too
Ah nice
On another note, would anyone want to review sir-lancebot#909? A quick fix (4 lines or so) for .challenge
hi! I was planning to rereview that in two hours or so, don't worry. Unless someone gets to it before me π
Sounds great! Thank you so much!
You already have reviewed it :p
Edit: nvm, you ended up requesting changes afterwards
The PR just needs a core dev approval and then it can be merged
(for some reason GitHub won't let me assign them so commenting instead)
They need to comment on the issue or be in the org to get assigned. I assume it's an anti-spam measure
Do you not have the permission to resolve comments Fronto?
Merged, thanks
.challenge R
Really nice
Do we not populate the site's OT name list in the postgres init? This is the first time I'm running the bot this late at night, so it's the first time I encounter this error.
channel_0_name, channel_1_name, channel_2_name = await bot.api_client.get(ValueError: not enough values to unpack (expected 3, got 0)
I've never gotten that error and I've never had to populate off topic names manually
?
I deleted it
Welp, no idea what to say then lol
The bot doesn't have checks against the site API returning nothing, and the site init doesn't populate the table, so I'm not sure how you aren't getting errors
Are you running at midnight utc
No
Ah, that'd explain it. It only runs at midnight
I did get this error just now though https://paste.pythondiscord.com/fewerutaca.sql
Might be related to using fakeredis and it getting some invalid cache value?
Well, no one is PRing right now, but the debug is there I think
Yeah I think so. Someone else's bot made the channel claimed and then shut down, so it stayed claimed.
Right, makes sense
So when mine started it sees it should be dormant but it has no info for it in cache
I do, just forgot to remove them
Thanks!
Uhh sooo I kinda need help from someone who has nitro and is on the test server
Found a willing victim
sir-lancebot#842 should be good to go, looking for extra testers. I think Blue requested changes before the restructure, so I have re-requested a review.
Some previews of the current behavior are below
@dim pelican Could I join your testing server and test out some edge cases from there?
I would bring it to my local environment but I have ~7 minutes till I have to go somewhere
(if you don't mind)
Some of the previous review comments are still not addressed/nor have been commented
I'll add them really quick since its mostly cosmetic
https://github.com/python-discord/sir-lancebot/pull/842#discussion_r746180499 @dim pelican I made a typo, there should be no not in that if case
if ctx.invoked_subcommand:
return
try:
extra_colour = ImageColor.getrgb(extra)
await self.send_colour_response(ctx, extra_colour)
except ValueError:
await invoke_help_command(ctx)
can't comment on github for some reason
Aiiight I'm done hopefully. Jump up here to look at some pretty embeds. #dev-contrib message

This sounds a little wrong to me, it's like saying "here's some randomly selected info for this color" where I'm assuming it should be "here's some information about this randomly selected color"
I see, currently that first word comes from the sub-command used, but I can just drop in Color or Colour instead
@rapid igloo Better?
yup
Alright, done!
is the bot supposed to request reviews from no one? https://i.imgur.com/FyTv6SI.png
What PR is that?
I think it's just getting cut-off on your screen for some reason
Maybe?
Can you view https://github.com/orgs/python-discord/teams/devops @brazen charm
404
404

