#dev-contrib
1 messages Β· Page 18 of 1
I know in the past people have tried using PyCharm's md preview, which doesn't behave the same way as our site does
no
if you remove the .md does it work?
I didn't use Pycharm tho
I remeber our talk last time
../discordpy-subclassing-context.md
Change it to ../discordpy-subclassing-context
this works btw
yep, this removes the .md
in the url
π€¦ββοΈ
I'm curious, if anyone has context, if we're making the request with raise_for_status=True, will this line still be reachable ? if response_json["status"] != "success" ?
I'm assuming this is only possible because the API itself could return a response with status code < 400 but the response['status'] isn't a success ?
bot/exts/fun/latex.py lines 84 to 88
async with self.bot.http_session.post(LATEX_API_URL, data=payload, raise_for_status=True) as response:
response_json = await response.json()
if response_json["status"] != "success":
raise InvalidLatexError(logs=response_json.get("log"))
async with self.bot.http_session.get(```
If you send invalid latex it will still be a 200 but response['status'] will be "error".
I'm assuming this is only possible because the API itself could return a response with status code < 400 but the response['status'] isn't a success ?
That's what I was trying to say by this. I see.
Alright, that's clear.
Thank you !
I would expect a 400, but hey π€·
Hi mates, is this channel for conrtibutors?
I've project and looking for devs who interested in it
Ah, this channel is only for contributions to our projects only I'm afraid.
Please note that we do not have any channel that serves that purpose, and that advertisement isn't allowed in our server. So I'm afraid you won't find what you're looking for here.
Np , thanks for help
@clever wraith @vale ibex re: https://github.com/python-discord/sir-lancebot/pull/1223#discussion_r1120903184
I'm not entirely sure if I'm supposed to fix Preoct's issue (#1179) in this PR but it seems like you and Chris want it to be included as a fix in this PR? Please let me know if I'm misunderstanding, I don't want to fix something that belongs to another issue :P
We could also have this PR (#1223) close Preocts issue (#1179) if that's something y'all want to do
DIdn't see there was an issue for it, just noticed while I was reviewing
It's a 2 line change, and bella has already given you a copy-paste code block diff
so might as well do it in this PR
since you need to push ruff fixes anyway
Yup thanks, hope Tizzy doesn't mind haha
Fixed. Requested a review from both of you. Thanks!
I don't :)
!charinfo v
s
\u0076 : LATIN SMALL LETTER V - v
\u000a : -
\u0020 : SPACE -
\u0073 : LATIN SMALL LETTER S - s
\u0076\u000a\u000a\u0020\u0073
!charinfo [](
\u005b : LEFT SQUARE BRACKET - [
\u005d : RIGHT SQUARE BRACKET - ]
\u0028 : LEFT PARENTHESIS - (
\u005b\u005d\u0028
!embed v
s
v
s
!charinfo v
s
\u0076\u000a\u000a\u0073
I am so very confused why this wasn't run into before
I suppose it has been, but never worked on
This channel is for discussion about python discord's open source projects. Unfortunately we don't have a channel for sharing your projects/recruitment, but you could try posting it in the r/python subreddit because it's better suited there.
Hi π
We don't advertise projects or anything of that sort on our server, and this channel is, like noob told you, is for discussions related to our OSS projects.
Hello folks - so I'm trying to set up python-discord/bot, I've use_fakeredis set to true in my config.yml, yet it's still throwing an error:
Traceback (most recent call last):
...
redis.exceptions.ConnectionError: Error -2 connecting to redis.default.svc.cluster.local:6379. -2.
Full traceback: https://paste.pythondiscord.com/egoraquvar
I'm also up to date with the main branch
Looks like I had use_fakeredis set to False in constants.py 
Now I'm getting
Error response from daemon: Head "https://ghcr.io/v2/python-discord/site/manifests/latest": denied: denied
When I try to docker compose up web
I have made sure to do docker login
Did it work?
How did you login?
Username & password
... password?
Yeah, just my normal password
π¨
Was I supposed to use a PAT or something?

Erm.. where do I obtain one of those 
You only need read:packages
Oh I just.. pass in my normal GitHub PAT into the password field?
Nevermind. I don't have that scope.
.... "normal"?
The one I use for cloning private repos and whatnot.
@outer oasis That's giving me
Error response from daemon: Get "https://registry-1.docker.io/v2/": unauthorized: incorrect username or password
Does it have something to do with the new fine-grained tokens vs classic?
Double check that message
I know. Username is correct, I'm 100% sure. Password came straight from copying it off GitHub
you're trying to login to dockerhub with github creds
you need to run docker login ghcr.io -u <USERNAME>
config.yml isn't used by the bot anymore
Thanks! Can pull web now.
we use pydantic now
Guess I am on an older version after all :P
bot#2618 just to remove the "Run in 3.10" button until we support multi-version again
@clever wraith I removed your approval since I decided to change the PR a bit more so that it's nicer to use in dev
(read actually possible to use in dev)
I have a one free approval per day policy

basically I just made it so that there is only ever 1 snekbox container that uses the latest tag
Alright, let me have a look
since the idea with supporting multiple versions is that that would bet the case
With a query param/body key would changing the version used
@gritty wind What happened to snekbox#175 ?
Also, site#988 to update the docs
You're pushing the limit mr Chris
lol
will do free reviews in exchange for money
Get in the line please
Thereβs a long comment chain between myself and Mark in his review
If someone wants to pick this up and figure it out go for it
β’
Β» args-kwargs
Β» async-await
Β» blocking
Β» botvar
Β» class
Β» classmethod
Β» codeblock
Β» comparison
Β» contribute
Β» customchecks
Β» customcooldown
Β» customhelp
Β» dashmpip
Β» decorators
What channel does !cban traverse first (if it's not arbitrary), and can it be pygen? I just cbanned someone in pygen, and it took a moment before their messages disappeared.
!src cban
Same as ban, but also cleans all their messages from the last hour.
cban calls clean_cog._clean_messages to do the actual deleting, which calls co-method _channels_set to translate from the input to a collection of channels to delete.
as may be guessed by the name, this returns a set:
https://github.com/python-discord/bot/blob/main/bot/exts/moderation/clean.py#L134-L140
bot/exts/moderation/clean.py lines 134 to 140
if channels == "*":
channels = {
channel for channel in itertools.chain(ctx.guild.channels, ctx.guild.threads)
if isinstance(channel, TextChannel | Thread)
# Assume that non-public channels are not needed to optimize for speed.
and channel.permissions_for(ctx.guild.default_role).view_channel
}```
a few lines later, after the else, is return channels
Can someone check sir-lancebot#1275? It's been up for a while and I would like to get started on it.
Hello everyone, I was seeking collaboration on a android and web project, I there a channel where I can do that?
We don't have a specific channel for that, but I believe you could ask in #python-discussion.
For staff that check this channel more frequently than the events planning channel, pls check #943526620940083220 for Trivia Night port stuff
@clever wraith you saw nothing
please approve prs thank
very important that we get uhhhhhhhh
Added Indonesian and Simplified Chinese
and
Bug fixing
for emoji package
thanks
nevermind, I have merged
I saw EVERYTHING
Sorry, i was busy getting hurt by running after the train
D:
oh no! hope you feel better soon
@vale ibex since it seems we can't do your suggestion of asyncio.run here, am I to assume we just leave it as-is? https://github.com/python-discord/bot-core/pull/177/files/d1bd13638b7652a3eb5776fc66cc1b20e077e0e9#r1189135832
I'm not familiar enough with asyncio to come up with an alternative
Although, based on the fact we can't use asyncio.run there, I suppose that means I also can't here (https://github.com/python-discord/bot-core/pull/177/files/d1bd13638b7652a3eb5776fc66cc1b20e077e0e9#diff-1228dfa5c0683d9b67a9ff72bb77552b1fbd0b8570a2d9a8e48231c777dd2ae6R251) and so I need to make some sort of change anyway (just, again, idk what since I'm not familiar enough with asyncio)
Does the current code work?
I think I tested it and it all worked. At least, I normally test stuff
It's just whether we care about asyncio.run creating a new task loop (based on what Mark said)
Lemme find my laptop and run it to see
Actually, not sure how I'd test since bot-core doesn't have a bot
I would have thought that asyncio.run would raise an error if there's an existing event loop
I'm trying to figure out how to run it though π€
Guess I can create a dummy bot in the bot-core project locally that just imports stuff
Mark's suggestion would work
Ah, cool, thanks
I'll give that a try then π
I did poetry run pip install ../bot-core but got an error:```
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
bot 1.0.0 requires pydis_core[async-rediscache]==9.5.1, but you have pydis-core 10.0.0 which is incompatible.
yea, because you've bumped pydis_core to 10.0.0 in your pr but bot requires 9.5.1
Ah, right, so I just need to downgrade it for now?
either bring bot-core down or bump the version bot needs
One solution may be to wrap the task being scheduled with another coroutine that awaits the original coroutine and the error handler afterwards.
My brain is struggling to figure out how to do this π
basically instead of creating a task for coroutine and then adding a done_callback to handle the error, write a new async function that gets passed coroutine, awaits it and then handles the error after
then that new fucntion is what we create the task for
(This worked btw, thanks)
π
def wrap_coro(coro: abc.Coroutine[typing.Any, typing.Any, TASK_RETURN], **kwargs):
async def run():
try:
await coro(**kwargs)
except Forbidden as e:
await handle_forbidden_from_block(e)
return run()```something like this? π€
I've been doing almost exclusively js/ts for the past few months, and it's made me forget how stuff works in python π
Hmm, that's not quite right since it needs to call _log_task_exception
Something like```py
def schedule(self, task_id: abc.Hashable, coroutine: abc.Coroutine) -> None:
...
task = asyncio.create_task(coro_wrapper(coroutine), name=f"{self.name}{task_id}")
task.add_done_callback(partial(self._task_done_callback, task_id))
async def _coro_wrapper(coroutine: abc.Coroutine):
try:
await coro
except Forbidden as e:
await handle_forbidden_from_block(e)
Where does the **kwargs get passed into the corouritine?
Nvm, the **kwargs is passed to asyncio.create_task, not the coro
def create_task(
coro: abc.Coroutine[typing.Any, typing.Any, TASK_RETURN],
*,
suppressed_exceptions: tuple[type[Exception], ...] = (),
event_loop: typing.Optional[asyncio.AbstractEventLoop] = None,
**kwargs,
) -> asyncio.Task[TASK_RETURN]:```these `kwargs`
async def _coro_wrapper(coro: abc.Coroutine[typing.Any, typing.Any, TASK_RETURN], *, suppressed_exceptions, **kwargs):
await coro(**kwargs)
await _log_task_exception(task=xxx, suppressed_exceptions=suppressed_exceptions)```the problem here is that `_coro_wrapper` doesn't have the `task`
But _log_task_exception is now a coro
does it need to be?
It calls await handle_forbidden_from_block, so yes
we call that inside the wrapper though
But...
The wrapper should call _log_task_exception, not handle_forbidden_from_block
Unless π€
I guess that works
_coro_wrapper calls handle_forbidden_from_block, and then we add _log_task_exception as a done callback (and it won't call the forbidden handler so doesn't need to be async)
yea
Yeah, sorry, my brain just isn't working properly π
Hopefully this is correct: https://github.com/python-discord/bot-core/pull/177/commits/467867fea3fcc757843575b599625984c48c1368
Going to test it now
Wouldn't py task = event_loop.create_task(partial(_coro_wrapper, coro), **kwargs) be this instead? ```py
task = event_loop.create_task(_coro_wrapper(coro), **kwargs)
Also, this isn't breaking so can just be a minor version bump
Also, I think the module should be error_handler or something like that, rather than errors as the latter suggests that it contains exception/error classes
Right, _log_task_exception isn't async anymore so no longer breaking
I... believe so, yes
It seems to still not be working....
The incidents crawler still raises the 90001 forbidden error
bot-bot-1 | 2023-06-10 15:38:33 | pydis_core.utils.scheduling | ERROR | Error in task Task-87 275305148096!
bot-bot-1 | Traceback (most recent call last):
bot-bot-1 | File "/bot/bot/exts/moderation/incidents.py", line 361, in crawl_incidents
bot-bot-1 | await add_signals(message)
bot-bot-1 | File "/bot/bot/exts/moderation/incidents.py", line 269, in add_signals
bot-bot-1 | await incident.add_reaction(signal_emoji.value)
bot-bot-1 | File "/opt/poetry/cache/virtualenvs/bot-TFcQMFAJ-py3.11/lib/python3.11/site-packages/discord/message.py", line 1098, in add_reaction
bot-bot-1 | await self._state.http.add_reaction(self.channel.id, self.id, emoji)
bot-bot-1 | File "/opt/poetry/cache/virtualenvs/bot-TFcQMFAJ-py3.11/lib/python3.11/site-packages/discord/http.py", line 738, in request
bot-bot-1 | raise Forbidden(response, data)
bot-bot-1 | discord.errors.Forbidden: 403 Forbidden (error code: 90001): Reaction blocked```
Can you push your current changeset to the pr?
Done
(And I reinstalled bot-core on bot after making the changes)
Seems like it should work
could you add some logging and/or breakpoints in the new code to see if it actually gets ran?
Hmm, can try
I'd add the logs in bot-core, right? I'm not seeing them atm (did docker compose up to start bot)
Docker don't run your local bot core changes
Since you installed the module to your host venv
You'd need to mount the bot core folder inside the container and run pip install there
Or run the bot locally
Or you can use the basic bot within bot core
Hmm, how do I do this?
Copy the bot core folder into your bot folder, add an exception in dockerignore and update the docker file to install it
Can I just add poetry run pip install ../bot-core to the docker file and then not copy the bot-core folder?
That path would be inside the container
Unless you mount the bot core folder at that path
Hmm, can't seem to get the pip install working
=> ERROR [5/6] RUN poetry run pip install bot-core 7.8s
------
> [5/6] RUN poetry run pip install bot-core:
#0 7.046 ERROR: Could not find a version that satisfies the requirement bot-core (from versions: none)
#0 7.048 ERROR: No matching distribution found for bot-core
------
failed to solve: executor failed running [/bin/sh -c poetry run pip install bot-core]: exit code: 1```
I'm guessing I need to somehow add it to pyproject.toml or something?
./bot-core gives an error saying file not found
What change did you make to the dockerfile, and the dockerignore?
dockerfile RUN poetry run pip install ./bot-core after the RUN poetry install -without dev and the ignore just bot-core
Does bot do the exclude everything and make exceptions in the dockerignore?
Or is that just lance?
The full .dockerignore is```
bot-core
.venv
scripts
htmlcov
pycache
.vagrant
.pytest_cache
.github
.gitlab
.cache
Vagrantfile
.coverage
.coveragerc
.gitignore
.travis.yml
*.log
docker
Since if you do bot-core in the docker ignore, that's telling it to ignore it
Right, remove bot core from there then
=> ERROR [5/6] RUN poetry run pip install ./bot-core 7.2s
------
> [5/6] RUN poetry run pip install ./bot-core:
#0 6.069 ERROR: Invalid requirement: './bot-core'
#0 6.069 Hint: It looks like a path. File './bot-core' does not exist.
------
failed to solve: executor failed running [/bin/sh -c poetry run pip install ./bot-core]: exit code: 1```
Should bot-core be in bot (the same folder as the pyproject.toml) or bot/bot?
The former
Can you link me to the dockerfile
FROM --platform=linux/amd64 ghcr.io/owl-corp/python-poetry-base:3.11-slim
# Define Git SHA build argument for sentry
ARG git_sha="development"
ENV GIT_SHA=$git_sha
# Install project dependencies
WORKDIR /bot
COPY pyproject.toml poetry.lock ./
RUN poetry install --without dev
RUN poetry run pip install ./bot-core
# Copy the source code in last to optimize rebuilding the image
COPY . .
ENTRYPOINT ["poetry"]
CMD ["run", "python", "-m", "bot"]
Maybe I need to do it before the WORKDIR /bot?
You'll need to move the pip install after the copy . .
Or copy bot-core before trying to install it
Seems to be installing now :)
It... seems to work :)
No error in the incidents crawler π
Do we also want to do the same thing for schedules?
I suppose it makes sense?
Yea sure
Try to figure out how to test this, since I can't find a schedule that reacts to a message
Guess I can temporarily modify one of the schedules to react to a message
Tested and it works π
bot-core#177 should now be ready for review :)
Whilst I'm here, bot#2520 also needs another review
merged down with my other PR and pushed both as 9.7.0
Amazing, thanks!
If you get a chance, would appreciate a 2nd review on this
will do if I have time after looking at CJMS
!contribute
Looking to contribute to Open Source Projects for the first time? Want to add a feature or fix a bug on the bots on this server? We have on-going projects that people can contribute to, even if you've never contributed to open source before!
Projects to Contribute to
β’ Sir Lancebot - our fun, beginner-friendly bot
β’ Python - our utility & moderation bot
β’ Site - resources, guides, and more
Where to start
- Read our contribution guide
- Chat with us in #dev-contrib if you're ready to jump in or have any questions
- Open an issue or ask to be assigned to an issue to work on
@vale ibex do I need to manually bump the bot-core version inside bot now that bot-core#177 is merged?
yes
And is that just bumping the version in pyproject.toml and then poetry run pip install .?
bump version in pyproject and poetry lock
then you can poetry install --sync to update your local venv
Do I have to update the file hashes in the poetry.lock?
poetry lock will do that
It... didn't seem to
did you save pyproject.toml before running poetry lock ?
Yes
are you running poetry lock in the same folder as the pyproject.toml?
yes
I thought you meant editing the poetry.lock file 
The current project's Python requirement (>=3.11.0,<3.12.0) is not compatible with some of the required packages Python requirement:
- pydis-core requires Python >=3.10.dev0,<3.12.dev0, so it will not be satisfied for Python >=3.12.dev0,<3.12.0
Because bot depends on pydis-core (9.7.0) which requires Python >=3.10.dev0,<3.12.dev0, version solving failed.```
So I guess pydis-core needs to be bumped to py3.11.0?
pydis-core supports both 3.10 and 3.11
3.11.2 in the root repo folder
alright, what about poetry --version?
1.4.1
alright, you could poetry self update to get 1.5.1 but that's likely not the issue
what is your diff on pyproject.toml to main right now?
# See https://bot-core.pythondiscord.com/ for docs.
-pydis_core = { version = "9.5.1", extras = ["async-rediscache"] }
+pydis_core = { version = "9.7.0", extras = ["async-rediscache"] }```
I didn't merge main into my branch before doing this, so the pydis_core was 9.5.1, not 9.6.0
I've just replaced 9.6.0 with 9.7.0 on my local bot repo and it worked fine
You might want to kill your branch and make a new one from main anyway, since you don't need any of the other changes
Hmm, looks like poetry self update fixed it 
fair enough
(bot-py3.11) β Sun 11 Jun 14:36 ~/Documents/personal/bot % poetry lock
Updating dependencies
Resolving dependencies... (2.1s)
Writing lock file```
So I add poetry.lock and pyproject.toml, then commit?
yea
Cool, looks like it's worked, thanks π
@vale ibex should I start on the equivalent PR for sir-lancebot?
Or do we want to wait for the error handling to all be migrated to bot-core?
Either seem fine to me
I think it's simpler to just wait for error handling to be in bot-core then
Left a comment
replied
Thanks, approved π
In the Github API is it possible to distinguish between a PR being closed vs merged? Would be nice for #dev-log
Oh wait, that's not using code, it's webhooks
Yeah, just realised
In fact, going back to this, it appears that it is possible to distinguish between "closed" and "merged" even within the webhook:
A pull request was closed. If
mergedis false in the webhook payload, the pull request was closed with unmerged commits. Ifmergedis true in the webhook payload, the pull request was merged.
Src: https://docs.github.com/en/webhooks-and-events/webhooks/webhook-events-and-payloads?actionType=closed#pull_request,
Is it possible to "read" the payload at all?
You'll need to check Sebastiaan's status embed project because that's the one that hooks into our channel
I don't remember what the requirements are tbh
Will take a look, thanks
Yeah, it definitely seems feasible to edit Seb's code to include the merged field for PRs. CC @hardy gorge
Uh, yeah, context? The GitHub status embed thing?
If you want, I can transfer the repo to Python Discord. I don't use it myself anymore.
Context here: #dev-contrib message
Basically having a different message in #dev-log for "PR closed" vs "PR merged" (currently both state "closed")
Ah, yes, that sounds like an easy change
I just don't have time to look into it myself
I'm happy to PR myself :)
Either to your account or python-discord, whichever is better
( @hardy gorge )
I think it would be fine to transfer it to pydis, but it obviously has to be a core dev decision to take on another project, as it does come with a (small) maintanance burden
Right, makes sense
I think there's some confusion here
The PR closed webhook is diretly form github, we don't touch it
Seb's project is for the status checks webhook
Look at the user, Github is directly form github Github Actions is seb's project
Hmm, right...
So... could the "PR closed" thing be added to Seb's project? So that we could modify the message
No, as we don't trigger the webhook ourselves
I see
the only way we could do what you're saying is to intercept the webhook from github and change it before it hits discord
We can by intercepting the webhoook, which i think we already do with a cloudflare worker
And... is that a practical/feasible approach?
would be something akin to this https://github.com/python-discord/workers/tree/main/github-filter
(or a modification to this)
Hmmmm
So I guess it would be checking whether the json.action === "closed", and if so, modifying the message (wherever that's stored) based on the json.pull_request!.merged?
It's not clear where the actual embed content is generated
we just pass that through from github, github is the one that generates the correct discord webhook data
And where is that stored (so that I can modify it)?
github-filter/src/index.ts lines 86 to 90
const data: Data = {
body: await request.text(),
headers: request.headers,
method: request.method,
}```
Ah, yes, I missed that π
So can I work on a PR for this? Realistically it makes sense to apply to the github-filter, and then just update the README to mention it also distinguishes between "closed" and "merged" PRs.
Also, how would I go about testing it once I've coded something?
The way we've tested this in the past is using our own cloudflare accounts
since the free tier comes with workers
Do you just.... Expose your IP like a heathen??
So can I work on a PR for this?
Sure, if it's something you're interested in. It's used quite a lot so we'd want to see that it's tested properly before merging.
I've never needed to host anything ||(idek if that's what cloudflare is for)||
Any idea what's going on here?
incorrect type if i had to guess
It's being detected automatically though from hc, so not sure how
Unless the version of @cloudfare/workers-honeycomb-logger is somehow wrong, despite being installed from the package.json (via yarn install)
the way we use it is how it's documented in the readme of honeycomb
@vale ibex so I've made some progress, but the main issue I'm having is honeycomb not showing logs for some reason. Cloudflare shows that the endpoint was called, but honeycomb doesn't. And honeycomb is the service with the detailed logs of what's going on (where the request.tracer.log() calls go to)
I've spent about 2 hours solely on trying to figure out how to properly test this code, and am just not getting anywhere
I've got the wrangler publish ... which deploys the changes, and that's it
Tried closing a PR, and no webhook is sent to Discord, nor is there any logs I can read about what's going on (cloudfare tells me the endpoint was called though).
I get webhooks for some other stuff though, like opening a PR (but no logs again on honeycomb) 
Sometimes I get logs on honeycomb and sometimes not, and I can't see what the determining factor is
Looking at https://github.com/python-discord/workers/blob/main/github-filter/src/bindings.d.ts it's expected to have a variable HONEYCOMB_KEY and a labels key value namespace available to the worker, are both of those setup on your CF instance?
It doesn't have a labels as I couldn't quite figure that out
And for HONEYCOMB_KEY I just changed it to process.env.HONEYCOMB_KEY for ease
https://dash.cloudflare.com/<account_id>/workers/kv/namespaces
Where do I get my account id?
There's a bit of logic to determine whether to ignore the webhook https://github.com/python-discord/workers/blob/main/github-filter/src/index.ts#L39-L69
with the aim to reduce noisy events
Right, yes
it'll be in the url when you load any other CF page
That might be the issue
Which url? It's not in the worker url
go to https://dash.cloudflare.com/ and click your account
(it might auto-forward if you only have one)
@rapid swallow I forgive you
@vale ibex add review this very instant thanks https://github.com/python-discord/bot/pull/2639
β [ERROR] A request to the Cloudflare API (/accounts/{account_id}/workers/scripts/github-filter-worker) failed.
Uncaught ReferenceError: HONEYCOMB_KEY is not defined
at worker.js:909:13
at worker.js:1017:3
[code: 10021]
If you think this is a bug, please open an issue at:
https://github.com/cloudflare/workers-sdk/issues/new/choose```How do I make it point to the labels namespace?
I added it to the kv_namespaces in the config
that error seems to be complaining about the honeycomb key, rather than the labels kv
It's not reading the kv namespace though
kv_namespaces = [
{ binding = "github-filters-kv", id = "xxxxxxx" }
]```
oh, we use a worker variable for this in prod, rather than a kv
it's a feature that we don't actually use anymore
There's a label kv that can have channels & webhooks to push all notifcations to
pre-commit auto update by yours truly please approve thanks https://github.com/python-discord/bot/pull/2640
here as well: https://github.com/python-discord/site/pull/997
if CI passes I am happy
Yea :)
coveralls internal error
very interesting
but this doesn't look like a problem that the PR caused directly
unless I somehow made their servers go kaboom
bot-core#181
Hello, I am seeking help regarding snekbox, here is the original message. #python-discussion message
Both of these are now setup, and I'm still not getting logs as I'd expect. The worker code is now```ts
export async function handleRequest(request: Request): Promise<Response> {
// Don't apply any logic to non-POSTs.
if (request.method !== 'POST') {
return new Response(
'Worker lives! Ignoring this request because it is not a POST.',
)
}
request.tracer.log('POST request received')```and I'm not getting the 'POST request received' logged, despite cloudflare showing that there was a POST request to that endpoint
might be worth turning on the logs websocket in the CF worker
If you mean this, I've already been using it
Ya, that's the one
Not entirely sure what's going on then
How can I make stuff show in the cloudflare logs: [] array?
console.log is my uneducated guess
Ah, yests "logs": [ { "message": [ "Does this show in cloudflare logs array?" ], "level": "log", "timestamp": 1686663537823 } ]
Let's see if I can use this instead of honeycomb
From the seems of it this isn't actually correct, in that Discord themselves generated the embed content, from the event payload passed in as the body. So looks like it's not possible to customise the message.
So it's not like a discord embed payload where I could just adjust the .title or something
The body is so big that json.loads() just crashes the idle shell when I try to parse it π
This is the payload, so gonna try messing with things to see what happens https://paste.pythondiscord.com/luzibemupe.json?noredirect
From preliminary testing, it looks like discord sees body.action == "closed" and that's it. It doesn't look for body.pull_request.merged as well
Tl;Dr; it's Discord themselves that generate the webhook message content, so unless you can intercept Discord --> channel, this isn't possible
@vale ibex
Looks like the best option is to do a PATCH request after the POST request, to update the message sent to Discord (meaning it would have "edited" next to it), if we want to do this.
Or, we parse the github event and send an embed payload to the webhook ourselves, instead of having Discord parse the github event.
Fair enough, I don't think it's worth the effort for the gain at this point then
Yeah, agree
Unfortunately it wasn't as simple as I'd hoped
Another project down the drain
Honeycomb issue could be a matter of modifying the sample rate
Somebody may help me, please?
what host system are you running?
if it's linux, what kernel version are you on?
Also, how are you running snekbox?
I'm running it on Debian Kernel 5.4.143-1-pve
I used to docker command in the snekbox repo, I also tried to sudo run the docker but the error persists.
could you add -e SNEKBOX_DEBUG=true to the docker command (before the image url) and put the entire output into a paste?
and then the error you posted above happens when you make a request to the snekbox api?
any chance you could include that in a new paste too?
So the warning line ```
Swap memory is available, but the swap memory controller is not enabled. This is probably due to the CONFIG_MEMCG_SWAP or CONFIG_MEMCG_SWAP_ENABLED kernel parameters not being set. NsJail will not be able to limit memory effectively. Please turn off swap memory on the system, or enable the swap memory controller.
not overly familiar with nsjail myself, so not sure if setting those kernel params will just work
okay, I will try to enable the swap memory controller and tell you if it worked
from the nsjail docs it says this ```
--cgroup_mem_memsw_max VALUE
Maximum number of memory+swap bytes to use (default: '0' - disabled)
--cgroup_mem_swap_max VALUE
Maximum number of swap bytes to use (default: '-1' - disabled)
and in your error, it shows that those are set to disabled
so not sure what's causing the issue without looking into it further
hm yeah, thanks for the help though.
Fixed the tests in bot#2642
There's likely room for a followup PR to use some of the new features added in d.py 2.3
Not sure if there's an issue for this specifically, I found tizzy's removal of backticks issue, but you get whatever the character limit is to write an executable and have it embed in Discord from Python directly. Is that intended?
ref: #bot-commands message
Most bot filters donβt apply to staff.
... Ah.
Does /sys/fs/cgroup/ exist on your system?
Which cgroup version is your system using: v1, v2, or hybdrid? Snekbox determined that your system uses v2, but there may be a bug and it got it wrong. There are commands to check which version your system uses, but I don't have them at hand.
Also check if the memory controller is enabled. I believe you can look at /sys/fs/cgroup/cgroup.subtree_control or /sys/fs/cgroup/cgroup.controllers to see which controllers are enabled, assuming your system uses cgroup v2
Also try passing the verbose option to nsjail and then share the logs here. Several ways to do this (choose one):
- Mount a custom nsjail config using a Docker volume or bind mount.
- Modify the default config at config/snekbox.cfg. Then rebuild the Docker image
- Modify the source code of
nsjail.pyto pass the option--verboseto the nsjail subprocess. Then build the Docker image.
I don't think the error you get from nsjail is directly related to the warning you get about swap memory. Snekbox will tell nsjail to disable swap memory limits in such case. The error you get from nsjail is about memory.max, which I believe is separate from the swap memory limit.
Thanks for your response!
So the directory /sys/fs/cgroup/ exists on my system and I think it uses cgroup v2.
The file /sys/fs/cgroup/cgroup.subtree_control and /sys/fs/cgroup/cgroup.controllers are both empty, maybe this is the issue?
Yes, them being empty is most definitely the problem.I don't know why they'd both be empty. You said you're using a VPS. Maybe they disable cgroups?
I donβt know if itβs disabled by default, I will look into this and tell you !
if bot#2646 gets approved we should find all replies where markdown could be used
If you want to get help you should check out #1035199133436354600
no its not help i just pated that in the wrong room
@patent pivot I would like to fill a formal complaint toward metricity not being kubenootes friendly
the config file is in the same folder as the app
would y'all accept a PR that make it also look into /config/config.toml?
or even better, use an env var to set the config location
yeah imma just PR that lmao
would appreciate a merge, as this is blocking my deployment π
Hello
Role select seems to be broken
Works for me now but other users complain is still broken > #community-meta message
Scratch that, has fixed itself for other users too :P
Still might want to check logs to see what went wrong, if possible
i recall i think Scale had identified some bug with this but unsure whether this is the same or something new
The other thing you recall was a permission related thing where the bot says this isn't yours to interact with. And that's fixed.
This seems to either be:
- timing out for some purpose
- Throwing an exception which I doubt because we didn't see any alerts.
I'll try to have a look at logs, if I find any, later on
Yeah, i can see something wrong in the logs happening with that view.
I'm on mobile so it's pretty impractical. I'll give more details later
It's failing upon sending the followup message (the one that says that a role has been added / removed).
We're getting a 404 unknown webhook.
It could be a discord api issue for all i know atm
Seems like a fine change, will merge it this morning, what blocks you from mounting a file using k8s though? ```yml
volumeMounts:
- name: metricty-config
mountPath: /metricity/config.toml
subPath: config.toml
While I was investigate this, I found a different issue, raised bot#2650
usually this error happens whn you try to use a followup webhook when you haven't responded yet. IE using interaction.followup before using interaction.response
Hmmmmmm does that actually work
I use it for another deployment
so depends on what "work" means in your context
I can try that
Yea, mountPath is where to mount it subPath is a way to select a path within the volume to mount
it's also useful if you have a single volume with a few directories, but you only want to mount a certain directory into one container, and another in another container
I've also fixed an issue with the pride facts cog, where it was giving this error #sir-lancebot-playground message due to the facts being year-specific sir-lancebot#1302
root[14] INFO Waiting for guild 267624335836053506 to be avialable before loading extensions.
nice one lmao
ah okay that's the pydis ID
yeah that ain't gonna work
what do your manifests look like?
I just typo-ed the file name, it is my bad
hah ya that's fixed in a newer version, guess we haven't bumped metricity
newer version of bot-core I mean, and we haven't bumped metricity to use it
Ah cool, so the subPath mount worked?
I've used the env var as it is what I had yesterday
buuuut it ain't working
alright time to spawn a shell and look
hmmmmmmmmm it is reinserting all the users
that doesn't sound correct lmao
dooooooes it do that all the time on startup?
oh it seems like it
Yea, it'll resync all users on startup
it appears to be working
No worries
I'm gonna bump some deps and migrate to ruff now
since I have the repo cloned :P
How would that happen in our case ?
We don't necessarily "response" in our case, we only edit the response message here https://github.com/python-discord/bot/blob/56c57ea7b73582fe46eff9fd4771c738891dd650/bot/exts/info/subscribe.py#L149
Then we use the followup later in https://github.com/python-discord/bot/blob/56c57ea7b73582fe46eff9fd4771c738891dd650/bot/exts/info/subscribe.py#L139
bot/exts/info/subscribe.py line 149
await interaction.response.edit_message(view=self.view)```
`bot/exts/info/subscribe.py` line 139
```py
await interaction.followup.send(```
Unless the update_view throws, but we then stop the view so it shouldn't be visible.
self.view.stop() doesn't delete the view
it just stops listening for interactions
π€¦
I'm getting an error when trying to run that PR, although it doesn't seem to be related to the PR afaict, happens when clicking the subscribe buttons
Traceback (most recent call last):
File "C:\Users\wookie\AppData\Local\pypoetry\Cache\virtualenvs\bot-hu2rt1Uv-py3.11\Lib\site-packages\discord\ui\view.py", line 427, in _scheduled_task
await item.callback(interaction)
File "C:\Users\wookie\Documents\GitHub\bot\bot\exts\info\subscribe.py", line 101, in callback
await self.update_view(interaction)
File "C:\Users\wookie\Documents\GitHub\bot\bot\exts\info\subscribe.py", line 108, in update_view
await interaction.followup.edit_message(view=self.view)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Webhook.edit_message() missing 1 required positional argument: 'message_id'
any ideas?
Are you running that in a container?
Yea, I know the issue
interaction.followup is a webhook, so you can't use it to edit arbitrary messages, only ones sent by webhooks with the same token
But how come it will hit a message that wasn't sent by the original view? Isn't that the message trigger?
Since the message can be sent by the bot, rather than a webhook
If you use the command
Do we still want to keep the command?
I feel like (from a quick search) that it isn't use much
Used *
The view has been there for a while, and I think people have gotten used to its existence
We can cleanup the cog even further
I still seem to be getting an error when clicking the buttons
2023-06-21 15:36:55 | discord.ui.view | ERROR | Ignoring exception in view <RoleButtonView timeout=300 children=6> for item <SingleRoleButton style=<ButtonStyle.danger: 4> url=None disabled=False label='Remove role Advent of Code' emoji=None row=0>
Traceback (most recent call last):
File "C:\Users\wookie\AppData\Local\pypoetry\Cache\virtualenvs\bot-hu2rt1Uv-py3.11\Lib\site-packages\discord\ui\view.py", line 427, in _scheduled_task
await item.callback(interaction)
File "C:\Users\wookie\Documents\GitHub\bot\bot\exts\info\subscribe.py", line 105, in callback
await send_function.send_message(
^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Webhook' object has no attribute 'send_message'
Is the command what's causing the complication? I don't mind getting rid of it
Yea, the command adds quite a bit of complexity, since the command and the button share the same view
This is an easy fix though
tfw discord breaks your bot
I'm trying to get my own instance of @stable mountain working, but it's throwing this error: ```
/usr/local/bin/docker-compose -f /Users/danielgu/Repositories/python-bot/docker-compose.yml -p python-bot up
[+] Running 1/5
β metricity Error 0.8s
β web Pulling 0.8s
β postgres 8 layers [β β β β β β β β ] 0B/0B Pulling 0.8s
β redis 6 layers [β β β β β β ] 0B/0B Pulling 0.8s
β snekbox-311 14 layers [β β β β β β β β β β β β β β ] 0B/0B Pulling 0.8s
no matching manifest for linux/arm64/v8 in the manifest list entries
docker-compose process finished with exit code 18
Run configuration (Docker-compose):
Am I missing something here?
(same error when trying to run through terminal with poetry run docker-compose up)
try DOCKER_DEFAULT_PLATFORM=linux/amd64 docker compose up
keep in mind docker-compose is deprecated, it's docker compose now (no hyphen)
it worked, thanks!
No worries
you might find this happens a lot on other repos, since we don't build for apple silicone
adding that env var at the start tells docker to use the amd64 image instead
Oh I see
im trying to spin up an instance of snekbox but each time i execute code i get greeted with
2023-06-26 18:55:04,689 | 9 | snekbox.nsjail | INFO | Executing code...
2023-06-26 18:55:04,778 | 9 | snekbox.nsjail | INFO | Found 0 files.
2023-06-26 18:55:04,779 | 9 | snekbox.nsjail | ERROR | Couldn't open '/sys/fs/cgroup/NSJAIL.11/memory.swap.max' for writing: No such file or directory
2023-06-26 18:55:04,780 | 9 | snekbox.nsjail | WARNING | Could not update memory.swap.max
2023-06-26 18:55:04,780 | 9 | snekbox.nsjail | ERROR | Couldn't initialize cgroup 2 user namespace for pid=11
2023-06-26 18:55:04,780 | 9 | snekbox.nsjail | ERROR | Launching child process failed
2023-06-26 18:55:04,782 | 9 | snekbox.nsjail | INFO | nsjail return code: 255``` im building it from source, locally on my rpi i checked the makefile of nsjail there isnt any cross compiling so it is being compiled for arm64, but it doesnt work, could anyone help me with this at all? the file `/sys/fs/cgroup/NSJAIL.11/memory.swap.max` never gets created after executing code, just the `NSJAIL.11` directory
What OS is your rpi? I know that snekbox doesn't currently support Apple architecture, so you won't get it working for that.
raspbian 64 bit lite, but if im building it from source it should? Im building everything for my architecture
i git cloned it and built the docker image that way
I'm not familiar enough with how this stuff works tbh
i changed my swap size from 100 to 1024 rebuilt the image, now i get this https://paste.pythondiscord.com/lesidewola
nvm, re ran it and now it seems to have booted fine
2023-06-26 19:15:47,932 | 1 | gunicorn.error | INFO | Starting gunicorn 20.1.0
2023-06-26 19:15:47,934 | 1 | gunicorn.error | INFO | Listening at: http://0.0.0.0:8060 (1)
2023-06-26 19:15:47,934 | 1 | gunicorn.error | INFO | Using worker: sync
2023-06-26 19:15:47,943 | 8 | gunicorn.error | INFO | Booting worker with pid: 8
2023-06-26 19:15:47,994 | 8 | snekbox.nsjail | INFO | Assuming cgroup version 2.
2023-06-26 19:15:48,011 | 9 | gunicorn.error | INFO | Booting worker with pid: 9
2023-06-26 19:15:48,033 | 9 | snekbox.nsjail | INFO | Assuming cgroup version 2.``` and no errors yet
try sending it some code
yep about to do that
and once again
2023-06-26 19:16:41,463 | 8 | snekbox.nsjail | INFO | Executing code...
2023-06-26 19:16:41,554 | 8 | snekbox.nsjail | INFO | Found 0 files.
2023-06-26 19:16:41,555 | 8 | snekbox.nsjail | ERROR | Couldn't open '/sys/fs/cgroup/NSJAIL.11/memory.swap.max' for writing: No such file or directory
2023-06-26 19:16:41,556 | 8 | snekbox.nsjail | WARNING | Could not update memory.swap.max
2023-06-26 19:16:41,556 | 8 | snekbox.nsjail | ERROR | Couldn't initialize cgroup 2 user namespace for pid=11
2023-06-26 19:16:41,557 | 8 | snekbox.nsjail | ERROR | Launching child process failed
2023-06-26 19:16:41,558 | 8 | snekbox.nsjail | INFO | nsjail return code: 255```
memory.swap.max isnt being created
ive tried tinkering with the snekbox.cfg especially with the memory parts, but that didnt work either
i set it to a high number, low number, zeros too
@spring hinge you had a very similar issue recently, did you ever come up with a fix?
Couldn't open '/sys/fs/cgroup/NSJAIL.11/memory.swap.max' for writing: No such file or directory
@clever wraith here's a conversation where parzival had similar issues
in my case both /sys/fs/cgroup/cgroup.subtree_control and /sys/fs/cgroup/cgroup.controllers output cpuset cpu io pids and /sys/fs/cgroup exists
@tawdry vapor have you got any more tricks up your sleeve?
Looks like your system does not have the memory controller enabled
I have not personally encountered this so I don't know how to enable it. Maybe it's as simple as writing +memory into the file?
what file?
ill try that out
I believe the controller has to be enabled in cgroup.controllers in order for it to be enabled in subtree_control
If that's the case I'm not sure if there's something special to be done to enable the controller for the root cgroup
jan@raspberrypi:~/snekbox $ sudo echo "+cpu +memory -io" > /sys/fs/cgroup/cgroup.subtree_control
-bash: /sys/fs/cgroup/cgroup.subtree_control: Permission denied``` eh
Iirc you cannot change it if the cgroup already has child processes in it
and how do i disable the child process? i dont even know what it could be
Hmm maybe you can follow this approach? Though now I see that the error this is working around is not permission denied like you're getting https://github.com/python-discord/snekbox/blob/main/snekbox/utils/cgroup.py#L99
This is new territory so I think you'll have to do some research to find how to enable the memory controller for the root cgroup
If you figure it out please let us know and I'll add it to a faq on snekbox
doubt ill figure it out on my own but ill try
No not really, it could be Debian related because on Ubuntu it worked fine for me.
could try reinstalling ubuntu server on my pi
@tawdry vapor re installed ubuntu
2023-06-26 20:33:28,835 | 9 | snekbox.nsjail | INFO | Executing code...
2023-06-26 20:33:28,886 | 9 | snekbox.nsjail | INFO | Found 0 files.
2023-06-26 20:33:28,887 | 9 | snekbox.nsjail | WARNING | mount(''/lib64' -> '/lib64' flags:MS_RDONLY|MS_BIND|MS_REC|MS_PRIVATE type:'' options:'' dir:false') src:'/lib64' dstpath:'/tmp/nsjail.0.root//lib64' failed: No such file or directory
2023-06-26 20:33:28,888 | 9 | snekbox.nsjail | ERROR | Launching child process failed
2023-06-26 20:33:28,888 | 9 | snekbox.nsjail | WARNING | Received error message from the child process before it has been executed
2023-06-26 20:33:28,889 | 9 | snekbox.nsjail | ERROR | Couldn't launch the child process
2023-06-26 20:33:28,890 | 9 | snekbox.nsjail | INFO | nsjail return code: 255``` new error
this one seems a bit more fixable haha
@atomic ivy seems like u had something similar..
and i am on a 64-bit operating system, yes
looks vaguely familiar
but unfortunately I didn't investigate further and kinda gave up running snekbox on the Mac
I don't know what ubuntus directory structure is like, but the point of mounting lib64 is so that python has access to the shared libraries it needs to run.
Just figure out where those are stored on ubuntu and mount that directory.
I donβt think this is necessarily an OS issue, Iβve tested snekbox on all the popular ones
But that advice probably holds either way
Doing this on a pi is brave for sure haha
i really dont know why it doesnt work anymore
python packages u mean?
/usr/lib/pythonXX/site-packages
Could you do ls /
bin boot dev etc home lib lost+found media mnt opt proc root run sbin snap srv sys tmp usr var
Just double checking, are you on a 32-bit system?
pretty sure its 64 but how can i check
Either way, if your system doesn't have it, you can probably just remove it from snekbox completely
Try deleting these lines and rebuilding
config/snekbox.cfg lines 60 to 65
mount {
src: "/lib64"
dst: "/lib64"
is_bind: true
rw: false
}```
it wont cause it to be unsafe right
The possible side-effect of this change is completely breaking python
So if it doesn't break, it doesn't affect safety
ah okay
(It won't break python fwiw)
idk how docker works really, do i need to rebuild it with --no-cache?
Shouldn't be necessary
Oh that's good news
although i think ill have to re install it again.. i think i broke my pip with upgrading python
That is an interesting color pallete
im in powershell
Did you figure out if it's 64 or 32 bit
This could be helpful for solving the problem in a more permanent way
uname -m says aarch64, so 64 bit i assume
no worries, while youre here u think u can help with this?
running python2 outputs this
jan@raspberrypi:~/MatrixBot/src$ python2
Traceback (most recent call last):
File "/usr/lib/command-not-found", line 28, in <module>
from CommandNotFound import CommandNotFound
File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 19, in <module>
from CommandNotFound.db.db import SqliteDatabase
File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 5, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'``` so i think i broke the installation or something
Haven't seen this error before but the general recommendation seems to be reinstalling python3-apt with your package manager (apt)
In this case it'd probably be python2-apt
ill try, thanks so much for snekbox, i spent all day on that thing, turns out i had to use non-debian distro after all
@tawdry vapor for this issue, perhaps we should look into making some of the mounts non-mandatory. I imagine if they don't exist and the system python doesn't fail then they aren't necessary to mount
How does removing those mounts influence the cgroups Scale?
Why are we mounting those already?
Try seeing what's in your lib64 folders, but as Mark pointed out they are shared libraries which can be used by your applications, including python
However if your OS doesn't have those to begin, and python still runs on your OS, then they aren't necessary when mounting in snekbox
The cgroups issue is independent, seems to have been more about the OS being used (it was switched half way through the help session)
A large factor for these issues is also the hardware (rpi)
OSes are just built different
yep, as parzival stated before, for him moving to ubuntu worked and same for me
seems like its an issue with debian
I'm leaning more towards documenting this as a potential failure of the default config. We can't accomodate for every system's setup. Maybe we can make a few things like lib64 optional but I don't want it to become a slippery slope. Feel free to open an issue for this.
It's also just not as nice when we need to have config in code instead of in the config file.
Mandatory is part of the config file, it just ignores it instead of erroring if the directory doesnβt exist
Nsjail handles any complexity
I get the slippery slope argument, but there are only like 5 mounts, and Iβm pretty sure one of them is python itself
Mandatory is part of the config file, it just ignores it instead of erroring if the directory doesnβt exis
Oh I didn't know that. Yeah let's just do that then
IDK why I quoted that I forgot I can reply
Hello - could I get a review on python-discord/sir-lancebot#1223 and python-discord/bot#2316 ? I believe I've commited the requested changes. Thanks!
maybe just check if it exists or not and depending on that mount it?
Iβve been thinking about this, but why did any of these issues occur in the first place. I understand why a lib64 might not exist on the host OS, but why would that be the case inside the docker container. Does snekbox use the host fs directly?
For some things the container relies on the host. Like cgroups for example. Maybe that applies to root directories as well. I'm not sure
Thank you, Iβll keep looking
i suppose #reddit should be re-enabled given python hasn't been private for several days now
#community-meta
Are they allowing posts?
ah, i see, all the posts are by the mods, with comments allowed. fair fair
@trim fable cc @thorny obsidian -- Should we update #reddit now that r/Python is public again?
The webhook still won't function, no new posts are being allowed besides the automated ones and moderator ones.
!ot
#ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.
Ask in an off-topic channel please 
oh i am so sorry i actually was writing on that only but accidently written on this lol
my bad
Hi! Do you have a question about one of Python Discord's repositories/projects?
recovery action successful
β― docker compose up
[+] Running 0/2
β Ή web Pulling 1.1s
β Ή metricity Pulling 1.1s
no matching manifest for linux/arm64/v8 in the manifest list entries
``` so thats what i get when i try to run `docker compose up` in the main `bot` project any ideas?
add
platform: linux/amd64
in web, metricity, and snekbox
thanks looks like its pulling now
updated bot#2646 with example look
Huh, I did not realise that discord.ext.tasks.loop automatically reruns tasks by default on some errors. The implementation doesn't seem great though because:
- The error is never logged.
- There is no limit on the number of times it will retry afaict.
- The error may not be something that will be fixed by retrying.
Caught me out testing bot#2662 as for python_news the loop was running but nothing was being output. Turns out there was an SSL error that was being suppressed and causing the function to keep looping and failing without any log output.
IMO this feature does not seem helpful. If we want rerun logic I think it should be explicit, more localised than a whole loop function, only handle errors that are expected, and include logging + limits.
There is a reconnect parameter you can set to false, although it could be worth having a botcore wrapper for loops that makes it default to false, or could reimplement the rerunning logic but better...
What happens when you set reconnect to False ? Does the exception flow ?
Yeah, I think it would just be raised and logged to sentry as an unhandled error (I don't think it would go through our command error handler)
I think there's a way to relay those exceptions to our error handier
I'll look it up after lunch
It should be possible, I guess that would be an argument for having a utility in botcore, since it gives us more flexibility.
Yes, we can wrap around the task decorator even further and have it bind to the error event bus
I made an issue https://github.com/python-discord/bot-core/issues/186
Nice, thanks !
Ruff is trying to change these two lines
AFAICT, this should be fine
Is there a specific reason they were like this?
Dont know if this has been discussed already, but a help thread is still open after a day.
https://discord.com/channels/267624335836053506/1127544083687161906
how is this related to contributors chat?
Because it's the bot that is supposed to close it after an hour of inactivity
I did raise this internally, but didn't get much of a response. It seems discord did have some API issues on that day, but not sure if the timing matches
It wasn't a bot restart, so that's the next most likely thing
ah okay did not catch it sorry then 
Alright, 
Yeah I wasn't quite sure to be honest, that's why I asked the question.
@clever wraith Is that what you were asking ?
yeah thats what i was asking if you can select range of lines
yeah im talking about this feature
Yeah that'll be the CodeSnippet cog
!source CodeSnippets
Cog that parses and sends code snippets to Discord.
I'm not sure it's worth having for the paste service though
yeah i know im on it
welp if it had multiple lines it could be worth considering
but its 1 line only for now at least
I was trying to contribute to an open source project by forking it, then cloning it remotely and then when I did git clone ... I got this error message, I don't know what happened, if I should be alarmed, or what I should do.
I tried turning on VPN and then clone again to protect against man-in-middle attacks, but I still got it
Cloning into 'mkdocs-material'...
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
SHA256:123456abcd.
Please contact your system administrator.
Add correct host key in /c/Users/username/.ssh/known_hosts to get rid of this message.
Offending RSA key in /c/Users/username/.ssh/known_hosts:1
Host key for github.com has changed and you have requested strict checking.
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
@sharp crag sir-lancebot#1223 Is ready for you to update it, then one of us will merge it!
Also @sharp crag, if your PR ^ does fix sir-lancebot#1179 (I seem to remember you saying it does), can you please add "Closes #1179" to the top of your PR so that it'll close both issues
pinnwand#170
ah
thanks to @stark crypt now it will be possible
i am not sure where to bump the version for deployment, i doubt i have the necessary perms anyway
i am sure the dev(o)ops team will get on it when they have bandwidth π
Thanks ! I've raised it internally, and we'll deploy the new version
what about the bot#2679 tho 
apologies for the ping.
would we also consider promoting autodetect as one of the preferred lexers?
reasoning: https://discordapp.com/channels/267624335836053506/1128363286975483914/1128435087923494963
yea, added it
sweet π
annoyingly, clicking the dropdown no longer shows you the Python at the top of the list though
it shows you where Python is in the "normal" list
so you don't get to see the preferred lexers easily
oh? is this not what you are seeing?
I see this
hmmmm, clearing cache and reloading seems to have fixed it
probably had some old js in there
potentially, the regular "Python" option is still buried down there even there is one at the top, feel like that's a bug π€·ββοΈ imo same option should not be shown twice
but hey if it works ain't broke don't fix it heh
Done, thanks!
Is there anything else I'm missing? I think we can go ahead and merge it now
Nothing, i just wanted you to do it (update the branch)
Oh right, done as well β
Hi everyone, I've been doing a commit here (this is a first for me). I read about these protected branches and didn't understand anything. Do I need to do something or will everything be fine?
You don't need to do anything
After your Pr gets two approvals from staff, a core dev will merge your branch to main
Got it. thnx.
Protected branches are usually a concept in applications that allow code hosting and version control.
It's just a set of rules that allow/disallow things for specific users when they're trying to do specific actions into branches. Like merging code, or pushing straight to it, etc.
We do this so that, obviously, not everyone will be able to introduce code we haven't reviewed to our repositories.
!rule 6 Remove your advertisement
Hi
bot#2460 is this accepted? if so i can work on this
Hey all,
Can I give praise to the people / person who worked on the new !pastebin.
It looks great and now also works on mobile with lining up line numbers.
Nice to see the "multiple file" upload as well, although I havent used it myself yet, seen it shared by others, looks great!
Thanks for doing that β€οΈ
That'd be the great Chris man @vale ibex
We didn't write it but we're happy to have found it π https://github.com/supakeen/pinnwand
There's a discussion there about an issue with this transition, so not accepted currently
hi, i know this isnt much python related but i love the snekbox, is there a way to sort of make it work with node or something?
snekbox is interfaced with an API, so you could have your node app call that API. Would mean you'd need to run snekbox somewhere.
Yes, though you'll need to get nodejs into the docker image together with python. Then it's just a matter of changing which binary nsjail is executing (and making sure it's mounted). Haven't tried it myself but if you do let us know how it goes.
Oh I was scrolled up..I guess we have two different interpretations of your question
My answer is for if you meant you want to make snekbox evaluate JS code
Hah yea we both read that quesiton differently, but both work :P
yes you are correct! Could you possibly give me a lead on how i could achieve this? After some experience i might be able to interpret more languages by myself if needed, looking forward to your response
oh wait, i just mount the executable?
ive got a quick question, why does it put all the executables to /usr/local/bin/whatever if they are in /usr/bin/whatever im just a little confused if i should continue this schema
I'm not intimately familiar with the semantics of Linux directories. We use a base Docker image that comes with Python, and usr local bin is where it put Pythpn, so that's what we have to use in that case.
I don't think nsjail cares where the binary is, as long as it's accessible
You will need to have nodejs in the Docker image and then you'll need to configure https://github.com/python-discord/snekbox/blob/main/config/snekbox.cfg
yes, ive already done the necessary changes, im struggling to have 2 interpreters in snekbox.cfg tho
exec_bin_py {
path: "/usr/local/bin/python"
arg: "-BSqu"
}
exec_bin_node {
path: "/usr/local/bin/node"
arg: ""
}
``` ive tried to do it like this but seems like that wont work as its expecting just exec_bin
You want it to support both python and js?
yeah i want it to evaluate both python and js
now i only need to have these 2 setup and it might work
but config.proto expects just exec_bin in there
and i suppose i cant have 2 exec_bins
You need to have separate configs then. And you'll need another instance of this https://github.com/python-discord/snekbox/blob/main/snekbox/api/snekapi.py#L30 that uses the different config path..the easiest way then would be to have a separate api route for the 2nd language but that likely results in some copy pasting. You could be clever and re-use one route but I haven't thought about what that would look like exactly
snekbox/api/snekapi.py line 30
nsjail = NsJail(*args, **kwargs)```
i shouldnt need to tho? I added a "language" parameter to decide between python and nodejs
You can see the object can take a different config https://github.com/python-discord/snekbox/blob/main/snekbox/nsjail.py#L52
snekbox/nsjail.py line 52
config_path: str = "./config/snekbox.cfg",```
yes, but that would be unnecessary code, there has to be a work around for it to have exec_bin_py and exec_bin_node no?
The config is directly for nsjail. It is not our config schema. Nsjail does not support configuring multiple binaries cause it wouldn't make sense.
so there isnt a way to merge the 2 configs into 1 api then?
i could make my own config.proto
We pass the config to NsJail. If you change config.proto then you need to make your own build of NsJail that understands that new config schema. In any case, that is approach is not necessary.
You can just create two NsJail() objects and pass a different config to each. You can modify the EvalRoute to accept two NsJail objects (one for JS and one for Python). Or something along those lines.
I'm not saying that's the nicest way to architect the code for supporting multiple languages, but it will at least get you going.
so there isnt a way to make the endpoint accept 2 languages?
Doing it in a nicer way would require more thought - the code was not designed with multiple languages in mind so it's gonna be a bit awkward without some redesigns
theres no EvalRoute? u meant this?
def __init__(self, *args, **kwargs):
super().__init__()
nsjail = NsJail(*args, **kwargs)
self.add_route("/eval", EvalResource(nsjail))
Yes, sorry, EvalResource
So something like
nsjail_py = NsJail(*args, config_path='...', **kwargs)
nsjail_js = NsJail(*args, config_path='...', **kwargs)
self.add_route("/eval", EvalResource(nsjail_py, nsjail_js))
And then EvalResource has something like
if request is for python:
self.nsjail_py.python3()
else if request is for js:
# The function is still called python3 which is a little weird
# but it's just a name - the config dictates which interpreter is executed
self.nsjail_js.python3()
i've added a parameter language so i can just do if language == "python": as well no?
yes, that was just pseudocode
seemed to work, now i get this OSError: [Errno 30] Read-only file system: '/sys/fs/cgroup/init'OSError: [Errno 30] Read-only file system: '/sys/fs/cgroup/init'
do i need to chmod anything or something
What's the full error?
That doesn't look like the full error - it got cut off?
no, thats all thats the entire thing
hmm oh wait
def __init__(self, nsjail: NsJail):
self.nsjail = nsjail``` probably need to change this too right @tawdry vapor but to what? do i just do nsjail_py = nsjail and then nsjail_js = nsjail or what
Change the function signature to accept two NsJail arguments and then you need to assign each to its own instance field
ah right thought there would be a little bit more dynamic way to do this but i guess its fine for now
okay still the same error
https://paste.pythondiscord.com/5MHQ
nvm
my bad
okay @tawdry vapor ive done it
but
execve('/usr/bin/node') failed: No such file or directory
root@493731395b15:/snekbox# /usr/bin/node -e "console.log('hi')"
hi
so i don't know whats going on here
uhhh ```
{"stdout": "node[1]: pthread_create: Resource temporarily unavailable\n", "returncode": 139, "files": []}β
How did you add node to the container?
You are most likely missing some mounts in the nsjail config
Oh I see the other error now
I don't knew what that means exactly
Try increasing the memory limit in nsjail
Or in general playing with the limits until it works
oh so both configs must match eachother i just change the exec_bin right
and u mean this? cgroup_pids_max: 6 or what
I meant the memory limit but you can also try increasing pids
wont this make it less secure by anything or make it slow down anything?
And no the config won't exactly match, they likely need different mounts
It doesn't make it less secure it just lets the process use more resources
apparently i can limit the threads in node itself
set the threads to 6 and nsjail return code: 137 amazing
2023-07-21 00:48:01,880 | 9 | nsbox.nsjail | INFO | Executing code...
2023-07-21 00:48:02,457 | 9 | nsbox.nsjail | INFO | Found 0 files.
2023-07-21 00:48:02,457 | 9 | nsbox.nsjail | INFO | pid=11 ([STANDALONE MODE]) terminated with signal: SIGSEGV (11), (PIDs left: 0)
2023-07-21 00:48:02,457 | 9 | nsbox.nsjail | INFO | nsjail return code: 139```
and it returns this
`{"stdout": "", "returncode": 139, "files": []}`
okay so the cgroup max memory and swap memory?
If you fixed the pthread issue already then never mind
If you have a segmentation fault then I'd guess you're missing some mount for a shared library or something along those lines
oh hmm what could nodejs be using
u reckon i need npm as well?
No
If you can run node in the container, outside of nsjail, then you already have everything you need. You just need to give nsjail access via mounts
but access to what
Shared libraries
Use ldd
I think the python config already mounts then all but maybe not
If it's not a mount issue then I have no idea why you get a seg fault
how does ldd work then? i dont know what could possibly be wrong
Ldd tells you which libs a binary uses
linux-vdso.so.1 (0x00007ffe02fa9000)
libnode.so.64 => /usr/lib/x86_64-linux-gnu/libnode.so.64 (0x00007fd726a5a000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fd726a3c000)
libuv.so.1 => /usr/lib/x86_64-linux-gnu/libuv.so.1 (0x00007fd726a0f000)
libbrotlidec.so.1 => /usr/lib/x86_64-linux-gnu/libbrotlidec.so.1 (0x00007fd726a00000)
libbrotlienc.so.1 => /usr/lib/x86_64-linux-gnu/libbrotlienc.so.1 (0x00007fd726972000)
libcares.so.2 => /usr/lib/x86_64-linux-gnu/libcares.so.2 (0x00007fd72695e000)
libcrypto.so.1.1 => /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 (0x00007fd726670000)
libssl.so.1.1 => /usr/lib/x86_64-linux-gnu/libssl.so.1.1 (0x00007fd7265dd000)
libicui18n.so.63 => /usr/lib/x86_64-linux-gnu/libicui18n.so.63 (0x00007fd726302000)
libicuuc.so.63 => /usr/lib/x86_64-linux-gnu/libicuuc.so.63 (0x00007fd726133000)
libicudata.so.63 => /usr/lib/x86_64-linux-gnu/libicudata.so.63 (0x00007fd724743000)
libatomic.so.1 => /usr/lib/x86_64-linux-gnu/libatomic.so.1 (0x00007fd724739000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fd724732000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fd724728000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fd7245a4000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fd724421000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fd724407000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fd7243e6000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd724224000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd728017000)
libnsl.so.1 => /lib/x86_64-linux-gnu/libnsl.so.1 (0x00007fd72420b000)
libbrotlicommon.so.1 => /usr/lib/x86_64-linux-gnu/libbrotlicommon.so.1 (0x00007fd7241e8000)
there dont seem to be any that are not found?
Make sure those directories are mounted in nsjail
i have mounted /usr/lib, /lib64, /lib
I dunno what the problem is then
do they need to be rw set to true maybe?
Doubtful but you can try
what does rw do anyways
It means read/write
If it's false then it's a read only mount
You can experiment with running node directly through nsjail command line until you find settings that work
There are a lot of settings to mess with
That's a different error than the segmentation fault isn't it?
yeah thats when i run nsjail --config config.cfg /bin/bash through the docker container
curl -X POST -H "Content-Type: application/json" -d '{"language":"python","input":"print(\'hi\')"}' http://localhost:8060/eval
{"stdout": "hi\n", "returncode": 0, "files": []}``` python works just fine
curl -X POST -H "Content-Type: application/json" -d '{"language":"nodejs","input":"console.log(\'hi\')"}' http://localhost:8060/eval
{"stdout": "", "returncode": 139, "files": []}``` nodejs doesnt return aything
Yeah that won't work because nsjail will not automatically create the cgroup directory it needs. It has to be created manually beforehand. This is part of the work snekbox does. You can do it manually or you can just disable the cgroup limits for now while youre debugging
mkdir('/sys/fs/cgroup/pids/NSJAIL/NSJAIL.17', 0700) so i run the mkdir file on that yeah
[E][2023-07-21T01:51:33+0000][49] bool util::writeBufToFile(const char*, const void*, size_t, int)():95 Couldn't open '/sys/fs/cgroup/pids/NSJAIL/NSJAIL.50/pids.max' for writing: No such file or directory
``` now i get this and i cant make files in that directory so
i dont understand why its not working
Hmm maybe the pids controller is not enabled. I suggest you just remove the cgroup stuff from the config for now..I doubt it's the reason for the segfault
should i remove memory too or not
All cgroup stuff
now i get this
[E][2023-07-21T01:59:08+0000][1] bool mnt::initNsInternal(nsjconf_t*)():487 chdir('/home'): No such file or directory
but /home exists
@tawdry vapor 2023-07-21 02:02:24,027 | 9 | nsbox.nsjail | INFO | Executing code... 2023-07-21 02:02:24,381 | 9 | nsbox.nsjail | INFO | Found 0 files. 2023-07-21 02:02:24,382 | 9 | nsbox.nsjail | INFO | pid=24 ([STANDALONE MODE]) exited with status: 0, (PIDs left: 0) 2023-07-21 02:02:24,382 | 9 | nsbox.nsjail | INFO | nsjail return code: 0 i think i found the issue, but it still doesn't output anything
oh now were getting somewhere
changed the cwd to /snekbox instead of /home now it works
oh nvm im dumb okay lets see
root@eb66b59ed0c8:/nsbox# nsjail --config /config/nsbox_js.cfg /usr/bin/node sc.js
outputs:
[Function: Object]
sc.js:
console.log(this.constructor)``` so it seems to execute, now why dont i get any output when i use curl
Is it possible to have a command that deletes a thread given its snowflake, without having to iterate through any history?
wdym by iterate through history
and what's the use case
To let users delete their own python help threads. I don't think it should be incumbent on moderators to do this.
But I don't want to waste API calls iterating through the history of python-help to find the thread they want to delete (it might have been months ago)
perfect, thank you @tawdry vapor so much for your help
Yes, the thread as a whole can be deleted
post = await pydis_core.utils.channel.get_or_fetch_channel(post_id)
await post.delete()
obviously with validation in there to make sure the ctx.author is the post's owner and whatever else would be needed
Np glad you figured it out
haha, back at it again
ERROR | execve('/usr/bin/csharp') failed: No such file or directory
``` does this mean i forgot to mount something? Cus if i bash into the docker container i can run that executable just fine, also ldd outputs that its not a dynamic library
so since its not dynamic, it shouldnt need any special mounts, and should just run the app right? if i exec into the container i can run the executable no problem in the nsjail config i mount the src usr bin csharp to dst usr bin csharp so thats not an issue either i dont know
It looks like execve is erroring with ENOENT, which is documented as:
The file pathname or a script or ELF interpreter does not exist.
https://www.man7.org/linux/man-pages/man2/execve.2.html#ERRORS
It's vague what they mean by a "script"
Mounting /usr/bin/csharp should be enough
Try mounting that chsarp binary in another language's config (one that you know works), and then evaluate some code in that language that checks if the csharp binary exists
As a sanity check
so i mount it in python snd then what do i like do os.listdir or something
yeah
ill try in a sec, and if it does exist then what and if it doesnt then what
not sure. maybe the debug logs for nsjail will reveal something useful
yeah so listing the /usr/bin/ directory shows csharp
idk if it might be helpful but its a bash script running exec /usr/bin/mono/ which i have mounted ran ldd on that says lib64 and /usr/lib should be there and ive mounted those also
So /usr/bin/csharp is a bash script?
If so, don't you need bash mounted? And shouldn't the command be something like /usr/bin/bash /usr/bin/csharp?
idk about having the najail access to bash, what if i use the actual script that runs it and add args to it leave out the bash script completely
I don't understand why you even need a shell script to execute mono
Just execute mono directly
YYY
@clever wraith r/Python was inaccessible because the subreddit went private for a period of time.
Is there some place where they talk about why it went private ? (I'm just curious, that's all)
Subreddits going private to protest the Reddit proposed API changes was a big thing on Reddit as a whole. I made a mod heads-up post about it when r/Python went private, there are several threads on r/Python itself discussing it, Chris posted in #reddit as well when it was turned off.
Alright, understood.
Thank you ! (you too @outer oasis )
https://www.pythondiscord.com/pages/guides/pydis-guides/how-to-contribute-a-page/#having-the-category-also-be-a-page
In the above guide, it lists the following hierarchy to define having a category also be a page.
guides
βββ contributing.md
βββ contributing
β βββ _info.yml
β βββ bot.md
βββ _info.yml``` I have replicated this....
guides
βββ venv-troubleshooting.md
βββ venv-troubleshooting
β βββ _info.yml
β βββ os-selection.md
βββ _info.yml```
However I'm getting some strange results, such as os-selection being rendered instead of venv-troubleshooting.md, and further, venv-troubleshooting.md not being present at all.
should os-selection.md be one-level higher, so that it's in the same dir as the folder?
since it looks like you have a category inside another category
Figured it out, as is tradition, directly after I posted. Was missing an _info.yml
@vale ibex / @clever wraith RE bot#2692 would it also be worth doing the same if the author is muted (especially if the mute is 1hr+, since the channel will be closed by the time they can message again)?
Not imo, since we'd also need to check if the mute was did to a false positive filter
I'd rather we keep it to bans for now and talk about mutes in another issue
The "only 1hr+" would solve that
Timeout a user for the given reason and duration.
I meant default*
But the automutes are 5-15 mins, aren't they?
And actually if you put it in the !mute command itself then you wouldn't
the ones given by bot are 10 minutes I think
It shouldn't be that hard to add this logic to the mute & ban commands
I'd want to post to be closed even if the ban was from a filter
lets keep this issue for bans and we can talk about doing mutes in another issue.
If we're auto-closing based on ban, we should include that the post was closed due to the OP being banned in the close message
so that we don't get people coming in here saying the bot is bugged since it closed a post early
@clever wraith I've updated that bot-core PR
since app commands don't pass through process_commands anyway, there's no point in waiting for those to be sync'd
So I've just re-used the existing task
Think I'm just going to squash the fixups, since the diff is so small anyway
yeah go ahead & squash
In that case @vale ibex
Do you even need the extra wait_until_extensions_loaded method ?
Alright
Sounds good
Weird, I don't get why is pycharm still showing me the old code, even though I pulled then reloaded from disk.
The commit hash is the correct one (the latest one you force pushed)
I have both bot and bot-core projects attached, but when I open bot-core separately, it displays the correct code. XD
Yeah
Time to switch to gedit
Actually not
actually, there's a problem
is it
if a 3rd party is using BotBase, but not using load_extensions() this won't work
re awaiting the task ?
nah that task is fine
Yeah
But that's just a matter of documenting, isn't it ?
It's a usage issue
Can we just say "if you don't use this, it's your fault"?
Or do we want it to be available separately?
It's actually re-awaiting a coro that throws, my bad.
I mixed them up
@clever wraith check for updates
For what exactly ? Pycharm ?
Or gedit ?
Np
Don't know why the issue was happening
(I didn't know that would even work) π³
It's surprising how often that could work ahahhaa
I didn't think u would ACTUALLY have an update lol
Yeah, but i thought the Reload from disk option was for that
Which also didn't solve it ahahha
I hope this is the correct place to ask about this! I'm wondering if there's a good way to find issues with the "Easy" label that aren't being worked on yet. I've tried using the "no:assignee" filter, but it seems like all or nearly all of the remaining issues have no assignee but do have linked PRs fixing them. How should I approach this differently?
Thanks for your help!
Hi, Yes it indeed the right channel.
We do have the: good first issue label, which is the equivalent of the: easy one you're looking for.
However, it's not present on all of our projects unfortunately
You can find it in bot, site and sir-lancebot especially (which are the projects that people contribute to the most)
!contribute
Looking to contribute to Open Source Projects for the first time? Want to add a feature or fix a bug on the bots on this server? We have on-going projects that people can contribute to, even if you've never contributed to open source before!
Projects to Contribute to
β’ Sir Lancebot - our fun, beginner-friendly bot
β’ Python - our utility & moderation bot
β’ Site - resources, guides, and more
Where to start
- Read our contribution guide
- Chat with us in #dev-contrib if you're ready to jump in or have any questions
- Open an issue or ask to be assigned to an issue to work on
You can have a read at this for our contribution process/guidelines