#dev-contrib

1 messages · Page 177 of 1

surreal veldt
#

Can asyncpraw be added to the docs command?

vale ibex
stable mountainBOT
#

Added the package asyncpraw to the database and updated the inventories.

vale ibex
#

!d asyncpraw.Reddit

stable mountainBOT
#
class asyncpraw.Reddit(site_name: Optional[str] = None, config_interpolation: Optional[str] = None, requestor_class: Optional[Type[asyncprawcore.requestor.Requestor]] = None, ...)```
The Reddit class provides convenient access to Reddit’s API.

Instances of this class are the gateway to interacting with Reddit’s API through Async PRAW. The canonical way to obtain an instance of this class is via...
vale ibex
#

using it on an actual class/method will work

surreal veldt
#

Oh okay thanks

vale ibex
#

can you find the class in the docs?

brazen charm
#

I think it may be, but I can't really get anything to work. Documenting the typevar with either a comment or a docstring under didn't change the error. When I let it emit all warnings it also can't resolve the Callable uses, not sure if that needs to be brought into scope for sphinx or something

clever wraith
#

Remove write-protected folder (y/n)?

gritty wind
#

I’ll look into it, but no promises yet. We might just have to disable symbols for that typevar which wouldn’t be great but

gritty wind
#

This is wonderful

#

Running sphinx with -v complains about a different not found symbol than running with -vv

#

How does verbosity affect the problem, well...

#

haha

brazen charm
#

It looks like it works if they're public an exported, thought I tried that but apparently I didn't correctly. Though it's having problems with the paramspec as it's trying to use it as a normal typevar

#

and callable is still messed up

tawdry vapor
#

Maybe sphinx doesn't work with ParamSpec yet?

brazen charm
#

Yeah, it looks like it's happy if I make it a typevar before the TYPE_CHECKING if so it can find it, and then patch an attribute it tries to access from the paramspec

#

How should a decorator be documented to expose what the wrapper raises? Should I just add a raises to the function that creates the decorator?

tawdry vapor
#

No I don't think that would be correct.

#

Maybe the best way is to just write it out as a sentence that's part of the summary.

#

Or description/body. Whatever the proper term is.

gritty wind
#

I've done some more testing, and I think this is actually not at all related to TypeVars

#

We just don't have a proper handler for unexported internal references

#

Sphinx has support for adding one

#

I'll draft something up

#

Minimum repro:

class A:
    ...

class B(A):
    """Abc."""
    ...

With B exported. Substitute A for generic, and you're at the same point we started

brazen charm
#
__all__ = ["CommandOnCooldown", "block_duplicate_invocations", "P", "R"]

_ArgsTuple = tuple[object]

P = typing.TypeVar("P")
"""The command's signature."""

if typing.TYPE_CHECKING:
    from botcore import BotBase
    import typing_extensions
    P = typing_extensions.ParamSpec("P")
    P.__constraints__ = ()

R = typing.TypeVar("R")
"""The command's return type."""

builds for me, though it only sees the typevars. Haven't really been able to get it to have proper typing while satisfying whatever sphinx wants as it doesn't like the P TypeVar under an else for TYPE_CHECKING

tawdry vapor
#

Thoughts on removing the extra space before the code block for eval results?

#

It throws me off sometimes. Looks weird. I dunno

fallen patrol
#

it's too compressed on some devices, and doesn't give the codeblock room to breathe

cold island
#

Hey @vale ibex do you remember when we updated dpy we had that weird bug where pressing a help embed button would cause it to change the embed, but then still load and say the interaction failed?

#

Do you remember what that was about?

vale ibex
cold island
#

hmmm that's really weird. All I did was fix the return button and now it's back

vale ibex
cold island
#

Oh hmm

#

We didn't fix it actually

#

Try !help i and then clicking the search button

vale ibex
#

yea, not sure

#

all I saw was that this was reverted, so not sure what else is causing the issue

cold island
#

The interaction might be hanging

vale ibex
#

this was the revert

#

it wasn't a strict revert, so might be something causing issues still

cold island
#

Ok, I'll investigate, thanks

whole forge
#

ImportError: cannot import name 'music_cog' from 'music_cog'

#

Anyone knows how I can fix this?

cold island
# cold island Ok, I'll investigate, thanks

fwiw the issue was that I had to defer the response. The odd thing is that from the Discord API, editing the original message should be its own type of response, but I wasn't able to do it with dpy so I ended up with making two API calls

fallen patrol
cold island
cold island
fallen patrol
#

yes

cold island
#

Hmm. This is confusing af

fallen patrol
cold island
#

😂

#

I hope you see why these naming choices seem problematic to me

fallen patrol
#

then the other methods are usable

cold island
#

Alr, thanks

cold island
full fractal
#

a wa

vocal wolf
#

a wa

severe tangle
#

what the

solemn vine
#

what's absolute referencing ?

#

relative imports are erroneous afaik right ?

gritty wind
#

Is this part of this server’s docs?

#

But no relative imports are valid

#

A lot of people struggle with the import system and tend to use hacky methods to avoid actually understanding and fixing their systems, but in a well configured system it’s fine

solemn vine
#

i see

#

ll look at it more

solemn vine
gritty wind
#

That sounds about right

solemn vine
#

hmm

gritty wind
#

I see I also missed a part of your question, absolute imports will use the name of the package in the import itself

solemn vine
#

do you know any source where one can learn about imports in depth

gritty wind
#

In my experience, it’s best to get hands on experience with it to see what does and doesn’t work, but let me see

solemn vine
#

oh maybe like import *

#

or importing a already imported library(in file one) from file one

#

right ?

gritty wind
#

We don't allow import * as it creates a mess in terms of scoping for the file

#

But that's not what's relative and absolute

#

An example would better demonstrate this:

#

In our bots, we have all our source code under one bot pacakge (folder)

# To import bot/utils.py
from bot import utils

# utils.py might have a function such as send_message
# we can call it as
utils.send_message()

# We could also do:
from bot.utils import send_message
send_message()

This is all absolute because we start the path from bot.
A relative import would look more like:

If you have a file bot/logic.py, and wanted to import the utils file, you could also do:

from . import utils
# or
from .utils import send_message

We almost never use the latter in our codebase though

solemn vine
#

nice

#

is it not good way of doing it or just a convention for project

gritty wind
#

Are you referring to relative imports, or star (*) imports?

solemn vine
#

and what if the package name is something like "sir lancebot"

solemn vine
gritty wind
#

sir lancebot would technically be a valid package name, but you can't import it because the import statement wouldn't parse it because of the space. You have a few solutions in that case:

  1. Rename the package. Anything that's a valid variable name would work. For instance: sir_lancebot.
  2. Use relative imports
  3. Directly import it using importlib which can accept a string, but this has it's own mess and issues, so ultimately option 1 is preferable.

We just call it bot for sir-lancebot though

solemn vine
#

oh ok cool

gritty wind
# solemn vine relative imports

Relative imports are fine. We usually don't use them because it can make things harder to understand and track, especially since things can move around.

They do have their uses though, and they are used here and there. I personally only find them useful if you have a deeply nested structure that would make it difficult to type out and read the entire path

#

I've just finished skimming the real-python article on imports. They are usually pretty good, if a little long (this one is really long), and I can't see anything that stands out here. https://realpython.com/python-import/

For all the technical and in-depth aspects, I suggest:
https://docs.python.org/3/reference/import.html
Specifically, 5.2.1, 5.3 first section, 5.4 first section, 5.7, and 5.8 would cover most of what you need to know as a user.

If you're already familiar with packages in other languages, the docs are much shorter and straight to the point than the realpython article. The python import system is pretty similar to other languages.

solemn vine
cedar frigate
#

quick question .. I am pressing on with the idea of doing a Sir Lancebot lyrics command. is it better to use an API (with the downsides of a new API credential to manage and another quota) to fetch lyrics, or is it preferred to scrape a web page (assuming such a thing exists) so no additional API keys/tokens are required? still deciding what to use.

#

..or option 3 - scrap the idea 😄

tawdry vapor
#

If the API credentials don't expire then I do not think it's much of a burden to manage - there really wouldn't be anything to manage (just create creds once for production and forget about them).

cedar frigate
#

ok 👍 thanks

tawdry vapor
#

If all the APIs have quotas then it's probably not going to have much effect on users since I doubt the command will be used too much.

#

If anything it would affect the implementation since you'd need to respect rate limits and whatnot. Whether you're willing to deal with that is up to you.

#

Or if you are really keen on doing something with webscraping then that's fine too.

#

Web scraping just tends to be less stable.

#

Anyone else have an opinion?

#

It's sir lancebot so as far as I'm concerned you can do whatever you want within reason.

cedar frigate
# tawdry vapor Web scraping just tends to be less stable.

Thanks for the pointers. Based on that, and real world constraints encounteted while exploring the Genius API, I think I found a way forward:
Use the Genius API to make a search query. This gives back some metadata along with a URI pointing to the song lyrics on their web site. This must then be scraped, as the API doesn't provide an endpoint to get the actual text. But luckily it is a simple scrape one request and bs4 can easily handle.
I'm working on it on my own fork of sir lancebot, though I it's not yet PR-ready. lemon_s_winter

gritty wind
#

I’ve looked into this myself a while back

#

If memory serves they don’t allow you to scrape them as per their ToS

#

In fact, I basically found no free APIs

#

With the recruitment of staff, we did manage to stumble upon one that was undocumented, and the only reference on the internet to it was one SO post comment

#

So I’m willing to bet that’s some shady stuff

#

But you can just link the lyrics link returned by the genius API

#

You dont need to get the lyrics all the way to discord

placid ermine
#

hahahha i remember

gritty wind
#

A few weeks later Spotify literally just implemented the exact same thing

#

One of y’all is a spy and I want my cut

surreal veldt
#

what are the open sir lancebot issues or PR's that one can contribute to?

#

also, were all the #discord-bots pins moved to the website guides yet?

hoary haven
#

not yet, that project is on hold for a bit

hoary haven
#

be sure to check out the same for our other repos as well :)

#

if you see one that interests you add a comment asking to be assigned to it (or ask any questions you may have about it) and a core dev will respond in due time

surreal veldt
hoary haven
#

i'll be looking for a new lead, frontogenesis had to step down due to personal life stuff

#

but at the moment we have some more time-sensitive things that require planning, such as code jam prep

surreal veldt
#

Who can become project leads?

hoary haven
#

from staff members, sometimes we do an open call asking for someone who is interested, other times we have specific staff members in mind that we recruit/ask to become project lead
i haven't decided yet what to do for this specific project

surreal veldt
#

Is there any update on Python bot using slash commands and time soon?

#

Specifically the docs command

vocal wolf
#

@fallen patrol oi m8 status on these PRs? sir-lancebot#982 sir-lancebot#981

fallen patrol
#

!remind 3d are you free again

stable mountainBOT
#
Can do!

Your reminder will arrive on <t:1655868894:F>!

vocal wolf
#

Very well

fallen patrol
#

that's a question for me

#

basically busy rn

vocal wolf
#

ty for response

austere hornet
#

@fallen patrol I believe you were also working on sir-lancebot#968. Are you still planning to? Would love to see it implemented.

dusky shoreBOT
fallen patrol
austere hornet
cold island
# surreal veldt bump

Haven't really discussed it. Also dpy is still undergoing breaking changes (especially slash commands) so we're not in too much of a hurry

surreal veldt
#

Is this a good suggestion:
Allow users to send two documentation embeds at once by doing like
!d x, y will send two embeds

surreal veldt
#

I think it's pretty cool, if anyone agrees, am I allowed to make a PR?

brisk brook
stable mountainBOT
#

6.10.2. Membership test operations¶

The operators in and not in test for membership. x in s evaluates to True if x is a member of s, and False otherwise. x not in s returns the negation of x in s. All built-in sequences and set types support this as well as dictionary, for which in tests whether the dictionary has a given key. For container types such as list, tuple, set, frozenset, dict, or collections.deque, the expression x in y is equivalent to any(x is e or x == e for e in y).

For the string and bytes types, x in y is True if and only if x is a substring of y. An equivalent test is y.find(x) != -1. Empty strings are always considered to be a substring of any other string, so "" in "abc" will return True.

brazen charm
#

I don't think parsing multiple symbols is worth it, as compatibility with sending a message after the symbol should also be kept and would complicate things more for not that much of a benefit

surreal veldt
#

Well, I think an example of where it'll be useful can be #discord-bots

#

Although I don't get

compatibility with sending a message after the symbol should also be kept

#

Oh nevermind I get it

#

Can't something like how the rule command works be done?

#

You can have multiple rule indices with a text after the indices

brazen charm
#

rules don't need to deal with the ambiguity of what's a word from the message, and what is a doc symbol. It can definitely be done, but I'm just not of the opinion that it'd be worth it considering you can wait a bit and invoke the command again if it's necessary to send multiple embeds

severe tangle
#

PyWeek Champions Embed

vale ibex
#

hah thanks, that one has been in there a while apparently

surreal veldt
#

the count function is not in the !docs?

vocal prairie
tawdry vapor
#

It's just the way the Python docs are structured

vale ibex
surreal veldt
#

is it something that can be fixed, or due to what Mark said, it can't?

vale ibex
#

It's something that needs to be fixed in the CPython codebase itself

#

hence the CPython bug issue

#

We could special case it in our docs command with some amount of effort, but we haven't wanted to

cold island
#

head scratch does anyone have an idea what's going on here? I copied it from last year's page. It works there, here it gives this error

vale ibex
#

Is there a {% load staticfiles%} in the file?

#

I think just {% load static %} works too

#

needs to be after any extends tags

cold island
#

Aha!

#

Thanks

surreal veldt
#

why does the !eval not support the help() method?

gritty wind
#

So python has a site module which includes a couple things, one of which is help. You can read more about that here:
https://docs.python.org/3/library/site.html

Snekbox disables it as a consequence of passing the -S option to avoid exposing snekbox’s dependencies (dependencies of the API calling snekbox not the evaluation layer, such as falcon or gunicorn)

#

You can still manually load it and execute it to get it if you need it

surreal veldt
#

what does this mean? You can still manually load it and execute it to get it if you need it?

vale ibex
#

you can do import site in your snippet

gritty wind
#

import site; site.main()

#

This at the top of your script

surreal veldt
#

site.main() does what?

gritty wind
#

It’s in the docs. It adds all the standard search paths removed by the S option, which adds back what was removed

#

Chris was more right, you don’t need to call main yourself. It’s called when importing

#

Wait no

#

You do need to call it

surreal veldt
#

so i did it in #bot-commands but it error'd again

vale ibex
#

yea you need to call .main() since we use -S

surreal veldt
#

oh okay thanks

#

what's the limit of lines in the eval command output?

gritty wind
#

Ten lines or 1000 characters

#

Whichever comes first

surreal veldt
#

how'd I get 11 in #bot-commands?

gritty wind
#

It counts the number of \n which is one off from actual lines

#

Meaning you get > 11

cold island
#

Also, why did the static preview fail 😦

gritty wind
#

GitHub is ratelimiting us

#

But their API does not allow us to get a read-only token, so the only way around the limits is giving netlify a write token, so anyone that modifies the build script can write anything to our main branch on all our projects 😄

cold island
#

wonderful

gritty wind
#

I’m thinking of having an intermediate which uploads the build off GitHub so we can pull it more easily

#

It’ll simplify like 3-4 steps in the script

#

I just don’t know where

#

Dropbox lmao

vale ibex
#

we've got a shit load of storage that we will likely never fill

gritty wind
#

Would that pose a security risk for PRs

vale ibex
#

depends how much we can lock down rsync

subtle kraken
#

what about uploading it to random discord server and pulling from there?

vale ibex
#

lol

gritty wind
#

Actually

#

Github apps might work for this

vale ibex
#

you cna place a file that gets built from an action to our servers?

#

and then have a github builder do something with it

gritty wind
#

I don't know, my jank detector just fired up automatically when it detected "Warning: Uploading untrusted content to prod servers"

vale ibex
#

hah yea

gritty wind
#

Well you can rewrite the action to upload anything

vale ibex
#

it doesn't get ran nativly though right

gritty wind
#

The vector is basically unlimited access to a rsync to our servers

vale ibex
#

unless you can also change the path to overwrite something like /etc lol

gritty wind
#

This is where my lack of knowledge of rsync limits me

vale ibex
#

it should be fine if
1- we hardcode the path
2- we require devops approval to change the action

gritty wind
#

@patent pivot could you look into github apps? Can we get one with just read access to our public repos, and nothing else

#
  1. Is that something github can do
#

Specifically limit it to changes

vale ibex
#

we have it via policybot atm

gritty wind
#

I don't follow

#

I mean you can cause the exact same damage on a PR or master

#

You don't need to merge for the vector to apply

vale ibex
#

actions are always run from main

#

and changes to the actions in main require a PR with devops approval

gritty wind
#

I still don't follow

#

Like you have the action, which runs on PRs, and has access to a token

#

Modifying it does change what the PR runs

vale ibex
#

Yea, but all the action does is push a build artifact to the server

#

on a hardcoded path

gritty wind
#

Right, so 2 is not a real possibility then

#

Just 1

vale ibex
#

wdym not a possibility, we already have it?

gritty wind
#

I mean you can do the exact same thing on a PR that you can on main wrt the concerns from having an rsync anyone can access

vale ibex
#

if you change an action in a PR, the actions that run are still the ones that are in main

gritty wind
#

That isn't true though

#

I mean, I can pull up any of my PRs which add or change actions

#

They run too

#

It added a whole new action as well

cold island
gritty wind
#

Diff is too small, won't make a dent

#

Get gud

#

I'll try to review it once netlify works again

#

I'll rerun

#

Nope, still 403

vale ibex
#

any PR that uses pull_request as a target, and then checks out the head branch uses the action from that branch

#

So yea, it would open us up to any staff member being able to change things

gritty wind
#

Wouldn't it be any non-first time collaborator?

#

Actually, we don't have that limit enabled, so any collaborator

vale ibex
#

apparently ```
Only users with write access to your repo can push to and create new branches in your repo, so it is assumed that they are trustworthy.

