#dev-contrib

1 messages · Page 76 of 1

crude gyro
#

I think this will be a fun little project when it's done.

tawdry vapor
#

Regarding logging, wouldn't sshing into containers require them to be running sshd?

crude gyro
#

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?

tawdry vapor
#

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

crude gyro
#

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

tawdry vapor
#

Wait maybe cause it's k8s there is no Docker socket

crude gyro
#

there is a docker socket

green oriole
#

You can pull the Docker logs but you need to mount the docker socket, yeah

crude gyro
#

and the k8 containers are on the socket actually.

green oriole
#

Security wise it seems indeed pretty bad

crude gyro
#

doesn't seem too bad for it to see the docker socket.

tawdry vapor
#

So that means it's using Docker as the engine?

#

Wasn't there some depreciation regarding that

crude gyro
#

there was..

#

that might be a problem if we build a system around it.

green oriole
#

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

tawdry vapor
#

Can you have k8s upload the logs somewhere

#

Or can they only be retrieved by the recipient initiating the request

crude gyro
#

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?

green oriole
#

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

crude gyro
#

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.

tawdry vapor
#

But that would put more reliance on external setups

green oriole
#

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?

crude gyro
#

no idea. @patent pivot would have input.

tawdry vapor
#

Oh wrong link

#

Which is basically what you said about using a proper logging service it seems

#

Cause the previous seems to be just access with kubectl

crude gyro
#

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.

tawdry vapor
#

Ssh to get Docker logs seems a bit awkward

#

But I don't have better idea for remote container logs besides the socket

hardy gorge
#

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.

crude gyro
#

I'm getting the backups up and running first even if logging were easy.

#

postgres works already, sorta.

tawdry vapor
#

That second link has an open source logging agent for k8s but it seems to expect an elastic search server

crude gyro
#

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

green oriole
#

That could work, yeah

crude gyro
#

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

#

thanks for all the super helpful input, guys. lemon_hearteyes

patent pivot
#

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

crude gyro
#

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

patent pivot
#

yeah

crude gyro
#

but I think arbitrary command execution is an absolutely acceptable solution here

#

then they can do whatever they want with it

patent pivot
#

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

crude gyro
#

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)

patent pivot
#

I think Loki solves the task better than Dozzle, but having to run Grafana, Loki and Promtail isn't the most gorgeous

crude gyro
#

I just liked how simple Dozzle was

green oriole
#

Dozzle was truly great

crude gyro
#

but I guess with the docker engine being deprecated, forking Dozzle would not work for kubernetes anyway

green oriole
#

Simplicity at its finest

crude gyro
#

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

green oriole
#

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

crude gyro
#

it was hideous, and filtering and search was really poorly implemented imo.

green oriole
#

Yeah I have to admit the search wasn't great

patent pivot
#

If we forked Dozzle to work with k8s it'd have to go through the Kubernetes API

crude gyro
#

yeah

#

I don't know, maybe not even forking

green oriole
#

I didn't mind the style though

crude gyro
#

but just writing something like it

green oriole
#

Yeah, I don't think it is worth forking at this point

#

We would only keep the front-end that lemon hated haha

patent pivot
crude gyro
#

hell yeah, that's fucking cool

patent pivot
#

hahahahaha

green oriole
#

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

patent pivot
#

hahahaha

#

it is done on the guilds display

green oriole
#

But it is cumulative, I wanted to see the sweet little spikes

#

And I ended up with micro spikes everywhere haha

patent pivot
#

ah you want spikes

green oriole
#

Yeah

patent pivot
green oriole
#

I'm guessing I needed to do a sum of every hour, but eh, no idea how

#

Aaaahh

#

Very cool, thanks!

patent pivot
green oriole
#

.bm 793789922527805492 Make grafana queries actually readable

patent pivot
#

hahahahahahaha

green oriole
#

Now I wanna see what this 1k spike is all about haha

patent pivot
#

tiktok raid a few months back iirc

#

bot caught it all p much

green oriole
#

Aah

cold moon
#

Few ideas (for future) about Black Box: 2 more backup locations: e-mail and Mega Cloud.

rapid swallow
#

email?

cold moon
#

Getting backup as attachment to email

gritty wind
#

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

rapid swallow
#

hmm

cold moon
#

I get my website backup to email weekly

gritty wind
#

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

cold moon
#

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)

crude gyro
#

