added some info regarding this to https://github.com/python-discord/black-box/issues/9, I'll fix it at some point
#dev-contrib
1 messages · Page 76 of 1
Regarding logging, wouldn't sshing into containers require them to be running sshd?
probably. I just haven't invested much time into thinking about the logging portion.
but it's not really a black-box if we don't save logs, you know?
I'm not familiar with k8s much but I thought it would be able to provide the logs for the container
Alternatively you can maybe expose the Docker socket over the network but securing that may be a headache
it's easy enough to get logs for a k8 element with something like kubectl, but it requires that you have access to the cluster, and I didn't really envision this app as having total access to the k8 cluster.
it seems like a lot.
hi @glacial lava
Wait maybe cause it's k8s there is no Docker socket
there is a docker socket
You can pull the Docker logs but you need to mount the docker socket, yeah
and the k8 containers are on the socket actually.
Security wise it seems indeed pretty bad
doesn't seem too bad for it to see the docker socket.
So that means it's using Docker as the engine?
Wasn't there some depreciation regarding that
Seeing the Docker socket would allow an attacker to open a terminal in any running container including bitwarden
It seems like a major security breach IMO
Can you have k8s upload the logs somewhere
Or can they only be retrieved by the recipient initiating the request
at that point we may as well just leave logging to a real service that's actually designed to do logging.
and just have black-box focus on backups.
which is a perfectly viable option imo.
I mean we do have logs in grafana now, don't we?
What you perhaps could do is have black-box ssh into the host and retrieve the logs using the k8s CLI, so you can apply restrictions on it
Yeah, we do
could still support getting syslogs via ssh though.
yeah and maybe ssh into a host that had kubectl logs or docker logs access already set up..
that would be fairly trivial.
not necessary that common though.
especially the kubectl bit. usually you run it locally.
But that would put more reliance on external setups
Can you have a per-user access restrictions with kubectl? Like this user can only get logs from this service and this service, but not that one?
no idea. @patent pivot would have input.
This talks about sending logs out https://docs.mongodb.com/manual/reference/connection-string/
Oh wrong link
Kubernetes
Application logs can help you understand what is happening inside your application. The logs are particularly useful for debugging problems and monitoring cluster activity. Most modern applications have some kind of logging mechanism; as such, most container engines are likewise designed to support some kind of logging. The easiest and most embr...
Which is basically what you said about using a proper logging service it seems
Cause the previous seems to be just access with kubectl
Maybe another useful article https://sematext.com/guides/kubernetes-logging/ but I'm not gonna go into it tonight
yeah using a sidecar seems like a logical approach, but not sure how to use that concept together with black-box.
anyway I think I might just ignore logging in the context of kubernetes for this project
and provide a syslog option that relies on ssh and a docker log option that either runs on the local machine or relies on ssh into a machine where it does have access.
Ssh to get Docker logs seems a bit awkward
But I don't have better idea for remote container logs besides the socket
If logs are a huge complication, why not limit ourselves to get the back-ups up and running first?
We've talked about getting in touch with a proper logging service for our logs, although it required some steps we have yet to take to be eligible for an open source/non-profit thing, I think.
I'm getting the backups up and running first even if logging were easy.
postgres works already, sorta.
That second link has an open source logging agent for k8s but it seems to expect an elastic search server
just not running in production.
okay how about this
we just support a single connstring for logging, and it's arbitrary command execution.
logs://[user:password@host:port]?command="docker logs api"
then the user can configure whatever is convenient to either run locally or from an ssh target and use this however they want.
any more complexity than that seems gross to me.
so black-box just runs this command in the specified environment (defaulting to locally) and then saves the stdout to a log file, which it then uploads into the storage providers
That could work, yeah
I think I like that idea.
I mean, then there's nothing stopping you from fetching those logs from an API or from some logging service or whatever the hell you need.
just specify the right command for your setup
or the right commands. add as many as you want.
probably not a system we need for pydis but that's okay
okay, logging spec is now at https://github.com/python-discord/black-box/issues/10
thanks for all the super helpful input, guys. 
yeah both SSH and docker socket are not the way to do it, we should use the Kubernetes API @crude gyro @tawdry vapor
but Loki is currently exporting logs to grafana so I'm not hugely worried
I'm okay with the system we have right now at pydis
just thinking about how I can provide a helpful feature for other users
yeah
but I think arbitrary command execution is an absolutely acceptable solution here
then they can do whatever they want with it
worth looking at promtail if we want logs and see how they do it, they provide native k8s logging with absolutely no configuration
I think they just use a ws stream
yeah it's just that I'm not really looking to write an end-to-end logging service
there are plenty of those
at least not with this project
(I have considered suggesting we fork and write dozzle for kubernetes though)
I think Loki solves the task better than Dozzle, but having to run Grafana, Loki and Promtail isn't the most gorgeous
I just liked how simple Dozzle was
Dozzle was truly great
but I guess with the docker engine being deprecated, forking Dozzle would not work for kubernetes anyway
Simplicity at its finest
eh, Dozzle was mediocre
we could've made a better app
it was a UX nightmare
but it was a nice concept
zero config docker logging, plug and play, simple, self-hosted, free and open source
if it wasn't so ugly and unusable it would've been brilliant
Weirdly enough I didn't have any UX issues, and it worked fine on my iPad where most app usually fail to even start
I wonder if we could make a similar app
it was hideous, and filtering and search was really poorly implemented imo.
Yeah I have to admit the search wasn't great
If we forked Dozzle to work with k8s it'd have to go through the Kubernetes API
I didn't mind the style though
but just writing something like it
Yeah, I don't think it is worth forking at this point
We would only keep the front-end that lemon hated haha
Loki let's us do cool things like this
hell yeah, that's fucking cool
hahahahaha
That's cool
I tried to use grafana yesterday to display the average mod alerts per hour or so, I failed miserably haha
I need to read up on how that works
But it is cumulative, I wanted to see the sweet little spikes
And I ended up with micro spikes everywhere haha
Yeah
I'm guessing I needed to do a sum of every hour, but eh, no idea how
Aaaahh
Very cool, thanks!
a week looks a bit better
.bm 793789922527805492 Make grafana queries actually readable
hahahahahahaha
Now I wanna see what this 1k spike is all about haha
Aah
Few ideas (for future) about Black Box: 2 more backup locations: e-mail and Mega Cloud.
email?
Getting backup as attachment to email
I think that would be more trouble than it's worth because of size limitations
An email link to a file hoster isn't a bad idea
hmm
I get my website backup to email weekly
It'll depend on what you're backing up
A small website is probably fine
A large scale DB, not so much
Gmail for example only allows up to 25MB before you need to upload to drive
But when we make this publicly available, then such small websites can use it (we should just attach note to docs about not using for large DBs)
I don't think email is a good idea
but megacloud seems reasonable, feel free to open an issue for that
Will there be any support for things like rsyncing the whole host, or something similar?
I found 1 problem: Mega have SDK (written in C++), but not REST API (at least I can't find any references to it)
There is mega.py package, I'm looking into it now
I'd leave Mega currently out. This would make this package heavy.
But when I searched about Mega, I found 1 storage option that have upload API: Amazon S3
?
what are you guys currently doing?
We are talking about https://git.pydis.com/black-box
Our k8s backup service, with a misleading description
I know that, but that's as far as I know
Well, there isn't much more right now, we are trying to think of other things it could provide
by rsync, I assumed you mean "smart" backup where only changed files will move or something
BTW @crude gyro maybe the description could be changed? It is a backup service, not an emergency recovery service, no?
Yeah, using the rsync CLI
But I'm not sure if it would fit in this project
so currently all data is simply dumped into google drive? (over simplification xD)
I think so
with plans to support redis?
And Redis support will come
hmm ok
But I think (low priority) should be adding MySQL support too, as this is pretty common.
I think if we start doing this we will never end lol
lol
I'd say we only add what we need, and let anyone contribute what they need
I actually would like to replace my script that handles MySQL backup with Black Box
Time to contribute!
I have to wait until this is removed
That is true
no plans to do that.
weeelll. the idea is
a) an actual black box is an emergency recovery device so I was trying to be cute
b) you can also use this to store logs
c) when would you ever need backups and logs? in case of an emergency.
our entire k8 cluster implodes? it's okay, we've got a blackbox
we can use this to restore our databases and maybe figure out what went wrong
Buut you can't restore it using black box
But I guess that works
Yeah, that make sense
Alright
updated the description now anyway
Guess that works too
I haven't 100% decided yet if I'm gonna move this project into my personal github or keep it on python-discord
Could someone link me the issue which contained the shh equivalent for voice channels.
https://github.com/python-discord/bot/pull/1297
I think it would be the two related to this
From the creator of the Python compiler.
Hey this channel is specifically about python-discord projects. If you'd like to discuss something python related, try the #python-discussion channel
Hey guys so for the pr 1297, if a person leaves the vc when it was silenced the would it require an admin or a mod to un server mute them??
I think this would be one of the issues with shh for voice.
The silencing isn’t applied on a per member basis
But on a channel basis
It’s an extension of the silence command, which already does this for text channels
whats the reason for using django-environ instead of something like python-dotenv, what advantages does django-environ give
They do the opposite:
django-environis a package that allows you to read values from environment variables in a convenient waypython-dotenvallows you to parse a.envfile and add those values to your environment/set those values as environment variables
So, in principle, if you have an .env file, you could do:
.env --[python-dotenv]--> environment variables --[django-environ]--> values accessible in Python
The django-environ package comes with a few neat parsing options specifically meant for Django, such as parsing a database URL to something directly suitable for Django's database settings.
ooh
thats cool
thanks for the info!
okay so I have another question
how is the .env file geting parsed if django-environ can only access the env variables but not the .env file
cuz the docs say this line actually reads the .env file
or am I missing something
for local setup: pipenv loads the environment variables
for docker setup: docker sets them in the compose file: https://github.com/python-discord/site/blob/e00be6b44b56c9e74917754c9e0af3e46e0b368c/docker-compose.yml
GitHub
pythondiscord.com - A Django and Bulma web application. - python-discord/site
In production, we don't use a .env file; kubernetes takes care of inserting the secrets/environment variables into the container
right, thanks
I need to take a look at kubernetes, I dont know much about it
In the past, we used salt stack to insert the environment into our Docker containers (before migrating to kubernetes)
There are some great videos on YouTube, let me find some for you
Welcome to the first episode of my new series, Kubernetes 101!
In this episode, I'll introduce Kubernetes, give some reasons why it might—or might not—be a good fit for you, and we'll even build our first cluster and run an application on it!
Tune in every Wednesday at 11 a.m. ET! More info: https://kube101.jeffgeerling.com
Special thanks t...
thanks a lot!
Hey guys I think there has been circumstances where a mod had to apply infractions to multiple members but they couldn't do it in on message.
I was thinking of making it so that they would be able to apply an infraction to multiple people through a single message.
so basically !mute [greedy user converter] <duration> <reason>?
and they'd all share the same reason and duration? is that the idea?
cc: <@&267629731250176001> <@&778376272509141023> any thoughts on this?
ye like that
here is an example of when a mod had to apply an infraction to 2 members, with 2 different messges
Related issue, but not quite: I accidentally addressed a warning using a reply instead of a tag (it seemed that it would work in my head), so I ended up warning an innocent user called Please
Maybe disallow using the display name like that?
not quite related. maybe let's not get sidetracked
We should highlight this discussion in our moderation-tools channel I think
That could be useful, but I don't think it is top priority right now, compared to other improvements we wanted to do
We've opened a discussion in #mod-tools
My bad on the failed check, I see the issue now (missing new line at eof). What did I do wrong for this not to show up when i ran the checks myself? ```
PS C:\Users\Chris\src\bot> python -m pipenv run pre-commit
[INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Initializing environment for https://github.com/pre-commit/pygrep-hooks.
[INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
Check for merge conflicts............................(no files to check)Skipped
Check Toml...........................................(no files to check)Skipped
Check Yaml...........................................(no files to check)Skipped
Fix End of Files.....................................(no files to check)Skipped
Mixed line ending....................................(no files to check)Skipped
Trim Trailing Whitespace.............................(no files to check)Skipped
check blanket noqa...................................(no files to check)Skipped
Flake8...............................................(no files to check)Skipped
PS C:\Users\Chris\src\bot> python -m flake8 .
PS C:\Users\Chris\src\bot>
Did you not install the git hook?
it looks like it got added automatically when I ran pipenv run pre-commit
got installed to .git\hooks\pre-commit
Ok, found a solution, If I stage changes and then run it, it shows the issues
Yup it’s safe to assume when you see that many skipped checks that no changes were staged
Yea, it was my bad for not knowing it only checked staged changes
@tawdry vapor For the most recent post in #779073065560703007, should it be done for every single repository we have or just the main ones?
Main ones being bot, sir-lancebot, snekbox, and site.
Nevermind, I reread what you said another time and I now understand that it needs to be for all repositories that have this hook.
are discord api requests rate-limited?
Yes, they are
I'm trying to make sure that a user can only give one reaction on a message
This is my code:
@Cog.listener()
async def on_reaction_add(self, reaction: Reaction, user: User) -> None:
"""Ensures that each user adds one and only one reaction."""
if user == self.bot.user:
return
if not await self.messages.contains(reaction.message.id):
return
async with self.checking_messages: # Acquire the lock so that the dictionary isn't reset while iterating.
if reaction.emoji in EMOJIS_VAL and await self.messages.contains(reaction.message.id):
# create a custom counter
reaction_counter = defaultdict(int)
for reaction in reaction.message.reactions:
async for reaction_user in reaction.users():
if reaction_user == self.bot.user:
continue
reaction_counter[reaction_user] += 1
if reaction_counter[user] > 1:
await user.send(
"Sorry, you have already added a reaction, "
"please remove your reaction and try again."
)
await reaction.remove(user)
return
When I add 4-5 reactions very quickly, the bot fails to remove the last 3-4 reactions, and only removes the first one
How can I overcome this problem? By await asyncio.sleeping?
Hmm, that's an interesting problem
Note that rate limits won't make an action not go through
Discord.py will automatically wait until retrying
You may have some race conditions somewhere
Hmm what issue on our repos are you working on?
.pr 509
This is from there
Yes, it's from the seasonalbot sir lancebot
why does snekbox use docker-compose
what difference it would make if there wasnt docker-compose
it's for ease of development
yeah sure, i was reading abt it but like how does snekbox benefit from it
Snekbox, much like all the other py-dis projects relies on a few services, which could be annoying to setup locally. It's usually easier to have docker do it
Pretty much all py-dis projects can be run on host
so you don't have to run something like docker build -t snekbox . && docker run --name snekbox --privileged -p 8060:8060 --init --ipc none snekbox every time you want to build and start it
wait but isnt that supposed to be handled by my Dockerfile?
it is not handled by our dockerfile
well, you can't specify most of those in the dockerfile, i don't think
yeah
that isn't possible
privileged and ipc certainly
dockerfile just tells docker how to build the image, minimal details about running it
i see
the options for running the actual image are through your container host
for example, we use Docker Compose locally on our dev machines since that allows us to bootstrap a database and all other requirements
in production we use Kubernetes which has a very similar YAML format
interesting
in factttttt
where is snekboxes deployment
oh yeah it's in the repo
so this is the spec for how it actually gets deployed on our production machines
Hey guys why do we use log.trace and not log.info
I believe info is what the production logging is set to; debug and trace then give more granularity for local dev
how so
Production actually shows debug, because it turns out it's convenient to see those logs to avoid having to locally reproduce an issue to get detailed logs.
Well, at least Sentry has shows debug.
Log levels are defined by how they are used; they don't technically have any intrinsic meaning. Trace is used for very verbose logging about the current location and state of execution e.g. which function is currently running. Keeping it separate from the info level allows more verbose logs intended for debugging to be easily turned off by adjusting the log level threshold for output.
hmmmmn
@lament totem in case you didn't see my ping on GitHub, are you still planning to work on this?
Why does !source silence lead to this page
https://github.com/python-discord/bot/blob/master/bot/utils/lock.py#L64-L94
rather than leadig to this page
https://github.com/python-discord/bot/blob/master/bot/exts/moderation/silence.py
Command: source
Display information and a GitHub link to the source code of a command, tag, or cog.
Source Code
bot/exts/info/source.py:51
but the point of source is to link the exact thing isn't it?
I guess that wrapper is simply the registered entry point for that command 🤷♂️
Source links dynamically
So if that's what the code thinks it is
That's what it'll link to
hmmmmm
The alternative would be building a large mapping of command to source code
Which is just not... ideal
Did some digging, and this'll probably be the only command that does this
None of the other usages of lock are for a command directly
And the reason the lock is the entrypoint is that the command isn't actually the function, but the lock calling the function
We could probably add in a custom case for lock instances, and add a command property to locks, but it seems like its more trouble than it's worth for what is at the moment one command
https://github.com/python-discord/bot/issues/665
have u guys decided what to do about this?
I think that's a yes, there wouldn't be any reason to not support it
I'm gonna ask in #mod-tools first though
It has been decided that only commands that aren't mod+ will be given suggestions
@vocal wolf are we gonna give suggestions in mod channels though?
Well there's rarely any non-mod command in mod channels
but yeah it's probably still best to block suggestions within mod channels
Didn't we say that we wanted suggestions in mod channels? I might be misremembering
I don't think there was any conclusion about suggestions in mod channels
I wouldn't mind them for general commands
hmmmm well either way this fix will probably be one if statement. If we do want to block mod channels, there's a constant for that.
ah I thought it would be something like MOD_CHANNELS, forgot that util existed. Thanks for that.
.issue 551
would anyone take a look at this please
We need to update the sir lancebot guide, since its name has changed to sir lancebot but the guide says seasonal bot
which guide?
also for sir Lancelot bot, we need to add that users will have to have fake_redi=true in their .env file
Yeah I noticed that, but I was waiting for dewikification to update it, otherwise it would be a mess
.issue 60 meta
Can you mention it here please ^
sure thing
Thank you
alright
the one on pydis site, in contribution section.
Actually, it seems like it has been updated
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.
not here:
https://pythondiscord.com/pages/contributing/cloning-repository/
https://pythondiscord.com/pages/contributing/forking-repository/
sub contributing guides, where use is directed from the main one
Yeah it's been added
Cool
What are discord forms?
Are you talking about our forms or some native forms in discord?
not sure where you are getting that from?
have you seen this be mentioned somewhere?
Yes privacy policy
yeah that's pydis forms, not native to discord or anything
https://github.com/python-discord/forms-frontend
https://github.com/python-discord/forms-backend
https://forms.pythondiscord.com/
GitHub
Frontend for Python Discord forms. Contribute to python-discord/forms-frontend development by creating an account on GitHub.
GitHub
Backend for Python Discord forms. Contribute to python-discord/forms-backend development by creating an account on GitHub.
Python Discord Forms is the surveying system for the Python Discord server.
maybe sharing the deploy preview is a good idea since that has all the upcoming form components
Python Discord Forms is the surveying system for the Python Discord server.
Ty
our plan is to handle code jam submissions, ban appeals and other insights projects through this app
I think that’s been added under the env variables for both bots on the website
Though I think a warning or tip would be nice
https://github.com/python-discord/bot/pull/760 this PR is ready for review, if anyone wants to take it.
why not make it depend on the command, and not the invoker's role?
I think the only real issue was suggestions for mod commands
I couldn't find a consistent way of doing that.
Actually it does depend on the command kind of where it checks if the user can run the command.
Also you recommended me to look at the help command, and that does have a pretty complex way of filtering commands for different users (as far as I could tell).
hmm
Right, but that's under the debug section of the "full env variables for this project"
not on the bot contribution page
i was suggesting to add it there
Hey guys so we should remove the @everyone filter issue, because what's the point of it?
To prevent people that can actually ping everyone from quoting it, well that's fixed because of replies
so i don't currently see a point in having it
That's a good point
The filter is currently disabled, but we don’t want people going around and using some at-here and at-everyone
Is it disabled?
Yeah
It tripped earlier today
but it doesn't matter if they did though, cause if they spam it then mention filter will get triggered
Well, we don’t mute or mod ping @patent pivot
@green oriole #mod-alerts message
ah, right yeah
I mean we could just remove it though
the point was to prevent quoting after the incident where lemon quoted a thing in pygen
Because of the structure of an at-everyone that won’t get caught by our filter
wdym
An at-everyone is just the string @ followed by everyone, while mentions are made with something like this <@userid>
Our regex will only detect the latter
Even if we don’ auto-mute, I think it is a good idea to remove those messages and DM the user
but we could use message.mention_everyone for the mention filter and count it as a mention
Not pinging 120k people to ask your question sounds like common sense to me
yeah but the thing is
it won't ping though
- it won't ping
- quoting is a gone feature now
- it is very common for non-beginner discord users to just use the pings where they know they have no permissions
Hmm.. I mean, we have a lot of new users, that can teach them to not ping everyone without a good reason, they don’t get an infraction or anything
wait we check for mentions using regex?
I thiiink so
why???
why?
message.mentions exist
Yeah
message.mention_everyone exists
because the author can't ping everyone
that flag is only true if the author actually has permissions
We use message.mentions
Nope
send everyone
!int e ```py
msg = await channel.fetch_message(796773469852663858)
print(msg.mentions)
In [57]: msg = await channel.fetch_message(796773469852663858)
...: print(msg.mentions)
...:
[]```
!int e ```py
msg = await channel.fetch_message(796773469852663858)
print(msg.mention_everyone)
In [58]: msg = await channel.fetch_message(796773469852663858)
...: print(msg.mention_everyone)
...:
False```
eh voila
right
Yep
so we need to use regex
!raw 796773469852663858
== Raw message ==
@everyone blame joe if this ping
An in check would work
Actually
Why did we have some issues with the previous implementation?
I remember that it trigerred in codeblock
tried it?
but that’s about it
yeah it was codeblocks
That’s all?
iirc
EVERYONE_PING_RE = re.compile(rf"@everyone|<@&{Guild.id}>|@here")
Lol
What a regex
It does remove codeblocks
So it being removed or what?
That's a good question
In the end I don't really mind either way
But I still think it would be better to keep it
a lot of people post @ everyone's because they think they can, and it's ultimately just spam
true
We can relax the filter I guess, but it's pretty useful
yeah I think I'd rather keep it
Like make it not capture large messages
Anyone have any idea what could be causing a socket.gaierror: [Errno 11001] getaddrinfo failed error from aioredis. I've just forked sir-lancebot and ran python -m pipenv --sync and then python -m pipenv start run
(ofc made a bot, filled in the .env etc)
It's coming from loop.run_until_complete(redis_session.connect()) within bot/bot
Do you have redis running?
I haven't ran it on purpose no
Was just following 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.
You can specify USE_FAKEREDIS=true in your .env if you're not using something that relies on it to avoid setting it up
Ah alright cool, all looks to be working now, thanks
Ahh I see that note within the extended info on env vars
possibly something that should be made more obvious?
I think it's something we need to work on, yeah
Documentation is difficult, but we could make a few steps to make things easier to set up
We have some plans to make sure we're a little more on top of that in the future, so I'll keep that point in mind
Yea I understand that, I mean the docs are on the better side of some that I've seen, very easy to follow, so no complaints there 🙂
Feedback's always welcome.
It's better to know the kind of stumbling blocks people are confronted with
👍
I think we could move the fake_redis var to the main page on sir Lancelot like inheritance suggested
It’s honestly the main reason the sub page was made
To do something similar for the other bot, we’d either have to dedicate it it’s own note, or make fakeredis an env var
Another option would be to default to a state where redis is disabled, and a env var is required for it to be enabled
Possibly the presence of the REDIS_ env vars?
I think we should encourage the use of redis where possible
Not because it’s necessarily better
But because testing on software that is as close as possible to prod version can help catch issues that might not otherwise occur
It would certainly be easier to write a setup guide if we could assume everyone would use the docker compose file for all the needed services.
.help refers to a lot of deleted channels if you call it in pygen, apparently
Is it only pygen, or does it happen in other channels too
@trim cradle is it sir Lancebot or should we look at both bots
should be the same everywhere for the commands that are not allowed. Are they deleted deleted channels, or just ones that are hidden from normal users? There's https://github.com/python-discord/sir-lancebot/issues/539 but if there are consts for channels that no longer exist then they should be removed
lancebot
I only saw it for a moment and then the user deleted the bot's response
Let me try my alt
Are alts secret?👀
not necessarily
I think we should be able to test this in the testing server, so that's enough spam for pygen now
inb4 I make the python bot say "spam spam spam spam spam" in pygen
People will be more confused than amused
Here is a fun tidbit
Sir lancebot still has references to the old help channels in the constants file
Ok issue investigated: it's the sprint channels
They aren't visible to the bot, so they just show up as deleted
These are the channels that the bot sends. The easiest solution would probably be to not show deleted channels in that embed at all
If the bot can't see them anyway because they're archived/whatever they should be removed alongside not showing channels that aren't relevant to the user that invoked the command
All of the sprint channels should removed from the constants
But either way, I think the right move would be to make it suggest only #sir-lancebot-playground
That it can be used in one or two other channels doesn't matter
It can be useful for when the check is used with an override
But we can handle that spam through the mention filter rather than having the everyone
We can't
As shown, mentions and mention_everyone do not work when perms are missing
Or do you mean adding to the mention rule?
The cases mbaruh refers to probably doesn't trip the mentions filter
But we can use regex to check for that in the mention filter, can't we?
we could, but we intentionally don't want to trip filters for this
it's way too high volume and ruins our signal-to-noise ratio
hmm
I don't think the current location or presence of the filter is particularly complicating anything
It has proved useful, and I think it will continue to. We should educate people that trying to ping thousands of people isn't a great idea.
"educate" lol
you jest, but it doesn't tend to have reoffenders
If someone wants a freebie PR, please update @stable mountain d.py to 1.6. It's currently using some 1.6 pre-release via git.
how to do that?
"discord.py" = {git = "https://github.com/Rapptz/discord.py.git", ref = "94f76e63947b102e5de6dae9a2cd687b308033"}
Change this to
discord.py="1.6.0"
?
"discord.py" = "~1.6.0"
like this?
In the same way as every package defined in the pipfile
right
Building requirements...
Resolving dependencies...
✔ Success!
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
✔ Success!
Warning: colorama~=0.4.3; sys_platform == 'win32' doesn't match your environment, its dependencies won't be resolved.
Updated Pipfile.lock (399848)!
ok done
now what do I do
@tawdry vapor ?
Create a PR
it gonna take a while ok cause idk how to create a pr so i need to do some research
Github has a decent guide on the fork-pr workflow
https://opensource.com/article/19/7/create-pull-request-github
i am doing what this is saying
Yup, seems good. Alternatively you can use a graphical UI, but it's always good to learn to do it manually
I am looking for an open-source project to contribute to, whether by code, documentation or other means. I have done some for small projects in the past. Any pointers?
We have the contributing guide on our website if you’d like to contribute to a pydis project
Sir lancebot is by far the most beginner friendly, all the details here: https://pythondiscord.com/pages/contributing/
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’d like projects not run by pydis, or projects in other languages, check out https://github.com/MunGell/awesome-for-beginners
That's very helpful, thank you
Hey guys i can't currently do that pr thingy, cause some work came up.
I am exteremly sorry
I am not sure if this is the right place to ask, but I tried running the sir lancebot repo, but I keep getting this error: socket.gaierror: [Errno 8] nodename nor servname provided, or not known
On second thought, I think I should go to a help channel
if you are running one of our projects and encountering errors this is a fine channel for that 😄
could you post the full logs of starting the bot, censor out anything sensitive
I have put further information in #help-candy
I will try to censor out sensitive info
you can just put those help requests here, instead of using the help channels for it. This is where that competency lives
I think your configuration file is probably not set up correctly in this case
maybe you can put your config file into a paste and share it here?
!paste @gritty bolt
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
Okay, give me a second
I kinda have a feeling the reason for that error is fake_redis=True is not set
@gritty bolt have u set fake_redis=Truein .env file?
Err no, should I add that in?
Works like a charm, thanks for the help guys
👍
We can use the reply feature on eval .
I got this error on the sir lancebot: discord.errors.HTTPException: 400 Bad Request (error code: 10014): Unknown Emoji
I tried using the .extension list command on my own private test server
It is probably the trash emoji that is missing
You need to add it on your server, and change the configuration
Well, you can put any emoji
Wait Akarys, I was just looking at the issue you posted on the sir lancebot github page. The one about feeding to many lines into the paginator
I am still new to this, so I am not sure, but did no one fix it?
Also, how do I change emojis?
Server settings > upload emoji?
Do I have to manually enter emojis? I thought they were built into discord
some emojis it uses are custom
we could replace the trashcan with likke
🗑️
This one looks like garbage though pun intended
Although our trashcan can be better
So how do I replace the emoji?
That's a good question, it should be an env var somewhere
Well
It is hardcoded lul
So hmm..
I guess you can add an env var here
I think it’s hard coded into constants.py
By env var, you mean os.environ['...']=...?
Yeah, you can replace the line I just linked to allow env vars
So, first I set the environment variable, and then in the line you linked, I put trashcan = os.getenv('emoji_name')?
Yeah, with the current value as a default
And I have to do this with every custom emoji?
Technically yes, but you probably won't need much of them
Wait, now .extension list doesn't even show an error message. I am trying to replicate the error here: https://github.com/python-discord/sir-lancebot/issues/533
I've just ran pipenv run lint against my fork of sirlancebot, its modified every file in the repo, the changes look to be line endings, anyone able to let me know what I can do to not have this happen when I run lint?
oh wait, I think I had autoclrf in my global git conf
changing to to false in this repo seems to have solved it
Ah nice
would doing a dry run help?
your editor's linter should warn you about line endings, if you set it to flake8
yea, I changed the repo git.autoclrf to false, discarded all of the changes and re-ran linting, seemed to have done the job
@lament hedge Just added a couple of requested changes on your https://github.com/python-discord/bot/pull/1303 PR. Should be able to get it reviewed and merged not long after that.
.issue 397
@cold moon Sorry for forgetting about this PR, I've reviewed it.
The pyside2 doc package could use a rename to pyside6 as that's what the inventory refers to now
Hey @tawdry vapor
On your comment here: https://github.com/python-discord/bot/pull/1297/files#r548905832
I'm a little confused by what you mean for condition 1. As for condition 2, I didn't think it would be necessary to test, as the function shouldn't have a way of accessing the second channel when it isn't passed. If you think we should test it, it won't be difficult exactly to add one line.
@vocal wolf About tic-tac-toe, moving to embed make emojis really really small.
hmmmmmmm
We should think of a solution that lets compact and non-compact users see the game properly.
-
When the source channel is equal to the target channel, then you need to test that no string replacement happens i.e.
"current channel"remains. -
yes, the function is written correctly. However, you should still test it because sending a message when the variables are equal is undersirable behaviour. The test effectively makes sure that the
source_channel != target_channelcondition exists and is correct.
Ah okay, I get what you mean
thanks
https://github.com/python-discord/bot/pull/1297/files#r548919230
And one more question, would it be preferable for me to combine all three decorators into a single autospec, or only combine the last 2, as the first one would need to have its return value set in the function otherwise afaik
I guess more proper to keep them separate but the other two functions don't return anything nor does anything expect it to, so it wouldn't change anything if the mock added a return value.
Either way an autospec is good if just for its ability to test that all needed function args are passed
Good point, it did fail the existing tests lol
Anyways, I've put them all in an autospec for now, and will revisit it if need be
@vocal wolf Of course we can generate tic-tac-toe board image, but this would need big refactor of whole cog and doesn't have good performance.
Could we have a newline at the start and then put the emojis after?
I'm not sure doesn't Discord cut this off and this doesn't make emojis small
More questions since I'm going through your comments one at a time
On https://github.com/python-discord/bot/pull/1297/files#r548920403 about using subtests: I've already removed most of the setup in accordance with your other suggestions. The only things left are the ctx and channel mocks, as well as the autospeced variables.
I'm wondering if it would be better or worse to break these out into their separate functions, especially since with text channels, it's up to 4 tests. Possibly it could use it's own class like I did with send message, but then I'd have to copy over a bunch of stuff from the main class
Yeah, I don't know either
This is the sort of thing pytest's fixtures would be nice for
But alas we use unittest
Why do we use unittest rather than pytest?
In part because unittest is a standard library module and in part because site was developed with a unittest-testsuite using Django's test runner and had extensive coverage. When we started testing for bot, we had a few tests in pytest (but just a few), but we decided to migrate it to use a single test framework across our main projects. Migrating bot to unittest was way less work than migrating site to pytest.
.pr 552
Is there a place where I should note how to get a client id & secret from the IGDB api?
Hmm that should probably be added to the env var page
How much space do you think you need?
Not too much, we could also link to https://api-docs.igdb.com/#breaking-changes or https://dev.twitch.tv/docs/authentication
Step 5 in the first link explains the steps, so we could change that to be project specific
I mean if we can just link the page explaining it, that would fit better with the existing docs
I'm not sure how stable the first link will be though
The other vars have the var name, a link, and possibly a description
What about this page
https://api-docs.igdb.com/#about
That's what we currently have on there, along with:
Required for API access. A Twitch account is needed.
Ehh, hopefully someone will be around to update it
I'm just trying to find my way around the site repo to see what needs changing
What are we using IGDB for anyways?
.games
Hmm, I've never seen that before. Cool
Looked like an easy issue for my first pr 😛
Huh that changes the env var name
yea, we need 2 now, instead of just the one
Can you leave a note on the PR that this needs to be updated
https://pythondiscord.com/pages/contributing/sir-lancebot/sir-lancebot-env-var-reference/#tokensapis
Thanks
Also please note on the PR that we need to make the secrets available in the bot's environment. It's a logical step, but if someone misses it and hits "merge", it will not work.
If no other features depend on the old values, I could also add it proactively soon
Yea, nothing uses the old env var, I'll add a comment
@hardy gorge Do you remember why the square bracket was escaped in this?
"::error file=%(path)s,line=%(row)d,col=%(col)d::\[flake8] %(code)s: %(text)s"
Never mind, sorry.
It's just cause there was a newline, which I removed.
This is ready for a review https://github.com/python-discord/snekbox/pull/64
What would be the right channel to send the logs from https://github.com/python-discord/bot/pull/1014#discussion_r532956783 to? From the issues Mark highlighted logging it through logging is really only adequate during development.
@green oriole I am trying to reproduce the error on the issue you opened: https://github.com/python-discord/sir-lancebot/issues/533
The command doesn't work, but it does not raise an exception either.
Does anybody have suggestion how to make https://github.com/python-discord/sir-lancebot/pull/397 working in compact mode
I opened the issue but idk what to do now
Do you want to work on it?
If not, then we need to wait for someone to come around and tackle it
ofc i do, that's the reason i opened it
I mean people open issues for things they want implemented but dont want to work on
well i want to work on it, ye
Do you know where to start with contributing?
huh
I.E do you have the project set up and running locally
yes
In that case, you can start writing your code
We follow a fork and pull workflow
So once you have all your work ready, fork the project, and open a PR.
oh ok, i thought i needed an approval or something like that
ok
also i never added any of those labels but why does it say that I did?
ah i see, thx. Well ima get to work now
the file should be located in bot/exts/evergreen/typerace.py
right?
I believe that's accurate
We just need to add a non-empty line before the board
I know it'll work with something like a period
Still haven't tested an invisible character or something
"\u200B\n" + "\n".join(```
compact mode
It does however add an empty space on regular
We can probably avoid all of this if we send as one message, we don't need the big numbers
Hmm, when we don't need big numbers, we can use embed too
Hmm, the thing is that we got a sentry issue, so I am assuming that it is failing silently. Can you try to add a try/except block around it to make sure that you catch the error?
If it isn't responding at all
make sure you have the correct permissions
And make sure you are using .extensions or .ext as the one in the issue title and repro steps isn't an alias
The @stable mountain bot and possibly the other one have issues authorizing the tag command for non-developer users
I replicated the issue, and can confirm the tag commands work fine for @developers but not @everyone
Strangely enough
DEBUG | Cancelling attempt to invoke silence/unsilence due to failed checks. is logged
To clarify
The tags command works
But displays an empty list
And trying to invoke one manually doesn't do anything
@green oriole "Markov chain to generate the input and train it on something Python related."
what did u mean by this?
I found the part that wasn't updated correctly
This needs to be changed from developers
I think they were referring to something like this https://github.com/jsvine/markovify
Oh wow
This repo is MIT licensed to, so you could use it in lancebot if needed. This is actually a package on pypi if you wanted to add it as a dependancy.
The above copyright notice and this permission notice shall be included
Don't add MIT licenced code without consulting staff here first
Its better to ask first, than be told you can't do it in a PR after you put in all the work
But what did he mean by a chain generator?
It's something from mathematics: https://en.wikipedia.org/wiki/Markov_chain
I still don't get how it applies to the typerace command, but ig i will ask him when he comes online
My idea was to use the Markov chain to generate the text you have to retype, to spice up the feature a bit
Bumping this because it should be fixed quickly :x
!remind 4h Update it
ROGER THAT
Your reminder will arrive in 4 hours!
ID: 1232, Due: 2021-01-10T16:47:40
Actually, the fix could not actually be very simple
All you'd need to do is set that to None, and add a None check
Or drop the checks completely because all tags are publicly visible atm
I actually already made a patch for the first solution if you need it
@green oriole
Here's your reminder: Update it.
[Jump back to when you created the reminder](#dev-contrib message)
Done
Woah if I didn't know any better I'd say you finished that in < 1 min
Haha
@obsidian patio for the embed helper are u saying we should create our own class inheriting from discord.Embed or do you have another idea for how it should be created?
Creating a new separate function imo
Could u elaborate a bit more on that?
def get_embed(category: str, title: str = "Embed", ddescription: str = "Description"):
embed = Embed(
title = title,
description = description,
)
if category == "error":
embed.title = random.choice(constants.ERROR_REPLIES)
embed.color = constants.colors.soft_red
return embed
In its essence, I think something like this would work. We could have a dictionary with defaults for the categories, use more general (not if-else) logic and similar things, but that's just implementation details
It's just a more convenient way of creating the embeds. And if we want to add things like footers, we could add arguments for that, instead of having to add afterwards
That was a class first, but I realized it should be a function hahah
You saw nothing hahah
Needs a review - it's just some dependency changes really https://github.com/python-discord/snekbox/pull/64
There needs to be a bigger discussion on how to handle logging overall (like if it should ping or be in a new channel), but put it in #dev-log for now.
Should it ping for now while in dev log? The false positives I mentioned may have been because of a link pointing at an older version of the page but can't confirm it now as the old logs have been overwritten
No, let's not ping for now
Is there an easy way to find issues that are free to pickup, I'm looking through the issues in sir-lancebot and some have assignees, some don't (but in the comments someone says they're working on it)
Also, am I correct to assume only issues with Status: approved should be worked on?
If they have the approved label and no one assigned (or a similar comment in the issue), then the issue is free.
Filtering by labels and lack of assignee is a built-in feature in GH
If you see unassigned issues but someone commenting about wanting to work on it, you can check in with them or us on the status of their progress.
Sometimes people say they want to work on it but they fall through on it
Other times we don't notice the requests in a timely manner
@vocal wolf do you have an idea of how messy the issues are in this regard?
I'm on the snekbox grind. I have another PR that needs a review https://github.com/python-discord/snekbox/pull/88
Sorry for not replying earlier. Yes, I have somewhat of an idea. I'll be looking over issues during the following weeks to see what can be done to organize them. It's a bit late, I'll probably have a better answer for you once I wake.
Hey so for the typerace command it will be using an API, so where do I specify that we would need an API key?
No markov chain? 
no cause i didn't understand how i would use that and for markov chain as well it seemed that u needed sentences
My idea was to use a Markov chain to generate text, put the text on an image and use it as the typeraced input
As for the chain input, maybe you can use the Python docs, some talks, or something like that?
well that would only generate python related text, not overall text
but ye, #dev-contrib message
ping me for an answer
Is that really an issue? We are a Python server afterall
i will make a separate command for python based inputs maybe we could use your markov chain solution there, but for the normal ones i would like to use quotes
how does that sound?
huh
!e import pandas
@sharp timber :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/snekbox/user_base/lib/python3.9/site-packages/pandas/__init__.py", line 29, in <module>
003 | from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib
004 | File "/snekbox/user_base/lib/python3.9/site-packages/pandas/_libs/__init__.py", line 13, in <module>
005 | from pandas._libs.interval import Interval
006 | File "pandas/_libs/interval.pyx", line 1, in init pandas._libs.interval
007 | File "pandas/_libs/hashtable.pyx", line 1, in init pandas._libs.hashtable
008 | File "pandas/_libs/missing.pyx", line 1, in init pandas._libs.missing
009 | File "/snekbox/user_base/lib/python3.9/site-packages/pandas/_libs/tslibs/__init__.py", line 30, in <module>
010 | from .conversion import OutOfBoundsTimedelta, localize_pydatetime
011 | File "pandas/_libs/tslibs/conversion.pyx", line 1, in init pandas._libs.tslibs.conversion
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/avemiyivet.txt
Should I finish up my bug report on this?
Filed anyway, in snekbox repo, enjoy clicking the fixed button :P
Nice, thanks for the issue
Uh, I don't know why, when I am adding multiple reactions to a message (of different emojis ofcourse), the emoji in on_reaction_add is always the same...
@Cog.listener()
async def on_reaction_add(self, reaction: Reaction, user: User) -> None:
"""Ensures that each user adds one and only one reaction."""
if user == self.bot.user:
return
if not await self.messages.contains(reaction.message.id):
return
async with self.checking_messages: # Acquire the lock so that the dictionary isn't reset while iterating.
if reaction.emoji in EMOJIS_VAL:
# create a custom counter
reaction_counter = defaultdict(int)
for reaction in reaction.message.reactions:
async for reaction_user in reaction.users():
if reaction_user == self.bot.user:
continue
reaction_counter[reaction_user] += 1
if reaction_counter[user] > 1:
await user.send(
"Sorry, you have already added a reaction, "
"please remove your reaction and try again."
)
await reaction.remove(user)
return
So this is my code, and the reaction.emoji is always the emoji first reaction on the message
oh wait I think I got it
Ok sorry I got it, it was because I used the already decleared reaction variable in the for loop, which caused issues I guess
If someone has time to give this a once over I'd appreciate it: https://github.com/python-discord/bot/pull/1303
I can have a look at it after 12 hours 😛
I took care of it
you can still provide your own input if you have something additional to say
I don't, the only two things I thought I could remark have already been commented on by Mark.
I'm having a bit of trouble with tests that import the test helpers, looks like the spec isn't being set correctly? https://paste.fuelrats.com/wogonotoxe.tex I'm on up to date master and 3.8.7
Any idea what's going on there? The tests apparently work as the checks passed
Hmm yeah it happened to me as well yesterday, but oddly the tests passed in the PR
Is this happening specifically on that line or are there multiple helpers that have issues?
Not sure if it's due to a specific spec being problematic or that generally the mixin is messed up
My preliminary investigation leads me to believe that some kwargs are being passed to the mock which are invalid for the spec.
Recall that extra kwargs to a mock are just used to set arbitrary attributes on the mock
Based on the error, the culprit is this pending kwarg https://github.com/python-discord/bot/blob/master/tests/helpers.py#L233
This is new in d.py 1.6
If it's failing locally then your venv is likely out of date
Ah, it looks like pipenv didn't want to jump to the alpha itself but looks like uninstalling discord.py manually and then letting pipenv do its job fixed it
Is anyone working on the version bump?
Someone was but I think they're new to contributing so they had trouble opening the PR
@late wolf do you still plan on opening the PR soon?
I am sorry, but no
That's okay, I'll take over.
!d itertools
This module implements a number of iterator building blocks inspired by constructs from APL, Haskell, and SML. Each has been recast in a form suitable for Python.
The module standardizes a core set of fast, memory efficient tools that are useful by themselves or in combination. Together, they form an “iterator algebra” making it possible to construct specialized tools succinctly and efficiently in pure Python.
For instance, SML provides a tabulation tool: tabulate(f) which produces a sequence f(0), f(1), .... The same effect can be achieved in Python by combining map() and count() to form map(f, count()).... read more
2to3fixer.itertools
what do you mean?
!d itertools.combinations
itertools.combinations(iterable, r)```
Return *r* length subsequences of elements from the input *iterable*.
The combination tuples are emitted in lexicographic ordering according to the order of the input *iterable*. So, if the input *iterable* is sorted, the combination tuples will be produced in sorted order.
Elements are treated as unique based on their position, not on their value. So if the input elements are unique, there will be no repeat values in each combination.
Roughly equivalent to:... [read more](https://docs.python.org/3/library/itertools.html#itertools.combinations)
well that is weird
Should work normally, don't see anything special there
You are not allowed to use that command here. Please use the #bot-commands channel instead.
@cold moon so about that tic-tac-toe command, were you eventually able to find a solution for compact users?
I think I'm gonna use embed. It's small then, but at least looks better in compact mode
Alright, sounds good to me.
But I will do this after I finish my Pokemon bot PostgreSQL command (dynamic queries is nightmare in Rust).
glhf!
2 PRs here that need reviews https://github.com/python-discord/snekbox/pulls
How does the bot use Async-RedisCache to persist between restarts?
Redis doesn't run inside the bot container
We have a separate Redis instance which the bot connects to to persist data
What about the database on the website?
I assume that the database is a separate container as well
Not really, we store different data
Redis is, as the name suggests, a cache
It is a much easier development process
We did have a KV implementation on the site, but it meant every time you wanted to persist something on the bot you had to make site changes, it just wasn't worth it when there are solutions like Redis that do this out of the box
Plus we already have a Redis instance for the paste server.
using Redis means you just create a new redis cache object and it just works, KV is just there
So redis data would be lost in a restart?
No, both Redis and site data are persisted onto volumes
but if we did lose Redis it would not be catastrophic
At worst we'd lose the information on the current help channel claimants
Ok, so Redis is to store temporary information, the site DB is for permanent info.
I would say the distinguishing factor is critical vs. non-critical
Ok
Redis is a very simple KV for one key one value, Postgres stores our critical data like infractions in a relational database with multiple columns and much more information
Ohh, Redis is one key to value?
yes
127.0.0.1:6379> SET abc def
OK
127.0.0.1:6379> GET abc
"def"
127.0.0.1:6379> DEL abc
(integer) 1
127.0.0.1:6379> GET abc
(nil)
You can get around that by storing serialised data, which we do in a few spots.
Yeah, and we have some typing built in since in Redis everything is a string
but that's all abstracted away by async-rediscache
Also, one more question: how is the bot made into a docker container?
And how does it automatically download Redis, the site, etc.?
I’m not sure how much you know about docker, but here’s a really quick introduction to docker. You’ll be presented with the fundamentals of it https://youtu.be/Gjnup-PuquQ
🐳 Docker is a required skill for almost every developer in today's world. Learn the basics of Dockerfiles, images, and containers in 100 seconds. https://fireship.io
Docker Docs https://docs.docker.com/
#docker #dev #100SecondsOfCode
Install the quiz app 🤓
iOS https://itunes.apple.com/us/app/fireship/id1462592372?mt=8
Android https://play.g...
@brazen charm Would you prefer me to leave comments on your doc PR incrementally, or would you rather me do a full pass through it before submitting? I'm asking cause I'm only reviewing a portion every day.
Incrementally sounds fine, gives me more time to respond too
Okay, thanks. I will submit what I have so far
I think the first 2 were really old comments so not sure if they're still relevant.
I'm trying to replicate the itertools.product docs being missing, can I get the command to add the inventory?
!help docs set
!docs set <package_name> <base_url> <inventory_url>
Can also use: docs s
*Adds a new documentation metadata object to the site's database.
The database will update the object, should an existing item with the specified package_name already exist.
Example:
!docs set python https://docs.python.org/3/ https://docs.python.org/3/objects.inv*
I believe it is this one followed by a !docs refresh
Worked fine for me locally
would objects be itertools (in the inv url)?
The example is the exact command
itertools.product(*iterables, repeat=1)```
Cartesian product of input iterables.
Roughly equivalent to nested for-loops in a generator expression. For example, `product(A, B)` returns the same as `((x,y) for x in A for y in B)`.
The nested loops cycle like an odometer with the rightmost element advancing on every iteration. This pattern creates a lexicographic ordering so that if the input’s iterables are sorted, the product tuples are emitted in sorted order.
To compute the product of an iterable with itself, specify the number of repetitions with the optional *repeat* keyword argument. For example, `product(A, repeat=4)` means the same as `product(A, A, A, A)`.
This function is roughly equivalent to the following code, except that the actual implementation does not build up intermediate results in memory:... [read more](https://docs.python.org/3/library/itertools.html#itertools.product)
Sorry about that
I'd guess the piece of code that tries to take care of duplicates was the culprit here
https://github.com/python-discord/smartconfig
@green oriole could you let me know what the project is about? the README.md says it's in development : P
This project will be a PyPi package to provide effortless configuration files, although it isn’t quite ready to accept contributions right now
If you're looking to contribute to the pydis repos, check out https://pythondiscord.com/pages/contributing/
Those 3 projects are the best ones to start with
Some of the ones on the github org are not ready for public contributions yet
A question about lancebot's docker setup (I'm new to docker so might be missing something)
From what I can tell, to get the docker setup working I needed to add env vars to the docker-compose file like the image below.
Obviously this means that I need to make sure I don't commit this change when pushing, is there a different way to do this?
can we have a un-assigned issue label, for new contributors to know, which issues can be worked on?
@vale ibex I was wondering the same lately. I haven't really used the compose way of running our projects before, but I was doing so now and it seems like a little bit of a hassle to make local configuration changes to ensure this file doesn't show up as changed in git. I think adding it to the local exclude would work (.git/info/exclude), but I actually think we should switch to the .env-file way of specifying these variables. This means that we have a file that's ignored by default and can both be used for the pipenv way of running the projects as well as the docker-compose way of running the project.
Maybe there's a reason I'm overlooking for why this can't be used though.
Maybe @green oriole knows
Are we not passing env vars through?
What do you mean?
I don't think we're using the option to read them from the shell environment
(No ${NAME})
The container env vars are completely shielded from your actual environment, including the .env file. You need to specify which variables you want to pass through in the environment section
yes
but you can also specify an .env file
or specify which specific environment variables need to be read
bot:
env_file:
- .env
That would work
or
You still need to add the variable name in the environment section even if you load them from the .env file for security reasons afaik
Hmm, yeah, maybe we can use that
Fwiw you don't need the =${BOT_TOKEN} part
There are plenty of ways that don't require the end user to actually modify the docker-compose.yaml file itself, which is watched by git
Right, I suppose that's true (the valueless inclusion)
In any case, I think it may be wise to set it up so we don't actually ask people to modify a file that's under source control but should never be committed
Yep, we should set an env_file entry
An .env file is the easiest way, since it doesn't require knowledge of how to set environment variables for processes
yeah
Alright, let's do this
I can open a PR tomorrow if nobody does it in the meantime
!remind 21h Add an env_file entry to the sir lancebot compose
You're the boss!
Your reminder will arrive in 21 hours!
ID: 1248, Due: 2021-01-14T09:48:02
We should test out how it behaves if the file is missing
And modify the contribution guide
I thiiiink compose won't start if there isn't the env file
But even if it does, the bot will exit because it doesn't have any token
Hmm.. I guess you could set it as an actual env var
I don't mind asking people to create a .env file. It's the default route for a purely pipenv-based application flow as well.
It would be great if those two files were completely compatible (you could switch between docker-compose/pipenv without having to change anything)
I think the .env dialects both support should allow for that
Yep
This already exists on GitHub by default
When looking at the issues, click assignee, then select the no assignee option from the drop down
I've changed the docker-compose file to just this ```yml
version: "3.7"
services:
sir-lancebot:
build:
context: .
dockerfile: Dockerfile
container_name: sir-lancebot
init: true
restart: always
depends_on:
- redis
env_file:
- .env
volumes:
- .:/bot
redis:
image: redis:latest
ports:
- "127.0.0.1:6379:6379"
and it seems to be working fine, given a .env file
I can PR the change, but we probably want something in the wiki changed too?
ok , so i can work on issues with no assignee?
Please comment on them that you want to work, so we can assign you
But yeah
This is all documented in the getting started and contributing guides I believe
It’s a little buried, but the first pin in this channel links to the getting started pages
ok, thanks!
@vale ibex fwiw, I wouldn't usually recommend you open a PR without having an issue opened, as an issue allows for discussion, and you can be given the "good to go", and get assigned before you start working. The discussions here sort of suffice some times, but an issue is usually a better bet
Ah yea alright, should I add a link to the above convo in the PR for context at least?
Since there is no issue, that's probably not a bad idea
Yea, making an issue for this slipped my mind, due to the discussion above
But it makes sense for people who missed it to have the context behind it
I'll be sure to make one in future 🙂
No worries, I just don't want to see people putting in the work and getting told its not something we want to be worked on, etc
I wonder if this will cause problems in deploy
so about sir-lancebot#554, you can already use a .env file instead of modifying your docker-compose.yml
it should not cause issues with deploy
we don't use docker-compose in CI or production
Right, that makes sense
How would you go about using the .env with docker-compose?
Whenever I do docker-compose up it doesn't seem to use the vars from my .env
it should just work automatically, as long as you start it in the same directory where your .env is
i've always used a .env instead of modifying the docker-compose.yml
right now my docker-compose.yml looks like this ... environment: - BOT_TOKEN - BOT_DEBUG - BOT_GUILD - BOT_ADMIN_ROLE_ID - CHANNEL_DEVLOG - CHANNEL_COMMUNITY_BOT_COMMANDS - REDIS_HOST=redis
oh, right, it should use .env automatically
my .env has values for those, but also has values for IGDB_CLIENT_ID and IGDB_CLIENT_SECRET
yes, those variables should be added to the config
so would I need to add those keys to the yml file for it to pull them?
yep
Will it pass undefined variables though?
as an empty string
Would docker complain if it can't find those keys in the .env?
We would end up with a really long env var list though, and not always up to date
ah, so should we update the docker-compose file with all possible env vars?
it should give a warning, but will continue running
I’d rather have it stuff the whole env file into the container
Doesn't it automatically pull the entire .env file?
Nope
Try to pass any random env var @gritty wind, it shouldn’t go through
yea, it looks like it only pulls env vars from the .env that are listed in the environment section of docker-compose.yml
IMO it is a good plan on the paper, but in reality we will just end up with 30 lines or so of env vars, not always up to date
I think we should define manually env vars that have default values, otherwise bring from .env
so env_file + enviroment for defaults?
Yes
The default should be in the code IMO, along with where we use the variables
And it is pretty ugly to define defaults with compose
No, like Redis data shouldn't
Well, if we use env_file we don’t need environment I think
well, we should at the least keep some sort of documentation up to date that's not the code
yea, the only use for enviroment for that case would be to define defaults
Well, other than digging through the consts file
i don't think site is even up to date, is it? lol
I updated it
ahhh nice, cheers
nothing is up to date
haha
But most of it will go away with smartconfig, so that’s that
And tested it now, docker pulled my file in, word for word
Comments, and vars that only exist in the .env file
As long as the bot is running in the same directory as the env file, it should just work (and considering my bot is up right now, it should be)
so your .env is in /bot?
we do need to create better documentation for our projects
root directory of the repository
It is, I'm trying to find out if it has access to it