If the head branch is in a forked repo (external contributor), there is no access to secrets in the workflow. They will simply be not set. This applies to on: pull_request

#

If that's the case then external contribs just wouldn't get previews then

vale ibex
#

this isn't from your changeset though

#

no idea when it was added

#

also inconsistent capitalisation PepeHands

gritty wind
#

I'm experimenting right now

#

But you can get very specific with what you enable and disable

#

And everything can be set to read-only, or read/write

#

That will be installed per-repo

vale ibex
#

That does sound promising

cold island
#

Oh hey the preview succeeded this time

gritty wind
#

Alright, I think I found a blocker for apps

#

To use the API with them, you need to generate a JWT, which is only allowed to last a max of 10 minutes. Generating this means keeping the app's private key accessible to the netlify build, or hosting an independent signing server to generate the JWTs (this is a no go).

If the worst that can be done is generating a JWT with the read only scopes, then we can live with that. I'm not sure if this exposes us to anything else though, that's what I'm figuring out now

#

Yeah this whole thing seems like a dead-end

#

That's a shame

gritty wind
#

@vale ibex I've documented all the things I've thought of/tried so far. Would appreciate if you could give it a look and add your thoughts

#

site#728

dusky shoreBOT
vale ibex
gritty wind
#

Thanks

stable mountainBOT
timber meadow
#

