#dev-contrib
1 messages · Page 80 of 1
alright cool, is your json tag on a branch?
yes
And you said you rebased that branch on top of master right?
yes i rebased from github desktop (since i'm more of a gui person over command line)
They already rebased so it is uptop date
Do the flake8 errors say what file they're coming from?
and this is the flake8 https://github.com/python-discord/bot/pull/1338/checks?check_run_id=1801665190
looking at exactly it is failing in bot.py, so a change i didn't make
like here for instance
https://stackoverflow.com/a/6794290 u cld have a look at this
how do i revert all my files on my local copy back to a certain commit?
commit 4a155e5b3b4548f5f8139b5210b9bb477fa549de
Author: John Doe Doe.John.10@gmail.com
Date: Thu Jul 21 20:51:38 2...
i'm almost tempted to just delete the branch atm and make a new one
I think that might be the easiest
since it has become such a mess now
for some reason the PR diff has some lines that are already in master too
git reset --hard <commit sha> to rollback to a certain commit
That is a destructive action though
Hence i said “cld” in that 😛
Well gtg guys, if someone is free have a look at the issue automatic link
@gritty wind gentle reminder that i have mentioned your requested changes ( u didn’t reply to my earlier msg, so thought u didn’t see that)
there we go, now lets play the waiting game
was getting a bit sick and tired of it with all those conflicting issues. So just backed up my work and restarted. And that worked so i'm happy now
the only thing that got lost was my local lint tester and i forgot how to install it :p
pipenv run precommit to setup the pre-commit hook
pipenv run pre-commit to then run it manually
you might need to do pipenv sync --dev first
FYI, my PR got merged into cheat.sh so it should work without overwriting the headers now 🙂
!e ```py
import aiohttp, asyncio
async def test():
async with aiohttp.ClientSession() as s:
async with s.get('https://cheat.sh/python/json') as response:
without_headers = await response.text()
s.headers['User-Agent'] = 'curl/7.68.0'
async with s.get('https://cheat.sh/python/json') as response:
with_headers = await response.text()
print(without_headers == with_headers)
asyncio.get_event_loop().run_until_complete(test())
@vale ibex :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | ModuleNotFoundError: No module named 'aiohttp'
There is no networking
yea, that actually makes sense...
well, you can run it yourself and see that it spits out True now 🙂
.pr 554
What are people's thoughts on this? Is it something we want to do, or are we going to wait for smart config?
It should probably come with some updates to the contributing guide describing how to use docker
Although, the two aren't linked entirely. Since these changes wouldn't impact people who aren't using docker. Tt would just mean people who are using docker will need to create a .env file.
I’ll give it a look soon
lol
@vale ibex mentioned the requested changes except the last one (since am not still convinced to use that)
on CheatSheet pr
The last one being about the line pagination?
yeah
yea, that's not something we can do atm, until its ported over from the other bot
So I've just closed that comment
ok, and dog status code comments also mentioned
Cool 👍 I'm heading off for bed now though, so I'll give them both a once over after work tomorrow 🙂
my first pr gets merged ! 
🎉
lets wait for the bot to restart
Hey folks, can you please check bot#13 and metricity#1 and snekbox#11
noice
Does this exclude private repos?
yeah
it gets public pydis repos
since it is getting the repo_list through the github api
ak's idea
#sir-lancebot-playground message shouldn't the cooldown be reset here?
ty
nicely done
@patent pivot RE #sir-lancebot-playground message lancebot doesn't have member intent enabled
looking through the code base, only this and AoC seem to be effected
ah that was unurelated
the user was on cooldown, that's why we were sad
ahhh
we figured out that discord.py could reliably fetch that data even without the member intent
#sir-lancebot-playground message was about this then?
that's cuz of it ig
Can you int e the role
yea, there are a few places in the valentines cog where this is happening
eg
.love @vale ibex
it can't see the members
Would have raised a IndexError
staff = ctx.guild.get_role(Roles.helpers).members
whom = random.choice(staff)
There are no users avilable to whome your valentine can be sent.
but many ppl have the lovefest role
send it to me @rapid swallow (.bemyvalentine)
i have lovefest
I'm on a cooldown right now
ah
the cooldown thing needs to be fixed
the command should not go into a cooldown if the user makes any input mistakes
and might think about lowering the cooldown
yeah, the cooldown should be reverted on UserInputError or something
there's these typos too
I english was quite bad when I was writing that feature 2 years ago 
ahh lol
whome is sort of valid
Hey, can anyone have a look at the following, since i won't be able to commit to them after 4th due to exams:
sir-lancebot#571 , sir-lancebot#572
hmmm
, sir-lancebot#571 , sir-lancebot#572
It obviously shouldn't work that way, but as a temp workaround 😄 @short snow
hmm, lets see why this happens
!e
import re
print(re.findall(".+?(test)", "test"))
print(re.findall(".+?(test)", "something test"))
@gritty wind :white_check_mark: Your eval job has completed with return code 0.
001 | []
002 | ['test']
oh wait bot has re
Wdym?
fr".+?({self.repo_regex})#(\d+)"
Why do we have .+? here
Anyways, you can move sir-lance first, since bot is a substring of it
it'll try to match it first, before matching the shorter bot substring
https://regex101.com/r/tD5x6o/1 look at this, hmm
"(meta|sir-lancebot|bot})#(\d+)"gm this works
Also waaaay fewer steps lol
english please.
down to 500 from 25000
bot}
Why is there a closing bracket here
The actual replied message also had that which is why it got 0 matches
(And can you PR the fix)
re.findall(fr".+?({self.repo_regex})#(\d+)", message.content) the actual one doesn't have that
it was just a typo of the f-strings
#bot-commands message this works tho
Hello @clever wraith, we are an english speaking server, so please try to speak english to the best of your abilities
sir-lancebot#571 , sir-lancebot#572
Oh, we merged it
yeah, and i jsut found this bug
The code does match it <#bot-commands message>
#bot-commands message regex is being weird
I'm not sure why it only does that in that instance
both cases, bot comes first
Alright I think it matches the way it does because of the lazy operator
At least, removing it made it match correctly
(The operator and operand)
Which channels is it enabled in?
Development, #organisation and a couple of mod channels
can we get it in bot channels too 😛
Time to make a master commit
Anyways I'm pushing the updated regex to master if no one has concerns
fr"({self.repo_regex})#(\d+)"
lol yeah
Did we remove the notifications from sir-lancebot when it reconnects?
bot#320
Or did it just not restart yet
Ah actions
and here it comes.
Hey, can anyone have a look at the following, since i won't be able to commit to them after 4th due to exams:
sir-lancebot#571 , sir-lancebot#572
hey guys
cool
#❓|how-to-get-help or #python-discussion 😄 (edit: if it is not related to pydis projects)
oh sure
Is it related to the pydis projects?
@short snow https://github.com/python-discord/sir-lancebot/pull/560#discussion_r560045919
I'm not sure if this was never addressed, or if it snuck back in at some point, but this is still an issue
+ if game in self.games:
self.games.remove(game)
Its not that game might not be in list, game might not be defined at all
!e
def test():
raise ValueError()
try:
game = test()
except:
print(game)
@gritty wind :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 4, in <module>
003 | File "<string>", line 2, in test
004 | ValueError
005 |
006 | During handling of the above exception, another exception occurred:
007 |
008 | Traceback (most recent call last):
009 | File "<string>", line 6, in <module>
010 | NameError: name 'game' is not defined
ah ok
You can give game a placeholder value outside the try block
Good job on keeping up with all the changes though, I think I'm good with the current iteration
yup
@gritty wind done.
another review needed for c4, if anyone is free 😄
.love command is always taking laudmo.
Yeah seems pretty broken
staff = ctx.guild.get_role(Roles.helpers).members
whom = random.choice(staff)
seems it should be a random person https://github.com/python-discord/sir-lancebot/blob/master/bot/exts/valentines/lovecalculator.py#L53
was thinking it could be an intents problem?
I don't know enough about discord.py though
looks like intents issue yeah
intents.member should be True?
I don't think single command warrants adding intents
especially if that command is not necessary for the bot to work
yeah
(well it is not a single command, the count command also needs them)
still doesn't sound reasonable
intents shouldn't be enabled unless core/important features need them
yeah
ok
the memory & cpu usage of sir lancebot after removing those intents brings me great joy
What do you think the best way to get around that would be, I guess we can just require two users as an input?
Maybe we should use lovefest role for random member?
why do we support a random member?
It was fun, but if we're going to replace it with a constant, there's no real point in it
Just have a command that always needs two members to calculate their love score
An idea would be the member that sent the last message
that would be good (for ves)
or perhaps random choice from last 50 messages?
also whoever does that change, also correct the typos in it
Depending on message cache
I think it should have to be a helper or user with the lovefest role, so I'm not sure about random choice/user who sent the last message. I think a command that requires two members is probably the best option
How do we review a pull request? (As in the technical details, not the guide) Do I need to do it from the pythondiscord/repo or the author's fork?
the orginal main repo
Okay, so do I need to clone the main repository or do I need to do it directly from github.com?
Also, how could I do it from Pycharm (Professional)?
directly from the main
open your clone project , and then go prs tab on left hand column
and then open the pr u wanna see
and then u can do it
i prefer using the github.com at start
Okay, and how can I test the code?
gh is the Github CLI?
another way
yep
Could I like create a branch and clone the code to that branch and run it from there?
Another fork of the author's fork?
okay thank
for testing
s
Also, is there an easier way to update your fork other than creating a reverse pull request?
# IF this is your main and has no commits of yours
$ git remote add upstream <main_Repo url>
$ git fetch upstream
$ git reset --hard upstream/main
$ git push origin main --force
this is what i do
(only on main)
(and i commit on feature/<name>)
Do you mean upstream/master? Is main the same as master?
Also what does git reset do?
Nevermind I got it
for bot#1393 can someone quickly do a sanity check that in terms of grammar and sentence structure it makes sense? i sometimes have a habbit of writing a messy sentence from time to time
Hey @trim cradle, can you please have a look?
You want me to look at the issue in that comment from Sir Lancebot?
!remind 3h look at issue
Your reminder will arrive in 3 hours!
At the wording of the tag, yep
I'm trying to figure out the internet situation in my room. Hopefully I'll have it sorted out by then.
Thanks!
If not I will cry btw.
don’t do it 
for a full review i'll just wait but i know from experience i sometimes make a mess when writing sentences so just a small second look from someone else that nothing is wrong lol
how would I go about checking out a PR to test it?
I tried git fetch upstream pull/571 as an example but didn't have any luck
ahhh I got it
git fetch upstream pull/571/head:dogsh && git checkout dogsh
Add this as an alias to your gitconfig
cpr = "!cd ${GIT_PREFIX:-.} && git fetch origin refs/pull/${1}/head && git checkout FETCH_HEAD #"
That reminder has been deleted successfully!
Thank you!
i'd recommend using the github cli
then you'd be able to do gh pr checkout <pr number>
What advantage does that have
Was gone for dinner but thanks
uh
i think you were looking at an outdated file :p
I don't really know how to navigate github
already made a reply on one but yeah
this one should show the latest update
and from here i can add like a comment regarding that line
that should apply it to the latest one
@mossy wolf This is what you want to have reviewed?
yup that's the latest version
i'll see from the comments you made which one apply to the current one
and see if i can resolve those
You don’t have to setup an alias
That’s about it
In exchange for an extra dependency 🤔
You can push too, not sure if it works with the ref thing
@mossy wolf it might be easier to rethink what's being communicated: as I understand it, the error that this is meant to help you debug is that your json file contains absolutely nothing, but it needs to at least have the literal characters {} so that it represents a json object (which is also, in a sense, "nothing"), yes?
the intention indeed is to debug this common error when someone created a new .json file and forgot to give it a valid "structure"
for instance, using the very common object {}, even tho it doesn't contain data just yet at least the brackets are needed
which is also, in a sense, "nothing"
Not really, it will return an empty dictionary. You could have used an empty list too.
But I’m being picky
one could say that the json {} "doesn't have anything in it" and that's true, but the .json file in the file system does have something in it. But people will refer to either as "a json" and thus it's ambiguous.
Hmmm
We have to be terse with tag messages or people won't read them, so I don't think we should attempt to teach any json-specific terminology unless we absolutely have to.
pushed a slight wording update to indicate clearly that the .json file itself cannot be empty, but the json data can
waiting for the lint test to run
`JSONDecodeError: Expecting value: line 1 column 1 (char 0)`
This means that your `.json` *file* is completely empty, but it still needs to represent some kind of data, even if it's an empty container.
To solve the error, simply change the file to read `{}`. This will save an empty "object", which is very similar to what a dict is in Python.
What about that?
@green oriole @mossy wolf ^
I’d use dictionary on the last sentence, but it seems pretty good to me
made a few commits it's this now
When creating a new JSON file you might run into the following error.
`JSONDecodeError: Expecting value: line 1 column 1 (char 0)`
In short, this means that your JSON is invalid in its current state. This could very well happen because the file is just new and completely empty.
Whilst the JSON data, the data you wish to store, may be empty, the .json file must not. You most likely want to use one of the following data types in your .json file:
I haven’t looked at the proposal though
whilst this suggestion does make it a lot shorter, i'd say it might just simplify it too much
this implies you must always make an object
i guess my tag suggestion might go a bit too much into technical details but yeah json is complex lol
I don't think a tag is the right platform to teach this much about jsons
sure yes, it's about having a normalised way to help with a common error
but i have a feeling this simplifies it just too much, unless that's fine for a tag here
@mossy wolf is there an article that explains this topic in sufficient depth? You could link it at the end of the message.
not that i know off right away
otherwise i'm fine with making 2 tags, one being !empty_json with just a very simple brief solution, and that links to a !json_advanced one or something similar that goes a bit more into the technical side of things
i can see if i can find something online for it tho, so give me a second
We should aim to keep tags short in either case. If you can find an article that explains this topic to your satisfaction, the tag itself should contain a brief message, and then you can link to a page that gives a more thorough explanation.
JSON - DataTypes - JSON format supports the following data types −
can you quickly see if you think this will explain json data types well enough?
I will look to see if there's one that uses Python examples as I am able.
well this tag tries to solve an invalid json, the error appears from python but yeah
If you’re using pycharm, you can just select the PR in the PR tab, and press checkout/update (the text changes based on if you have the branch currently checked out or not). That automatically creates a branch for you, and brings it back up to date when you update
You can do it on your fork, or main, or whatever
sir-lancebot#569
If anyone has a bunch of time, a review on this PR would be greatly appreciated.
@vale ibex I'm hesitating to merge this PR because it's so small https://github.com/python-discord/bot/pull/1390 lol
No more dilemma
alright let's go lmao
I'm waiting for all the checks to pass so we can get that delicious green merge button
Sweeet
😀
and the bot didn't break? it still works? :p
!remind 1000000000000000000000y [REDACTED MESSAGE]
1000000000000000000000y results in a datetime outside the supported range.
!remind [mentions]... <expiration> <content>
Can also use: reminder, reminders, remindme
Commands for managing your reminders.
Subcommands:
!remind delete <id_>
Delete one of your active reminders.
!remind edit
Commands for modifying your current reminders.
!remind list
View a paginated embed of all reminders for your user.
!remind new [mentions]... <expiration> <content>
Set yourself a simple reminder.
good
Before for ref:
to set help channels should i use a category check or help channels check (one by one)
and is there a category check deco ?
What are you working on?
And what do you need the channels for?
Right, probably want to check category then
Not a built in one, no
Heh i put that there just as a comment, forgetting that commands won't work in there
no, i was talking about utils.deco scaleios
Yeah, don't have one in there either
We don't really do channel checks on most sir-lancebot features
its usually only season checks, and sir-lancebot channel
ok, i should make one?
It isn't that simple
The bot has an overall check
You'd instead have to do an override
and pass it the channel list
yea, it uses contants.WHITELISTED_CHANNELS, which determine what channels it can be used in
I'd say ignore my comment about it being useful in help channels for now 😄
ok, that means i need to add all the help channels to the class
hmm, what do others think on that?
I haven't vetted the docs, other than my initial look months ago
I think I'd personally still recommend something like the python docs, or a more tutor based resource, so I don't know how helpful it would be
If you have time for it, go for it
The help category is already in the constants file, no?
hmm right that's the old static system
If you want to do it:
- remove the help channels that are still there
- add a new category class
- add the category ID
yeah am doing that, is there a way to get all channels out of category id in dpy?
You'd have to get the category object and iterate over the channels
I'm trying to check our rate-limits for that right now
but it should be one fetch per command
On second thought, that'd be pretty easy to abuse
like?
The check runs as the first thing when you invoke the command
If you send it a bunch of times in a channel that forces it to do the check
you can make a bunch of api hits
and get us rate limited
You'd have to add a cooldown to make it feasible
ok
Why do you need all channels in the category?
The channels are dynamic, and he wants to add the channels to the whitelist
Actually I see a flaw in that reasoning lol
Why not whitelist by the category id?
☝️ .
I don't understand
yeah
(override_in_channel)
can anyone have a look at sir-lancebot#571 , sir-lancebot#560
@gritty wind can i do a over-ride of all channels and then check for it using if else in the function
since i don't see any way of doing tthat in the __init__
Yeah, the link I sent does an all channel override
You can also override just using the everyone role for simplicity
267624335836053506
You can replace the developer role in the constant file
I think it was renamed to something like everone_role in the bot's constants
let me check
Yeah
@vocal wolf @vale ibex mentioned the changes 😄
I can't give a full review, but I've commented on the things we discussed
Done!
Awesome, thanks
ok sure! will try.
@eternal owl what do u put in the reddit client id?
the image paginator doesn't seem to work on this.
yep
Give it another shot when the API is back in full force, and let us know if it still fails
weird, the emojis (reddit_ work on webhook but not normal pagination
(i don't have them on the server)
ok
they work on .help
@short snow <#sir-lancebot-playground message>
Seems fine now, can you give it another shot?
still having issues @short snow ?
got the ids done, just checking for the paginator issue once again
ok pagination still doesn't work
what error
discord.errors.HTTPException: 400 Bad Request (error code: 10014): Unknown Emoji
``` (for trash emoji)
yes
for pagination on help works
go to constants,
search for trash_can in Emojis dataclass
and replace it with the one in your server
how would that matter, the .help pagination works, but not in .reddit top
cuz you are geting the error
can u give the trash can logo image?
huh
hmm, can u join the test server, would be easier to explain
okay
i will send invite
k
hi
hello!
In our internal eval command, what is this part doing
try:
with contextlib.redirect_stdout(self.stdout):
{0}
if '_' in locals():
if inspect.isawaitable(_):
_ = await _
return _
```?
Uuhhh
That's a good question
Hmm
Is it because the last line result will be stored in _?
Does it just run async input
I honestly don’t know why you’re asking, didn’t you see
Ignore this code, it works
🙃
who is ikuyarihS on discord?
Shirayuki haha
@gusty sonnet Can u check out sir-lancebot#560 as u were the original reviewer. thanks
I am not sure if they will be able to review it, I haven't seen them in a while
I want to know what it does though, ik it works but it will work even if we remove that part from there
probably ping whoever did it
@cold moon do you have any idea? (iirc you were a code owner of that file)
Context?
Not sure. I'm code owner, but I haven't never worked on eval.
!source int e
Run eval in a REPL-like format.
joe seems to have done it
That’s an oooooooollld code
"Automatically awaits awaitables if they are the return value"
I'd assume it just does that
So i guess you can do something like !int e ctx.send("hello") and it will work
ooo
isn't _ just last statement/expression
that will work even if that part isn't there though
The command itself adds _ = in front of expressions to return them when it sees one, the function returns (and awaits) that and then the code formatter works with that result
ah got it
so this will give 64?
!int e 8*8
``` and
!int e ctx.send(_)
I think the former will work, not sure about the latter
I think they both should work
can u try?
its admins+
it is in the command itself
Why am I being pinged
about internal command
int eval things
can u try that joe
supposedly you are aware of what those sacred texts mean
Why not just make it like this.
f'async def func():\n{textwrap.indent(body, " ")}'
!int e 8*8
In [1]: 8*8
Out[1]: 64```
!int e ctx.send(_)
In [2]: ctx.send(_)
Out[2]:
File "/bot/bot/exts/utils/internal.py", line 178, in _eval
res = await func()
File "<string>", line 5, in func
UnboundLocalError: local variable '_' referenced before assignment```
lol
Hmm
I didn't write that
I guess it is used as a placeholder for printing the result
ah makes sense
hmmmmm
because the env is passed in as globals
that will also error out
That would give the same result
!int e ```py
8*8
await ctx.send(_)
In [3]: 8*8
...: await ctx.send(_)
...:
Out[3]:
File "/bot/bot/exts/utils/internal.py", line 178, in _eval
res = await func()
File "<string>", line 6, in func
UnboundLocalError: local variable '_' referenced before assignment```
lol
if you want to play around with it setting up a test server is probably your best bet
I think that use of _ will only work in ipython
^
We can store that value in env and then we wouldn't need to have any thing in code_, just the defining the function part
int e is not a repl
hello @spring ermine, are the one who created !int e? We are pretty clueless about how it actually works, could you please enlight us?
I mean, I think it makes sense
int e just uses exec, the _ is created manually as was shown above
yeah
I get that, but we could move _ to env and just have the function definition part in code_
The cog is a bit of a mess but I don't think there's a need to change what worked so far
k
yeah
We will have a better eval command with rattlesnake anyway
black knight
rattlesnake?
rattlesnake?

right.
@subtle kraken if I do work on internal eval for sir lancelot, i would like to change that.
Is that fine?
The int e part might be indirectly open source since we will probably copy it to other bots haha
I'm not sure what your proposal for changing it is
I'd say current solution is better than just moving it around
That bit needs to be executed in the function, so it can return the expression if necessary
we also should keep things consistent between bots
hmm, k
!int e ```py
ctx.send("hi")
In [4]: ctx.send("hi")```
Not really, we can move that to env and it would still work
oh so it doesn't work anyway lol
and we can have only the function definition in code_
I can imagine there are reasons as to why our eval is not that simple
!int e ```py
_ = ctx.send("hi")
hi
In [5]: ctx.send("hi")
Out[5]: <Message id=806160940046745631 channel=<TextChannel id=635950537262759947 name='dev-contrib' position=68 nsfw=False news=False category_id=411199786025484308> type=<MessageType.default: 0> author=<Member id=409107086526644234 name='Python' discriminator='4329' bot=True nick=None guild=<Guild id=267624335836053506 name='Python' shard_id=None chunked=True member_count=141801>> flags=<MessageFlags value=0>>```
yea
I’d rather have a carbon copy of the code in @stable mountain, it will make things easier when updating
k
The codeblock with higlighting probably messes with the regex
Ah so it doesn't realise it's an expression you think?
I was wondering what the easiest way to PR a tag to the bot is, can I do it entirely through github?
yeah that's the easiest, github has a nice markdown editor
ah cool, thanks
Why am I being pinged
Did you get pinged?
joe lagging out again
ah, it is @everyone
what's int e? I might've forgotten lol
eval
This PR bot#3
You said in the PR that it is from another bot, is it open source?
been a while since I wrote that, what's the question?
it was my old bot which was closed source, and I think I might've even lost it
I could go through it with you @green oriole
It's not that difficult, but I wrote a different version of it for Black Knight
Alright, we were wondering about a few bits and pieces, but I thiiink we figured it out, at least mostly
There are some parts in the current eval that are not used
Probably remnants of development
Like the interactive interpreter instance
How close are you from completing the new eval btw?
It's finished
We got rid ld the interactive interpreter btw
It works in Black Knight and has worked for a few months now
Oh, I yoinked that (interpreter)
Basically it just does py async def func(): # (None,) -> Any try: with contextlib.redirect_stdout(self.stdout): {0} if '_' in locals(): if inspect.isawaitable(_): _ = await _ return _ finally: self.env.update(locals()) where {0} is your code, it execs that code in a scope so we have this new func() in a dict, then we just await func() from the cog
oh cool, do you think we can add that to @stable mountain ?
We could, yeah
is the black knight on the server yet ?
the _ is to await expressions more easily in case someone forgets
I don’t think we have an instance running yet
bruh, did you just not say its old and we shouldn't change it cause "it just works"
The thing it does differently is make sure to generate actual stack traces, because the current eval sometimes gives a stack trace to the cog
While we wait for the new eval, yeah
instead of the code that you're evalling that's actually giving you the error
Hey @hardy gorge could you share it?
I mean if there were issues with it you could've asked me to change things lol, would probably have been less effort
I changed the approach somewhat
I now analyses the code beforehand with AST and inserts it using AST
I see
instead of the string formatting
isn't that a fair bit slower though?
or I guess it could be fairly simple now that I think about it
We don’t use int e fairly often, so if the startup time is a bit slower, I don’t think it much of an issue
i c, but why is there a need of AST?
what is AST?
tree syntax ig
huh
https://github.com/MaryWeeb/bot_showcase/blob/master/cogs/custom_eval.py
Here's the more improved version of the one @stable mountain is running btw
if the result is an embed it sends it, it truncates long messages, etc
also supports ipython vs stdinterp formats I guess
With the current code when having a syntax error, it sometimes points to some code from the template
Oh nice
#bot-commands message
or wait
now that I look at that code it looks like I may have missed something maybe?
wait nvm I forgot how ast.PyCF_ALLOW_TOP_LEVEL_AWAIT worked
I could actually make an even simpler version now that I know how to do bytecode, but that's too hacky even for me
but that's too hacky even for me
that says a LOT coming from me :P
AST is used mainly for two things:
- Ensuring that the tracebacks always correctly identify the problem within the snippet to be evalled (instead of a syntaxerror causing a stack trace to the cog)
- Capturing the value of the last expression if it's not an assignment or call that already generates output, even if it's not a single expression/single statement eval.
There's also slightly better separation between the "default environment" and the "local environment" that caries over between different evals within the same session using ChainMap.
ah thankyou so much, it is clear now!
It also has some things that are now already implemented for @stable mountain as well (the bot did not handle long output graciously before, but now it uses the upload method, Black Knight also has that).
i didn't get any of that, but @hardy gorge is the code sharable?
ok
check out the docs on python
This was not yet added to @stable mountain
it is gonna be added right?
hi.. been hosting snekbox here, anyways to expose the container to the internet? as in.. use requests module on evals?
You’ll have to modify the nsjail config, I don’t know if they are any easy way to do that (Cc @tawdry vapor)
oh.. will see.
also
&eval
from requests import post
r = post("http://127.0.0.1:8060/eval", data={"input", "print('test')"})
print(r.response)
how does it even escape the ports even the interpreter is exposed to? the above code errors out
Well, our setup will block network access
even tho the interpreter sends data thro that port?
Why this block network access?
Say that you have two PCs, one with an internet connection and one without an internet connection. There's only a special USB cable between them that allows them to communicate only text. The PC with internet connection receives the Python code from the internet, but does not run it. Rather, it just takes the code (which is just text) and sends it over the text-only USB connection to the other PC that runs the code.
The code that's being executed does not have access to the internet, since the PC it runs on does not have internet access. The PC just runs the code and captures the output (text). It then sends the text output back to the first PC with internet access over the text-only USB connection. This PC with a connection now sends the result over the internet.
This is an enormous simplification, but you could visualise snekbox this way: The outer snekbox API, with an internet connection, receives the code and passes it as text to an interpreter that's "walled off" inside of NSJail. Inside of this "jail", no connection to the internet can be made, so the code is just run and the output stored as text. Then, the text is returned out of the jail to the outer Snekbox process (which does have a connection), which sends back the code to the client.
In short: The ports are not escaped; the code is executed within an environment that should have no outside access to anything at all.
ohhh, a box inside a box , that cleared up stuff ty
afaik that's how a lot of interactive websites do it now. They have a jailed environment that has access to the database, then 1 outside connection to another environment that communicates and at most runs a few checks to check if the input is valid but doesn't execute anything
it's just 1 jailed environment blocked off from the internet and it gets inputs relayed through a limited local connection to a relay environment
@royal creek
but sebastiaan's explanation probably is more extensive and well written in simple language
(it still feels odd when i need to mention their name as it's almost the same as my name lol)
haha..
The bot is talking unusually long to get eval responses
hi, i'm trying my first open source contribution on a simple issue in the python bot and i'm having trouble getting the bot on my machine locally, i'd be happy if someone could help me cuz im kinda lost
What have you done so far?
i managed to fork and clone it onto my machine
That's a good start
there are many docker stuff here i have no idea what to do with that
never used docker in my life
not really
Are you following the contribution guide?
i'm a beginner, all i know is some C/C++ and Python
Simply put, it helps run code without having to install things on your system
(At least that's what we use it for)
all you need to know is if you have docker installed, just type docker-compose up -d to start the bot
If you don't, its simplest to get it installed
yes, i got lost in the part where i need to create a reddit client
Which part is that?
You can leave those empty if you aren't working on things with reddit
oh ok
so i need to install docker now?
cause it says in the guide that you don't need to
The alternative is a lot more complex
It involves cloning another repo, running it on your system, and playing around with configuration
We recommend docker because it simplifies all that down to 1 step
ye you've convinced me
Though I'd be happy to guide you through it if you still want the alternative
i think it would be good for me to learn docker too
You seem to be on windows?
yeah
Alright, all you'd need to install for docker is
(Check the note about system requirements in that link)
ok, it's downloading
i finished downloading and running docker (and i ran the docker-compose command), what next
Well, if you've done everything correctly, the bot should now be running
Do you have the docker desktop application open?
That does happen, feel free to post it
You can click the run button in this window
it pops up if you hover over it
still got an error
Is it the same error?
Some of these aren't correct for the @stable mountain bot?
For example sesonalbot is for @dusky shore
BOT_TOKEN=YourDiscordBotTokenHere
BOT_API_KEY=badbot13m0n8f570f942013fc818f234916ca531```
pretty sure i followed the instructions
ok ill try this
Where do you see seasonal bot on the page?
Yeah the second one is already correct
okok
If you don't mind, could you share where you saw these though?
Oh I think I see what you were looking at
Those were just examples, the ones you need to set are on the main page
yes it was the environment variables page
If you follow the link, SEASONALBOT_DEBUG=True and CHANNEL_ANNOUNCEMENTS=12345 are only examples
they don't apply to the bot
The ones that do apply are listed on this page in the table
ok thank you
i love the open source community already ❤️
i am still getting the same error though 😕
Can you try running docker-compose up again
docker-compose up -d or docker-compose up?
-d just stops it from logging things to your console
since you are using the docker app, it's probably easier
Hey @foggy crater!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
here is my full error
What do you have in your env file right now?
It should be fine
Did you configure the hosts in your config file?
not sure what that is
It shouldn't have to be set for docker
The defaults are for deployment I believe, docker only needs web:8000 etc. right?
Yeah, but the redis connection error is strange
Usually I would recommend not bothering with it and using fakeredis
One thing I can think of
can you add REDIS_PASSWORD= to your env file and run docker-compose up -d --build bot
I believe it is somewhere in the guide, in the config.yml file you created from config-default.yml you'll either need to set the redis host or set use_fakeredis to true, then you'll also need to configure the site url and schema
do i need to create a reddit app for this?
No, just leave it empty
ok
(Also fwiw, that's redis not reddit. redis is a sort of database thing, but you can learn about that when you have time)
i still have the same error
Can you share your env file again?
And did you run the command with --build?
i coppied the command you sent and pasted it in the terminal
Hmm that's strange. I had managed to recreate the issue, and adding the password var solved it
I'll look into it later, but for now you can set USE_FAKEREDIS to true in your config file
Did you already create a copy and rename it as mentioned in https://pythondiscord.com/pages/contributing/bot/#configure-the-bot?
No those should be fine
They are related to the reddit commands, and shouldn't affect startup
ok i have progress!
Different error, or did it start?
no
Ok, can you go to the docker app, and click on bot
If you look in the area with the logs, you should see an Inspect button
uhu
Top right here
yeah, im in the inspect
That should have a list of Environment variables, what do you see in there?
Be careful because your token could be there in plain text
yes
should i screenshot it?
Does the bot token match what you have in the env file?
yeah
Ok, I'm not too sure. Never had anyone run into that before lol
Can you regenerate the token and copy it again
Oh wait
No my bad
This isn't a discord api error
its a site api error lol
Do you have any changes to your config file, other than the FAKEREDIS one?
(Also can you check that BOT_API_KEY matches)
Ok, that's fine
imma go to sleep now, thanks so much for the help @gritty wind
Whenever you have time, feel free to check in and we'll try to get it solved
FWIW, sorry that you have to jump through so many hoops, we are working on making things easier
it's ok, every mistake means learning lessons for the future
i can't wait to start contributing
sir-lancebot#560 , sir-lancebot#571. sir-lancebot#572 are up for review, one review pending for each, if anyone would like to have a quick look at them 🙂
@timid sentinel I just saw you online, i put a comment on your tag, incase u haven't seen that
yep yep, just seen, replying now
@timid sentinel f0kin beautiful m8
yaaay
Although don't think I didn't notice this, now I see how you value my contributions 
I just don't think tags are that high priority atm lol
Smh I’m sure you did this because wookie opened the pr
lmfao
lol
Bullying other mods
Wookie is a wonderful person and I very respect them
really?
Because we had a really good conversation a really long time ago
you better say that wookie is a nice person
Was that before you were a helper, I think I know what you're referring too

Yep, back in the stone ages of me helping people
The one dpy conversation that started it all
makes me feel old (here), because I feel like you've been mod for ages, and I was a mod before you were a helper
but anyway, this isn't the compliments and talking about the past channel smh, we're quite off topic lol
lmao
Haha
WEE WOO WEE WOO IT'S A DUPE OF #150
lol
i can finish of the left of prs on sir-lancebot if needed xith.
xith stole that from me fwiw smh
lol, and was that yours, or stolen?
I said I will close it for being a dupe
we are currently talking about many issues to close resolved ones, outdated ones etc
Will ask
since eso challenges have went down
Yeah, nope
sir-lancebot#213 show be closed by sir-lancebot#350

Is https://github.com/AvianAnalyst on this server?
regarding the prideanthems issue
they had a lis of songs
if they could just post it on the issue, it could a bit easier for the next one
Hello @granite goblet, would you please have the song list for the pride anthem command?
Hmm
Ah, they left
ah ok
is there some site or place where i could find these anthems?
pydis-api where did this project come from?
ves' status
@hardy gorge is probably working on separating the API from our site
yeah
What do you mean?
no, the site doesn't depend onn the API
and for the text based adventure game, can i take the story from repl.it talks? there many nice interesting stories on that
and what about the bot?
the idea is:
- site (after dewikification) will become our content application, it won't have a databae at all
- api will be a separate django application (separate project, not another app inside) that handles only db interaction
the bot will speak to the api
We will need the API, yes, but not the site
yes
I'm not working on our project; misleading name
I'm doing a personal project to learn FastAPI by migrating it to FastAPI
ohh
lul
Haha
or if someone has a nice story wirtten up
Gotta write one :P
would some sort of among us game be counted in that?
i will make it first and then show, would be better to understnad
Could use a non-Mark review on https://github.com/python-discord/bot/pull/1014
I've request a review from myself
#sir-lancebot-playground message for some reason, it takes the user name as the text
and user name as the username also
Who is GhostOfGoes?
Thanks
KnownError#0001
Ah ok
Thanks
Doesn't dog status codes have two approvals?
link?
I guess it does
then press the the super power button
I already have
, i was slow
Well, is that ok? using the everyone role to over-ride that channels?
in cht.sh
I saw the comment, I'll reply fully at a later time, must look at stuff and things within bot to confirm if it's good or not
Need some help formatting a long list of imports from one file
from file import x, y, z
With everything on one line, I pass the line limit.
from file import (
x,
y,
z
)
I believe this is the typical structure we'd follow in such cases, and that works, but there are ~10 imports, and I don't think they deserve ten lines.
from file import (
x, y, z
)
This doesn't surpass line length, would it be fine?
Alternatively, I could use import file and go down that route, but I first want to see what people think before I start restructuring everything
I don’t mind any of those solutions, do what feels the best IMO
If you're splitting it up I'd personally prefer the style in the second codeblock as it can always be collapsed in most editors if the amount of lines is a problem. But depending on what the module and imported names are, doing the import normally (maybe with an alias to a shorter name) may be the best solution
if the are mannny, then u can use something like the third one, with 2-3 in one line
otherwise i had say 2nd
I don't think the third one works unless you do them all in one line
Because if you are already going to be doing multiple lines, might as well commit
#sir-lancebot-playground message it seems to be lock on boredevil now
he is gonna get irritated of pings soon lol
we need to either remove it or fix it fast
... we should still get that bug report filed 👀
a high priority one
!remind 4h Work!
Your reminder will arrive in 4 hours!
!remind delete 1397
That reminder has been deleted successfully!
@surreal venture


