#dev-contrib
1 messages · Page 77 of 1
Also, if you guys have any suggestion ^
if mine is in the root dir, it doesn't pull any vars that aren't defined in docker-compose
if its in bot/ it doesn't pull anything 😂
I've learned if you start a notion page titled documentation, it'll somehow get auto populated
How are you running the project? (working dir and command)
PS C:\Users\Chris\src\sir-lancebot> docker-compose up
Hmm that's what I'm doing too
Interesting
Also, I'm going through the consts file right now, does anything even load the env file?
Wot it doesn't
Well that explains why it wouldn't work
I think the enviroment part of docker-compose pulls the env vars from the host into the container
I was running locally by having my IDE load in the env file, so I thought we had dotenv
using the .env file
Yep yep, but it will only pass the defined variable, which is our main issue
Its pulling the file into the container, but not adding the vars to the env
Which would be fine
if we had dotenv
which I thought we did
Wait what, variables have to be defined in environment to be loaded from .env?
if we don't use dotenv yea
Yep
We could match @stable mountain’s setup and use dotenv
But I’m fine with using docker-compose for that
I think that's ultimately the best solution, and drop the env setup from the compose completely
yea the only issue with my fix, that F1re mentioned was that we need to make sure docs are upto date with what env vars there are
To reduce discrepancy between docker testing, and local
Ultimately there won’t be any env var in a couple of months or so
Locally pipenv will load the .env file
The docs being up to date will ultimately only help us, but docker will load the content of the env file either way
Is this the smartconfig package I've heard about?
Yep
I guess we just need to think of an interim solution until then?
or accept the current process
I’m fine with using docker-compose for now
So should we push on through with merging Chris' solution?
I believe @hardy gorge wanted to experience a bit with how docker-compose behave, I’d also like to
It throws an error if the env file doesn't exist if that's what you're asking about
Hmm
Just
ERROR: Couldn't find env file: <path>\sir-lancebot\.env
Discord edited out a slash there
The contrib page doesn't mention docker 👀
Nah, it doesn't
Lol wut
The README is also abysmal
sorta what started my question, since I was trying to figure it out
Hey at least it has the new branding lol
Lmao, that’s.. an issue
We can get a description drafted for all 3
It should be easy to modify the bot's one
In fact, I wanted to write a more thought through README with what are our bots, what they are used for, some screenshots, and fun stuff like that
yes the docs for lancebot are indeed in bad shape
Scal's work to list the possible env vars was a good start but there are still a few issues
@nocturne hare Can you please review my Pull Request?
well presumably there is no space in the command group itself
title casing helps make it more readable, and easier to remember and type
There's the contrib page on the site which describes setup
And there is the CONTRIBUTING.md on the repo root that describes the contribution procedures
Would there be an explanation of docker anywhere?
That's currently lacking on the sir-lancebot repo, but available on the bot
Hopefully that gets fixed soon
We can answer your questions in the mean time
I just wanted to be clear, docker is something like a Virtual Machine right?
Yeah sort of.
To be clear, you don't need to use it
I don't for example
(Except for some DBs)
Ok thank you!
Hello I have 2 PRs that need reviews https://github.com/python-discord/snekbox/pull/88 https://github.com/python-discord/bot/pull/1346
GitHub
Fixes #74
Protobuf is used to parse the config because it's the proper way to do it and it's less maintenance than a custom parser. A Python module is generated from the protoc tool...
Maybe the snekbox PR could be in the #779073065560703007? (CC @vocal wolf )
hmmmmmmmmmmmm
I can take a look at the bot PR soon-ish but can't help much with snekbox
I think the snekbox one is more worthy of #779073065560703007
the repo isn't looked at often
T'was my thought as well
Hopefully I got the interpretation of the PR correct
If I didn't, please correct me so I can correct my post on the #779073065560703007
Thanks it looks good
ty for confirmation
@green oriole
Here's your reminder: Add an env_file entry to the sir lancebot compose.
[Jump back to when you created the reminder](#dev-contrib message)
Someone made it already, all good
Why is the README.md in the sir-lancebot repo an executable?
¯_(ツ)_/¯
This is what l returns for me on a fresh clone of the repo
bot/ CONTRIBUTING.md docker-compose.yml Dockerfile LICENSE Pipfile Pipfile.lock README.md* sir-lancebot-logo.png tox.ini
@green oriole You left a comment on my PR asking me to change it to Spooky Mane Rate instead. You did mean Spooky Name Rate right?
Yeah, I edited it, sorry
Okay thank you!
I often type mane instead of name haha
😆
If an issue is open from two years ago, can I still ask to be assigned to it?
For the sir-lancebot repo
Can you tell me which one? It will depend on what the issue is about
Also Akarys, while you are here, I submitted a PR to port the python-discord LinePaginator class to Sir-lancebot, which fixes one of the issues that you opened
Alright, this looks good to me, can you comment on the issue so I can assign you?
Awesome! Good work 
#dev-log message Woahh
Does sir-lancebot have unit testing?
no.
@stable mountain has some unit tests, but we've intentionally avoided putting tests in @dusky shore so that it'll be more approachable and beginner-friendly
besides, if @dusky shore breaks, it isn't actually a big deal.
it might even be a nice learning opportunity for whoever gets to fix it.
I see... I like test-driven development, so I was hoping that there would be unit tests.
Does that mean you are not actually against having unit tests for sir-lancebot?
I am against unit tests for sir-lancebot, but every other repo we have welcomes unit tests with open arms.
so perhaps you'd prefer to solve an issue for one of those?
I see, okay, just checking to make sure
For the valentines issue, I need to create a txt file with poems on it, do I put it into bot>resources>valentines?
Yep
Would it be txt, or MDs?
What would be?
Well, the first file type that came to mind to me was txt
There are no font decorations, like bold and italics
I am currently referring to a closed PR that was never merged, so I am basing my current PR off someone else's
Well text decorations make more sense in md
The resources can be any format
because that's what you'll do for discord
I suppose it is possible to use MDs?
But either will work
Alright, let's say if it's MD, is it still in the same directory?
Since it will be used for a Markov chain, pure text makes more sense
Yes, that's what I thought
Unless, additional features outside of the Markov chain are added
I think using text files is fine, even if we need additional data
m_cht are you storing your poems in the resources?
and are those poems all from one site?
The previous assignee created a corpus from Shakespeare's poems and plays
The txt file contains that corpus
https://poets.org/love-poems heres a bunch of them, if you could try web scraping, or if the data is json, then could be better
Whether you’re searching for words to express a romantic love or a lovely friendship, or a love that’s painful and complex, we’ve curated a selection of popular love poems for you to choose from, from the classic to the contemporary. What better way to express one’s feelings of love than through reading and sharing a poem?
I will take a look at it, thanks
Just wondering, when I install a new module with pipenv install ..., will it automatically run pipenv lock?
I think it does, yes.
doesn’t pipenv install automatically add it ?
it will relock, yeah
This should ping the user it's referring to, yes?
I guess it could
Seems like a great place to use reply
the bot should respond instantly, i feel like it’d just be more noise
Is logging the formal version of print?
Yeah sort of
It has a few added benefits, such as level, time stamps, and we’re writing to a file, not just stdout
The “when to use logging” header on this page describes a few use cases for the library
Ah I see, thanks
how about improving the wikipedia to show a short summary or 100 words or less when the user chooses
using line paginator
(not using wikipedia module)
like:
.wikipedia football
--
and here, a cheatsheet command just like tldr pages, but no need of a zip file here
#dev-contrib message
Yall discussed anything about this?
I think the consensus was it wasn't something we needed
May I know why?
rarely ever do we need to give same infraction with same duration and same reason to more than one user
its just very big niche that yet is not worth the development time it'd take
How would it take development time?
Would it not just be changing the parameter to greedy and looping through the input, and applying the infraction
considering that chances are we would only use it once a month if not less
Any development time for it is a waste
Any change to @stable mountain does not only come down to the literal time to implement it, there is also the time to test it, write tests, review it, and maintain it
If it isn't a solution to an active problem, why waste resources on implementing it
🥺 ok
Is it a good idea to have a bot respond to one request at a time? The current poem generator cog takes about 5 seconds to process, if everyone does it in that same 5 seconds, I am afraid it might crash
What command is that?
It's currently in my fork
ah. Is that public for me to look at?
I can push the changes to my fork and send you the link
Actually
I can also invite you to my private test server
Either is fine
Realistically the compute time doesn't matter too much, it's the blocking time that matters
There's also typing() that can be useful
I have PM'ed you the invite link
what do you do? like web scrape , requests or is it stored?
@sharp timber Here is the fork: https://github.com/melodicht/sir-lancebot/tree/markov-poem-gen
It is based on the code of this PR: https://github.com/python-discord/sir-lancebot/pull/97
GitHub
A Discord bot started as a community project for Hacktoberfest 2018, later evolved to an introductory project for aspiring new developers starting out with open source development. - melodicht/sir-...
It primarily uses API requests. As it is used, it will cache results
oh ok
When I should I use an embed and when should I not?
👍
Or should I use an embed 100% of the time?
embed should be used all the time probably.
Honestly I'm not familiar enough to tell you. But in this case, perhaps a code block could be neat.
also instead of catching the error in the poem function (the cog function), why not just raise the error in the functions
for example on line 192
Aren't I raising the error in the function?
ah you do, my bad
I like the embed format
But I'm no dev lead so ymmv. On the other hand, due to how you run it, you're awaiting things fairly often
Yeah, I already feel like it's valentines already
keep in mind that asyncio transitions to other tanks upon await
So despite the bot spending a lot of time working, it's really spending most of that waiting on the api, and is free to respond to other commands in the meantime
Not just the API, but also the markov chain
right
You're guaranteed to await on every loop iteration, so that's free enough imo
Should I make it so that the bot can work on only one poem at a time?
I don't know. You could consider using the reply feature because of the delay between poem request and response, but I'm not sure how that'll go, and honestly a bit out of my depth
the real concern I had was that it would for-loop lock up for the duration, but that's not an issue here at least
What's a for-loop lock up?
If you were just processing and not awaiting anything inside your for loop, then you never release control to asyncio
Oh I see
because of that, the bot would lose the ability to do important things like respond to other messages or remain connected to the api
yeah
So that means I have to make sure that it awaits something in every path
Yes, no? Just ensure there's no chances of ending up locked in a non-awaiting path for a large chunk of time
considering how you're hitting an api for all this, probably no concerns here. The python code is probably quite fast and unlikely to cause an issue
It also depends on the size of the poem, I am considering adding a limit to the # of lines the user can make
And complicated rhythm structures also take a while because the bot has to take more time to find rhymes
and msgs below that, (went up in chat history)
y site all commands show in help message
but doc one doesnt
both are using group.commands
!docs is not part of our Site group, is it?
Because we're not searching our docs or our website. We're searching through the docs of others.
nope but doc also has subcommands
I think it does show all the commands that you have access to
But the docs group only has one public command
it shows which the user has access to
!docs [symbol]
Can also use: d, doc
Lookup documentation for Python symbols.
Subcommands:
!docs delete <package_name>
Removes the specified package from the database.
!docs get [symbol]
Return a documentation embed for a given symbol.
!docs refresh
Refresh inventories and send differences to channel.
!docs set <package_name> <base_url> <inventory_url>
Adds a new documentation metadata object to the site's database.
woah, powerful ves
Ah, they're subcommands of that main command
Did you look for configuration related to them showing up in the help or not?
I think you can set options for that in the decorators
Not sure
hmm
well yeah i can
@hardy gorge i can manage the reactions on your help command.
yeah we don't mind that generally
it did?
yeah
yep
see?
We don't bind it to a specific user, no
yes but we do so for the trashcan iirc
There's a consideration here: We don't want to bind it too closely, as mods often use each others embeds
try for sirlancebot
.help
right but other people shouldn't be able to delete others help messages
Yeah, trashcans should probably be bound to the author + staff
ok yeah it's a bug
feel free to open an issue on the bot https://git.pydis.com/bot/issues
can someone open a issue, away from laptop rn, or i can later
It seems to be related to the root_aliases kwarg that was added
I'm not sure though
Not sure then
😓
But there are probably others that are way more familiar with this part of our bot
ok
@cold island can you do another command which has the use of line paginator in bot?
just want to see if it is paginator issue or the help command
since the paginator looks good and doesn't seem to cuz the problem
looks like the help command bug
yep is a help command bug
I just tried another command and the bug is there as well
hmmm, can u do it here?
sorry, it's a mod command
#bot-commands message not here tho
couldn't think of another paginator
ah it shld a paginator
I think the eval trashcan is written separately from the paginator
and since the help command and the command I just tried both have the bug and they both use the paginator, it's probably the paginator
yea got that
but the paginator source looks good, can't seem to find the problem in there
it might be related to the check, i.e what reactions it's listening to
do !tags
!tags
yep
What's up?
!tag
@green oriole sorry for the ping but u know how all sub command of site show in help embed but docs one doesnt, just curious
Hmmm
use !help and check docs and then move to page 3 and check site
it shows all command in an embed
#dev-contrib message check from here
being able to navigate someone else's embed is intended
We don't need to show each command
We will be porting the paginator to sir lancebot, so this will be solved
Some order 😅
The issue currently is that in the bot paginator anyone can click the trashcan and the embed will be removed
yeah
Alright, I was about to open an issue about allowing moderators to use the trashcan on any embed, we can do that at the same time
Whenever an error is raised in sir lancebot on my cog, my cog's error handler captures it, but it still logs this:
bot.exts.evergreen.error_handler ERROR: Unhandled command
We considered enabling it for helpers as well, a while back when it was discussed
Hmm
How we should solve https://github.com/python-discord/site/pull/427 ? Current solution doesn't give way to move to event-specific pages, but we have to provide this there.
Also, how does this looks like? Too small?
imo it does the job
X and Os are distinctive shapes, so they're mostly distinguishable on smaller sizes
I remember when I was making a tictactoe command for my own bot, I made the X and O with 4 custom emojis each, so when they're put together they're of a decent size
hey guys what auto formatter is used for the official cpython repo?
I don't believe they have one
There is clang on the c side
Nothing for python though
This may be a better question for #python-discussion, possibly #internals-and-peps
oh i guess they just formatted it by hand then, dunno cuz i thought the formatting was nice
but i tried few auto formatters and i didnt really like them
i asked in #python-discussion no one really answered, or if u guys recommend a good python formater?
one thing i thought was interesting was that it didnt seem like it was exactly pep8
@cold moon sorry, miscommunication I my end, I meant whenever you wanted me to review.
so is pep8 not that important or?
It's pretty important, I'd say.
Are you looking for a program that formats your code for you?
Or one that tells you what's wrong
This is ready for reviewing yeah
I shall test soon
thank you for the speedy reply
this
i mean like in cpython repo i see little stuffs like between function definitons only 1 line i think it should be 2?
so i mean technically its not strictly adhering to pep8
Two lines between classes, etc, but between functions one is fine
oh ok
idk black always makes it 2 for me
between everything so ye
so u guys format the python code by hand then?
I mean my IDE points out linting problems as I write
So it's never really a major problem
On the pydis projects, we also use flake8
If anything I'd just use flake8 which can be found here: https://github.com/pycqa/flake8
Which helps enforce it on the repo level, and can point out some errors my IDE doesn't catch, but not frequently
ok thanks guys
np
and u guys use vscode or pycharm?
for python, pycharm
oh same
i tried both but couldnt find an "inspect code" for vscode
where it will point out all code issues etc.
so no need to use flake8 with it or?
pycharm on its own should be fine
ite gucci thnks
If you're not sure you can always do flake8 your_file.py
After installing flake8, of course.
If I would to allow other contributors to work on my issue, I just put "[WIP]" in front of the issue and set my PR to draft mode, right?
You opened a PR and want someone else to complete it?
If you don't have a PR then just write in the issue that anyone can work on it. If you have a PR then set it to draft and write a similar comment
No no no, I haven't opened the PR yet. I am still interested in working on the issue, I just want to see if anyone else would be interested to work on it with me
Oh okay
also maybe worth linking it here for further visibility 👍
Hi guys, I am currently working on a poem generator that uses the markov chain for valentines: https://github.com/python-discord/sir-lancebot/pull/558
If you are interested in working on it with me, please feel free to check it out
where is your owner role?
was testsing a feature which meant I couldn't have it
ok
hello @frosty coral, this channel is for discussion of Python Discord projects
feel free to share in an off-topic channel though
(nice animation!)
cc @gritty wind https://github.com/python-discord/bot/issues/1362
another fun error
Though I suppose we'd be maintaining more bugs than code
hahaha
I'll look into it now
Can I get the invocation command? I hope that got logged somewhere before that error
It started with CommandNotFound('Command "!!" is not found')
Perfect, just what I was looking for
But now to figure out how that got past the checks
We want it to fall through and continue to the suggester
Well the suggester would also run it through the tag converter, and not cause problems, no?
Ah no, you're right
Why are we even running the input through the tags twice
Feels like we should just remove that portion all together
which portion and where do we run it twice
Trying to convert to tags in the suggestor
Lines 162-167 should be ripped straight out
The alternative is combining it, and ripping out the section before it
We'd need to duplicate the tag conversion code to keep both
Because it tries to suggest even when the tag name is invalid
The tag suggestions are already handled by the fuzzy match
There is no situation where the fuzzy match won't trip, but still have suggestions to show
At least I don't think
What I mean is that when the tag name is invalid BadArgument is raised and you never try to fuzzy match
You try to fuzzy match inside line 158 which is inside else
That's what line 149-158 achieve as well though. tag get calls display tag which shows the nearest suggestion, or fuzzy matches
Which is what the error this morning in #community-meta was about
And we'd presumably not want to search with a tag with a non valid name
The idea originally I guess was to find a suggestion
So if the 150-160 handle fuzzy matching tags, why does the suggestor try doing it again
I don't mind ripping it out, but I'm trying to follow the original logic that made the person add it
Hmm, maybe that could be done, but it already will return a tag if the fuzzy matching finds something
Otherwise it probably means it has no suggestions
No, but it's invalid so the else clause didn't run
So it will be the first time it's fuzzy matching
ok sorry
you're right yeah
it's not optimal
What should maybe happen is to get rid of the try and make the get command deal with an invalid name internally
The thing is it normally would
Like if you invoked !tag get
But the converter doesn't get run on a code invocation
!tag get !!
Bad argument
Tag names must contain at least one letter.
!tags get [tag_name]
Can also use: tags g, tags show
*Get a specified tag, or a list of all tags if no tag is specified.
Returns False if a tag is on cooldown, or if no matches are found.*
hmmmm
ok but it does manage to reach the suggesting code
It just doesn't handle the string well
The get tag function expects that there will always be a letter in the input
but yeah something should be done about the duplication regardless
Which the converters gaurentee
it fails in the fuzzy matcher
because the regex removes any non-alphabet characters
and !! has none
so basically what you just said
Do we even want to suggest anything if it's a bad argument?
The definition of a bad argument for a command and tag might at some point diverge
And the suggestor handles other options well
A bad argument in the context of a tag
Ah okay, no it shouldn't
No characters, too long, etc.
It doesn't atm
Oh yeah the suggestor does, which is what I think should be removed
yeah so just rip out everything after the try-except-else part
Yeah pretty much lol
I meant everything inside the if
Which makes me believe that the suggester should have been a separate thing
So
if not any(role.id in MODERATION_ROLES for role in ctx.author.roles):
...
if not sent:
await self.send_command_suggestion(ctx, command_name)
To:
if not any(role.id in MODERATION_ROLES for role in ctx.author.roles):
await self.send_command_suggestion(ctx, ctx.invoked_with)```
Which does what it currently does
But without tags
ah yeah
that works
that can just go into the except part though
And not have an if in the else
and just invoke the command instead
Hmm I think I prefer it the way it is, as it creates a clear logical divide between trying to convert to tags, and trying to fuzzy match a command
Though either will be functionally identical
not any can be replaced by all can't it?
leme check
It won't work for people that only have mod, or only admin, etc
You can get it to work with an all if you move the not
But this structure is used throughout the project
(This line specifically)
try:
await ctx.invoke(tags_get_command, tag_name=tag_name):
except errors.BadArgument:
if not any(role.id in MODERATION_ROLES for role in ctx.author.roles):
await self.send_command_suggestion(ctx, command_name)
except ResponseCodeError:
pass
won't that just work?
Invoke the tag, if the tag name is bad, suggest anyway
Yes, but see comment on purpose separation
yeah but with this you have don't have the conversion part, you just try to run a tag
You still need to run the converter, otherwise you get the error that started all this
The converter is run in the tag get command implicitly
The BadArgument is not raised by the function itself, but the converter which doesn't get called on an invoke
See note here
We can get it through bot.invoke which calls the checks
I think... maybe
But the thing is
We probably don't want to send a conversion error
Because like if I type
!@help
That can be converted to !help, but not a tag
and if we just run the check like it was entered as a !tag get
It'll send the conversion error, as well as a suggestion for help
ok yeah, that's getting too complicated to be worth it
lets keep the change minimal
And I still don't know how it even tried to run !! as a tag lol
Its a very hyped tag ¯_(ツ)_/¯
https://github.com/python-discord/site/pull/421 Can anybody take a look at this? I updated this to match with current state in site, but somebody should take a look to find did I missed something. After this is done, I think this is good to go.
Pushed a fix for the zero division error from this morning which was sort of stuck in limbo
https://github.com/python-discord/sir-lancebot/issues/428 Can i work on this?
I don't think deferred issues are usually open for work
Though that was only waiting on 3.9
@green oriole status of this ^
cuz i know fix using regex
Yep, it is waiting for the 3.9 migration
async with self.client.session.get('https://http.cat/') as response:
text = await response.text()
http_codes = re.findall(r'<a href="/(\d{3})">', text)
http_codes.append(0) # Easter egg code
self.http_codes = [int(x) for x in http_codes]
I mean, that was suggested even before a 3.9 migration became viable
We didn't go with it so we can use the stdlib
So you'd still need to wait for the 3.9 migration
ah alright
There are ~12 unassigned approved issues, and 9 unassigned planning
One of those would be a safer bet
(the planning ones for discussion not direct assignment)
yeah, currently looking at them
in connect four, will it be a player vs player, or player vs plaer and player vs ai?
Another thing that would really help is submitting PR reviews, though it isn't for everyone
What's the issue #?
not much experienced with it, just started doing codereviews, (For gurkbot), so later can can help there.
Looking at the connect four issue, bot seems optional. Though there is also a PR open, and I believe the preferred path here would be resuscitating the PR and addressing the feedback
I'm working on upgrading dpy and py version, but I'll finish after forms current stuff is ready
ok.
Do you want to hand that issue off?
there are so many prs with waiting for author 😮
No, I will do this. I have this already started in my computer
Hey @green oriole in pr 1358
or user_.id == restrict_to_user.id
user_.id == restrict_to_user.id
why do you have 2 of these?
Huh
in your pr why is there 2 same lines
Yeah, the first one is a deleted line
In your pr if you didn't make the change and it already existed beforehand but i want to request something, can I?
You can write a comment, yeah
aight
Hmm you might want to expand the rest of that file haha
There is more code in that scope after the if
I don't understand your suggestion @late wolf
Wait leme check what scaleios was saying
Those two ifs are doing two different stuff
@gritty wind can i start working on connect 4 pr now?
My bad, github didn't show the entire thing
Doing review in githubs are hard,
they don't show the entire thing,
you have to go the bottom of the page to scroll sidways (for me at least)
i don't like its plus minus thingy, it confuses me
Yeah lol, try checking if your editor/IDE has any review tools
i use pycharm to see the file, and keep github open on side
but now, i have got used to github, not much of a problem
Pycharm should be able to show you a diff like github, and allows you to interact directly with the PR, so I usually use it for reviews
I was trying to get you the review guide, but I need to dig for that a bit more
pycharm proffesional has
I'm looking into that atm
Ah ok
i don't like its plus minus thingy, it confuses me
@late wolf it's pretty nifty at showing what actually changed
you could do this though
to view the changes side by side
another question, not doing ai is fine right?
What do you mean by ai ?
Yeah the issue lists it as optional
Oh, this AI
Hmm, I'm still waiting on a reply on whether its okay to assign you
I uhh... really have no clue lol
ok
I don't get the logic behind lock decorater, 😕
I've worked with it a bit for one of my PRs, any specific questions?
what does it do and how does it work?
my sir-lancebot fork didn't show up on devlog
we might have them disabled
but why enabled for bot, and not sir lance?
Because we are the masters of consistency
Alright so as simply put as possible, it tries to prevent a function from running more than once on a single resource
For example, if we had a command to rename a channel, and a user typed:
!rename A
!renamd B
Shh bot
You’d expect the bot to first rename to A, then switch to B
What do you mean by a single resource?
To guarantee that order you might lock the channel so the command only runs once at a time
Well a resource is pretty vague
In the example, it was a channel
But as long as the lock can look at the new request and compare it to the locked item
What do you mean by "lock" in this sentence
Then it can be locked
Right so
You would typically hear about locking in multi synchronous operations
so it basically makes it not run parrallel, and one by one?
Things like threading, or async
Yeah that’s one way to look at it
ok cool
oooh
But basically, it ensures that an object can only be used if the function has the lock, otherwise the object can not be modified
If you want to compare it to real life, well, imagine a lockable door that only has one key. If you only have one key, then only one person at a time (the key holder) can unlock the door and enter
thanks, understood it pretty well now.
#bot-commands message
Hey guys we have this issue with !raw#bot-commands message
RuntimeError: Line exceeds maximum page size 1992
Yep yep, we got a sentry issue
You could also say that the line paginator should be robust against such input
Instead of patching every function that tries to use the paginator one by one
Only 1 available help channel, is the bot having issues?
At this point we should just have the reloads automatically scheduled lol
Just a cog reload
!ext reload help_channels
:ok_hand: Extension successfully reloaded: bot.exts.help_channels.
I wonder why that keeps happening
Thanks :D
I haven't found the time to setup a test server for the main bot, I'd be interested in investigating that though
Do we have an open issue for it? Maybe we should
Would a script to setup a blank server to one compatible with the main bot, and save all of the relevant IDs locally be something worth considering?
smart config is being made for that purpose
ahh oki, cool 😄
@gritty wind Yep, very much a stale PR. Since it's so old it would probably be best to make a new PR.
At the same time there's still a lot of stuff that needs to be resolved
We'll just continue where it left off
@short snow I've assigned you and reopened the PR.
Make sure that you fix up everything from Shira's comments.
Ok thanks 😄
Ok am probably done with it, so do i need to call someone to my test server to test the bot?
We test it on our own test server. You submit the code and we test the functionality.
oh ok
Make sure you include things that'd help with that. For example, screenshots & command example never go amiss
yep
since i was working on a pr, which was left of by the original person
ok
when i did lint, i got issues in file which i haven't worked on
bot/exts/evergreen/branding.py:3:1: F401 'json' imported but unused
bot/exts/evergreen/branding.py:21:3: T000 Todo note found.
bot/exts/halloween/hacktoberstats.py:16:3: T000 Todo note found.
bot/exts/halloween/hacktoberstats.py:44:26: F821 undefined name 'make_persistent'
bot/exts/halloween/candy_collection.py:13:3: T000 Todo note found.
bot/exts/halloween/candy_collection.py:42:26: F821 undefined name 'make_persistent'
hmm.. you were working on an stale pr? did you update the branch?
the gurkancount branch?
yeah, idk how
shld i close that pr and open new? or?
just remove those files
and stash them?
you can technically fix that... but if you just opened the pr it might be simpler to just open a new one. Do you know how to transfer your changes to a new branch?
coool, correct now
is logcord for viewing logs on the web?
Is there a way of checking how efficient a function is? I know there is a timer module that can see how fast it runs in one use. If I want to automatically process it like a 10000 times and see the average, is there an easy way to do it or do I have to do it manually?
Is there a module that does it for you?
Like I can attach a decorator and it processes it a 100 hundred times fo rme
Is this question related to our projects somehow?
ig for their love poem gen
How did you know
cuz, u said it was taking a lot of time
I am working on a cog and it takes a while for certain stuff, so I need to be as efficient as I can
import timeit
def timer(function):
def new_function():
start_time = timeit.default_timer()
function()
elapsed = timeit.default_timer() - start_time
print('Function "{name}" took {time} seconds to complete.'.format(name=function.__name__, time=elapsed))
return new_function()
here
It only measures time performance, not memory or other resources
So I need a good way of testing efficiency for the purposes of sir lance bot
yep, logs of discord messages
message logs, or mod logs?
message logs
for use with our antispam filters and a !relay command coming in the future
what advantages would that give?
like what is the use of message logs?
won't they just take a shit lot of space
can anyone link the code review guide of hemlock?
We're a large, friendly community focused around the Python programming language. Our community is open to those who wish to learn the language, as well as those looking to help others.
thankyou, can u have a look at my pr when you are free 😄
Might not be till later today, but sure
What's the problem?
cc @cold moon you were working on the branding manger recenetly
Alright its a problem in the usage of the in_whitelist deco (cc @tawdry vapor @hardy gorge). Because the redirect was automatically set to the bot commands channel, we were able to bypass the role checks in there
!branding
You are not allowed to use that command here. Please use the #bot-commands channel instead.
We can't use it here, or anywhere else
The most obvious fix is to set redirect to None, though maybe something should be added to the decorator docs?
Though a has any role built-in deco would've worked better in this context
Huh, shouldn't helpers be able to use it in every channel?
Its mods+
oh i see, what's that command meant for?
right, but what does that command do
(and the image at the top of the channel list I think)
It changes them, and controls the automatic cycling
If you hover over the server logo everyday, you'd see a different animation
oh that's very cool
Oh did you decide to abandon the other PR?
Hmm did you use code from the old PR?
Alright
thankyou
If you mention the issue number in your PR, it'll automatically link to it
So something like:
closes #<number>
You can still edit your post to add it
Thanks
can we add command suggestions if the commandnotfound error comes to seasonal bot too?
Hmm do we have an open issue for command suggestions on lancebot?
If not, could you open one
alright
Maybe, but it would need to be limited to #sir-lancebot-playground
Is there anyone here familiar with async? I am working on the valentines poem generator and one of the feedback in the past is to have an async_timeout as a fail-safe measure in case the bot freezes or takes too long. I think some blocking functions are being ran even after the timeout though, but I am not too sure how to fix, can someone help me out?
https://github.com/melodicht/sir-lancebot/tree/markov-poem-gen
you can see the battleshpi cog, the last part
where it asks users for a reaction to join
Oh yeah I see that, but the use of async_timeout in mine is a bit different
@short snow I left a review on your PR. Don't get discouraged by the amount of feedback, its a good PR
yeah scaleios, am working on that
🚫 adds this, so that when this is clicked, it will end the game
Yeah that seems reasonable
if the user who those that is the orignal guy
Possibly the original user, and the second player
https://paste.pythondiscord.com/qiyurimafi.sql i get this weird error on running the bot, hadn't got it yesterday
it's not too weird
it's trying to connect to redis
but it can't find redis
@short snow you need to enable fakeredis
set this to true in your config file
in seasonal bot too?
okh
@gritty wind , when i did what u said this happened (thanks to numerior for letting me know of it)
In [1]: a = [[]]*3
In [2]: a[0].append(1)
In [3]: a
Out[3]: [[1], [1], [1]]
In [4]: id(a[0]), id(a[1])
Out[4]: (2199257602112, 2199257602112)
ah wait, on enter, a new issue got formed
lemme edit it
#bot-commands message error
ConversionError: (<class 'bot.converters.Duration'>, OverflowError('Python int too large to convert to C int'))
#sir-lancebot-playground message why does this happen?
it is probably because of lowercase letters
i.e.
me: A2
bot: ok
me: b3
bot: not ok
Fair enough, feel free to ignore that change then
in the tic tac toe command ks123 did, can we use gurks/lemons/snakes instead of x and o?
lemon: 🍋
gurks: 🥒
snakes: 🐍
it would randomly choose any two ig
https://pythondiscord.com/pages/contributing/bot/#server-setup I'm a little confused, does the template set up the channels, categories and roles here, or will I have to do it manually?
We're a large, friendly community focused around the Python programming language. Our community is open to those who wish to learn the language, as well as those looking to help others.
If you use the tempelate, everything on discord is good to go
All you have to do is copy the IDs and add them to the bot config
The categories listed correspond to the ones in the config file that need to be filled for it to work
The only things not covered by the template are emojis
Are the emojis necessary?
Some commands do require them yes
for example the line propagater requires the trashcan
Also, is the template pinned in this channel the same as the one on the site? I made a server with the one pinned here
Oh right
The template here and there are the same, yeah
Okay cool
Generally how long does it take to get a response, after making an issue on the repo?
Triage is usually pretty quick (things like basic labels and whatnot), but to go from a concept through discussion, to an approved idea might take a couple of days
Bugs are usually quicker
Alright, sounds good. Thanks!
Feel free to drop a link here if you think the issue needs attention quickly
No it isn't really urgent
I just wanted to be able to work on it in case it gets approved
I'll just see if there's something else I can do
Are you looking at the sir-lancebot or bot repo?
Bot, right now
But how are we supposed to add them?
Manually add the emoji and then change the ID in the file i assume
Will I need the webhooks?
right but to add them we actually need the emoji picture, where do we get that?
Hmm you might need them for some features, but everything you need to start the bot in general is listed in the getting started guide
You can add any emoji
ooh
For my test server, I just added random emojis off the internet
right
Thanks :)
It says webhooks there
what part of the URL are we supposed to add?
If you look through the unassigned approved issues, you might be able to find something to work on
In that case
The ID apparently
I believe it is the second number
Oh wait, no, the first number
I'm using the first part, the number, and it seems to work as expected
Wait a minute though, the url is of the form
@gritty wind, looks like you posted a Discord webhook URL. Therefore, your message has been removed. Your webhook may have been compromised so please re-create the webhook immediately. If you believe this was mistake, please let us know.
@green oriole, looks like you posted a Discord webhook URL. Therefore, your message has been removed. Your webhook may have been compromised so please re-create the webhook immediately. If you believe this was mistake, please let us know.
lmao
Oh really
i was about to do that as well
I mean, I redacted the secret part haha
it just matched the webhooks/ part lol
isn't the first number just the guild ID?
its the hook id
only two bits stored in the link, the specific hook id, and the token
oh right
I assume you might be able to extract the guild ID or something out of the hook ID, but I've never looked into their generation
This is taking longer than I expected 😅
Once I do this for the bot, will I have to make a different setup for lancebot?
Or can I copy my config file on there
Sir lancebot only requires a couple variables
I don't think we even use the same config for lancebot
we just edit the constants file directly
Not that you need to, all that needs to be added is the commands channel from the server you created
the bot token
(added to the env file so you don't accidentally commit)
Oh right
I think I personally set a large portion of the environment variables, but that's only to allow me to work on most features
The list of the ones you absolutely need is here:
https://pythondiscord.com/pages/contributing/sir-lancebot/
We're a large, friendly community focused around the Python programming language. Our community is open to those who wish to learn the language, as well as those looking to help others.
And if you follow the full environment variables link you can see all the other ones you can set
So the token is all I'd need in there really
Token and CHANNEL_COMMUNITY_BOT_COMMANDS otherwise it will keep telling you are using the wrong channel
Oh, why isn't that listed on the site?
This should just be the ID for the bot commands channel right?
https://pythondiscord.com/pages/contributing/sir-lancebot/#development-environment
It's there with a bunch of other vars
Yeah, or #sir-lancebot-playground. Whichever you prefer
Sweet, I've got the bot set up. Thanks @gritty wind!
I'm sorry if it was difficult to get it working, @green oriole is working on a project to streamline setup in the future
Glad its done now :D
Yep yep
I haven't used docker before so I might come here asking amateur questions 😅
Docker can be a little overwhelming (especially on windows and mac), so feel free to ask if it gives you any trouble
Also, what exactly is precommit? And do I only have to run pipenv run precommit once now?
Yep, and it will automatically lint your code before allowing you to commit
pre-commit, at least in git, are hooks (processes) that run before a commit is made
Here we use it to enforce things like code style
(And other things listed in the precommit.yml file)
Oh right right
https://github.com/python-discord/sir-lancebot/pull/560#discussion_r560129196 what do u mean by this? ig i am documenting the general behaviour only @gritty wind
The chance of not actually making the stated play is general behavior
The comment "10% chance to not place" should be included in the docstring, so you don't have to view the function to know its behavior
How long does it take for a PR to get reviewed and pushed? I am currently working on the love poem generator cog and I hope that it gets ready before Valentines day
Just asking so that I can plan my deadlines
Well, as everyone who contributes is a volunteer
There is no guarantee anyone will review your PR quickly
Though if its for an upcoming event, it'll usually be handled pretty fast
How long to go from a review to a merge will depend on your code quality though
Is submitting the review 2 weeks before enough time?
Considering that an event is upcoming
How large do you think this PR will be?
I can show you the link now. It's almost done, just need to fix some bugs
It seems most of the PR is from the pre-generated poems, so two weeks should be more than enough
Okay, perfect
But, the earlier you submit, the better the feedback you'll get will be, and the more time you'll have to update
Ah alright, I will get it done ASAP then
No worries, take your time
(Also just from a quick look through, you need to version lock dependencies you add. You can do so by following the format used in the pipfile)
Is it just pipenv lock?
That updates the lock file, but you have to actually write out the version in the pipfile
For instance, if you are using the latest version:
For instance: markovify = "~=0.8.3"
Oh I see
You can see in the other dependencies:
PyYAML = "~=5.3.1"
After that is updated, you can relock yeah
Alright, thanks, I will do that
i'm getting an odd pipenv error - the path it says is an old version of python that has since been deleted
i uninstalled and reinstalled pipenv, the error persists
Well, our projects run on 3.8/3.9 so you should try to update either way
but that's a weird error hmm
i run 3.8 3.7.9, I'll update
Did you recreate the local environment with the correct version of Python?
Could you show more of the error?
look for Python351 in regedit (win+r , regedit)
and delete the entries (their content)
or try
pip3.8 install pipenv==2020.11.15
(from issues in pypa/pipenv repo)
i don't know where i should be looking here
hmm, dunno am on linux, try going to their repo or google your error and the first result is that issue
Installing with your base python3 may work better than the anaconda install
#community-meta message might be the better place to post this
how should i be setting pipenv? maybe i've missed some step
just install pipenv, or do u have pycharm?
using vsc right now, installed pipenv
when does the sir lancebot get updated
I created a pull request and it got accepted. but i dont see the change
when I use the bot in this server
oh wait nvm,
it just passed the tests
The bot will redeploy automatically when the master branch receives new commits
In this case, after your PR has been merged
trying it with pycharm, it says pipenv executable not found
This might mean pipenv is not installed on your global 3.8
Or if you did not configure your PATH variable to include the script directory
If you have it installed, but it's not showing up automatically, you could try to locate it manually by clicking on that folder icon
The exact location depends on how you installed Python and the package, though
Scripts from User installs typically end up in %userdir%\AppData\Roaming\Python\python38\Scripts I think, but it probably depends on how you installed Python
I don't use Windows often
thats very convenient!
How exactly is does this process happen?
For the bot, it's this:
https://github.com/python-discord/bot/blob/master/.github/workflows/deploy.yml
A "push" event to master triggers a GitHub Actions workflow that first lints/tests (just like with a PR), then builds the docker container and pushes it to GHCR (GitHub container registry), and then triggers a redeploy
It builds a docker image, and sends the redeployment command to the k8s cluster
the bot also runs on k8s?
Our entire back-end runs on kubernetes
It would be quite difficult to only run a small portion on kubernetes. I mean, you can do it, but it kinda defeats the purpose of having the cluster.
new version of graph?
just the one from the last hour
wokay
@patent pivot mind taking a look at https://github.com/python-discord/bot/issues/998#issuecomment-758377137 when you have the time?
ooo missed that
so are we storing the data on our nodes or temporarily?
ah right
redis
hmmmmmm
yeah, I'm fine with it providing we have a clear up task
The first thing to know would be if it is a wanted feature, but wasn't sure on the privacy as it goes to permanent storage
privacy wise it's all fine as long as reasonable measures are taken to remove the data (e.g. clearing after an hour (TTL would make this nicer and then the burden is on redis, but I don't know how hook into async-rediscache is to TTLs)).
feature wise I think it's nice but I agree with Mark that the use we'd see would probably be low, it's not something we've received frequent complaint about
I uninstalled other installations of python and installed 3.8, installed pipenv and did this (manually selected pipenv executable in pycharm) and I think the environment is set up now (it shows (bot) in my terminal)
How do I run precommit now? When I try, I think it is checking for pipenv inside this environment
# install the development dependencies.
pipenv sync --dev
# This will install the pre-commit hooks.
pipenv run precommit
# initialize them.
pipenv run pre-commit run --all-files
# Run the bot
pipenv run start```
Try not creating an environment for the project, that might be what's throwing it off
pipenv creates its own environment
to get out of an active environment, type decativate
but then u won't be able to pipenv lock or pipenv sync the file
if u update the dependencies
if we update the depdendicies, are not into the virtual enviornment, will we able to lock the pipfiles?