I don't think email is a good idea

#

but megacloud seems reasonable, feel free to open an issue for that

green oriole
#

Will there be any support for things like rsyncing the whole host, or something similar?

cold moon
#

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

rapid swallow
green oriole
#

Our k8s backup service, with a misleading description

rapid swallow
#

I know that, but that's as far as I know

green oriole
#

Well, there isn't much more right now, we are trying to think of other things it could provide

rapid swallow
#

by rsync, I assumed you mean "smart" backup where only changed files will move or something

green oriole
#

BTW @crude gyro maybe the description could be changed? It is a backup service, not an emergency recovery service, no?

green oriole
#

But I'm not sure if it would fit in this project

rapid swallow
#

so currently all data is simply dumped into google drive? (over simplification xD)

green oriole
#

I think so

rapid swallow
#

hmm

#

what exactly is getting backed up?

#

the database?

green oriole
#

Yes

#

We support postgres and Mongo so far

rapid swallow
#

with plans to support redis?

cold moon
#

And Redis support will come

rapid swallow
#

hmm ok

cold moon
#

But I think (low priority) should be adding MySQL support too, as this is pretty common.

green oriole
#

I think if we start doing this we will never end lol

rapid swallow
#

lol

green oriole
#

I'd say we only add what we need, and let anyone contribute what they need

cold moon
#

I actually would like to replace my script that handles MySQL backup with Black Box

green oriole
#

Time to contribute!

cold moon
green oriole
#

That is true

crude gyro
#

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

green oriole
#

Buut you can't restore it using black box

#

But I guess that works

#

Yeah, that make sense

#

Alright

crude gyro
#

updated the description now anyway

green oriole
#

Guess that works too

crude gyro
#

I haven't 100% decided yet if I'm gonna move this project into my personal github or keep it on python-discord

late wolf
#

Could someone link me the issue which contained the shh equivalent for voice channels.

gritty wind
clever wraith
gritty wind
#

Hey this channel is specifically about python-discord projects. If you'd like to discuss something python related, try the #python-discussion channel

late wolf
#

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??

late wolf
#

I think this would be one of the issues with shh for voice.

gritty wind
#

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

late wolf
#

ah ok

#

that makes snese

eternal owl
#

whats the reason for using django-environ instead of something like python-dotenv, what advantages does django-environ give

hardy gorge
#

They do the opposite:

#
  • django-environ is a package that allows you to read values from environment variables in a convenient way
  • python-dotenv allows you to parse a .env file 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.

eternal owl
#

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

#

or am I missing something

exotic ember
eternal owl
#

ooh I did not know pipenv loads env vars, wow

#

thats handy

hardy gorge
#

In production, we don't use a .env file; kubernetes takes care of inserting the secrets/environment variables into the container

eternal owl
#

right, thanks

hardy gorge
#

It's pretty cool

#

I think that covers all of our typical run cases

eternal owl
#

I need to take a look at kubernetes, I dont know much about it

hardy gorge
#

In the past, we used salt stack to insert the environment into our Docker containers (before migrating to kubernetes)

hardy gorge
#

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...

▶ Play video
eternal owl
#

thanks a lot!

late wolf
#

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.

crude gyro
#

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?

late wolf
#

ye like that

celest charm
#

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?

crude gyro
#

not quite related. maybe let's not get sidetracked

hardy gorge
#

We should highlight this discussion in our moderation-tools channel I think

green oriole
#

That could be useful, but I don't think it is top priority right now, compared to other improvements we wanted to do

hardy gorge
vale ibex
#

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>

tawdry vapor
#

Did you not install the git hook?

vale ibex
#

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

gritty wind
#

Yup it’s safe to assume when you see that many skipped checks that no changes were staged

vale ibex
#

Yea, it was my bad for not knowing it only checked staged changes

gritty wind
#

Yeah no worries, it isn’t a big deal

#

Thanks for your contribution

vocal wolf
#

@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.

surreal venture
#

are discord api requests rate-limited?

green oriole
#

Yes, they are

surreal venture
#

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?

green oriole
#

Hmm, that's an interesting problem

#

Note that rate limits won't make an action not go through

#

You may have some race conditions somewhere

cold island
cold moon
#

.pr 509

dusky shoreBOT
cold moon
#

This is from there

surreal venture
sudden cradle
#

why does snekbox use docker-compose

#