so i wanted to update the discord logo in the navbar for python-discord/site but ive hit a roadblock.
if i use the discord logo as-is, the new blurple color doesnt match with the rest of the site's colors, so it looks a bit off, and discord.com/branding says

Please do not edit, change, distort, recolor, or reconfigure the Discord logo.
i guess this means i cant change the color to match with the rest of the site

further, i couldnt find the new discord logo font to use for the "Join Us" text

so, this leaves 4 options:

  1. dont change anything
  2. update the logo and every other bit of branding with discord's new blurple color
  3. just update the logo without modifying it as per discord's requirements
  4. update the logo and change the color
    (the question of the font still remains)

personally i think option 1 would be the easiest and safest. only after spending a good amount of time updating the svg did i realize that the new logo doesnt match the colors haha (was about to open a pr too). i guess this is why no one has bothered to update it in the past year, and my apologies if this has already been discussed. i would like to get some higher-ups input on this, thanks.

tawdry vapor
#

When Discord changed their branding, I think it was decided that our site would not follow suit.

timber meadow
#

very well, thank you

gritty wind
#

We don’t need to use the background from the discord logo, we can just use the actual icon, and place it on our own background

#

Aren’t we already using the latest icon tho

vale ibex
#

the website is using the old Discord icon in the join us button

vale ibex
#

page 41 of the guidelines

stable mountainBOT
#

Hey @timber meadow!

It looks like you tried to attach file type(s) that we do not allow (.svg). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a, .csv, .json.

Feel free to ask in #community-meta if you think this is a mistake.

timber meadow
#

heres my updated svg. i recolored the logo to match the site though which probably isnt ideal (screenshot because bot didnt let me upload svg)

gritty wind
#

We’re using the grayscale icon on mobile, so I assumed we were doing that on desktop

#

Don’t see why we couldn’t

#

It would be inline with their policies, and won’t require clashing colors

vale ibex
#

which is updated for free

gritty wind
#

That’s probably why we’re on the latest for mobile (and forms 💪)

vale ibex
#

we wanted to be fancy on desktop

#

a nice animated, sliding svg

vale ibex
atomic ivy
#

new help channels sometimes show up at the top of the list. #help-peanut is a newly claimed one now, for example

gritty wind
#

The placement logic is as simple as it gets. Request the category, read the number of entries, and set the position to that +1

#

The only way that fails is when discord returns wrong data or just does not respect our request

#

I don’t see a way to fix it

atomic ivy
#

I see. usually people don't check channels at the top, so the helpee may not get the help, but yeah, I understand

gritty wind
#

It might also be caused by our cache not being correct, but that’s managed by d.py so there’s no clear action there either

vale ibex
#

this one?

timber meadow
#

i didnt change the text at first

#

i can try that and see how it turns out now that i know the font name

vale ibex
#

you can just use the svg directly in their press pack

#

it has the correct padding etc

timber meadow
#

what about the "join us" text?

vale ibex
#

For the colour one, you can use the Mark only logo, might be worth seeing what that looks like with the discord font

#

for the white side, I'd just use the full white logo

timber meadow
#

i think if i change one half i should also change the other for consistency

#

alright i'll do that right after breakfast

vale ibex
#

Cool cool, thanks :D

timber meadow
#

grey background is just for visibility

#

this is with the old text

vale ibex
#

I think we definitely want the new text on the right

#

I'm more interested to see what the new text looks on the left

timber meadow
vale ibex
#

I like that

timber meadow
#

so what about the color?

vale ibex
#

I'd need to see it in-app to make a call on that

#

preferably we use the discord colours as stated in the branding guidelines

timber meadow
#

agreed

vale ibex
#

Are you familiar with git/github?

timber meadow
#

yes

vale ibex
#

alright awesome, if you open a PR to the site repo, replacing pydis_site/static/images/navbar/discord.svg our CI will create a deployment preview

#

we can see what it looks like in the site then

timber meadow
#

perfect

timber meadow
vale ibex
#

I think so

timber meadow
#

guess we'll find out

vale ibex
#

hah yea

timber meadow
vale ibex
#

yup

#

😎 Deploy Preview deploy-preview-729--pydis-static.netlify.app

#

from the comment

#

on hover seems to be falling back to a default font

timber meadow
#

works fine for me

#

oh probably cause i have the font installed

vale ibex
#

I'm guessing you have the font installed on your PC :P

timber meadow
#

maybe i can fix that in inkscape somehow

vale ibex
#

I think we either need to serve a .ttf file, or we use a fallback font in the svg itseelf

#

from the branding guides it says Ginto Nord could be replaced with Poppins Black (all caps). Whitney could be replaced with Roboto Normal.

#

as fallback fonts

timber meadow
#

i think i can just convert the text to paths in the svg

vale ibex
#

I am really unfamiliar with typefacing in svgs

#

@crude gyro @exotic ember I see you're both online do either of you have time to assist?

#

Picking on you since I know you speak svg

timber meadow
#

pff it was as simple as clicking one button 🤦‍♂️

vale ibex
#

oh lol

timber meadow
#

and running one google search to know which button to click of course

crude gyro
#

yeah convert them to paths.

vale ibex
#

that looks real nice

crude gyro
#

screenshots? on mobe

timber meadow
vale ibex
#

white is on hover

timber meadow
#

the color still bugs me

vale ibex
#

Yea, Discord updated their colours, but we stuck with our own to be more distinct from Discord themselves

crude gyro
#

their new font is so so ugly.

timber meadow
#

i agree 100%

vale ibex
#

