#dev-contrib
1 messages ยท Page 142 of 1
At first it is, yeah. It should fire up the postgres and api containers.
I don't really know. I only added the posgres part. However it didn't take so long for me.
Why
It must be the Token Authentication Middleware.
But as of now, there's nothing that you would need from the API.
You can test the models with just an interactive python interpreter.
Well.. I resorted to a very inconsistent solution.. I exec'd inside the api container and ran an interactive python shell ๐
It's a temporary solution. But you can install the modules as well and connect to the database that you're running in the container.
(ofc. you'll need to create the engine and a session to test out the models, (that'll be a dependency in the actual API))
No, but you can run python
It seems like with one of the last commits I introduced a minor error, I pushed a fix, and it successfully built the relationships. The only thing to test is the embed validation. ๐
But you can always check the relationships, just to make sure. 
Yeah, you have to create one.
I mean, you don't have to test the checks that are fairly straightforward. More like the ones that are more.. difficult.
That Constraint was generated from the actual database that is being used now. So, I don't think we should modify, there's a validation on the ORM side anyways.
Have you created a role with that id?
Hmm, have you run Base.metadata.create_all(bind=engine)?
Well.. yes. ๐
you can also use the "metadata" variable from the database package.
๐
Even the embed validation?
Nevermind, it should work anyways. Thank you for the rest! ๐
๐ Even better.
Your reminder will arrive on <t:1633637323:F>!
Would any core dev in their free time look at sir-lancebot#860? I think it just needs one more core dev approval before a merge
Ughhhhh joeeee git completely wiped out all my work when I merged the new main in :P
I'm gonna be dealing with merge conflicts for weeks ๐คก
joe needs more e's in his name
FYI the topic refresh reaction doesn't seem to be working in #sir-lancebot-playground
Ok managed to unfuck it
@vale ibex What do you think of the state of this PR? https://github.com/python-discord/sir-lancebot/pull/555
@vale ibex another ping. Does the user have to manually remove their own reaction for it to work?
.topic
yep
hmmm
yea, didn't add a call to remove the user's reaction
I could lie and say it was on purpose to avoid extra api calls, but it was just an oversight lol
prob should add remove reaction stuff so that we can reroll it multiple times easily
yea, sounds like a good idea
uhhhh, don't remember ever looking over it myself
it's the oldest one on sir lance
Hey @brisk brook I completely forgot about bot#1836, I'm not able to do it tonight but I'll try to do it tomorrow
Your reminder will arrive on <t:1633722532:F>!
yeah, probably a more generous one than normal projects for now though
1 staff review & devops for devops files
They do. Afaik. contribs count as staff.
hmmmm
for now we'll say staff only 1 review
i am proposing a 1 review requirement
Could you also look into that suggestion? https://github.com/python-discord/api/pull/17#issuecomment-933739292
i'm fine with a notice like that yep, just need someone to draft it up
do which bit
not a form, just an addition to the template
just needs a basic one then
what did you change, what issues does it address, checkboxes
Here's your reminder: Bump api#17
[Jump back to when you created the reminder](#dev-contrib message)
markdown
not yaml
we don't want a form
we just want a markdown file
so google moved us over to www.
that got picked up fast, google bot loves us
What's the standard error for something considered a "programming error" (I'm thinking opposed to runtime error). I'm trying to raise an error if someone (programmer) passes a value to a function that isn't an expected input (the input is basically an enum)
The arg is always of type str, just that str is one a set of three possible values
Think a literal
exception ValueError```
Raised when an operation or function receives an argument that has the right type but an inappropriate value, and the situation is not described by a more precise exception such as [`IndexError`](https://docs.python.org/3/library/exceptions.html#IndexError "IndexError").
Right, that's technically correct, but it doesn't feel like it expressed the right idea
ValueError?
This is mostly to please intelisense anyways
It's always a str, so I'd just leave that to the type annotations
!d TypeError
exception TypeError```
Raised when an operation or function is applied to an object of inappropriate type. The associated value is a string giving details about the type mismatch.
This exception may be raised by user code to indicate that an attempted operation on an object is not supported, and is not meant to be. If an object is meant to support a given operation but has not yet provided an implementation, [`NotImplementedError`](https://docs.python.org/3/library/exceptions.html#NotImplementedError "NotImplementedError") is the proper exception to raise.
Passing arguments of the wrong type (e.g. passing a [`list`](https://docs.python.org/3/library/stdtypes.html#list "list") when an [`int`](https://docs.python.org/3/library/functions.html#int "int") is expected) should result in a [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError"), but passing arguments with the wrong value (e.g. a number outside expected boundaries) should result in a [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError "ValueError").
Yeah, use that one
Rewrote the function so I never hit that error branch ๐คก
uhhh
i think we should use comments with a brief description of the content instead of examples
and we don't need an extra section I don't think for api
under the i confirm section
or
hm
sure, keep the section, add a comment above both telling people how to actually check it
also just shared this in staff but here is migration to www for all to enjoy
html comments
yea
probably not necessary
actually
we do on other repos
just stay in check with the other repos
lol
there was this
put the comments inside the blocks, also that "must be completed" bit can go, you just need to tell users how to actually check the boxes
yea
but say "replace with [x] to check boxes"
wrong bracket on line 10 otherwise lgtm
Guys can someone explain how the redirects app works?
Like
roles_redirect:
original_path: pages/roles/
redirect_route: "content:page_category"
redirect_arguments: ["server-info/roles"]
what's what here
redirect route is fine
but wth is original_path and redirect_argument
Like if I go to the main pydis site now, /pages/roles works with no redirect, but /server-info/roles 404s
https://www.pythondiscord.com/pages/roles redirects to https://www.pythondiscord.com/pages/server-info/roles/
Information on the various roles at Python Discord.
Information on the various roles at Python Discord.
I c
it loads the content:page_category app (mounted at /pages/) with the arg of server-info/roles
nope, we need to split out API before we consider anything major for Django site
ah, well we do have an issue open that talks about moving to a python ssg
site#500 does briefly discuss that in steps 2, 3, and 4
so question that I've been chewing on, with an ssg if I wanted to have a bit more of a dynamic/easy-to-update-without-a-pr calendar for events, is that possible? What does that look like?
just hook into google calendar at this point lol
wouldn't be overly difficult with a decent scope
but that would require some shared calendar which we don't really have
some form of calendar is the answer
Anything we do is going to mean we need to make/setup something though right?
You could probably connect it to Notion (I think the API could do that)
or just follow jamstack and have another database somewhere with all our events
that's a possibility
well yeah, but I was curious if there's some accepted tech already used in similar situations I wasn't aware of. I considered gcalendar but the issue there is who owns it? How do you get easy access? Currently getting access to stuff that only owners or admins have access to is a bit of a headache and waiting game
we would likely go for a python ssg so I don't know how much dynamic stuff we can get in there as opposed to if we did something like gatsby
K, update on current static site: I've got redirects working (sort of, it doesn't update the URL, just displays the content as if you were redirected). Now we're just waiting on notion
do you mean waiting on netlify
yeah they approved this morning lol forgot to tell you
Lol it's alright
what's the benefits of a ssg over something a bit more dynamic?
Static previews :O
... time to google then
Basically like what we had on forms
Where a PR would publish to a site, and anyone could access it
Without spinning up the project themselves
You're two days late bud ๐
you can have a dynamic jamstack app with ssg, that's where you use something like react.js or gatsby, but we likely wouldn't be doing down that route
This is a pretty good explanation or some of the benefits: https://jamstack.org/why-jamstack/
we'd be using a python ssg which takes in templates (probably some sort of jinja thing) and spits out HTML
we can throw JS in there, but it'd only be fairly primitive browser JS compared to what all the fancy frameworks are doing nowadays
or we source events from somewhere at build time I guess
and then just have to rebuild site to add new events
hurm, we'd want to go for a python one because it's python or some other reason?
we already have trouble getting js contribs for forms, main site being js too would likely drop contribution through the floor
Since the site is already in the Django template language, we'd need to use a SSG builder specifically for that
yea let me see if i can do like github or something
nah, this could involve a rewrite to something else
just as a matter of principle we would like to stick with python
makes sense. Okay, time to do some more thinking and tooling around with other potential solutions
lemons workaround here was to build everything in github actions and then use the cli tool to deploy, you can still use different flags to get previews and whatnot
Oh, I didn't realize that was being considered
yeah, this is me asking for how this idea I have could fit into a far future project
That was my original - nice solution, but it required constantly approving the CI tool, and secrets aren't propagated to PRs, so we can't get previews
ahh
Unless there is some way to log into netlify cli with PRs?
hmmmm
this bit specifically https://github.com/netlify/actions/tree/master/cli
Right, but that won't get the secret will it?
At least from my tests on my repo, the secrets aren't give to PRs
oh you're right yeah
hmmm isn't that where you can rnu the pull_request_target things?
Yeah, but that feels like dropping a layer of security, and I'm not sure if it's worth it yet
yea
If I fix caching, we should drop the time significantly from 3 minutes
๐
But, worst case scenario we're looking at ~300 builds a month
Would that be enough
Me and 50 commits
we did a bit of trolling
commented again, sorry for all the disjointed stuff
How does removing the word "OR" change that?
I clicked the plus on that line ๐คทโโ๏ธ
@gritty wind do you have a netlify account
dm me the email on it
Right, one sec
lol nice
it was probably just bot.prefix at some point
Perhaps before it got the ping
Yup that's it
Game added october 2020, mention added august 21
Is there any way for an HTML redirect to copy a fragment of the request URL?
i.e:
if someone makes a request to /a/b/resource_name, and I want to direct them to c/resource_name, is it possible to have /a/b/<anything> go to /c/<anything>
Ideally avoiding JS
Nah, just pure HTML
The whole "dynamic" part of the app doesn't super fly with the static site :P
The other alternative is generating tons of extra HTML files
sry for that
The first google result will be an IBM link if you're curious lol
I found this page: https://css-tricks.com/redirect-web-page/ don't know if thats what u were looking for
but anyway, umm what are the fonts available in sir lancebot?
uh for image drawn using pillow
UH it also had html
This is the part I'm referring to:
It's not an ideal solution and it's discouraged to use at all
right
So like, ex: I want to use fire code for typeface command which has the text displayed on an image, how would I do that?
For 
https://www.youtube.com/watch?v=evthRoKoE1o
Y'all know this ^ video?
Well:
https://615f80944a7c1b0b247418a2--pydis-static.netlify.app/pages/resources/guides ๐
https://615f80944a7c1b0b247418a2--pydis-static.netlify.app/pages/resources/videos ๐
https://615f80944a7c1b0b247418a2--pydis-static.netlify.app/pages/resources/interactive :| ???
https://615f80944a7c1b0b247418a2--pydis-static.netlify.app/pages/resources/reading ๐ญ
Lmfao
still want something? sir-lancebot#881
@clever wraith
Oh ty
why does @dusky shore react when .topic is ran? And why nothing happens when someone reacts to it as well, if anything is supposed to happen.
.topic
It does work
Did we mess up the check?
@cursive relic can you run topic and then click the reaction?
I think it is by design that I can't refresh it if it was Akarys who triggered the command.
I can't refresh if I do it myself tho
bot/exts/utilities/conversationstarters.py line 77
if is_moderator or user.id == message.author.id:```
@green oriole :white_check_mark: Your eval job has completed with return code 0.
True
so there is just smth wrong but no error is raised?
Yeah
There is a logic error here I believe, but I can't spot it
It probably need proper debugging
Would you like to open an issue?
bot/exts/utilities/conversationstarters.py line 80
return False```
Never opened one before
if you'd like to guide me on that, then I can surely open it
If you go here, the comments should explain it: https://github.com/python-discord/sir-lancebot/issues/new?assignees=&labels=type%3A+bug&template=bug-report.md&title=
ah thx
uuh I'm bad at writing all the info. I can't come up with anything
All I came up with was ```
When user reacts to bots reaction, nothing happens on it.
Yup! If you need feedback on what to write, feel free to ask. It doesn't have to be really detailed, this is a simple issue
You should say that it does work with mods
oh, right
If you feel like it, you can even link to the relevant portion of the code
the check code part?
Yup
as a link?
Do you know how to highlight lines on github?
If so, you can click copy perma link and paste the link in your issue
hmm I don't think I know how to do it
If not.. I'll let someone else guide you through because I am late to my class
Oh, have a good class. I will wait if someone knows how to write that
But what you should ask yourself when writing an issue is "What information do I need to give someone who doesn't know anything about the bug so they know what is the error and what we explored so far"
A'ight, bai
Cya, I will try to add that info
Hello, I am a newcomer, totally green. Trying to set everything up according to https://www.pythondiscord.com/pages/guides/pydis-guides/contributing/sir-lancebot/ and I wonder if using gitpod is an alternative to using docker locally? Eg I run gitpod workspace and clone repo from CLI inside of it?
A guide to setting up and configuring Sir Lancebot.
Any other information I should add? I can't come up with anything
What would be the reason for loading them dynamically?
I can't really come up with anything that should be added
I don't think I would normally do that in a work project, since it adds some complexity, introduces a bit of magic, but does not seem to add that much over explicitly listing the subrouters
It's also easier to temporarily disable routers for debugging purposes if you have an explicit list
But I also don't see a great harm in it
what do I put here?
You could put for example
- Use
.topicwithout any mod role- Click the reaction
- Nothing happens
Oh I think I will put that I there
I have explained what happens/what should happen. And platform desktop/mobile. And also the one who can implement it.
what about here?
Here, if you don't know how the bug is caused, you can remove that section
I had this on desc, should I remove it? ```
There may be a problem on a check function here. But it's just a wild guess.
now it looks like this and I think it's good enough, I'd like to know if it is before making it
Lgtm
sir-lancebot#894 is now opened
it was weird opening a issue first time
That's a good learning experience :D
@cursive relic it's supposed to work for both the message author and moderators. If you're not either of those, then it won't work (as intended) https://github.com/python-discord/sir-lancebot/pull/880/commits/515c6390563f33a02af2e46fe6f3d13b15353a0a#diff-ace24dfc4bb3c55afff79de98551d97f9f6a0ecbd7b4d51d15ea1e32e2a0df2dR77
Well I know what the issue is
It's listening for a reaction from message.author which is the bot
But then the bot doesn't trigger it either because there's an if statement stopping that
I'll fix this later today @cursive relic, thanks for the report + issue ๐
Good to know, thx!
hey, not sure if this is a right channel - I'd like to start with Lancebot and got a workflow question: can I insert my bot's token into a cloned sir-lancebot's repo and 'simulate' full lancelot on my server? Or should I develop my own bot locally and later in further steps merge it to lancebot?
got a bit lost, sry for noob question
You can fork the GitHub repo and run the entirety of @dusky shore on your bot by using your own bot token
You just specify the token in the env/config file (can't remember which)
oh wow thank you
If you aren't already aware, there's a guide for this on our website under the "Contributing" section
yes I am, I got lost following that guide
A guide to setting up and configuring Sir Lancebot.
so maybe you could guide in one more issue - as I understand a gitpod is an alternative to local docker develpment, am I right?
If im using docker, shall I separately install poetry?
@brisk brook have just pushed the asyncio-tag changes to bot#1836
If you're using docker, you need poetry
Gitpod is alternative to docker, yes -- I use docker myself so can only help with that
ok, thank you
It's in the .env btw```c
BOT_TOKEN="YOUR_TOKEN_HERE"
You may have to create the file if it doesn't already exist
Yeah, just create it then
It's because we've configured it so that git ignores .env files so you don't accidently upload your token etc.
And so the .env file isn't there when you clone/fork
ok, so i got to touch .env and set all these https://www.pythondiscord.com/pages/guides/pydis-guides/contributing/sir-lancebot/env-var-reference/#general-variables, right?
The full environment variable reference for Sir-Lancebot.
Yeah, you do
It's a pain I know; we're working on something to make the setup easier
ok, and once it's done I need to run main.py ?
For reference, this is my .env file```c
BOT_TOKEN="MY_TOKEN"
BOT_DEBUG=true
BOT_GUILD=476190141161930753
PREFIX="'"
USE_FAKEREDIS=true
AOC_ROLE_ID=651730380898041862
BOT_ADMIN_ROLE_ID=476190234653229056
LOVEFEST_ROLE_ID=795910065424171028
ROLE_HELPERS=476190429960732672
AOC_CHANNEL_ID=476190141161930755
AOC_COMMANDS_CHANNEL_ID=476196062214750219
CHANNEL_ANNOUNCEMENTS=476196024512413698
CHANNEL_COMMUNITY_BOT_COMMANDS=476196062214750219
CHANNEL_DEVLOG=476196115432210443
CHANNEL_REDDIT=476197119762366464
REDDIT_WEBHOOK=637295388998500352```
You may not need all of those though
No, you do docker-compose build and then docker-compose up in the terminal (make sure you're in the bot's root directory first)
@vale ibex is there a reason you put this wait_for in a while True: loop? https://github.com/python-discord/sir-lancebot/pull/880/files#diff-ace24dfc4bb3c55afff79de98551d97f9f6a0ecbd7b4d51d15ea1e32e2a0df2dR84-R95
I guess so you can re-roll multiple times, but then surely once it timeouts we want to break the loop?
Yea, there should be a break after the supress block
Fixed in sir-lancebot#895, thanks again ๐
Thx, it was weird opening a issue
@vale ibex with the suppresses, would it bepy with suppress(discord.NotFound): await message.edit(embed=self._build_topic_embed(message.channel.id)) await message.remove_reaction(reaction, user)orpy with suppress(discord.NotFound): await message.edit(embed=self._build_topic_embed(message.channel.id)) with suppress(discord.NotFound): await message.remove_reaction(reaction, user)?
I suppose the prior since if the message is deleted there's no point trying to remove the reaction
Or perhaps a try/except would be better, because then we can break
akapy try: await message.edit(embed=self._build_topic_embed(message.channel.id)) except discord.NotFound: break else: with suppress(discord.NotFound): await message.remove_reaction(reaction, user)
I think I prefer the try/except/else
Morning all
Morning GitPodifer
Yea, the former preferably
both would work
I'm pretty sure if the first line raises an error the context manager will break anyway
rather than try the second line
worth double checking but I think that's the defined behaviour
!e ```py
from contextlib import suppress
with suppress(ValueError):
int("t")
print("context manager continues")
@vale ibex :warning: Your eval job has completed with return code 0.
[No output]
yea, thought so
What about what I said with the try/except/else? @vale ibex
So that we get a break when the message is deleted
what I showed above is that supress does that for us
if the first line raises NotFound, the second line isn't evaulated
supress will exit the while True: loop?
oh, you're referring to the while true
yeah
I think we just add the break outside the suppress
but then it'll always break
Which we don't want
We only want to break when the message is deleted
can you show the code here?
^
async def _listen_for_refresh(
self,
command_invoker: Union[discord.User, discord.Member],
message: discord.Message
) -> None:
await message.add_reaction("๐")
while True:
try:
reaction, user = await self.bot.wait_for(
"reaction_add",
check=partial(self._predicate, command_invoker, message),
timeout=60.0
)
except asyncio.TimeoutError:
with suppress(discord.NotFound):
await message.clear_reaction("๐")
break
else:
try:
await message.edit(embed=self._build_topic_embed(message.channel.id))
except discord.NotFound:
break
else:
with suppress(discord.NotFound):
await message.remove_reaction(reaction, user)```
ah right ok, i get it now
lemme think
async def _listen_for_refresh(
self,
command_invoker: Union[discord.User, discord.Member],
message: discord.Message
) -> None:
await message.add_reaction("๐")
while True:
try:
reaction, user = await self.bot.wait_for(
"reaction_add",
check=partial(self._predicate, command_invoker, message),
timeout=60.0
)
except asyncio.TimeoutError:
with suppress(discord.NotFound):
await message.clear_reaction("๐")
break
try:
await message.edit(embed=self._build_topic_embed(message.channel.id))
except discord.NotFound:
break
with suppress(discord.NotFound):
await message.remove_reaction(reaction, user)
I think this is more readable, rather than the else blocks on the tries
since they're not needed and lead to more indentation
right, yeah. If we're breaking then the else isn't needed
yea
Okay, will go for that and then re-push
๐
Pushed ๐
Btw, can I make a separate PR for changing constants.py to use config for moderator role and owner role instead of hardcoding to the ids for this server?
I don't think this else block is needed either https://github.com/python-discord/sir-lancebot/pull/895/files#diff-ace24dfc4bb3c55afff79de98551d97f9f6a0ecbd7b4d51d15ea1e32e2a0df2dR102
Yea, that's a good idea, lancebot has that in a few places, so feel free to commit them to env vars when needed
as long as you keep the defaults
yep
Pushed as well
Also should I change moderator to moderation_team?
If I can have a review on https://github.com/python-discord/sir-lancebot/pull/893#pullrequestreview-774930941 I'd greatly appreciate, the logs are unreadable atm
Thank you sir jl
Yea, just do them in two commits
IE one to change the name in all the places, another to make it pull form env var
will make it easier to review
Right, okay
And finallypy admin = int(environ.get("BOT_ADMIN_ROLE_ID", 267628507062992896))should I rename the value to be ROLE_ADMIN so it's consistent with the others? @vale ibex
I'd argue that if they're in a Role class, having a role suffix at all is redundant
The variables don't, the envs do
Since in the .env there's no "classes"
yea, envs make sense, since there's no context
I'm referring to that here
I assumed you were referring to the variable name not having the role suffix
get("BOT_ADMIN_ROLE_ID", ...) --> get("ROLE_ADMIN", ...)
Ah, I thought you were referring to the variable name not being consistent
i.e. without changing it would be```py
class Roles(NamedTuple):
owner = int(environ.get("ROLE_OWNER", 267627879762755584))
admin = int(environ.get("BOT_ADMIN_ROLE_ID", 267628507062992896))
moderation_team = int(environ.get("ROLE_MODERATION_TEAM", 267629731250176001))
helpers = int(environ.get("ROLE_HELPERS", 267630620367257601))
core_developers = int(environ.get("ROLE_CORE_DEVELOPERS", 587606783669829632))
everyone = int(environ.get("BOT_GUILD", 267624335836053506))
changing actualy env var names isn't a good idea since it may lead to confusion to contribs since their .env won't work anymore
The env-variable named
Eh, I guess.
I'll leave it then
Also I suppose the contributing docs would need to be updated
The full environment variable reference for Sir-Lancebot.
yea, there's no need to update them before this gets merged
since you're adding more options, rather than removing them
mhm
it may also be something that wants to wait for Zig's pr to be merged too
since I'm not sure if it would conflict
It was more a question of "can I do this by submitting a PR or does joe/admin have to do?"
๐
I guess the changes would need to be reflected in https://github.com/python-discord/site/blob/main/pydis_site/apps/content/resources/guides/pydis-guides/contributing/sir-lancebot/env-var-reference.md#L7 and https://github.com/python-discord/site/blob/main/pydis_site/apps/content/resources/guides/pydis-guides/contributing/sir-lancebot.md#L67
(In those files)
I'll check before I do the PR
If you're referring to site#591 that only touches @stable mountain stuff, so no, it doesn't touch the two files in question
Have pushed these changes to site#607 and sir-lancebot#896; think I've linked them as best as I can (just mentioning the other issue)
CC @vale ibex
def convert_to_image(text:str, filename) -> discord.File:
"""Converts the given text into an image."""
im = Image.new("RGB", (1200, 1024), "black")
font = ImageFont.truetype('bot/resources/fun/FiraCode-Retina.ttf')
draw_image = Image.Draw(im)
text = text.split()
split_text_evenly = '\n'.join(
' '.join(text[i : i + 8]) for i in range(0, len(text), 8)
)
draw_image.multiline_text(
(10, 10),
split_text_evenly,
font=font,
fill=255
)
buffer = BytesIO()
im.save(buffer, format="PNG")
return discord.File(buffer, filename=filename)
Should this function be ran in an executor?
Would someone mind to take a look at sir-lancebot#857 ? It's close to be merged.
If I may, I think we should migrate a few endpoints to FastAPI to get used to the context etc. etc.(We should also test to those endpoints) (and migrate the models first of all ๐ )
(Also, we can just introduce a decorator to temporarily disable routers based on a list.)
@vocal wolf , cowsay was closed because the branch was stale and a new branch was created. ill open a new PR once the rewrite with cowpy is donw
done
ok
the branch was 2 months old 
I don't know SQLAlchemy
Here's your reminder: Do this if haven't already ^
[Jump back to when you created the reminder](#dev-contrib message)
What happened to sir-lancebot#778?
It seems like it's been approved for a while
Also, when threads can be used by the Python bot, I think the quiz command and hangman command (multiplayer, suggested by Bluenix in sir-lancebot#872) should migrate to threads because quiz uses the entire channel
What do you all think?
Yeah I think all of those commands should use threads
which PR?
Your reminder will arrive on <t:1633735820:F>!
Yaay, thank you for the PR campaign ๐
@thorny obsidian for sir-lancebot#861 which of these two were you envisioning (or something else)?
Uhhhh, I would probs want everything hacktoberfest related to be under the hacktoberfest subgroup just to ensure we don't clutter the command namespace
That way if we ever did want a future .stats command to pull fun pydis stats it won't conflict (as a hypothetical example)
Right, okay
There's also the fact that current there's 3 different files for hacktoberfest (excluding __init__.py)
One file for issue-finder, one for hacktoberstats, and one for timeleft.
If we want to move them all into the hacktoberfest subcommand namespace then I'm guessing we'll have to combine these files into one file (which will be messy)? @thorny obsidian
Unless imports work I guess
There's no actual "hacktoberfest" command currently so we'd need to decide how to structure it all
I don't like the idea of having it all in one big file (said file would be ~650 lines)
Hmmmm, let me take a look after I'm done working and I may be able to provide better clarification
Ping me when you respond please as I'm going to bed now, so will look when I wake up ๐
Hey Rick, got time to push that color file?
Not that I'll likely have time to work on it over the weekend lol
Your reminder will arrive on <t:1633774440:F>!
Lmao
shoulda sudo'd
Here's your reminder: that
[Jump back to when you created the reminder](#dev-contrib message)
unpopular opinion: -word should be annihilated in favour of --word
-word removes the whole benefit of being able to do multiple flags following a single -
Here's your reminder: push colour file smh
[Jump back to when you created the reminder](#dev-contrib message)
Uh, the bot just randomly sent this in my test server.
wut just happened?
Sir Lancebot doesn't have any functionality like that, are you sure it isn't a different bot?
Absolutely, cause thats the only one there.
sir-lancebot | 10/09/21 11:59:09 - bot.exts.fun.typerace TRACE: Running convert_to_image in an executor
sir-lancebot | 10/09/21 11:59:59 - bot.exts.holidays.halloween.spookyreact DEBUG: Ignoring reactions on self message. Message ID: 896366383984701480
Oh wait, that probably is a Sir Lance command, nvm
I thought you meant as an unprovoked message
You most likely accidentally triggered one of the commands inside the cog, that's all
It seems to be a loop that runs every day in October. ๐
https://github.com/python-discord/sir-lancebot/blob/main/bot/exts/holidays/halloween/spookynamerate.py#L215:L216
bot/exts/holidays/halloween/spookynamerate.py lines 215 to 216
@tasks.loop(hours=24.0)
async def announce_name(self) -> None:```
ah
...why? I don't see what's the point in that.
It's a game. ๐
Yeah, but do we really want an unprovoked message every 24 hours? Or is it a core part of the game to happen that often?
Oh I see, it's sort of like a leaderboard
I personally think it would be better to have that as a command rather than a looped message
I mean, it's sort of the point of the game that it runs every day, and everyone can play. Then the next day it announces the winners of the last day as well.
what's up with the <function when mentioned or... bit, seems like bot.command_prefix isn't a string? Is that something that changed at some point?
Yes, it was. https://discordpy.readthedocs.io/en/master/ext/commands/api.html?highlight=when_mentioned#discord.ext.commands.when_mentioned_or
It seems like that function returns another callable.
I think we should just be using constants.Client.prefix instead
Might be the best, this callable it returns needs: a bot instance, and a message as arguments, I'm not sure why though.
It allows you to do things like
@stable mountain help
Big Brother
!bigbrother
Monitors users by relaying their messages to the Big Brother watch channel.
!bigbrother unwatch <user> <reason>
Stop relaying messages by the given user.
!bigbrother watch <user> <reason>
Relay messages sent by the given user to the #big-brother channel.
Bot
!echo [channel] <text>
Repeat the given message in either a specified channel or the current channel.
!embed [channel] <text>
Send the input within an embed to either a specified channel or the current channel.
BotSource
!source [source_item]
Display information and a GitHub link to the source code of a command, tag, or cog.
Branding
!branding
Control the branding cog.
Clean
!clean
Commands for cleaning messages in channels.
yeah the problem is that we're using bot.command_prefix in help commands to show the user the prefix
Yea, in the help command we should just use the constant then
yep
This function(the one that gets returned) also returns the prefix, but I don't think it's worth the effort at all, when we can use the constant ๐
We have quite a few commands that send stuff like this for different months
We have for valentine too
Thing is, it goes into #sir-lancebot-playground
The probability anyoneโs ever seen that hovers between 0 and zilch
But youโll have seen it if you tested the bots in those months
We have a lot of inexplicable stuff like that, most very old
Thereโs that candy minigame which adds random candy emotes to certain messages, and keeps a leaderboard for who clicks them
But without context (which it always will be) itโs just confusing and pointless
@hardy gorge would you like to get one in first?
I can also merge it, up to you
If it's been reviewed, it's fine to merge it
Wow, Thank you!ย @last patio
You can click "edit" in the upper right (the one you click to change the name" and change the branch iirc
oh wait, yeah, oops
If you really wanted, you can merge your new branch into your main, but there is no problem with opening/closing provided you don't have any reviews yet
@mellow hare About https://github.com/python-discord/site/issues/605 , so we need to create new infraction type voicemute and rename all current voiceban infractions to voicemute in DB?
Yup!
You can use a RunPython step inside your migration for that
do we use enums for infractions?
can't we use something like ALTER TYPE colors RENAME VALUE 'purple' TO 'mauve';
I don't think so. Looks like just choices at code side.
Raw SQL bad though
raw SQL for the whole application is bad because then generally no one does migrations
but for migrations raw SQL is fairly common providing the ORM understands the before and after
yea it's possible we don't use enums, will double check once home though
!remind 1h that
Your reminder will arrive on <t:1633810943:F>!
I feel like using python for this is way simpler and will avoid making django understand one type is gone but the other isn't, and it actually has to recreate voice_ban but it has to add voice_mute to its internal registry
@cold moon Would you mind opening an issue in the API repository regarding your recent model changes? I believe a pull request template was added to indicate this, but it's relatively new. ๐
I think work hasn't started yet to migrate endpoints to new API, only offtopic names.
No, it hasn't but a PR has just been merged, that migrated models from Django the SQLAlchemy.
That's the reason why https://github.com/python-discord/site/blob/main/.github/PULL_REQUEST_TEMPLATE/pull_request.md was added yesterday.
Oh, looks like if you create PR using recent push notification, then you don't see templates.
I will open issue tomorrow
!remindme 12h this
Your reminder will arrive on <t:1633852671:F>!
Here's your reminder: that
[Jump back to when you created the reminder](#dev-contrib message)
It's shouldn't do no
Shouldn't really take >5 seconds
Do you have a branch I can checkout?
alright
sure, send me the config
Did you google how to make your own search engine?
Happens to the best of us
Just sign the non-compete form - provided you can find it
Do you share the network with others?
Lol are you on a pub network
Yea, then it's likely that either you, or someone on that network is sending traffic that looks like automated scraping
it could also be from an extension you have
I think it's the --diff arg on the flake8 call that's causing the issue
flake8 will wait to be passed a diff via stdin
pre-commit itself does the pruning of files anyway, so there's no need to use --diff
So I'd just go for ```yaml
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:- id: check-merge-conflict
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
hooks:- id: python-check-blanket-noqa
- repo: local
hooks:- name: Black
description: Runs Black within the project environment
id: black
entry: poetry run black . --check
language: system
types: [python]
require_serial: true - name: Flake8
description: Runs Flake8 within the project environment
id: flake8
entry: poetry run flake8
language: system
types: [python]
require_serial: true
- name: Black
Your reminder will arrive on <t:1633855761:F>!
yea, fwiw, what I mean here is that the pre-commit hooks only get ran against files that are staged
and that's managed by pre-commit
Oooooooooooookay it's taken some work but I've now gotten static previews PR open
I'll hammer out some caching stuff, but it should be otherwise basically good to review
site#609
oh nice nice
I'd also like thoughts on the redirects app
I've left a comment there describing the problem
I tend to agreetothis
What do we use redirects for in the site?
I think an old article or guide still had an old URL
which is fine, it just goes through a redirect on the main site
but that's not easy here
Let me find it
Ahh yea, there's also https://www.pythondiscord.com/pages/*/ -> https://www.pythondiscord.com/*/
Ah right, are they important? or can they just be removed
/resources/reading, etc
I wrote this about the /resources/<w/e> problem
I also wrote this to open every single redirect for testing:
https://paste.pythondiscord.com/uhomeduhuz.py
Acc I may have fixed /events/resources, gotta check real quick
Nop, /events/resources is still broken :)
Acctually... I'm not seeing a redirect called /events/resources
Must've imagined that one
I also just figured out the other issue, so now it's down to /resources/<...>
How come every time I complain about something, it just works
bot_1 | Traceback (most recent call last):
bot_1 | File "/bot/bot/api.py", line 66, in maybe_raise_for_status
bot_1 | response_json = await response.json()
bot_1 | File "/usr/local/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 1097, in json
bot_1 | raise ContentTypeError(
bot_1 | aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html', url=URL('http://api.web:8000/healthcheck')
bot_1 |
bot_1 | During handling of the above exception, another exception occurred:
bot_1 |
bot_1 | Traceback (most recent call last):
bot_1 | File "/bot/bot/bot.py", line 251, in login
bot_1 | await self.ping_services()
bot_1 | File "/bot/bot/bot.py", line 99, in ping_services
bot_1 | await self.api_client.get("healthcheck")
bot_1 | File "/bot/bot/api.py", line 80, in get
bot_1 | return await self.request("GET", endpoint, raise_for_status=raise_for_status, **kwargs)
bot_1 | File "/bot/bot/api.py", line 75, in request
bot_1 | await self.maybe_raise_for_status(resp, raise_for_status)
bot_1 | File "/bot/bot/api.py", line 70, in maybe_raise_for_status
bot_1 | raise ResponseCodeError(response=response, response_text=response_text)
bot_1 | bot.api.ResponseCodeError: Status: 404 Response: <!DOCTYPE html>
what did I fuck up this time ๐ฆ
I'm trying to setup an instance of the @stable mountain bot using the staff bot test server (and its instructions) and I get this error at startup...
What do you see if you navigate to http://api.web:8000/healthcheck
Maaay have to change api.web to localhost to give me an answer
Ah actually, I do know
Either your bot or site is out of date
Make sure to pull main
weren't subdomains removed recently or something like that
FWIW these instructions were super unclear: https://www.notion.so/pythondiscord/config-yml-1673fcd1232048b5a9bd2cc47c2f2769#146b7bb32d37483e96fd01dce64a8ec3
try web:8000/api for the url
That wouldn't get updated with the clone
bot_1 | Traceback (most recent call last):
bot_1 | File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
bot_1 | return _run_code(code, main_globals, None,
bot_1 | File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
bot_1 | exec(code, run_globals)
bot_1 | File "/bot/bot/__main__.py", line 15, in <module>
bot_1 | bot.instance.run(constants.Bot.token)
bot_1 | File "/usr/local/lib/python3.9/site-packages/discord/client.py", line 723, in run
bot_1 | return future.result()
bot_1 | File "/usr/local/lib/python3.9/site-packages/discord/client.py", line 702, in runner
bot_1 | await self.start(*args, **kwargs)
bot_1 | File "/usr/local/lib/python3.9/site-packages/discord/client.py", line 665, in start
bot_1 | await self.login(*args, bot=bot)
bot_1 | File "/bot/bot/bot.py", line 256, in login
bot_1 | await self.cache_filter_list_data()
bot_1 | File "/bot/bot/bot.py", line 87, in cache_filter_list_data
bot_1 | full_cache = await self.api_client.get('bot/filter-lists')
bot_1 | File "/bot/bot/api.py", line 80, in get
bot_1 | return await self.request("GET", endpoint, raise_for_status=raise_for_status, **kwargs)
bot_1 | File "/bot/bot/api.py", line 75, in request
bot_1 | await self.maybe_raise_for_status(resp, raise_for_status)
bot_1 | File "/bot/bot/api.py", line 67, in maybe_raise_for_status
bot_1 | raise ResponseCodeError(response=response, response_json=response_json)
bot_1 | bot.api.ResponseCodeError: Status: 401 Response: {'detail': 'Invalid token.'}
well I got progress but I'm confused at what token I managed to mess up
I'm trying to update the test server config now to work with the changes
What do you have in your .env file
Just for BOT_API_KEY
Right, so there is another token for the site, but luckily that's static for dev environments
BOT_API_KEY=badbot13m0n8f570f942013fc818f234916ca531
BOT_TOKEN is fine
Could you share them? We may be able to work through some of them now
Hm that's curious
2021-10-09 23:29:40 | bot.exts.moderation.watchchannels.bigbrother | ERROR | Failed to fetch webhook with id `609535034474496063`
bot_1 | Traceback (most recent call last):
bot_1 | File "/bot/bot/exts/moderation/watchchannels/_watchchannel.py", line 107, in start_watchchannel
bot_1 | self.webhook = await self.bot.fetch_webhook(self.webhook_id)
bot_1 | File "/usr/local/lib/python3.9/site-packages/discord/client.py", line 1493, in fetch_webhook
bot_1 | data = await self.http.get_webhook(webhook_id)
bot_1 | File "/usr/local/lib/python3.9/site-packages/discord/http.py", line 248, in request
bot_1 | raise Forbidden(r, data)
bot_1 | discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
bot_1 | 2021-10-09 23:29:40 | bot.exts.moderation.watchchannels.bigbrother | ERROR | Failed to start the watch channel; unloading the cog.
Oh
I think it's related to this part of the log
Ok so I don't have any roles on that server
But could you give your bot the super bot role?
If not, I gave it admin anyway so it should work now I hope
Seems you can't either, will have to wait for Mark to do that
yeah I can't either as just an admin
I've rarely worked with an application that spits out as many log entries as this one
a bit of a firehose ^^
Hah that's true
I've gone ahead and fixed the other issue, so no one else should hit it now ๐ค
Make sure to update the following if you are running the bot on docker
Site URL: `site: &DOMAIN "localhost:8000"`to `web:8000
snekbox_eval_api` URL: `"http://localhost:8060/eval"` to `"http://snekbox:8060/eval"`
What is this all about by the way?
the contributing guide will also need updating for the urls
So if you're running on docker, there's the config var on line 359 that needs the URL to be specifically set to use docker
That is, if the actual bot application itself is running on docker, it'll use the internal routing system, i.e the website with name web will be on http://web...
I can't do that rn, but would be great if someone gets to it
Right, I did change the snekbox URL
!remind 12H update contributing guides for new url
Your reminder will arrive on <t:1633865971:F>!
does feel a bit weirdly worded, no?
It could use some work for sure
It would probably look better if not forced onto one line as it is now
Thoughts on that?
still broken but I have to go for the moment, thanks @gritty wind for helping ^^
If you're referring to the first part, it means the bot calculated a ping time to be negative (most likely meaning your system time is not in sync with discord's)
I've found that it's almost guaranteed to be the case on docker
Haven't found a fix
There was another error in the logs but my memory sucks
I'll be here if you ever feel like debugging again
web_1 | Exception occurred during processing of request from ('172.18.0.7', 56860)
web_1 | Traceback (most recent call last):
web_1 | File "/usr/local/lib/python3.9/socketserver.py", line 683, in process_request_thread
web_1 | self.finish_request(request, client_address)
web_1 | File "/usr/local/lib/python3.9/socketserver.py", line 360, in finish_request
web_1 | self.RequestHandlerClass(request, client_address, self)
web_1 | File "/usr/local/lib/python3.9/socketserver.py", line 747, in __init__
web_1 | self.handle()
web_1 | File "/usr/local/lib/python3.9/site-packages/django/core/servers/basehttp.py", line 174, in handle
web_1 | self.handle_one_request()
web_1 | File "/usr/local/lib/python3.9/site-packages/django/core/servers/basehttp.py", line 182, in handle_one_request
web_1 | self.raw_requestline = self.rfile.readline(65537)
web_1 | File "/usr/local/lib/python3.9/socket.py", line 704, in readinto
web_1 | return self._sock.recv_into(b)
web_1 | ConnectionResetError: [Errno 104] Connection reset by peer
this is probably safe to ignore, yeah?
For the redirects issues, are these for prod or only for the previews?
Just previews
Oh ok
Success! I've played around with Daylily for like 30 minutes and I haven't seen an error (other than me being stupid with commands)
Just noticed the word "scat" can be used in the .anagram command, not too sure bout that one
What's the issue with that?
Only meaning I'm aware of is like "scat!" when you're telling an animal/someone to go away
Yeah, just "poop" doesn't seem bad to me
Here's your reminder: this
[Jump back to when you created the reminder](#dev-contrib message)
!remindme 3h this again
Your reminder will arrive on <t:1633863494:F>!
Here's your reminder: remember this
[Jump back to when you created the reminder](#dev-contrib message)
Have you had time to think this through?
I've been thinking on it a bit, and perhaps everything in one file wouldn't be too bad since there are other commands which end up doing this (some stretching past 700 lines).
Yeah, nah, let's not put them into one file
I don't mind how we organize the interface, I just don't want any file that has more than 400 lines
Well there's already plenty of those lol
Even the help command is 562 lines https://github.com/python-discord/sir-lancebot/blob/main/bot/exts/core/help.py
4 of the exts/fun are over 400 lines, one of which is 675 lines
Yes, we want to avoid it where we can, but I'm not really sure we can avoid it here
We can either split out utilities in other files, or have each command be its own file, all joined under a single cog
How would the latter work? (since I believe all the functions are commands)
Just have the command defer all the work to an imported function
I don't think we should add structural complexity just to avoid having too many lines
It's a bit uhh
How do I put this
Superstitious
Fewer lines is ideal, but it isn't a big deal if we go over. Remember the goal here is to keep things understandable and approachable. More lines hurts that, but so does structural complexity
I've worked extensively on the silence cog, and I needed to pull out graphs just to understand what the hell it was doing
I don't think it is structure complexity to split it up
It is when you start splitting functions up into more and more calls just to save a bit of space
I mean, it is one very simple level of indirection
One level which will do the following:
- Add an import
- Make you go to a new file where you are splitting the interface and logic
Ultimately, it'll probably be fine with whatever you go with, but in general we shouldn't just make commands wrappers for other functions in the name of a "shorter" file
Here's your reminder: this again
[Jump back to when you created the reminder](#dev-contrib message)
!remindme 4h again...
Your reminder will arrive on <t:1633877921:F>!
Hey @last patio you wouldn't happen to know how to specify CMD from a shell in docker build would you?
Or actually
I see the problem now
command is used on run lol
Nah that's not what I'm trying to do. I have a default CMD specified in the dockerfile, but I'm trying to override it when building the image from the command line
I don't think that's feasible without adding like a second stage build to override it
I think docker commit is what you want: build the existing image, docker commit a layer on top of it
ooh, smart
yeah, you just push a layer on top of the file
docker commit --change "CMD ['hello'] $perv_tag $new_tag"
I just ended up slapping my run in a conditional
The thing is, I need this to happen in the build stage not the run stage
using commit you create a new image
I think you're missing my point
I don't actually want to modify the CMD it turns out
Since that is only used when running
I want this done during the build stage
Okay, I guess the question is why you want to modify it
Well, I'm trying to combine the static build dockerfile with the normal docker file
When doing a static build, it runs a different command to the normal docker file
This'll probably be easier to understand once I push the changes
probably haha
Here's your reminder: update contributing guides for new url
[Jump back to when you created the reminder](#dev-contrib message)
bot/exts/avatar_modification/avatar_modify.py line 291
async def spookyavatar(self, ctx: commands.Context) -> None:```
For what purpose?
to spookify other's profile picture?
Ah right, then no we purposefully removed the ability to do that
Noted, ๐
We no longer allow any commands that parrot back arbitrary images via the bot, or anything that allows members to run commands against other members without their permission.
i was going to make a pr on it, glad i asked first
๐
It's always good to ask here, or raise an issue first, before investing time in making a code change
Another question for one Mr. @last patio I've left a comment on the usage of __all__. I tried now setting the all in the init to not have the helper functions, but it seems I can still import them with no problems.
I don't think they should be used from there if someone wants to use them
What do you think?
Yeah, nothing will prevent you from importing them. Same for __, but since that's a convention linters will actively warn against it. We can't fully "hide it" in Python anyways, so it's really up to you about how we deal with it
If you just want to indicate it shouldn't be imported I think it should be a single rather than double underscore before the name.
School...
messages from help channels
Could have sworn I put this in the readme
but now I realise I put it in the k8s readme
Some of it is here https://github.com/python-discord/patsy#purpose
I'll pad it out with more
It will be consumed by AIโข๏ธ to produceโข๏ธ Bugdataโข๏ธ to be processed by ยฉ the pydis-hiveโข๏ธmind
Here's your reminder: again...
[Jump back to when you created the reminder](#dev-contrib message)
Can anyone help me with opening this issue in API repo about voice mute model changes? I'm currently busy with school stuff.
Of course, I'll open the issue.
When updating the bot's code, is a container rebuild for bot_bot_1 always necessary to pull in the updates?
I feel like I saw something about a faster way but I don't remember
No, docker compose up without --build will work because the bot source code is stored as a volume
So the container itself will be cached, so it'll be faster
I've only done sudo (which docker-compose) up ... is that the wrong command?
(I don't have rootless docker set up ATM)
did you stop the container before doing that?
^CGracefully stopping... (press Ctrl+C again to force)
Stopping bot_bot_1 ... done
Stopping bot_web_1 ... done
Stopping bot_snekbox_1 ... done
Stopping bot_redis_1 ... done
Stopping bot_postgres_1 ... done
~/programming/oss/bot on ๎ main [!] is ๐ฆ v1.0.0 via ๎ v3.8.5 took 3m16s792ms
โฏ sudo docker container ls --all
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ac18a4d9500a bot_bot "python3 -m bot" 17 hours ago Exited (0) 19 seconds ago bot_bot_1
174aca225190 ghcr.io/python-discord/site:latest "python manage.py ruโฆ" 18 hours ago Exited (137) 8 seconds ago bot_web_1
5a9e384a0b37 ghcr.io/python-discord/metricity:latest "bash entry_point.sh" 18 hours ago Exited (0) 3 minutes ago bot_metricity_1
323de1e0ab48 ghcr.io/python-discord/snekbox:latest "gunicorn -c config/โฆ" 18 hours ago Exited (0) 18 seconds ago bot_snekbox_1
4a156024b581 redis:5.0.9 "docker-entrypoint.sโฆ" 18 hours ago Exited (0) 18 seconds ago bot_redis_1
f38cafd4ccaf postgres:13-alpine "docker-entrypoint.sโฆ" 18 hours ago Exited (0) 20 seconds ago bot_postgres_1
preassumably?
it doesn't seem to be, I added a runtimerror within the set_command method of bot.exts.info.doc and it's not crashing :/
huh that's really odd, I don't think running it as sudo should have any affect
but also I run on a windows host so can't be sure
can you shove a error log in say the dunder init of bot and see if it appears?
web_1 | Applying migrations.
web_1 | Operations to perform:
web_1 | Apply all migrations: admin, api, auth, authtoken, contenttypes, home, sessions, sites, staff
web_1 | Running migrations:
web_1 | No migrations to apply.
web_1 | Collecting static files.
bot_1 | 2021-10-10 16:53:07 | bot.monkey_patches | DEBUG | Patching send_typing, which should fix things breaking when discord disables typing events. Stay safe!
bot_1 | 2021-10-10 16:53:07 | discord.client | WARNING | PyNaCl is not installed, voice will NOT be supported
bot_1 | 2021-10-10 16:53:07 | bot | ERROR | please show up >.<
bot_1 | 2021-10-10 16:53:08 | deepdiff.diff | INFO | jsonpickle is not installed. The to_json_pickle and from_json_pickle functions will not work.If you dont need those functions, there is nothing to do.
web_1 | Creating a superuser.
bot_1 | 2021-10-10 16:53:08 | bot | INFO | Cog loaded: Big Brother
web_1 | Admin superuser already exists.
bot_1 | 2021-10-10 16:53:08 | bot | INFO | Cog loaded: Clean
yup ๐คท
please show up in the middle
whelp then it's debugging time before I even develop a bugfix :p
Where did you add the error? when you run the command, does it just add the doc fine?
diff --git a/bot/exts/info/doc/_cog.py b/bot/exts/info/doc/_cog.py
index e7710db2..c3268c32 100644
--- a/bot/exts/info/doc/_cog.py
+++ b/bot/exts/info/doc/_cog.py
@@ -396,6 +396,7 @@ class DocCog(commands.Cog):
"inventory_url": inventory_url
}
await self.bot.api_client.post("bot/documentation-links", json=body)
+ raise RuntimeError("no")
log.info(
f"User @{ctx.author} ({ctx.author.id}) added a new documentation package:\n"
how odd
I'm just going to assume PEBKAC unless I hit something similar again ๐
problem exists between keyboard and chair
-> me doing a dumb-dumb somewhere
aka layer 8 issue
wrong server 
nope haha
phew
well, let's see how many review comments a 9 lines PR will get :D #dev-log message
oh fun I forgot to push my changes
Challenge accepted
Hello I am here to bikeshed, please stay calm.
awesome
what does the api response json look like
{'package': ['documentation link with this package already exists.']}
It would be sorta nice if the api gave error codes, checkin' in strings always feels a bit meh
{'package': 'pyth', 'base_url': '', 'inventory_url': 'https://docs.python.org/2/objects.inv'} on success
@vale ibex is there any specific reason why we haven't merged bot#1865 (stalling for something, another thing is broken, etc)?
Yea, there's a typo in the message and wookie had a could do for extra handling
Once the typo is fixed I'd be fine with merging and Richard has the option to do wookie's suggestion
Hmm, wookie's suggestion might be better fixed in the site
so it gives a meaningful error
core devs pls provide any additional constraints/implementation details: https://github.com/python-discord/bot/issues/1866
I'll be busy with some other stuff so once I fix the typo merging seems like the better call
๐
what's the current api response if it's too long right now?
wookie said it's the exact same
well that's not great
yea, i think we shouldn't special case it here
the problem is the site reports the wrong message
so we should fix the site api
Agreed.
So I considered that, but it's a lot more interaction required to bulk subscribe/unsubscribe vs toggle buttons
The idea with buttons is that they can be toggle buttons, so when a user clicks them, the text updates to reflect that they now have the role, and the user cna click again to remove the role
it'll be 2 for now
can't see it going over 5
Off the top of my head: Announcements, PyWeek, Python Trivia Night, Code Jam, maybe even Pixels
The idea is it'll be useful for ad hoc events where we want a temp self-assignable role for announements
A lot of this will be blurry with if it should be in lance
So even if there are more, they won't be all the time
we could add it to the branding cog and have that cog validate the id
So in the event md you'd also specify an announcements role id
shoot, I just realized I didn't escape the package name in my error handler, it's probably fine?
other than some fun markup presumably nothing bad could happen?
Yea, it'll be fine. The command itself is mod only, and the bot has strict allowed_mentions
so it won't cause issues
ofc nothing wrong with belt and braces though
IIRC the package name is checked against a regex (smth like [_0-9a-z]) before the request as well so there's your braces ๐
package_name_validator = RegexValidator(
regex=r"^[a-z0-9_]+$",
message="Package names can only consist of lowercase a-z letters, digits, and underscores."
)
so it is ๐
I think it does indicate that the error is caused by it being too long in the response, sorry, should have been more clear
Ahhh alright
I think it's pretty unlikely we'll encounter that error unless the server changes to a Welsh server or something though lol
It would be nice if the site api gave error codes for these sorts of things
Maybe that's something we could have in the new API
perhaps even through all endpoints
like
every response with an error supplies an error code
RE: sir-lancebot#859, it should be good to go. Just pending reviews from Xith and Dennis
@vocal wolf what do you think about #859 and sir-lancebot#860 (only one of these are mine)
small update on that poetry bug from previously, to solve it for myself I wrote a script that parses the poetry.lock file to export a requirements.txt in my ci, since it only takes a second to run rather than poetry taking around 15 seconds to run.
for those that didn't see scaleios' project yet ๐ https://github.com/python-discord/site/pull/612
specifically: https://deploy-preview-612--pydis-static.netlify.app/
We're a large, friendly community focused around the Python programming language. Our community is open to those who wish to learn the language, as well as those looking to help others.
static deploy previews for site!
I want to hire banks PR full time please
HELL yeah
i'm just ultra hype around this it's so cool
i still don't know how it works
Joe Iโm not convinced you didnโt come up with this after the first admin meeting
Itโs an html scrapper
i mean i won't not take the credit sometimes my brain waves are just that immense that i forget my idea
but i just pumped out buzz words you did the dirty work
Between the both of us, we make a functional person
exactly, the hivemind continues
Hey! Do I need some kind of formal approval to implement api#19 and api#20? They're fairly easy changes. ๐
@molten perch fyi I'm planning to do api#20 myself
No worries; I would've assigned myself but for some reason I can't on the API repo
Hello long time, I would start mentioning the review changes from Sunday ๐
Hey! Are you also planning to implement the OffTopic names Endpoint for the API?(and the corresponding tests, as well)
yeah
Could someone take a look at sir-lancebot#857? It's close to the finish. ๐
Hey! Is there a consensus about whether the API is going to use Async SQLAlchemy, or not?
ngl but the other repos have in their template if you want to do it yourself
Hi all, sir-lancebot#699 will be delayed due to my laptop being in need of repair.
Or whatever the new pr number is
Alembic setup is still remaining, so if you had like to do it you may go ahead as I don't think ves is getting enough time to do it
Anyone know why lint is failing on sir-lancebot#901?
What happens if you manually run flake8?
bot/exts/fun/madlibs/madlibs_templates.json does not end with a newline and there is a bunch of trailing whitespace
Ohhh
How do you do that?
Also if flake8 was not skipped then it probably would have just caught a syntaxerror
poetry run task lint
poetry run pre-commit run -a should run it for you, along with the rest of the pre-commit hooks
K thx
K thx
Oh wait, poetry run task lint is equivalent, nvm
You can also do poetry run precommit to install the hooks so you can't commit without the lint passing
Oh ok thx
also if you don't want to wait for them to install the first time
poetry run pre-commit install --install-hooks
The command that I was thinking of was flake8 madlibs.py
Ok thx
Also @sleek steppe I don't see any whitespace in the JSON, maybe I'm missing something?
If you're committing locally then you can just run the lint
and it will fix the whitespace automatically
Oh ok thx
I get this when I run that:
Oh wait I don't think so hold up
brad helper ๐ congo
@patent pivot Now I get this:
uhh yeah you need git, so you'll need git bash or however you get git on windows
Oh ok
Found a uncaught error in xkcd command sir-lancebot
Will open an issue in sometime, if someone didn't
We've had a lot of new staff recently ๐
brad, mina, and me in past three weeks IIRC
ah and etrotta too
Congrats to all of you! (ok ok, I know it's off topic)
So @patent pivot I installed git and poetry run task lint works now, but I'm getting this and can't figure out on what lines the errors are happening
not much I can tell you other than what it says, you should be using 4 spaces for indentation but have used tabs, so it's flagging it up as a complaint
Oh ok let's see what I can do
So you're saying I have to physically type 4 spaces for each indentation instead of tab even if tab gives you exactly 4 spaces?
unless your editor is converting a tab to 4 spaces, a tab is not guaranteed to give you 4 spaces equivalent
A system can configure a tab to display as any amount of spaces
Ok got it thx
oh even you are a helper, didn't notice lol, congo!
Also, if you're not using an editor that can convert tabs to spaces, you probably should. It makes it MUCH easier.
copy madlibs code put it into black formatter online, halff the lint errors would be solved
also enable pre-commit, which would run the linter before commiting
Hey @austere hornet, can you please set up a pre-commit hook to avoid having all of those failed lints?
poetry run task precommit
We don't use Black's style
I know we don't use them, but it would remove the tabs errors and long lines -- half of them, the rest can be followed by flake8
Long line wouldn't be using the right length though
and some of the style changes will have to be reverted
yeah
I think autopep8 might be better to fix the errors since it reads config files like tox.ini, .flake8 if present
Autopep8 does not follow enough of our style guide - and actively goes against it in some places - that I would not be comfortable adding it.
For instance, here is a file that violates almost every single rule in our style guide:
https://paste.pythondiscord.com/aqofeforiq.py
Here is how autopep8 handled it (max-aggressivness):
https://paste.pythondiscord.com/okeyaredim.yaml
Here is how it should look like according to our style guide:
https://paste.pythondiscord.com/qaxuhinifi.py
Now, I ran it on the entire codebase, and it generated a minimal diff, so I'm assuming it can follow our style guide when the code is already properly formatted, but for the people that would benefit most from this, I think it would be very confusing.
Why is linting failing, I ran the formatter?
"Well, you see, the formatter doesn't actually follow our style guide"
That is to say, we could consider a formatter, just not autopep8
We have actually considered #black-formatter a while back
https://paste.pythondiscord.com/newelopeno.yaml
But that will still require modifications to the style guide - just not as significant as autopep8
Thanks!
Yeah, makes sense. I might look into that
Yes, will do in a few hours hopefully
Cool!
!remind 6H that
Your reminder will arrive on <t:1634059397:F>!
Oops didn't mean to ping that time
I guess it would be amazing if trivial things like formatting errors could be fixed with script. I'm not sure why there are few formatters that uses flake8's errors... the advantage of black (despite not following the style guide fully) of course, is that it can be used in CI to --check whether the code is properly formatted and help you fix it automatically during development or before committing. maybe I'm missing something big here, but it isn't that hard to parse flake8 output and automatically fix (known) formatting errors[^1], so one could possibly have a scripted that accepts flake8 output as stdin so it can fix the trivial things? especially things like trailing whitespace. (Actually doesn't pre-commit automatically fix up some things?)
^1: as I understand it linting != formatter check -- so of course linter could fail after formatter is run (but yeah thanks for pointing out, autopep8 is actually worse than black. I didn't used a concrete example like you did when trying it out)
Of course one could argue this is the job for the IDE (and sure for stuff like trailing whitespace it makes total sense) but not everyone may be using a python-dedicated editor or have really good python support setup. For example, I use nvim with python LSP and it warns me unused variable, line too long etc. but it doesn't take into account config files in the project.
I hear you, but yeah for the most trivial of things, we do use extra formatters to fix them (though they don't take into account flake8). Trailing whitespace, missing newlines, wrong file endings are all fixed by pre-commit.
Having built a tool which fixes exactly one flake8 error (single to double quotes), it can get pretty complex.
Regardless, I don't see it as too much of a problem. I'm in the habit of writing okay-ish looking python code before any formatting, and any errors are pointed out to me before I commit (pre-commit), so I almost always never mess up linting. Ofc that isn't always viable, for instance, it won't help when commiting from the github UI, but I believe it's always viable where an automatic formatting script is.
One more tool we can add with little difficulty is some sort of import manager, possibly isort. I think Akarys was looking into that, but that's one error less
There is also the fact that for the case in question, it seems pre-commit wasn't set up before commiting, and linting was not run at all, and obv for those cases we can't do anything
You mean the Alembic setup or the endpoint?
(Sorry for the late answer)
alembic setup, and its fine
Oh,it has already been assigned to @clever wraith .
oh yes, I shall do that
If it is reviewed before this weekend, hell yeah
for your subscription command issue, how about we configure the roles in the config, something like this:
roles:
pyweek-announcements:
id: 1234567890987654321
about: "Get notified about pyweek announcements!"
I don't think these should be in config
@vale ibex you had some opinions about this. Should these roles be defined in the config or would something like constants.py make more sense? -- lol you beat me to it
we should have the role ID's in config, the ones that are used by the subscribe command should be a constant in the cog file itself
Agreed
Yeah, that makes sense to me. I want to be explicit in the file itself which roles are being added, not by running down some yml file
yea, in the cog file I expect there to be something like ```py
ANNOUNEMENT_ROLES = (
constants.Roles.subscribe_role,
contsants.Roles.pyweek,
)