what difference it would make if there wasnt docker-compose

sullen phoenix
#

it's for ease of development

sudden cradle
#

yeah sure, i was reading abt it but like how does snekbox benefit from it

gritty wind
#

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

sullen phoenix
sudden cradle
#

wait but isnt that supposed to be handled by my Dockerfile?

sullen phoenix
#

it is not handled by our dockerfile

sudden cradle
#

oh yeah, but why so

#

bad software dev practice or something?

sullen phoenix
#

well, you can't specify most of those in the dockerfile, i don't think

patent pivot
#

yeah

#

that isn't possible

#

privileged and ipc certainly

#

dockerfile just tells docker how to build the image, minimal details about running it

sudden cradle
#

i see

patent pivot
#

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

sudden cradle
#

interesting

patent pivot
#

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

late wolf
#

Hey guys why do we use log.trace and not log.info

brazen charm
#

I believe info is what the production logging is set to; debug and trace then give more granularity for local dev

late wolf
#

how so

tawdry vapor
#

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.

tawdry vapor
# late wolf how so

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.

late wolf
#

hmmmmn

vocal wolf
late wolf
gritty wind
#

So the lock gets called as the first thing when you call silence

#

!source source

stable mountainBOT
#
Command: source

Display information and a GitHub link to the source code of a command, tag, or cog.

Source Code
late wolf
#

but the point of source is to link the exact thing isn't it?

gritty wind
#

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

late wolf
#

hmmmmm

gritty wind
#

The alternative would be building a large mapping of command to source code

#

Which is just not... ideal

gritty wind
#

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

late wolf
green oriole
#

I think that's a yes, there wouldn't be any reason to not support it

green oriole
#

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?

vocal wolf
#

Well there's rarely any non-mod command in mod channels

#

but yeah it's probably still best to block suggestions within mod channels

green oriole
#

Didn't we say that we wanted suggestions in mod channels? I might be misremembering

cold island
#

I don't think there was any conclusion about suggestions in mod channels

#

I wouldn't mind them for general commands

vocal wolf
#

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.

cold island
#

there iiiiis a utility function for that

#

bot/utils/channel/is_mod_channel

vocal wolf
late wolf
#

.issue 551

late wolf
#

would anyone take a look at this please

short snow
#

We need to update the sir lancebot guide, since its name has changed to sir lancebot but the guide says seasonal bot

cold island
#

which guide?

late wolf
#

also for sir Lancelot bot, we need to add that users will have to have fake_redi=true in their .env file

green oriole
#

.issue 60 meta

dusky shoreBOT
green oriole
late wolf
#

sure thing

green oriole
#

Thank you

short snow
green oriole
#

Actually, it seems like it has been updated

short snow
cold island
green oriole
#

Cool

green mesa
#

What are discord forms?

obsidian patio
#

Are you talking about our forms or some native forms in discord?

green mesa
#

2nd

#

What are those

#

It sounds interesting

patent pivot
#

not sure where you are getting that from?

#

have you seen this be mentioned somewhere?

green mesa
#

Yes privacy policy

patent pivot
#

yeah that's pydis forms, not native to discord or anything

#
#

maybe sharing the deploy preview is a good idea since that has all the upcoming form components

green mesa
#

Ty

patent pivot
#

our plan is to handle code jam submissions, ban appeals and other insights projects through this app

gritty wind
#

Though I think a warning or tip would be nice

vocal wolf
cold island
#

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

vocal wolf
#

I couldn't find a consistent way of doing that.

vocal wolf
#

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).

cold island
#

hmm

late wolf
#

i was suggesting to add it there

late wolf
#

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

patent pivot
#

That's a good point

green oriole
#

The filter is currently disabled, but we don’t want people going around and using some at-here and at-everyone

patent pivot
#

Is it disabled?

green oriole
#

Yeah

patent pivot
#

It tripped earlier today

late wolf
green oriole
#

Well, we don’t mute or mod ping @patent pivot

patent pivot
#

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

green oriole
late wolf
#

wdym

green oriole
#

An at-everyone is just the string @ followed by everyone, while mentions are made with something like this <@userid>

patent pivot
#

the question here is though

#

do we need the filter

green oriole
#

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

late wolf
green oriole
#

Not pinging 120k people to ask your question sounds like common sense to me

patent pivot
#

yeah but the thing is

late wolf
#

it won't ping though