Yea, I dislike it too lol, but it their brand

crude gyro
#

Discords whole new branding is godawful, honestly, but it's nice to update this so it uses it anyway.

vale ibex
#

we could change the font for join us though

#

since that's not technically part of their branding, but it may make it look worse

timber meadow
#

we could also replace the blurple with black as Scaleios suggested since that would be inline with their policies

vale ibex
#

Yea, that's a good point, might look good

timber meadow
vale ibex
#

hmmm, I'm not too sure about that to be honest, it does lose something without the splash of colour

timber meadow
#

true

vale ibex
#

I think the best version is the one currently in the PR

exotic ember
timber meadow
#

just for fun, recolored with the old blurple color

vale ibex
#

Could you add those 3 screenshots to the PR for ease of access for people?

timber meadow
#

sure thing

vale ibex
#

Well, the most recent 2 screenshots and then a similar one for the "correct" blurple colour

vale ibex
#

we've figured out the blocker, and just looking for colour opinions now

exotic ember
timber meadow
full fractal
#

*gasp*, review has been requested from me 👀

crude gyro
#

I do feel like the capital U in Join Us bothers me though.

#

why would that letter be uppercase

#

I can't think of any justification for it

gritty wind
#

Not a big fan of title case I take it

crude gyro
gritty wind
#

Hah

crude gyro
#

just looks like a motivational poster from grandma

Your A Star And Believe In Urself!! 🌟

#

thanks grandma

crude gyro
#

yeees

#

now I like it a lot.

timber meadow
#

i'll commit this and un-draft the pr

vale ibex
rapid swallow
#

left: when I connect to uni wifi through their proxy
right: when I connect the laptop to mobile hotspot

#

oh, and when i type http://0.0.0.0:8000/ in my browser, the website loads when I'm connected to mobile hotspot but not when I'm connected to the uni proxy

#
ERROR
The requested URL could not be retrieved

The following error was encountered while trying to retrieve the URL: http://0.0.0.0/8000

    Access Denied.

Access control configuration prevents your request from being allowed at this time. Please contact your service provider if you feel this is incorrect.

Your cache administrator is *****

this is what I get

#

I havent tried running docker in windows yet, this is in linux

rapid swallow
#

ping me when replying \🥺
I'm gonna sleep ✌️

#

Scaleios, didn't you have to wrestle with your uni's proxy? joe_shrek

vale ibex
vale ibex
full fractal
fallen patrol
#

Hi where can i report a snekbox exploit pls kthx

#

@patent pivot already knows about it but its been quite a few months and I see no progress so I want to get it officially on the books somewhere so it can be patched

patent pivot
#

uhhh

#

DM me it again to remind me what it is

full fractal
#
Subject: [PATCH] Help: remove redundant space in subcommand aliases

`parent` already has a trailing space so let's not add *another* one.
---
 bot/exts/core/help.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bot/exts/core/help.py b/bot/exts/core/help.py
index db3c2aa67..f9b3513fe 100644
--- a/bot/exts/core/help.py
+++ b/bot/exts/core/help.py
@@ -306,7 +306,7 @@ async def _add_command_signature(self, paginator: LinePaginator) -> None:
         signature = self._get_command_params(self.query)
         parent = self.query.full_parent_name + " " if self.query.parent else ""
         paginator.add_line(f"**\`\`\`\n{prefix}{parent}{signature}\n\`\`\`**")
-        aliases = [f"`{alias}`" if not parent else f"`{parent} {alias}`" for alias in self.query.aliases]
+        aliases = [f"`{alias}`" if not parent else f"`{parent}{alias}`" for alias in self.query.aliases]
         aliases += [f"`{alias}`" for alias in getattr(self.query, "root_aliases", ())]
         aliases = ", ".join(sorted(aliases))
         if aliases:

Fixing this should only (hopefully) require this tiny change.

outer oasis
#

(just curious)

full fractal
#

this felt like lower overhead i.e. less work

#

but I guess in hindsight this is more work since I have to wait

#

I'll just file an issue instead.

rapid swallow
#

And cogs aren't loaded

rapid swallow
#

But the bot doesn't come online 😩

#

I'll have to connect to my phone's hotspot everytime I use docker then

rapid swallow
#

but the bot still doesn't come online on discord

#

(when I'm using cellular internet/mobile data/mobile internet by connecting to my phone's hotspot)

#

back to sleep I go

#

for in sleep, uni's proxy cannot fuck with me

gritty wind
#

I didn’t have issues with the bot no

#

But it seems the site itself is up, it’s just the bot that isn’t starting

vale ibex
#

What command are you using to start it?

rapid swallow
cold island
gritty wind
#

It’s the same on windows

#

Could you pull the logs for just bot from the docker desktop app

#

(When it fails to start)

fallen patrol
#

how does pydis do zero downtime updates with k8s?

#

specifically with the bots here

cold island
gritty wind
gritty wind
cold island
#

Should be

gritty wind
#

I mean

#

What was different for you

cold island
#

Not sure, it just failed to connect to site

gritty wind
#

Sounds unrelated or like a misconfiguration. Right now it should basically just be an alias

cold island
#

Well it definitely didn't work with one and worked with another

vale ibex
#

Yea, docker compose and docker-compose are different apps, even on windows

#

docker compose doesn't work for me on the bot

vale ibex
fallen patrol
#

ah

gritty wind
#

They are different executables, but they should just work as a drop in replacement. Strange it doesn’t work for y’all though, I suggest trying to figure it out because the docker-compose command still uses the old version, and I imagine it’ll be dropped all together eventually

#

I haven’t had any problems using the one with a space tho

rapid swallow
cold island
#

Then yeah try docker-compose

rapid swallow
gritty wind
#

Its on other OSes too as part of the normal cli, just most people haven’t updated docker in 20 years

#

But the same holds, could you pull the logs from the docker logs command

rapid swallow
#

Yeah i will

#
2022-06-26 03:25:32 | root | INFO | Cog loaded: DocCog
2022-06-26 03:25:32 | root | INFO | Cog loaded: ThreadBumper
2022-06-26 03:25:32 | bot.exts.backend.sync._syncers | INFO | role syncer finished: created `0`, updated `0`, deleted `0`.
2022-06-26 03:25:32 | bot.exts.backend.sync._syncers | INFO | Starting user syncer.
2022-06-26 03:25:32 | root | INFO | Cog loaded: Reminders
2022-06-26 03:25:32 | root | INFO | Cog loaded: Infractions
2022-06-26 03:25:32 | root | INFO | Cog loaded: Filtering
2022-06-26 03:25:32 | bot.exts.backend.sync._syncers | INFO | user syncer finished: created `0`, updated `0`.
2022-06-26 03:25:32 | root | INFO | Cog loaded: Sync
2022-06-26 03:25:32 | root | INFO | Cog loaded: DuckPond
2022-06-26 03:25:32 | bot.exts.moderation.incidents | DEBUG | Crawl task finished!
2022-06-26 03:25:32 | bot.exts.moderation.defcon | INFO | DEFCON synchronized: -
2022-06-26 03:25:32 | bot.exts.help_channels._cog | INFO | Cog is ready!
2022-06-26 03:25:32 | root | INFO | Cog loaded: HelpChannels
2022-06-26 03:25:32 | bot.exts.info.pep | INFO | Successfully refreshed PEP URLs listing.
2022-06-26 03:25:32 | root | INFO | Cog loaded: PythonEnhancementProposals
2022-06-26 03:25:33 | root | INFO | Cog loaded: Big Brother
2022-06-26 03:25:34 | root | INFO | Cog loaded: PythonNews
Found `config.yml` file, loading constants from it.
2022-06-26 12:50:50 | botcore.utils._monkey_patches | DEBUG | Patching send_typing, which should fix things breaking when Discord disables typing events. Stay safe!
2022-06-26 12:50:50 | discord.client | WARNING | PyNaCl is not installed, voice will NOT be supported
gritty wind
#

Is this on the uni network?

rapid swallow
#

yep

gritty wind
#

I thought you didn’t get any bot logs on the network

#

Oh I see, these are from two separate boots

rapid swallow
gritty wind
#

You have logs from 03:00 and 12:50

rapid swallow
#

oh

gritty wind
#

If that’s all in one boot, that’s quite the startup time haha

#

That last log line is from when we init the client

#

That happens on line 55 of __main__.py

#

Could you add some debug print statements around there to figure out if it gets through that part

