#dev-contrib
1 messages · Page 177 of 1
!docs setdoc asyncpraw https://asyncpraw.readthedocs.io/en/stable/objects.inv
Added the package asyncpraw to the database and updated the inventories.
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...
using it on an actual class/method will work
Oh okay thanks
can you find the class in the docs?
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
Remove write-protected folder (y/n)?
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
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
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
Maybe sphinx doesn't work with ParamSpec yet?
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?
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.
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
__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
Thoughts on removing the extra space before the code block for eval results?
It throws me off sometimes. Looks weird. I dunno
I tried it with monty, didn't like it
it's too compressed on some devices, and doesn't give the codeblock room to breathe
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?
they changed something about not being able to modify the context after creation
hmmm that's really weird. All I did was fix the return button and now it's back
it was this that was reverted https://github.com/Rapptz/discord.py/pull/7685
specifically this line is what was causing the problem with our help embed https://github.com/Rapptz/discord.py/pull/7685/files#diff-6afaab6ebc84984f398353e5b84ed690bc1cc12b6f03f8a9971a6580cc15d94dR284
yea, not sure
all I saw was that this was reverted, so not sure what else is causing the issue
The interaction might be hanging
this was the revert
it wasn't a strict revert, so might be something causing issues still
Ok, I'll investigate, thanks
ImportError: cannot import name 'music_cog' from 'music_cog'
Anyone knows how I can fix this?
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
you were using inter.response.edit_message, I presume?
I was trying interaction.edit_original_message
Is this what I'm supposed to be trying?
yes
Hmm. This is confusing af
this edits the response to the interaction
tldr to respond you need to use one of the messages on the InteractionResponse object
then the other methods are usable
Alr, thanks
interaction.edit_original_message -> edits the response message
interaction.response.edit_message -> edits the original message
a wa
a wa
what the
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
yeah its part of style guide referenced in contributing guide
That sounds about right
hmm
I see I also missed a part of your question, absolute imports will use the name of the package in the import itself
do you know any source where one can learn about imports in depth
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
is it also possible to import without package name ?
oh maybe like import *
or importing a already imported library(in file one) from file one
right ?
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
Are you referring to relative imports, or star (*) imports?
and what if the package name is something like "sir lancebot"
relative imports
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:
- Rename the package. Anything that's a valid variable name would work. For instance:
sir_lancebot. - Use relative imports
- 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
oh ok cool
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.
thanks you so much for helping out
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 😄
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).
ok 👍 thanks
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.
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. 
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
hahahha i remember
A few weeks later Spotify literally just implemented the exact same thing
One of y’all is a spy and I want my cut
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?
not yet, that project is on hold for a bit
i would search for approved issues and start with ones that are unassigned or that are up for grabs
https://github.com/python-discord/sir-lancebot/labels/status%3A approved
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
What happened to it?
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
Who can become project leads?
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
Is there any update on Python bot using slash commands and time soon?
Specifically the docs command
@fallen patrol oi m8 status on these PRs? sir-lancebot#982 sir-lancebot#981
!remind 3d are you free again
Your reminder will arrive on <t:1655868894:F>!
Very well
ty for response
@fallen patrol I believe you were also working on sir-lancebot#968. Are you still planning to? Would love to see it implemented.
see above reminder but for that command in specific i want to do something like this https://github.com/onerandomusername/monty-python/blob/a96d151fdb34392eceb8306eb65b0fa02ce10185/monty/exts/info/github_info.py
Oh that looks nice, yeah I saw the reminder
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
Is this a good suggestion:
Allow users to send two documentation embeds at once by doing like
!d x, y will send two embeds
I think it's pretty cool, if anyone agrees, am I allowed to make a PR?
Wouldn't a space be enough because there cannot be any spaces in names
!d not in
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.
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
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
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
Looking for one more approval on https://github.com/python-discord/site/pull/726
hah thanks, that one has been in there a while apparently
the count function is not in the !docs?
most list methods are not in the objects.inv file (what we get our docs from) for some reason (I'm afraid I do not remember what it was)
It's just the way the Python docs are structured
Yup, there's a bug for it https://github.com/python/cpython/issues/89923
is it something that can be fixed, or due to what Mark said, it can't?
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
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
Is there a {% load staticfiles%} in the file?
I think just {% load static %} works too
needs to be after any extends tags
why does the !eval not support the help() method?
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
what does this mean? You can still manually load it and execute it to get it if you need it?
you can do import site in your snippet
site.main() does what?
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
so i did it in #bot-commands but it error'd again
yea you need to call .main() since we use -S
how'd I get 11 in #bot-commands?
Reviews welcome https://github.com/python-discord/site/pull/727
Also, why did the static preview fail 😦
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 😄
wonderful
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
could rsync it to netcup servers
we've got a shit load of storage that we will likely never fill
Would that pose a security risk for PRs
depends how much we can lock down rsync
what about uploading it to random discord server and pulling from there?
lol
what would be the attack vector though?
you cna place a file that gets built from an action to our servers?
and then have a github builder do something with it
I don't know, my jank detector just fired up automatically when it detected "Warning: Uploading untrusted content to prod servers"
hah yea
Well you can rewrite the action to upload anything
it doesn't get ran nativly though right
The vector is basically unlimited access to a rsync to our servers
unless you can also change the path to overwrite something like /etc lol
This is where my lack of knowledge of rsync limits me
it should be fine if
1- we hardcode the path
2- we require devops approval to change the action
@patent pivot could you look into github apps? Can we get one with just read access to our public repos, and nothing else
- Is that something github can do
Specifically limit it to changes
we have it via policybot atm
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
actions are always run from main
and changes to the actions in main require a PR with devops approval
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
Yea, but all the action does is push a build artifact to the server
on a hardcoded path
wdym not a possibility, we already have it?
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
if you change an action in a PR, the actions that run are still the ones that are in main
That isn't true though
I mean, I can pull up any of my PRs which add or change actions
They run too
Sphinx-multiversion PR added a build step to the action, which was run on the PR
https://github.com/python-discord/bot-core/pull/79
It added a whole new action as well
Hello two wonderful core devs. Would you like a nice content-only PR to review to boost your stats?
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
ahhhh, ok I see why
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
Wouldn't it be any non-first time collaborator?
Actually, we don't have that limit enabled, so any collaborator
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
😢
this isn't from your changeset though
no idea when it was added
also inconsistent capitalisation 
I think apps might be our best bet for this
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
So far I've figure the app will need read-only to: Metadata (mandatory), actions, pull requests
What each of those enables is listed here:
https://docs.github.com/en/rest/overview/permissions-required-for-github-apps
That will be installed per-repo
That does sound promising
Oh hey the preview succeeded this time
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
@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
Sure I'll give it a read tomorrow
Thanks
Here's your reminder: are you free again
[Jump back to when you created the reminder](#dev-contrib message)
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:
- dont change anything
- update the logo and every other bit of branding with discord's new blurple color
- just update the logo without modifying it as per discord's requirements
- 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.
When Discord changed their branding, I think it was decided that our site would not follow suit.
very well, thank you
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
fwiw, in the brand guidelines they say they use two fonts Ginto Nord and
Whitney. They also included a download link
https://www.dropbox.com/sh/j2eq5qobyqm1v6i/AACt6OBMB0TvI0ZO8D5wTJi9a?dl=0
page 41 of the guidelines
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.
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)
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
Yea, that's the fontawesome icon
which is updated for free
That’s probably why we’re on the latest for mobile (and forms 💪)
Cool, and I guess for the transparent part of the svg you're just using the discord full white logo?
new help channels sometimes show up at the top of the list. #help-peanut is a newly claimed one now, for example
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
I see. usually people don't check channels at the top, so the helpee may not get the help, but yeah, I understand
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
yes, same logo but white
this one?
i didnt change the text at first
i can try that and see how it turns out now that i know the font name
what about the "join us" text?
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
i think if i change one half i should also change the other for consistency
alright i'll do that right after breakfast
Cool cool, thanks :D
not final
grey background is just for visibility
this is with the old text
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
I like that
so what about the color?
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
agreed
Are you familiar with git/github?
yes
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
perfect
will it create a preview for draft PRs as well?
I think so
guess we'll find out
hah yea
looks like its building something https://github.com/python-discord/site/pull/729
yup
😎 Deploy Preview deploy-preview-729--pydis-static.netlify.app
from the comment
on hover seems to be falling back to a default font
I'm guessing you have the font installed on your PC :P
maybe i can fix that in inkscape somehow
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
i think i can just convert the text to paths in the svg
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
pff it was as simple as clicking one button 🤦♂️
oh lol
and running one google search to know which button to click of course
yeah convert them to paths.
I'm not as online as I look.
that looks real nice
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.
screenshots? on mobe
the color still bugs me
Yea, Discord updated their colours, but we stuck with our own to be more distinct from Discord themselves
their new font is so so ugly.
i agree 100%
Yea, I dislike it too lol, but it their brand
Discords whole new branding is godawful, honestly, but it's nice to update this so it uses it anyway.
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
we could also replace the blurple with black as Scaleios suggested since that would be inline with their policies
Yea, that's a good point, might look good
hmmm, I'm not too sure about that to be honest, it does lose something without the splash of colour
true
I think the best version is the one currently in the PR
also not as online as I look, but give me 10 mins
just for fun, recolored with the old blurple color
Could you add those 3 screenshots to the PR for ease of access for people?
sure thing
Well, the most recent 2 screenshots and then a similar one for the "correct" blurple colour
no worries kosa, if you're busy it's fine
we've figured out the blocker, and just looking for colour opinions now
this looks the best to me, but its hard to tell without seeing it on the site
https://deploy-preview-729--pydis-static.netlify.app/
this is with the new blurple color. i agree that the old color looks better, but the question then is, are we fine with violating discord's branding policy by recoloring the logo?
*gasp*, review has been requested from me 👀
yes.
It is a step up from what we've got today, compliance-wise. and it's a pretty subtle difference. I think it's probably fine. if anyone complains, we can change it.
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
Not a big fan of title case I take it
Not When Used For Things That Aren't Titles, No
Hah
just looks like a motivational poster from grandma
Your A Star And Believe In Urself!! 🌟
thanks grandma
better?
i'll commit this and un-draft the pr
It's merged and live! https://www.pythondiscord.com/ Thanks again :D
I'm able to run the Python Bot on docker using cellular data but not using my university wifi. I have to connect to their proxy to access internet.
Docker daemon works FWICT ( docker login worked after I followed https://docs.docker.com/config/daemon/systemd/#httphttps-proxy ).
I tried https://docs.docker.com/network/proxy/#configure-the-docker-client but the container doesn't connect to the site (or even attempt to? idk, I'll send the screenshot)
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
ping me when replying \🥺
I'm gonna sleep ✌️
Scaleios, didn't you have to wrestle with your uni's proxy? 
0.0.0.0:8000 is internal to the docker container. It will be available on 127.0.0.1:8000 on your local machine
Also, from this output, it seems the bot connected to the site just fine, what makes you think it's not working?
https://github.com/python-discord/sir-lancebot/pull/1049 to be honest I feel unqualified to review this given the core devs don't seem to agree this feature in its current design is a good idea
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
Hey core devs, I'd like to submit a PR to sir-lancebot without an issue for this formatting quirk (the double spaces after the parent command) nvm, filed an issue https://github.com/python-discord/sir-lancebot/issues/1065
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.
What's wrong with creating an issue?
(just curious)
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.
"attempting site connect" doesn't show up
And cogs aren't loaded
Okie
But the bot doesn't come online 😩
I'll have to connect to my phone's hotspot everytime I use docker then
127.0.0.1:8000 works, ty
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
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
What command are you using to start it?
Docker compose up
docker compose or docker-compose?
It’s the same on windows
Could you pull the logs for just bot from the docker desktop app
(When it fails to start)
Wasn't the same for me when I tried it
Ez, we don’t
It should be according to the docs
Should be
Not sure, it just failed to connect to site
Sounds unrelated or like a misconfiguration. Right now it should basically just be an alias
Well it definitely didn't work with one and worked with another
Yea, docker compose and docker-compose are different apps, even on windows
docker compose doesn't work for me on the bot
yea, as scale said we don't for the bots. It's non-trivial to figure out when the new bot is "ready" and cut off the old bot, without having overlap where commands may get double responses
ah
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
The former
Then yeah try docker-compose
I'm not on windows
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
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
Is this on the uni network?
yep
I thought you didn’t get any bot logs on the network
Oh I see, these are from two separate boots
nah, it's on uni network
i thought it's an earlier boot but i forgot the logs were in UTC
You have logs from 03:00 and 12:50
oh
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
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
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
nope, doesn't work
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
https://github.com/python-discord/bot/blob/main/bot/__main__.py#L71
it gets through till here
bot/__main__.py line 71
)```
)
😎
It's just the under the hood call to discord login
Through d.py
(hence the tb)
Is there a good typehint for "pass this particular function", instead of a generic (args), return
Why do you need an argument if it's a constant value?
It's not, it's a choice between two funcs
Hmm
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
Literal would only work with an enum for something like that
just document it in the docstring
I'll try it later
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.
Top level commands and aliases seems best for discoverability, but also 2 sounds fine if it's easier
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
Keep in mind that regular users see the commands they can run, which is much more limited
@vale ibex Any idea why this doesn't have an await? Or how it's working haha
https://github.com/python-discord/bot-core/blob/e28b42f9b1e085df6961d195abe6a36210d25242/botcore/_bot.py#L200
botcore/_bot.py line 200
self.log_to_dev_log(msg)```
it probably doesn't work lol
but that condition rarely ever gets hit
nice nice
@timid sentinel for non-staff the help command gives 3 pages
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
I've opened an issue there since it seems to be an actual issue
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
type should work
and Callable from collections.abc is unfortunately bugged in the doc typehint package
Ahhh
Well we do have the ignore for this reason then
The type thing is probably just pycharm being funny
would it be referenced correctly with an ignore?
It wouldn't, but the warning will be silenced
It seemed to be an easy fix and I posted an issue, but I didn't get a reply there
tox-dev/sphinx-autodoc-typehints#237
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
Thanks
Hope you get a response soon
It's kind of unfortunate right now
I might just migrate everything else and leave this
I just used callable from typing in the PR I have open for now
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
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
thanks for letting us know, I'll work on a fix
also the alignment of the icons is a little off, i think a value of 30px instead of 33px for line-height would be better
https://github.com/python-discord/site/blob/main/pydis_site/static/css/home/index.css#L130
pydis_site/static/css/home/index.css line 130
line-height: 33px;```
PR opened here: site#731
known issue with pycharm
Anyone using GitHub Codespaces? If I create codespace from one of PyDis repos, I get DNS_PROBE_FINISHED_NXDOMAIN (MS Edge on Mac).
Hmm
Are you able to access the base github.dev domain?
What's the domain for your codespace?
Somehow, magically, it now started working.
🎉
@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)
bot-core\botcore\utils\scheduling.py:docstring of botcore.utils.scheduling.create_task::py:class reference target not found: TASK_RETURN
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
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
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
I've decided to shorten typevars, so now they'll look like this:
or that without the source link
I'd ignore them, the only thing the typevar can have other than its name is a docstring under it, and I'd assume if it has a docstring it's being properly done for sphinx too so it shouldn't be a missing ref
!pep 0
Sorry, an unexpected error occurred. Please let us know!
AttributeError: 'Context' object has no attribute 'trigger_typing'
^ this has happened for some reason
!pep 621
Sorry, an unexpected error occurred. Please let us know!
AttributeError: 'Context' object has no attribute 'trigger_typing'
huh
wtf why
Only three results
Doesn't look terrible
bot#2203
Four*
I'm dumb
Damn you're fast
ctrl_shift_f lol
python hastebin is bias against typescript? It redirects .ts and .tsx to .py
i think we redirect everything to py
it redirects everything to .py, you can add ?noredirect query param to stop it
.js works
I thought it would allow other extensions if you specified them
since we're a Python server, and the hastebin lang detection isn't the best, that's the most correct
Replace across files?
What editor?
Ah
Does it support regex?
yea
It's got match case and match whole word options
or regex if you want to be specific
Damn
It's really catching up to PyCharm these days
you can change the extension to .ext?noredirect if you don't want to redirect to .py
I've been playing with CodeSpaces, I'll have to give it a more serious look
Pycharm does have the ctrl+shift+f for the same purpose
Actually, most editors do (atom, notepad++, etc) 😛
Yea
huh
github isn't triggering the lint test action
ah
yup
Welcome to GitHub's home for real-time and historical data on system performance.
github actions down
😔 is it ever up at this point?
It's what you get for using Oracle products lol
... GH uses Oracle?
Oracle made that?
Don't they have their own database product?
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
Hey, form unit test code didn't seem that broken 
I got scared for a sec that I committed a french there but thankfully it was only @gritty wind
https://github.com/python-discord/forms-backend/blob/main/backend/routes/forms/unittesting.py#L46

backend/routes/forms/unittesting.py line 46
# Unite code```
hahaha
You know I wrote a transpiler for this year's qualifier
Fun stuff, fun stuff
it's very United
you WHAT
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
oh no you didn't
did you write a script to convert a normal unit test to the JSON format?
that is very funny and very stupid at the same time, and I'm all for it
Exactly haha
Yeah one sec
The alternative was adding it to every test, and CF was already rejecting my payloads
The JSON, and the file that gets sent to snekbox
I don't think I leaked any state secrets
This should be from the public test suite
truly amazing code
I'm unironically very proud
honestly that's very good
👋
pleased to meet you all, I'm a bot dev & admin at libera.chat, interested in branching out in to discord
@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
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
yea
What does that actually do?
I've never understood it
it's like --force, but fails if it would overwrite commits from other authors
at least afaik
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"
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
Sounds reasonable
hi
the sentry error on form backend is me
I may have been messing with unit testing
it is a non issue really
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?
yeah
cool cool
I got the unittesting to 99
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?
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
completely separate, but could we add typing_extensions to snekbox?
Yup
lmao
Technically yes, but the bigger question is if we want to, and that’s a question for the events team
So ask in #code-jams-planning
not for code jam, for @stable mountain
FWIW snekbox for !eval , and the snekbox for forms are separate
In that case, yeah we can add it
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
it'll be adding to the list here https://github.com/python-discord/snekbox/blob/main/deployment.yaml#L53
deployment.yaml line 53
yarl~=1.7```
could I open a PR 🥺
so is the snake
is it a snake if it has legs
do I need to like, test it, or can I just trust.
just make sure the version number you add exists on pypi and you're good
you'd have to start a k8s cluster to test that
yeah figured
have those been recently upgraded?
should be live now, no idea how to test since I haven't used that package before :P
!e
import typing_extensions
@vocal prairie :warning: Your eval job has completed with return code 0.
[No output]
bot-core#96 nice small PR, a simple fix for clients that don't want to use statsd
also @gritty wind is bot-core#91 in a state to be merged?
I see discussions around type hints, but I don't want that to block the bug fixes you have in there
very good very good
I'll roll a release once #96 is merged
unblocked sir lance work for now at least :D
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 ❤️
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
they do have an API though
https://docs.genius.com/
they dont provide lyrics though afaik
this implies they do,
https://docs.genius.com/#/songs-h2
A song is a document hosted on Genius. It's usually music lyrics.
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)
This was brought up a couple weeks ago here
And my personal opinion was this, due to the limitation Akarys mentioned above
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
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?
yeah it happened to us a few times, trying to figure out what might cause it
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
They do expire yeah, at the same time the discord data expires
(Doesn’t make sense to keep it once its expired)
But yes, it’s quite strange
I can’t get down a solid repro tho, and relogging seems to fix it
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
Is expirity correctly set then
Set correctly for what?
Is actually set to a week in the future?
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
You're in the wrong channel. See #❓|how-to-get-help
Actually no, that'd be the other way around
The frontend thinks you are logged in, but not the backend
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
I've had a very naïve look at the auth code
how come this sets the expiry to the one already on the bearer_token, rather than the recently updated token_expiry? https://github.com/python-discord/forms-backend/blob/main/backend/routes/auth/authorize.py#L71
backend/routes/auth/authorize.py line 71
await set_response_token(response, request, token, bearer_token["expires_in"])```
that should be the same though IG
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)
ahh right, that makes sense
another question, isn't expiry here a unix time stamp? https://github.com/python-discord/forms-frontend/blob/main/src/api/auth.ts#L206-L207
src/api/auth.ts lines 206 to 207
const expiry = Date.parse(response.data.expiry);
setTimeout(refreshBackendJWT, (expiry * 0.9));```
So basing the expiry on that, rather than a diff from the current time seems off
ahhh yea, mixed up expires and expires_in
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
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
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?
afaik the fronend should be (and excuse my js)
Parse returns a Unix time stamp
const expiry = Date.parse(response.data.expiry);
setTimeout(refreshBackendJWT, ((expiry-Date.parse(Date.now())) * 0.9));
We pass the td (7 days) to the frontend I think, so you can cut out the math entirely
it's in the max_age of the cookie
unl;ess the frontend has direct access ot the bearer_token
Honestly we just need to dump all this from the frontend
It’s in the token, so no
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
The refresh and first login are very strange
I don’t know what idiot designed this
I could update the refresh logic to do the same as this, just *.9, rather than updating the backend too
Don’t git blame
lol
vsc has git blame built-in
I always know who to blame
and sometimes it's not me
@@ -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
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?
Hey @patent pivot data man, do you have CF analytics set up for pydis?
What sort of analytics are you thinking of?
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
Yeaaaaah
What does the traffic between subdomains look like?
This is a totally random curiosity
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
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
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
We don't seem to have any of that, might be under the pro analytics I mentioned
Can only see total request numbers data saved, dns queries per response code etc
Hmmmmmmmmm
This is the one I was talking about not having access too
Not sure
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
If you select the first one, do you actually have no data?
Why is the blog bypassing CF 🤔
The snippet is supposed to be autoinjected
Yet I've looked, it isn't
That's so weird
You can use the bot to fetch the member here
You'll have to do that anyway to check for admin
Right, email is an issue
You can obtain member info, but a lot of user info requires oauth
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
Can the amount of memory that the code took be added to the timeit command, maybe?
I don't think it's trivial to implement
That's quite a bit more complex, and I don't think anything in the stdlib can do it either
The timeit command uses, well, timeit
talking about timeit, bot#2201 's a simple no code review
Oh wow that's cool
Can't you use sys.getsizeof?
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
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
!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!*
very cool
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
https://github.com/python-discord/bot/tree/main/bot
- why is the bot structured the way it is? (you will run the folder instead of running a file?)
- 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?
Running it as a module is pretty standard for large bots. It makes imports easier to contend with.
Pipenv takes forever
We swapped to poetry because it's better overall for our primary developers
Yaml allows for a more complex config file vs an env. So we use yaml because our server setup for Python is pretty complex. Not sure what you're asking about reading vs defining
Fix question #3.2
Why do you put it in a yml file instead of just a python class or dictionary?
- where can I find resources for standards on these kind of stuff? I really need it because I am very conscious about my project structure that I sometimes end up doing nothing.
Thanks for helping!
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
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
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.
Yup
where remote is the remote you set when cloning
What does this mean?
Just used origin. And it worked. Thanks!
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
Need a review https://github.com/python-discord/snekbox/pull/147
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
- "s|foo"
- "s|bar"
get calls do the same thing
anyone have an idea why?
running it docker-compose and real redis btw
What version of asyncrediscache and aioredis is installed?
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
You can bump asyncrediscache up to 0.2.0, but that shouldn't be a problem
are they pinned to that version or ~= set?
~=
try pinning aioredis to 1.3.1
does that even matter if that's already in the lock file?
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
hm nope, same behavior
did you also bump asyncrediscache version?
no
alright lets try that
are you saying that should be pinned as well?
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
nope, nothing changed
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
actually, there is this call https://github.com/SebastiaanZ/async-rediscache/blob/6a68850e48cc36f0a60a3ddd12bbf3c908e10380/async_rediscache/types/base.py#L271 but I'm not sure why this would cause the hanging issue you're seeing
async_rediscache/types/base.py line 271
def _maybe_value_from_typestring(```
could you push your changes so I can attach a debugger?
thanks
that was deprecated afaik
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
oh
was that an "oh" like "oops" or like "eureka"?
"oh" like "oh"