patent pivot
#
  1. it won't ping
  2. quoting is a gone feature now
  3. it is very common for non-beginner discord users to just use the pings where they know they have no permissions
green oriole
#

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

late wolf
green oriole
#

I thiiink so

late wolf
#

why???

patent pivot
#

what

#

we need to

#

there is no other way to deteect an everyone ping

late wolf
#

why?
message.mentions exist

patent pivot
#

no

#

it doesn't

green oriole
#

Yeah

late wolf
patent pivot
#

because the author can't ping everyone

#

that flag is only true if the author actually has permissions

green oriole
#

We use message.mentions

patent pivot
#

akarys you can't everyone here can you

#

no

green oriole
#

Nope

patent pivot
#

send everyone

green oriole
#

@everyone blame joe if this ping

#

Okay good

patent pivot
#

!int e ```py
msg = await channel.fetch_message(796773469852663858)

print(msg.mentions)

stable mountainBOT
#
In [57]: msg = await channel.fetch_message(796773469852663858)
    ...: print(msg.mentions)
    ...: 
[]```
patent pivot
#

!int e ```py
msg = await channel.fetch_message(796773469852663858)

print(msg.mention_everyone)

stable mountainBOT
#
In [58]: msg = await channel.fetch_message(796773469852663858)
    ...: print(msg.mention_everyone)
    ...: 
False```
patent pivot
#

eh voila

late wolf
#

right

green oriole
#

Yep

patent pivot
#

so we need to use regex

green oriole
#

!raw 796773469852663858

stable mountainBOT
#
== Raw message ==

@everyone blame joe if this ping
green oriole
#

An in check would work

#

Actually

#

Why did we have some issues with the previous implementation?

#

I remember that it trigerred in codeblock

late wolf
green oriole
#

but that’s about it

patent pivot
#

yeah it was codeblocks

green oriole
#

That’s all?

patent pivot
#

iirc

green oriole
#
EVERYONE_PING_RE = re.compile(rf"@everyone|<@&{Guild.id}>|@here")
#

Lol

#

What a regex

#

It does remove codeblocks

late wolf
#

So it being removed or what?

green oriole
#

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

cold island
patent pivot
#

true

cold island
#

We can relax the filter I guess, but it's pretty useful

patent pivot
#

yeah I think I'd rather keep it

cold island
#

Like make it not capture large messages

vale ibex
#

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

brazen charm
#

Do you have redis running?

vale ibex
#

I haven't ran it on purpose no

brazen charm
#

You can specify USE_FAKEREDIS=true in your .env if you're not using something that relies on it to avoid setting it up

vale ibex
#

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?

hardy gorge
#

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

vale ibex
#

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 🙂

hardy gorge
#

Feedback's always welcome.

#

It's better to know the kind of stumbling blocks people are confronted with

vale ibex
#

👍

gritty wind
#

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

vale ibex
#

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?

gritty wind
#

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

tawdry vapor
#

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.

trim cradle
#

.help refers to a lot of deleted channels if you call it in pygen, apparently

gritty wind
#

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

brazen charm
#

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

trim cradle
#

I only saw it for a moment and then the user deleted the bot's response

gritty wind
#

Let me try my alt

trim cradle
#

don't leak your alt 😮

gritty wind
#

Ok it's .help

#

Its uhh.. a 3rd party

obsidian patio
trim cradle
#

not necessarily

gritty wind
#

I think we should be able to test this in the testing server, so that's enough spam for pygen now

trim cradle
gritty wind
#

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

brazen charm
#

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

cold island
#

All of the sprint channels should removed from the constants

#

That it can be used in one or two other channels doesn't matter

brazen charm
#

It can be useful for when the check is used with an override

late wolf
patent pivot
#

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

late wolf
patent pivot
#

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

late wolf
#

hmm

patent pivot
#

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.

late wolf
#

"educate" lol

patent pivot
#

you jest, but it doesn't tend to have reoffenders

tawdry vapor
#

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.

late wolf
#

how to do that?

"discord.py" = {git = "https://github.com/Rapptz/discord.py.git", ref = "94f76e63947b102e5de6dae9a2cd687b308033"}

Change this to

discord.py="1.6.0"

?

gritty wind
#

That and relock

#

I think you may also need to keep the quotes

late wolf
#

ye

#

ok i locked it now what to do?

tawdry vapor
#