rapid swallow
# gritty wind Oh I see, these are from two separate boots
2022-06-26 13:10:45 | botcore.utils._monkey_patches | DEBUG | Patching send_typing, which should fix things breaking when Discord disables typing events. Stay safe!
2022-06-26 13:10:45 | discord.client | WARNING | PyNaCl is not installed, voice will NOT be supported

so this is pretty much what i got

rapid swallow
# rapid swallow but the bot still doesn't come online on discord

If i leave it running for a long time I get

Traceback (most recent call last):
  File "/bot/bot/__main__.py", line 73, in main
    await _bot.start(constants.Bot.token)
  File "/usr/local/lib/python3.9/site-packages/discord/client.py", line 682, in start
    await self.login(token)
  File "/usr/local/lib/python3.9/site-packages/discord/client.py", line 543, in login
    data = await self.http.static_login(token.strip())
  File "/usr/local/lib/python3.9/site-packages/discord/http.py", line 557, in static_login
    data = await self.request(Route('GET', '/users/@me'))
  File "/usr/local/lib/python3.9/site-packages/discord/http.py", line 439, in request
    async with self.__session.request(method, url, **kwargs) as response:
  File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 1138, in __aenter__
    self._resp = await self._coro
  File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 634, in _request
    break
  File "/usr/local/lib/python3.9/site-packages/aiohttp/helpers.py", line 721, in __exit__
    raise asyncio.TimeoutError from None
asyncio.exceptions.TimeoutError
rapid swallow
gritty wind
#

Yeah there’s no reason for that to work

#

What zig and Chris experienced is most likely unrelated to this

#

Anyway, that just shows it’s failing to log into discord

#

Could you create an empty d.py project which just calls bot.run

#

With the same intents as bot

stable mountainBOT
#

bot/__main__.py line 71

)```
rapid swallow
#

)
😎

gritty wind
#

It's just the under the hood call to discord login

#

(hence the tb)

#

Is there a good typehint for "pass this particular function", instead of a generic (args), return

cold island
#

Why do you need an argument if it's a constant value?

gritty wind
#

It's not, it's a choice between two funcs

cold island
#

Hmm

gritty wind
#

It's either discord.RemoveRole or discord.AddRole

#

Right now it's documented as a callable, and the docstring says pass one of these two

cold island
#

Literal?

#

Yeah the docs don't limit its use to strings

brazen charm
#

Literal would only work with an enum for something like that

#

just document it in the docstring

gritty wind
#

I'll see if something pops up there

rapid swallow
timid sentinel
#

Should the (bot or sir-lancebot) help command with no arguments display

  • All top level commands and their subcommands
  • Only top level commands
  • Top level commands and subcommands with root aliases
  • Something else

I think our current behavour is option 3 but i'm not sure if that's on purpose or not. I'm thinking we probably just want option 2, would be nice to try and make it more concise.

gritty wind
#

Top level commands and aliases seems best for discoverability, but also 2 sounds fine if it's easier

timid sentinel
#

I think all should be doable, was just thinking that the current 11-page output is a bit of a monster that hurts discoverability more than removing some subcommands would.

#

It's possible it could do with more of a redesign to try and make it shorter anyway though, idk

cold island
#

Keep in mind that regular users see the commands they can run, which is much more limited

gritty wind
stable mountainBOT
#

botcore/_bot.py line 200

self.log_to_dev_log(msg)```
vale ibex
#

but that condition rarely ever gets hit

gritty wind
#

Fair enough

#

I'm fixing a couple misc bugs like that

vale ibex
#

nice nice

cold island
#

@timid sentinel for non-staff the help command gives 3 pages

gritty wind
#

This is new

#

The request to nightly.link is timing out

#

It's usually GH that does that

#

It downloads fine for me hmm

#

Ah they change the url

gritty wind
#

I've opened an issue there since it seems to be an actual issue

gritty wind
#

Hey @brazen charm what's the generic equivalent for typing.Type? Seems to just be type, but that produces a warning Class 'type' does not define '__getitem__', so the '[]' operator cannot be used on its instances

#

It also seems to not like collections.abc

#

Not sure what's up with that

#
bot-core\botcore\utils\caching.py:docstring of botcore.utils.caching.AsyncCache.__call__:6:py:data reference target not found: collections.abc.Callable
brazen charm
#

type should work

#

and Callable from collections.abc is unfortunately bugged in the doc typehint package

gritty wind
#

Ahhh

#

Well we do have the ignore for this reason then

#

The type thing is probably just pycharm being funny

brazen charm
#

would it be referenced correctly with an ignore?

gritty wind
#

It wouldn't, but the warning will be silenced

brazen charm
#

It seemed to be an easy fix and I posted an issue, but I didn't get a reply there

gritty wind
#

Heh

#

Could you link it?

brazen charm
#

tox-dev/sphinx-autodoc-typehints#237

dusky shoreBOT
brazen charm
#

Callable uses a different role in typing for some reason, and it forces that different role for collections.abc.Callable too in which case it's wrong

gritty wind
#

Thanks

#

Hope you get a response soon

#

It's kind of unfortunate right now

#

I might just migrate everything else and leave this

brazen charm
#

I just used callable from typing in the PR I have open for now

gritty wind
#

That's fine

#

Speaking of

#

I wrote something to complement your solution

#

I added a hook for missing-reference which pulls anything from our project and gives a raw link instead of leaving it hanging

#

I've gotta remember to throw that up some time

timber meadow
#

looks like fontawesome fa-duck and fa-alien-monster aren't showing up on pythondiscord.com
any idea why? i searched for both on fontawesome.com under 6.1.1 and it found fa-duck but not fa-alien-monster

exotic ember
timber meadow
stable mountainBOT
#

pydis_site/static/css/home/index.css line 130

line-height: 33px;```
exotic ember
#

PR opened here: site#731

dusky shoreBOT
cold moon
#

Anyone using GitHub Codespaces? If I create codespace from one of PyDis repos, I get DNS_PROBE_FINISHED_NXDOMAIN (MS Edge on Mac).

outer oasis
cold moon
outer oasis
gritty wind
#

@brazen charm re: bot-core#91

Have you had luck with setting the typehint in the docstring? It can't resolve the type var (different error from the other one you had a while back)

dusky shoreBOT
gritty wind
#

bot-core\botcore\utils\scheduling.py:docstring of botcore.utils.scheduling.create_task::py:class reference target not found: TASK_RETURN

gritty wind
#

For some reason just putting TASK_RETURN evaluates as an absolute

#

Gotta give it the full qualified path

#

If I give it the full path, my resolver can link it's source code

#

But sphinx itself does not find it

brazen charm
#

you could document and export the typevar for it to find it, but I think normally for ones that are only in a function's signature they're not linked to anything so it should be fine to ignore

#

Maybe also wrap it in typing.TypeVar(), not really sure if better but it's consistent with what it generates elsewhere

gritty wind
#

The missing-reference handler will catch it either way, so I'm thinking I can add a special condition for type vars to be ignored. What I'm wondering though is if we want to ignore it, or link source code

#

Both would be trivial

#

for reference:

#

I changed source code to source to match the one at the top

gritty wind
#

I've decided to shorten typevars, so now they'll look like this:

#

or that without the source link

brazen charm
vocal prairie
#

!pep 0

stable mountainBOT
#

Sorry, an unexpected error occurred. Please let us know!

AttributeError: 'Context' object has no attribute 'trigger_typing'

vocal prairie
#

^ this has happened for some reason

outer oasis
#

!pep 621

stable mountainBOT
#

Sorry, an unexpected error occurred. Please let us know!

AttributeError: 'Context' object has no attribute 'trigger_typing'

outer oasis
#

huh

placid ermine
vale ibex
#

wtf why

outer oasis
#

Only three results
Doesn't look terrible

vale ibex
#

bot#2203

outer oasis
#

Four*
I'm dumb

outer oasis
vale ibex
#

ctrl_shift_f lol

white light
#

python hastebin is bias against typescript? It redirects .ts and .tsx to .py

placid ermine
#

i think we redirect everything to py

vale ibex
#

it redirects everything to .py, you can add ?noredirect query param to stop it

white light
#

.js works

outer oasis
#

I thought it would allow other extensions if you specified them

vale ibex
#

since we're a Python server, and the hastebin lang detection isn't the best, that's the most correct

outer oasis
vale ibex
#

oh, that's just project wide search

#

in vscode

outer oasis
#

Ah
Does it support regex?

vale ibex
#

yea

#

It's got match case and match whole word options

#

or regex if you want to be specific

outer oasis
#

Damn
It's really catching up to PyCharm these days

vocal prairie
outer oasis
#

I've been playing with CodeSpaces, I'll have to give it a more serious look

gritty wind
#

Pycharm does have the ctrl+shift+f for the same purpose

#

Actually, most editors do (atom, notepad++, etc) 😛

vale ibex
#

Yea

#

huh

#

github isn't triggering the lint test action

#

ah

#

yup

#

github actions down

thorny obsidian
#

😔 is it ever up at this point?

vale ibex
#

It's what you get for using Oracle products lol

outer oasis
#

... GH uses Oracle?

vale ibex
#

MySQL

#

for all things non-git

outer oasis
#

Oracle made that?
Don't they have their own database product?

vale ibex
#

it was bought by Sun microsystems

#

so oracle got that when they acquired sun in 2010

#

Around the same time was when it was forked to make mariadb

outer oasis
#

Isn't that Java

#

Oh wait Oracle owns Java

severe tangle
#

Lol

#

So basically Oracle owns the most used Android app making language

green oriole
#

Hey, form unit test code didn't seem that broken lgbeet

stable mountainBOT
#

backend/routes/forms/unittesting.py line 46

# Unite code```
gritty wind
#

