Allow snekbox to run in both 3.10 and 3.11#2218
Conversation
a2c95b4 to
08735a1
Compare
| self.jobs[ctx.author.id][ctx.message.id] = { | ||
| "code": code, | ||
| "python_version": python_version, | ||
| "start_date": datetime.datetime.now(), | ||
| "bot_response_message_id": response.id | ||
| } |
There was a problem hiding this comment.
A namedtuple would be nicer, though I have doubts that you even need to store most of this.
There was a problem hiding this comment.
You're correct, it only needs to be a invokation:response mapping 0817398
|
Being able to run in 3.11 sounds good. I'm not sure that the button to change versions is worth the added clutter given that in the vast majority of cases of eval commands the version wouldn't make a difference. Was having a separate command like |
This PR does add optional argument to the commands too. The thoughts behind the button is if the user runs into a 3.11 problem, they can easily switch to 3.10 and see if it works on that. |
|
Something that could reduce the clutter would be making the delete action a button too, so it's inn line, rather an emoji below. |
e5780bc to
7a852f0
Compare
|
I get the following error when trying to use the delete button |
I keep using the wrong delete method for these interactions 😮💨 |
|
Error Reproduction:
|
|
Hmm, it seems the cog_command_error isn't hit when the function is being called from the interaction. It's an easy fix, we just need to move the error handling from there to instead be a try/except around send_job inside run_job. |
|
Will squash some of these commits before merging. |
e5006b2 to
6a7d840
Compare
|
|
||
| return output, paste_link | ||
|
|
||
| @lock_arg("snekbox.run_job", "ctx", attrgetter("author.id"), raise_error=True) |
There was a problem hiding this comment.
Not really important but...
| @lock_arg("snekbox.run_job", "ctx", attrgetter("author.id"), raise_error=True) | |
| @lock_arg("snekbox.send_job", "ctx", attrgetter("author.id"), raise_error=True) |
There was a problem hiding this comment.
Good point, fixed this!
0c8f933 to
ec8aac5
Compare
To do this we need to track, for each user, the active eval's code, python version and response message. This is because a button press can now also trigger a job to continue. If we did not track these, then editing your own code and then re-evaluating it would trigger the wait_fors in continue_job for each time you pressed the button to change languages. Co-authored-by: Mark <1515135+MarkKoz@users.noreply.github.com>
Rather than passing around superfluous variables.
The cog_command_error isn't hit when the run_job function is called from the button interaction, this means if the lock error is raiseed, it doees not get handled.
This is so that we do not need to spawn the run_job call in a seperate task. This also wraps interaction.message.delete() in a NotFound suppress to cover the case where a user re-runs code and very quickly clicks the button. The log arg on send_job will stop the actual job from running in this case.
ec8aac5 to
aca5494
Compare
This PR updates the snekbox cog to run using Python 3.11 by default, and send a button with the code output response:

Clicking this button allows the use to re-run their same code, but under 3.10.

Clicking this button deletes the previous response and sends a new response, also with the button. Clicking the button again allows the user to change back to 3.11.
This also works with editing your evaled code, where the button ill always run the most recent edition of the user's code.
To do this the cog needed to track, for each user, the active eval's code, python version and response message.
Since a button press can now also trigger a job to continue, if we did not track these then editing your own code and then re-evaluating it would trigger the
wait_fors incontinue_jobfor each time you pressed the button to change languages.