No, do ~1.6.0, with the tilde

#

It will allow it to upgrade patch versions

late wolf
#

"discord.py" = "~1.6.0"
like this?

brazen charm
#

In the same way as every package defined in the pipfile

late wolf
#

right

late wolf
#
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 ?

tawdry vapor
#

Create a PR

late wolf
#

it gonna take a while ok cause idk how to create a pr so i need to do some research

gritty wind
#

Github has a decent guide on the fork-pr workflow

late wolf
gritty wind
#

Yup, seems good. Alternatively you can use a graphical UI, but it's always good to learn to do it manually

gritty bolt
#

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?

gritty wind
#

We have the contributing guide on our website if you’d like to contribute to a pydis project

gritty bolt
#

That's very helpful, thank you

late wolf
#

Hey guys i can't currently do that pr thingy, cause some work came up.
I am exteremly sorry

green oriole
#

No worries

#

Do you want to come back to it later?

gritty bolt
#

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

patent pivot
#

could you post the full logs of starting the bot, censor out anything sensitive

gritty bolt
#

I will try to censor out sensitive info

crude gyro
#

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

stable mountainBOT
#

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.

gritty bolt
#

Okay, give me a second

patent pivot
#

hm

#

lancebot doesn't have a config file

late wolf
#

I kinda have a feeling the reason for that error is fake_redis=True is not set

gritty bolt
patent pivot
#

ah yeah it's probably redis

#

yeah there we go

#

aioredis

late wolf
#

@gritty bolt have u set fake_redis=Truein .env file?

gritty bolt
#

Err no, should I add that in?

patent pivot
#

all caps

#

add USE_FAKEREDIS=true

gritty bolt
#

Works like a charm, thanks for the help guys

patent pivot
#

👍

short snow
#

We can use the reply feature on eval .

gritty bolt
#

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

green oriole
#

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

gritty bolt
#

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

patent pivot
#

why do we actually use custom emojis

#

just a thought

patent pivot
#

we could replace the trashcan with likke

#

🗑️

gritty bolt
#

How do I replace the emoji? Where do I do it?

#

Emojis class?

green oriole
#

Although our trashcan can be better

gritty bolt
#

So how do I replace the emoji?

green oriole
#

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

obsidian patio
gritty bolt
#

By env var, you mean os.environ['...']=...?

green oriole
#

Yeah, you can replace the line I just linked to allow env vars

gritty bolt
#

So, first I set the environment variable, and then in the line you linked, I put trashcan = os.getenv('emoji_name')?

green oriole
#

Yeah, with the current value as a default

gritty bolt
#

And I have to do this with every custom emoji?

green oriole
#

Technically yes, but you probably won't need much of them

gritty bolt
green oriole
#

Hmm

#

It doesn't error out?

vale ibex
#

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?

green oriole
#

Oh no, that again

#

Hmm

vale ibex
#

oh wait, I think I had autoclrf in my global git conf

#

changing to to false in this repo seems to have solved it

green oriole
#

Ah nice

rapid swallow
#

would doing a dry run help?

#

your editor's linter should warn you about line endings, if you set it to flake8

vale ibex
#

yea, I changed the repo git.autoclrf to false, discarded all of the changes and re-ran linting, seemed to have done the job

mellow hare
vocal wolf
#

.issue 397

dusky shoreBOT
vocal wolf
#

@cold moon Sorry for forgetting about this PR, I've reviewed it.

brazen charm
#

The pyside2 doc package could use a rename to pyside6 as that's what the inventory refers to now

gritty wind
#

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.

cold moon
#

@vocal wolf About tic-tac-toe, moving to embed make emojis really really small.

vocal wolf
#

hmmmmmmm

#

We should think of a solution that lets compact and non-compact users see the game properly.

tawdry vapor
# gritty wind Hey <@!137073073168973824> On your comment here: https://github.com/python-disc...
  1. 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.

  2. 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_channel condition exists and is correct.

gritty wind
#

Ah okay, I get what you mean

#

thanks

tawdry vapor
#

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

gritty wind
#

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

cold moon
#

@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.

vocal wolf
#

Could we have a newline at the start and then put the emojis after?

cold moon
#

I'm not sure doesn't Discord cut this off and this doesn't make emojis small

gritty wind
#

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

tawdry vapor
#

Yeah, I don't know either

#

This is the sort of thing pytest's fixtures would be nice for