hahaha

#

You know I wrote a transpiler for this year's qualifier

#

Fun stuff, fun stuff

vale ibex
#

it's very United

gritty wind
#

You know the programmer mantra

#

Why spend an hour converting tests by hand

#

When I can spend 7 hours writing a program to do it

green oriole
#

oh no you didn't

#

did you write a script to convert a normal unit test to the JSON format?

gritty wind
green oriole
#

that is very funny and very stupid at the same time, and I'm all for it

gritty wind
#

Exactly haha

green oriole
#

what even is that global madness

#

do you have a sample of what it outputs?

gritty wind
#

Yeah one sec

#

The alternative was adding it to every test, and CF was already rejecting my payloads

#

I don't think I leaked any state secrets

#

This should be from the public test suite

green oriole
#

truly amazing code

gritty wind
#

I'm unironically very proud

green oriole
#

honestly that's very good

pseudo igloo
#

👋

#

pleased to meet you all, I'm a bot dev & admin at libera.chat, interested in branching out in to discord

vale ibex
#

@gritty wind mostly because I can't think of a nice way to clear that state in the cog_command_error without impacting other calls

#

so it could become messy

gritty wind
#

Don't we have the cog that failed to unload in the error handler

#

If we have a dict of cog_name: state, I think it could work

#

But it's really not a big deal outside of help_channels

vale ibex
#

yea

vale ibex
#

TIL about git --force-with-lease

#

pretty neat

outer oasis
#

What does that actually do?
I've never understood it

vale ibex
#

it's like --force, but fails if it would overwrite commits from other authors

#

at least afaik

outer oasis
#

Sounds right
The part I get stuck on is if it supports doing partial stuffs
Does it fail to update any commits if just one of them is "wrong"

vale ibex
#

Yea, my understanding is the push entirely fails if it would discard another authors work

#

so it would make you reconsider, or use --force to actually do that

outer oasis
#

Sounds reasonable

green oriole
#

hi

#

the sentry error on form backend is me

#

I may have been messing with unit testing

#

it is a non issue really

vale ibex
#

I'm not seeing any recent sentry errors 😅

#

oh wait, there's a 500 axios error in front-end

#

guessing it's that one from 9 min ago?

green oriole
#

yeah

vale ibex
#

cool cool

green oriole
#

I got the unittesting to 99

vale ibex
#

I will ping joe and scale to fix immediately

#

thank

green oriole
#

lmao

#

also the backend gives much more information about failed tests than the frontend does

#

is that just a "we ran out of time" thing?

thorny obsidian
#

We could only do a css hack because of issues with state. If I tried to show more information it would clear all that was entered, which is non-ideal. We didn't have time to add in proper state handling

green oriole
#

that's fair

#

wait is the text below added by CSS

vocal prairie
#

completely separate, but could we add typing_extensions to snekbox?

thorny obsidian
green oriole
#

lmao

gritty wind
vocal prairie
#

not for code jam, for @stable mountain

vale ibex
#

FWIW snekbox for !eval , and the snekbox for forms are separate

gritty wind
#

In that case, yeah we can add it

green oriole
#

makes sense

#

being able to select what packages to use inside each snekbox eval when

#

the worst part is it is really not hard to do, just add a bind mount for each package

stable mountainBOT
#

deployment.yaml line 53

yarl~=1.7```
vocal prairie
#

could I open a PR 🥺

vale ibex
#

go for it

#

I'm fine with adding it

vale ibex
green oriole
#

is it a snake if it has legs

vocal prairie
#

do I need to like, test it, or can I just trust.

gritty wind
#

I mean that just adds a pop install

#

Nothing to test there

vale ibex
green oriole
#

you'd have to start a k8s cluster to test that

vocal prairie
#

yeah figured

green oriole
#

have those been recently upgraded?

gritty wind
#

No

#

Things in that list are just added/modified when there's a need

vale ibex
vocal prairie
#

!e

import typing_extensions
stable mountainBOT
#

@vocal prairie :warning: Your eval job has completed with return code 0.

[No output]
vocal prairie
#

yayy

#

thanks chris

vale ibex
#

bot-core#96 nice small PR, a simple fix for clients that don't want to use statsd

dusky shoreBOT
vale ibex
#

also @gritty wind is bot-core#91 in a state to be merged?

dusky shoreBOT
vale ibex
#

I see discussions around type hints, but I don't want that to block the bug fixes you have in there

gritty wind
#

They aren't blocking for this PR

#

we can work on it in another PR

vale ibex
#

very good very good

#

I'll roll a release once #96 is merged

#

unblocked sir lance work for now at least :D

vale ibex
#

thanks @cold island for some reason it didn't come up in #dev-log

cedar frigate
#

can somebody look at my command and give some feedback

#

also should i open an issue (it's for the lyric command @tranquil topaz and i were talking about) or is it ok to just link to our discussion about it

#

thanks ❤️

green oriole
#

Genius' ToS forbid automation

#

You agree to not use the Service to engage in any prohibited, illegal, or harmful activity, including without limitation:
4. harvesting or collecting, through use of automated scripts or otherwise, the contents of the Service or email addresses, contact information or other private information of other Users from the Service for any purpose, including without limitation for the purposes of sending unsolicited emails or other unsolicited communications to Users or reproducing the content of the Service;
https://genius.com/static/terms

#

You usually want to make an issue before working on it, for reasons such as this

#

If the stance of the core devs hasn't changed, this implementation cannot be accepted

atomic ivy
subtle kraken
atomic ivy
subtle kraken
#

except it does not

#

all I see from their response is link to lyrics, not the lyrics themselves

#
['album', 'annotation_count', 'api_path', 'apple_music_id', 'apple_music_player_url', 'artist_names', 'current_user_metadata', 'custom_performances', 'description', 'description_annotation', 'embed_content', 'featured_artists', 'featured_video', 'full_title', 'header_image_thumbnail_url', 'header_image_url', 'id', 'lyrics_marked_complete_by', 'lyrics_marked_staff_approved_by', 'lyrics_owner_id', 'lyrics_placeholder_reason', 'lyrics_state', 'media', 'path', 'primary_artist', 'producer_artists', 'pyongs_count', 'recording_location', 'relationships_index_url', 'release_date', 'release_date_for_display', 'song_art_image_thumbnail_url', 'song_art_image_url', 'song_relationships', 'stats', 'title', 'title_with_featured', 'url', 'verified_annotations_by', 'verified_contributors', 'verified_lyrics_by', 'writer_artists']``` is all they provide (in terms of keys that you can access)
gritty wind
#

This was brought up a couple weeks ago here

gritty wind
#

And as they've mentioned, this is why we do issues usually, to avoid miscommunication, and clarify details such as this

#

In it's current state, we can not accept it

green oriole
#

I got a 400 missing_discord_data when submitting a form, despite having a submit button available

#

cleared the cookies and it went fine (the login button actually appeared)

#

maybe expired?

cold island
#

yeah it happened to us a few times, trying to figure out what might cause it

green oriole
#

by the way, I can submit a patch for what mina forwarded in the dev channel

#

that's indeed very weird

#

considering

#

do tokens have an expiration

#

yes

#

actually no

#

it is discord expiration, not a standard exp

gritty wind
#

They do expire yeah, at the same time the discord data expires

#

(Doesn’t make sense to keep it once its expired)

gritty wind
#

I can’t get down a solid repro tho, and relogging seems to fix it

green oriole
#

There is a token refresh endpoint, but is it used correctly?

#

If the token is expired I guess you'd want to redirect to the refresh endpoint, but that isn't ideal, ideally the authentication should do that in the background if necessary

gritty wind
#

It does do it in the background

#

But who keeps forms open for 7 days

cold island
#

I never close tabs lol

gritty wind
#

It’s not the reason fwiw

#

I managed to do it twice in like 3 days

green oriole
#

Is expirity correctly set then

gritty wind
#

Set correctly for what?

green oriole
#

Is actually set to a week in the future?

gritty wind
#

The token definitely is, but you might be onto something

#

The cookie the frontend can actually see is out of sync

#

The automatic refresh probably doesn’t set it does it

#

That would explain things

tawdry vapor
green oriole
#

The frontend thinks you are logged in, but not the backend

gritty wind
#

Yeah you’re right

#

It’s a non-consequential bug

#

But I did do more investigation in the mean time

#

One thing the backend does is delete cookies when it runs into issues

#

It doesn’t delete the frontend cookie tho

#

In fact, backend never sets the frontend cookies despite being able to

vale ibex
#

I've had a very naïve look at the auth code

stable mountainBOT
#

backend/routes/auth/authorize.py line 71

await set_response_token(response, request, token, bearer_token["expires_in"])```
vale ibex
#

that should be the same though IG

gritty wind
#

Bearer token is the new token

#

This just avoids having to switch back and forth from datetime to ints

#

Also to be pedantic, token_expiry is a point in time, while this is a duration (7 days)

vale ibex
#

ahh right, that makes sense

stable mountainBOT
#

src/api/auth.ts lines 206 to 207

const expiry = Date.parse(response.data.expiry);
setTimeout(refreshBackendJWT, (expiry * 0.9));```
vale ibex
#

So basing the expiry on that, rather than a diff from the current time seems off

gritty wind
#

No it is a time diff

#

Same 7 days you linked above

vale ibex
#

ahhh yea, mixed up expires and expires_in

gritty wind
#

Tbh

#

It’s a mess

#

Could use a rewrite

#

In fact, if we do away with this JWT nonsense and use the DB

#

It becomes trivial

green oriole
#

and just use an opaque token?

#

Yeah that could make sense

gritty wind
#

I meant more the stateless stuff

#

It’s only so complicated because both the backend and frontend are needed to coordinate refreshes

#

We could still keep JWTs themselves

vale ibex
# gritty wind No it is a time diff

wait, i don't follow this ```py
interaction_start = datetime.datetime.now()
max_age = datetime.timedelta(seconds=int(bearer_token["expires_in"]))
token_expiry = interaction_start + max_age
data = {
...
"expiry": token_expiry.isoformat()
}

...

const expiry = Date.parse(response.data.expiry);
setTimeout(refreshBackendJWT, (expiry * 0.9));

#

in the backend the expiry is the iso date of when the token expires

#

So wouldn't passing that through Date.parse() return a unix timestamp of that date?

gritty wind
#

Oh I see what you’re saying

#

One sec

vale ibex
#

afaik the fronend should be (and excuse my js)

gritty wind
#

Parse returns a Unix time stamp

vale ibex
#
const expiry = Date.parse(response.data.expiry);
setTimeout(refreshBackendJWT, ((expiry-Date.parse(Date.now())) * 0.9));
gritty wind
#

We pass the td (7 days) to the frontend I think, so you can cut out the math entirely

vale ibex
#

it's in the max_age of the cookie

#

unl;ess the frontend has direct access ot the bearer_token

gritty wind
#

Honestly we just need to dump all this from the frontend

gritty wind
vale ibex
#

The only thing returned from the auth is ```
response = responses.JSONResponse({
"username": user.display_name,
"expiry": token_expiry.isoformat()
})

#

so we could include bearer_token["expires_in"] too

#

cut out the math as you say

#

then it would just be ```js
setTimeout(refreshBackendJWT, (response.data.expires_in/1000 * 0.9));

#

I can PR that now if you think it's correct

#