#

But alas we use unittest

late wolf
#

Why do we use unittest rather than pytest?

hardy gorge
#

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.

vale ibex
#

.pr 552

dusky shoreBOT
vale ibex
#

Is there a place where I should note how to get a client id & secret from the IGDB api?

gritty wind
#

Hmm that should probably be added to the env var page

#

How much space do you think you need?

vale ibex
#

Step 5 in the first link explains the steps, so we could change that to be project specific

gritty wind
#

I mean if we can just link the page explaining it, that would fit better with the existing docs

vale ibex
#

I'm not sure how stable the first link will be though

gritty wind
#

The other vars have the var name, a link, and possibly a description

vale ibex
#

Yea, that works

#

I imagine that'll work until they add a v5 😂

gritty wind
#

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

vale ibex
#

I'm just trying to find my way around the site repo to see what needs changing

gritty wind
#

What are we using IGDB for anyways?

vale ibex
#

.games

gritty wind
#

Hmm, I've never seen that before. Cool

vale ibex
#

Looked like an easy issue for my first pr 😛

gritty wind
#

Huh that changes the env var name

vale ibex
#

yea, we need 2 now, instead of just the one

gritty wind
#

Thanks

hardy gorge
#

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

vale ibex
#

Yea, nothing uses the old env var, I'll add a comment

tawdry vapor
#

@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.

tawdry vapor
brazen charm
gritty bolt
cold moon
late wolf
#

Umm hey could someone check this out

#

.issue 551

late wolf
#

I opened the issue but idk what to do now

gritty wind
#

Do you want to work on it?

#

If not, then we need to wait for someone to come around and tackle it

late wolf
gritty wind
#

I mean people open issues for things they want implemented but dont want to work on

late wolf
#

well i want to work on it, ye

gritty wind
#

Do you know where to start with contributing?

late wolf
#

huh

gritty wind
#

I.E do you have the project set up and running locally

late wolf
#

yes

gritty wind
#

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.

late wolf
#

oh ok, i thought i needed an approval or something like that

gritty wind
#

Do comment that you want to tackle this

#

And you'll get assigned on the issue

late wolf
#

ok

gritty wind
#

The comprehensive contributing guide is here

late wolf
#

also i never added any of those labels but why does it say that I did?

gritty wind
#

They are part of the template

#

They got added when you opened the issue

late wolf
#

ah i see, thx. Well ima get to work now

#

the file should be located in bot/exts/evergreen/typerace.py
right?

gritty wind
#

I believe that's accurate

gritty wind
#

I know it'll work with something like a period

#

Still haven't tested an invisible character or something

#

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

cold moon
#

Hmm, when we don't need big numbers, we can use embed too

green oriole
gritty wind
#

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

gritty wind
#

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

late wolf
#

@green oriole "Markov chain to generate the input and train it on something Python related."
what did u mean by this?

gritty wind
#

I found the part that wasn't updated correctly

#

This needs to be changed from developers

vale ibex
late wolf
#

Oh wow

vale ibex
#

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.

gritty wind
#

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

late wolf
hardy gorge
late wolf
#

I still don't get how it applies to the typerace command, but ig i will ask him when he comes online

green oriole
#

My idea was to use the Markov chain to generate the text you have to retype, to spice up the feature a bit

gritty wind
green oriole
stable mountainBOT
#
ROGER THAT

Your reminder will arrive in 4 hours!

green oriole
#

Actually, the fix could not actually be very simple

gritty wind
#

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

stable mountainBOT
#

@green oriole

It has arrived!

Here's your reminder: Update it.
[Jump back to when you created the reminder](#dev-contrib message)

green oriole
#

Done

gritty wind
#

Woah if I didn't know any better I'd say you finished that in < 1 min

green oriole
#

Haha

late wolf
#

@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?

obsidian patio
#

Creating a new separate function imo

late wolf
#

Could u elaborate a bit more on that?

obsidian patio
#
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

patent pivot
#

wow

#

pascal case

#

disgusting

obsidian patio
#

That was a class first, but I realized it should be a function hahah

obsidian patio
tawdry vapor
tawdry vapor
brazen charm
tawdry vapor
#

No, let's not ping for now

vale ibex
#

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?

tawdry vapor
#

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?

tawdry vapor
vocal wolf
late wolf
#

Hey so for the typerace command it will be using an API, so where do I specify that we would need an API key?

green oriole
#

No markov chain? lemon_sentimental

late wolf
#

no cause i didn't understand how i would use that and for markov chain as well it seemed that u needed sentences

green oriole
#

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?

late wolf
#

well that would only generate python related text, not overall text

green oriole
late wolf
#

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?

short snow
#

you can make category option

#

which defaults to none, and if none use the api

late wolf
#

huh

sharp timber
#

!e import pandas

stable mountainBOT
#

@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

green oriole
#

Hmmmm

#

@tawdry vapor I believe there’s something wrong with the new setup ^

sharp timber
#

Should I finish up my bug report on this?

#

Filed anyway, in snekbox repo, enjoy clicking the fixed button :P

green oriole
#

Nice, thanks for the issue

surreal venture
#

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

mellow hare
tawdry vapor
#

Yes, I will

#

I need to see if they addressed my requests

rapid swallow
#

I can have a look at it after 12 hours 😛

tawdry vapor
#

I took care of it

rapid swallow
#

oh, I was going through it

#

nvm then

cold island
rapid swallow
brazen charm
#

Any idea what's going on there? The tests apparently work as the checks passed

cold island
#

Hmm yeah it happened to me as well yesterday, but oddly the tests passed in the PR

tawdry vapor
#

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

#

This is new in d.py 1.6

#

If it's failing locally then your venv is likely out of date

brazen charm
#

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

brazen charm
#

Is anyone working on the version bump?

tawdry vapor
#

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?

late wolf
#

I am sorry, but no

tawdry vapor
#

That's okay, I'll take over.

late wolf
#

hmm WHy this?

patent pivot
#

!d itertools

stable mountainBOT
#

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

patent pivot
#

ah because it gets the weird itertools

#

hm

#

I think anyway

late wolf
#

what do you mean?

patent pivot
#

!d itertools.combinations

stable mountainBOT
#
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)
patent pivot
#

well that is weird

brazen charm
#

Should work normally, don't see anything special there

late wolf
#

huh?

#

It works for all of these
#bot-commands message
but not for itertools.product

stable mountainBOT
#

You are not allowed to use that command here. Please use the #bot-commands channel instead.

vocal wolf
#

@cold moon so about that tic-tac-toe command, were you eventually able to find a solution for compact users?

cold moon
#

I think I'm gonna use embed. It's small then, but at least looks better in compact mode

vocal wolf
#

Alright, sounds good to me.

cold moon
#

But I will do this after I finish my Pokemon bot PostgreSQL command (dynamic queries is nightmare in Rust).

vocal wolf
#

glhf!

tawdry vapor
empty sluice
#

How does the bot use Async-RedisCache to persist between restarts?

patent pivot
#

Redis doesn't run inside the bot container

#

We have a separate Redis instance which the bot connects to to persist data

empty sluice
#

What about the database on the website?

obsidian patio
#

I assume that the database is a separate container as well

empty sluice
#

Why does the bot need both, though?

#

Couldn't it just use one DB?

patent pivot
#

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

empty sluice
#

So redis data would be lost in a restart?

patent pivot
#

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

empty sluice
#

Ok, so Redis is to store temporary information, the site DB is for permanent info.

patent pivot
#

I would say the distinguishing factor is critical vs. non-critical

empty sluice
#

Ok

patent pivot
#

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

empty sluice
#

Ohh, Redis is one key to value?

patent pivot
#

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)
tawdry vapor
#

You can get around that by storing serialised data, which we do in a few spots.

patent pivot
#

Yeah, and we have some typing built in since in Redis everything is a string

#

but that's all abstracted away by async-rediscache

empty sluice
#

Also, one more question: how is the bot made into a docker container?

#

And how does it automatically download Redis, the site, etc.?

obsidian patio
# empty sluice Also, one more question: how is the bot made into a docker container?

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...

▶ Play video
tawdry vapor
#

@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.

brazen charm
#

Incrementally sounds fine, gives me more time to respond too

tawdry vapor
#

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.

gritty wind
#

I'm trying to replicate the itertools.product docs being missing, can I get the command to add the inventory?

green oriole
#

!help docs set

stable mountainBOT
#
Command Help

!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*

green oriole
brazen charm
#

Worked fine for me locally

gritty wind
#

would objects be itertools (in the inv url)?

brazen charm
#

The example is the exact command