ah looks like the frontend already does ```
const expiry = Date.parse(response.data.expiry);
return {username: response.data.username, maxAge: (expiry - Date.now()) / 1000};

#

that's in requestBackendJWT, which is used when getting the token initially

gritty wind
#

The refresh and first login are very strange

vale ibex
#

the refresh logic doesn'nt use this

#

Yea

gritty wind
#

I don’t know what idiot designed this

vale ibex
#

I could update the refresh logic to do the same as this, just *.9, rather than updating the backend too

gritty wind
#

Don’t git blame

vale ibex
#

lol

#

vsc has git blame built-in

#

I always know who to blame

#

and sometimes it's not me

gritty wind
#

Go for it if you wanna PR

#

Either is fine because I’ll hopefully rip it out lol

vale ibex
#
@@ -204,7 +204,7 @@ export async function refreshBackendJWT(): Promise<boolean> {
         cookies.set(CookieNames.Username, response.data.username, {sameSite: "strict", secure: PRODUCTION, path: "/", expires: new Date(3000, 1)});

         const expiry = Date.parse(response.data.expiry);
-        setTimeout(refreshBackendJWT, (expiry * 0.9));
+        setTimeout(refreshBackendJWT, ((expiry - Date.now()) / 1000 * 0.9));
     }).catch(() => {
         pass = false;
         cookies.remove(CookieNames.Scopes);
#

just gonna be this anyway

#

to share the logic with the initial auth

green oriole
#

What is that 0.9

#

This looks cursed

#

Ah I see

#

Isn't there a very small window of 0.7 days to refresh the token then?

green oriole
#

Hey @patent pivot data man, do you have CF analytics set up for pydis?

vale ibex
#

We don't have Web traffic analysis, since we don't have pro

#

We have the other cf analytics though, like requests, cached vs uncached etc

green oriole
#

Yeaaaaah

#

What does the traffic between subdomains look like?

#

This is a totally random curiosity

gritty wind
# green oriole Isn't there a very small window of 0.7 days to refresh the token then?

I don't know how discord handles expired refresh tokens (it would've required me sitting and waiting for 7 days to test), so I added in a little buffer for us. Doing it a little earlier means we don't get too close to the expiration time, and it gives the user a grace period, because as indicated earlier, it's unlikely we'll always have the frontend running to refresh things

green oriole
#

Question

#

Do we actually need to refresh anything?

#

Surely we just need to know the user ID (and that the user owns the account)

#

Everything else can be pulled from discord

gritty wind
#

Well you can't pull user info any other way

#

It's intended to power features such as the username and PFP, which haven't been implemented yet

#

And it means anything that tries to access user data will not have to account for the condition when it's logged in but no longer accessible

#

Such as scope elevation

#

The system is only as complicated as it is because everything needs to be done by the frontend

#

#StatelessWasAMistake

vale ibex
#

Can only see total request numbers data saved, dns queries per response code etc

green oriole
#

It should be available under web analytics

#

But it is something you have to turn on

vale ibex
#

This one?

green oriole
#

Hmmmmmmmmm

vale ibex
#

This is the one I was talking about not having access too

green oriole
#

Why do we have access to that

vale ibex
#

Not sure

green oriole
#

You are looking here, right ?

#

Oh wait, if you go to a site in particular it asks you to upgrade

#

But if you go to the account home and select web analytics here, you don't have to

vale ibex
#

account home just shows this

#

(on pc now)

green oriole
#

If you select the first one, do you actually have no data?

subtle cargo
#

Why is the blog bypassing CF 🤔

vale ibex
#

yup, no data

#

We're probably just not serving the snippet

green oriole
#

The snippet is supposed to be autoinjected

#

Yet I've looked, it isn't

#

That's so weird

green oriole
#

You'll have to do that anyway to check for admin

gritty wind
#

No, not for the features forms needs

#

Such as email

green oriole
#

Right, email is an issue

gritty wind
#

You can obtain member info, but a lot of user info requires oauth

green oriole
#

Emails and connections are the two things you cannot get

#

Hmm

gritty wind
#

What’s the problem with oauth anyway

#

Why are we trying to get rid of it

green oriole
#

Considering the issues refreshing caused, it could have been interesting to just use OAuth to verify ownership then forget about it

#

But yeah, emails are a thing

surreal veldt
#

Can the amount of memory that the code took be added to the timeit command, maybe?

gritty wind
#

I don't think it's trivial to implement

brazen charm
#

That's quite a bit more complex, and I don't think anything in the stdlib can do it either

gritty wind
#

The timeit command uses, well, timeit

brazen charm
#

talking about timeit, bot#2201 's a simple no code review

dusky shoreBOT
gritty wind
#

Oh wow that's cool

brazen charm
#

no

#

There's really not much you can do internally without significantly influencing the timing, so it would probably also need to be separate command

gritty wind
#

I imagine it'd also require injecting some boilerplate around user code unless we write a CLI utility for it

#

I still have nightmares from doing that with forms

#

!help eval

stable mountainBOT
#
Command Help

!eval <code, ...>
Can also use: e

*Run Python code and get the results.

This command supports multiple lines of code, including code wrapped inside a formatted code block. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.

If multiple codeblocks are in a message, all of them will be joined and evaluated, ignoring the text outside of them.

We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!*

gritty wind
#

very cool

green oriole
#

Hmmmm

#

Hmmmmmmmm

#

The system call wait4() can be used to retrieve that information

#

Is forking allowed in snekbox yet?

#

Yes

#

So it is possible to make a binary that will just call python and return the memory usage

#

Or go the lazy way and use time -v and parse that information

#

So yeah, it is doable

#

The question is whenever it is relevant

#

Don't forget that Python is an interpreted language, its memory usage would probably not fit your expectations

broken topaz
#

https://github.com/python-discord/bot/tree/main/bot

  1. why is the bot structured the way it is? (you will run the folder instead of running a file?)
  2. why not use pipenv for env management?
    3.1) in here https://github.com/python-discord/bot/blob/main/bot/constants.py why do we read a yaml file instead of a .env
    3.2) why are we reading instead of just defining it?
GitHub

The community bot for the Python Discord community - bot/bot at main · python-discord/bot

GitHub

The community bot for the Python Discord community - bot/constants.py at main · python-discord/bot

thorny obsidian
broken topaz
gritty wind
#

The reason it’s in yaml instead of a python file is that yaml supposedly is easier to parse and use especially when configs get larger

#

I’m not convinced, but not enough to change it

#

We do use python files for most other projects

#

(Though not dictionaries, we’d use things like data classes and what not. Look into pydantic, which does ship with a bunch of utilities that make this easier)

#

As for resources, I don’t really have anything. You can gather what is common by looking through large open source projects, but that’s far from the best options out there. Ultimately whatever works for you is most likely fine

surreal veldt
#

May I ask a question about github in general?
Let's say I fork a repository, and make changes to it and make a PR which is accepted.
Then, the owner of the repo makes changes to the files. How can I update the folder (VSCODE) to show the changes? I tried pressing the Fetch upstream from github but it didn't work

gritty wind
#

It didn’t work as in your fork on GitHub is still not updated, or only your local files?

#

I assume it’s the latter, in which case you need to make sure that you’re on the same branch on both (your fork on GitHub, and locally. Usually best to be on main). After that run git fetch <remote> and git pull <remote>, where remote is the remote you set when cloning. This is probably something like origin.

surreal veldt
#

oh yeah it's my local files. On github my fork is updated

#

should i do the above?

gritty wind
#

Yup

surreal veldt
#

where remote is the remote you set when cloning
What does this mean?

#

Just used origin. And it worked. Thanks!

gritty wind
#

Git remotes are basically a human-readable form of URLs. You can tell it that upstream binds to https://GitHub.com/repo, and origin binds to https://GitHub.com/fork, for instance. If you run fetch origin, it will pull from a different url than fetch upstream

#

The origin/upstream names are common in the forking model

tawdry vapor
wild prism
#

I'm trying to redis on sir-robin working but it's like get or set operations never return

cachey = RedisCache(namespace="scoff")

class Ping(commands.Cog):
    """Send an embed about the bot's ping."""

    def __init__(self, bot: SirRobin):
        self.bot = bot

    @commands.command(name="hi")
    async def hi(self, ctx):
        log.debug("Attempting to set 'foo' to 'bar'")
        await cachey.set("foo", "bar")
        log.debug(f"Set op successful")
```log:

sir-robin | 2022-07-05 21:10:05,541 | bot.exts.ping | DEBUG | Attempting to set 'foo' to 'bar'
sir-robin | 2022-07-05 21:10:05,541 | async_rediscache.types.base | DEBUG | Creating NamespaceLock for namespace='sir-robin.scoff'.
sir-robin | 2022-07-05 21:10:05,542 | async_rediscache.types.base | DEBUG | Trying to acquire <NamespaceLock namespace='sir-robin.scoff' [unlocked]> for RedisCache.set
sir-robin | 2022-07-05 21:10:05,542 | async_rediscache.types.base | DEBUG | Acquired <NamespaceLock namespace='sir-robin.scoff' [locked]> for RedisCache.set
sir-robin | 2022-07-05 21:10:05,542 | async_rediscache.types.cache | DEBUG | Setting s|foo to s|bar.

127.0.0.1:6379> hgetall sir-robin.scoff

  1. "s|foo"
  2. "s|bar"
get calls do the same thing
#

anyone have an idea why?

#

running it docker-compose and real redis btw

vale ibex
#

What version of asyncrediscache and aioredis is installed?

wild prism
#

lol i've had that adventure, i think ultimately i ended duplicating sir-lancebot

#

let me double check

#

0.1.4 and 1.3.1

vale ibex
#

You can bump asyncrediscache up to 0.2.0, but that shouldn't be a problem

#

are they pinned to that version or ~= set?

wild prism
#

~=

vale ibex
#

try pinning aioredis to 1.3.1

wild prism
#

does that even matter if that's already in the lock file?

vale ibex
#

I remember having a similar issue with lance in my d.py migration branch

#

pining to 1.3.1 solved it

#

I think it was a sub dep not being pinned correctly

wild prism
vale ibex
#

did you also bump asyncrediscache version?

wild prism
#

no

vale ibex
#

alright lets try that

wild prism
#

are you saying that should be pinned as well?

vale ibex
#

it should be bumped to at least 0.2.0

#

We're slowly moving to exact version pinning with dependabot to tell us whn we need to update

#

I'm looking at the diff and can't think why this would fix your issue, but worth a try

wild prism
#

nope, nothing changed

vale ibex
#

the only thing after the hset in set is releasing the connection

#

so if that's going through, it suggests a problem there some how

stable mountainBOT
#

async_rediscache/types/base.py line 271

def _maybe_value_from_typestring(```
vale ibex
#

could you push your changes so I can attach a debugger?

vale ibex
#

thanks

wild prism
#

when is the namespace lock released?

#

bc that's not happening either

vale ibex
#

that was deprecated afaik

wild prism
#
sir-robin              | 2022-07-05 21:54:17,551 | bot.exts.ping | DEBUG | Attempting to set 'foo' to 'bar'
sir-robin              | 2022-07-05 21:54:17,551 | async_rediscache.types.base | DEBUG | Creating NamespaceLock for namespace='sir-robin.scoff'.
sir-robin              | 2022-07-05 21:54:17,551 | async_rediscache.types.base | DEBUG | Trying to acquire <NamespaceLock namespace='sir-robin.scoff' [unlocked]> for RedisCache.set
sir-robin              | 2022-07-05 21:54:17,551 | async_rediscache.types.base | DEBUG | Acquired <NamespaceLock namespace='sir-robin.scoff' [locked]> for RedisCache.set
sir-robin              | 2022-07-05 21:54:17,551 | async_rediscache.types.cache | DEBUG | Setting s|foo to s|bar.
sir-robin              | 2022-07-05 21:54:37,456 | bot.exts.ping | DEBUG | Attempting to set 'foo' to 'bar'
sir-robin              | 2022-07-05 21:54:37,457 | async_rediscache.types.base | DEBUG | Trying to acquire <NamespaceLock namespace='sir-robin.scoff' [locked]> for RedisCache.set
vale ibex
#

oh

wild prism
#

was that an "oh" like "oops" or like "eureka"?

tawdry vapor
#

"oh" like "oh"