green oriole
#

Alright, it just needed a refresh

#

!d itertools.product

stable mountainBOT
#
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)
green oriole
#

Sorry about that

brazen charm
#

I'd guess the piece of code that tries to take care of duplicates was the culprit here

rustic juniper
green oriole
#

This project will be a PyPi package to provide effortless configuration files, although it isn’t quite ready to accept contributions right now

rustic juniper
#

aah

#

no issues i'll check out the other repos

gritty wind
#

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

vale ibex
#

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?

short snow
#

can we have a un-assigned issue label, for new contributors to know, which issues can be worked on?

hardy gorge
#

@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

green oriole
#

Are we not passing env vars through?

hardy gorge
#

What do you mean?

#

I don't think we're using the option to read them from the shell environment

#

(No ${NAME})

green oriole
#

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

hardy gorge
#

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

green oriole
#

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

hardy gorge
#
web:
  environment:
    - BOT_TOKEN=${BOT_TOKEN}
#

This would work as well

green oriole
#

Fwiw you don't need the =${BOT_TOKEN} part

hardy gorge
#

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

green oriole
#

Yep, we should set an env_file entry

hardy gorge
#

An .env file is the easiest way, since it doesn't require knowledge of how to set environment variables for processes

#

yeah

green oriole
#

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

stable mountainBOT
#
You're the boss!

Your reminder will arrive in 21 hours!

hardy gorge
#

We should test out how it behaves if the file is missing

#

And modify the contribution guide

green oriole
#

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

hardy gorge
#

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

green oriole
#

Yep

gritty wind
#

When looking at the issues, click assignee, then select the no assignee option from the drop down

vale ibex
#

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?

short snow
gritty wind
#

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

short snow
#

ok, thanks!

gritty wind
#

@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

vale ibex
#

Ah yea alright, should I add a link to the above convo in the PR for context at least?

gritty wind
#

Since there is no issue, that's probably not a bad idea

vale ibex
#

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 🙂

gritty wind
#

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

sullen phoenix
#

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

gritty wind
#

Right, that makes sense

vale ibex
#

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

sullen phoenix
#

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

vale ibex
#

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

hardy gorge
#

oh, right, it should use .env automatically

vale ibex
#

my .env has values for those, but also has values for IGDB_CLIENT_ID and IGDB_CLIENT_SECRET

sullen phoenix
#

yes, those variables should be added to the config

vale ibex
#

so would I need to add those keys to the yml file for it to pull them?

sullen phoenix
#

yep

green oriole
#

Will it pass undefined variables though?

sullen phoenix
#

as an empty string

vale ibex
#

Would docker complain if it can't find those keys in the .env?

green oriole
#

We would end up with a really long env var list though, and not always up to date

vale ibex
#

ah, so should we update the docker-compose file with all possible env vars?

sullen phoenix
#

it should give a warning, but will continue running

green oriole
#

I’d rather have it stuff the whole env file into the container

gritty wind
#

Doesn't it automatically pull the entire .env file?

green oriole
#

Nope

gritty wind
#

That's what it's doing locally for me

#

It's not ignored, so I don't see why not

sullen phoenix
#

i like the env vars being explicitly listed out

#

but maybe that's just me

green oriole
#

Try to pass any random env var @gritty wind, it shouldn’t go through

vale ibex
#

yea, it looks like it only pulls env vars from the .env that are listed in the environment section of docker-compose.yml

green oriole
cold moon
#

I think we should define manually env vars that have default values, otherwise bring from .env

vale ibex
#

so env_file + enviroment for defaults?

cold moon
#

Yes

green oriole
#

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

cold moon
#

No, like Redis data shouldn't

green oriole
sullen phoenix
gritty wind
#

We have that on the site atm

#

but not in code

vale ibex
gritty wind
#

Well, other than digging through the consts file

sullen phoenix
#

i don't think site is even up to date, is it? lol

gritty wind
#

I updated it

sullen phoenix
#

ahhh nice, cheers

green oriole
#

nothing is up to date

#

haha

#

But most of it will go away with smartconfig, so that’s that

gritty wind
#

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)

vale ibex
#

so your .env is in /bot?

sullen phoenix
#

we do need to create better documentation for our projects

sullen phoenix
gritty wind
#

It is, I'm trying to find out if it has access to it

green oriole
#

It is on my todo list lol

#

.issue 60 meta