#dev-contrib

1 messages · Page 88 of 1

short snow
#

sorry for interupting

green oriole
#

Threads are processes!

short snow
#

the logo is not visible just

gritty wind
#

can you have the WTF Python Link be the actual link instead of having it below it

short snow
#

alright

gritty wind
#

and I don't think we need the examples but eh

timid sentinel
#

But Python is just like any other process, so anything you could do by creating a new process you could just do from the Python process- maybe not easily, but you wouldn't want to rely on anything not being possible. So I guess limiting it to 1 PID is more of an extra layer of security than a core part of the sandboxing, and a limit of something like 10 should be fine?
I was mainly just asking because I was playing around with snekbox wondering if I could get plotly to work with it so i can make graphs, just as a personal project, but it requires another process. I'm not planning on using it elsewhere so it doesn't matter if it's not secure though.

patent pivot
#

hmmmmm

short snow
gritty wind
#

There are some things you'd need a new PID to start

patent pivot
#

so I wonder if we have any setuid binaries available

short snow
#

better?

patent pivot
#

!e ```py
... threads ...

stable mountainBOT
#

@patent pivot :x: Your eval job has completed with return code 1.

001 | 09:45:43: Main    : before creating thread
002 | 09:45:43: Main    : before running thread
003 | Traceback (most recent call last):
004 |   File "<string>", line 32, in <module>
005 |   File "/usr/local/lib/python3.9/threading.py", line 874, in start
006 |     _start_new_thread(self._bootstrap, ())
007 | RuntimeError: can't start new thread
patent pivot
#

hm

#

yeah

#

fair enough

gritty wind
#

there are easier ways to do threads, ya know 😛

patent pivot
#

lol

#

i can just

#

copy from realpython though

green oriole
#

I didn't notice that you edited at first, I was really confused about how on earth that would create threads

short snow
#

should i keep the examples or not scal?

gritty wind
#

I don't think you should, but I'm not the one reviewing your code

gritty wind
#

unless I am 🤔

patent pivot
#

i'm a wizard

#

actually

#

!e ```py
import sys
print(sys.version_info)

stable mountainBOT
#

@patent pivot :white_check_mark: Your eval job has completed with return code 0.

sys.version_info(major=3, minor=9, micro=2, releaselevel='final', serial=0)
green oriole
#

Joe is commanding python using his mind haha

patent pivot
#

nice

#

hm

green oriole
#

Yeah we did update it

patent pivot
#

i am going to say that

#

we should high prioritise 3.10 on snekbox

green oriole
#

Well, it is automatically updating I guess

#

Yes, we should stay as close to releases as possible

patent pivot
#

(when it is released that is)

green oriole
#

That said, we have dependencies that need to run

#

We could two interpreters I guess

patent pivot
#

typically we've lagged behind a bit to allow dependencies to become compatible yeah

gritty wind
#

Rewrite all the dependencies into our code base 😔

patent pivot
#

my reasoning is that patma is a huge feature and I think eval is a good thing to showcase it

green oriole
#

Yep

#

It shouldn't be hard to add support for another interpreter

#

It would be a 20 lines change

#

Famous last words

patent pivot
#

lol

green oriole
#

But you should be able to download the release tarball, uncompress it during the Docker build and change which directory we are mapping to /bin in nsjail

short snow
#

A wild PR appears

#

@gritty wind should i set a env variable CHECK_CHANNELS, which would a boolean value, to check for chanels or not?

gritty wind
#

Just use the DEBUG variable

short snow
#

alright

short snow
#

@cold island how should i store the channel-cog map?
in a yml file like this?

channel
  - cog
  - cog

# Or maybe
cog
  - channel
#

@gritty wind Yeah i understood that

gritty wind
#

I don’t think you should start working on this

cold island
#

Yeah it's gonna take a bit of discussion

short snow
#

Yeah i didn't start, i was just getting down some ideas on implementing it

cold island
#

Each cog will probably have its own channel constants, that's also in line with smartconfig

balmy sparrow
#

bot#1357 it's been a while since I've opened this, has there been any discussion/updates?

dusky shoreBOT
cold island
#

Seems pretty problematic to me since we sometimes remove pins, and then the whole numbering changes

fallen patrol
#

👀
I do think the concept makes sense tho

balmy sparrow
#

it won't error- it'll give you an unexpected result, yes.
but i think the target demographic is more regular people

#

we know when pins get updated

fallen patrol
#

I think zig is getting at muscle memory as well

fallen patrol
balmy sparrow
#

i made this issue mainly because of how cluttered the pins in #discord-bots (where i spend most of my time helping) is

fallen patrol
#

makes sense

balmy sparrow
#

me, and most of the other regulars there are pretty quick to catch up when pins get updated

fallen patrol
#

I'm currently thinking of a larger solution that would be more work, but could work better in the end

balmy sparrow
#

its not unusual that many users say they just couldnt find a pin we were referring to, because of how many messages are pinned there

fallen patrol
#

either a !tips id where the id refers to a database id of a specific tip for that channel

timid sentinel
#

It just feels a bit... unreliable. I think named tags would be a better solution

cold island
#

Alternatively, something more reliable to find the pin you want

fallen patrol
timid sentinel
#

Currently we've been wary about adding tags that are too specific to libraries, otherwise we'd end up with overlapping names and it can be more difficult to find one you want. Having channel specific tags could be an idea though..., or some other sort of namespacing.

balmy sparrow
#

that's why I'd made the issue in the first place, because of how we keep tags rather general

fallen patrol
#

to make channel spepcific tags, I would make it a !tips command, with a parameter to search a specific channel if need be. Ex !tips #discord․py bot vs client could be used in #bot-commands , but !tips bot vs client in #discord-bots would only search #discord-bots

cold island
#

If I have to throw in a design suggestion, off the top of my hat:
!pin <query> - The query is matched against the first sentence in each pin. Most pins have a title, so you can search by keywords in the title. If the query matches a single pin, show it. If it matches several, let you choose which one somehow or ask for a better query

balmy sparrow
#

that could work

cold island
#

so !pin intents will give you the intents pin, because it has that word in its title

balmy sparrow
#

but not all pins in the other channels are formatted similarly

fallen patrol
#

gtg

balmy sparrow
cold island
#

That's something we can address if it's an actual issue. But not all channels have a lot of pins

balmy sparrow
#

fair enough

#

am i overengineering a problem here though? in my defence, even though it is 2 seconds for me to go and pull the message from pins myself for someone, it adds up pretty quickly

cold island
#

Even with #async-and-concurrency, the pins have a starting sentence that you can use to search it, and it usually contains the purpose of the message

cold island
balmy sparrow
#

we can wait for others' opinions then

#

i think being able to cross-post pins across channels is also rather useful

wise oriole
#

the !pypi command should be disabled in #python-discussion

the embeds are so big that they cover previous messages and make the process of having a conversation difficult especially if someone were to use it frequently in lets say, #python-discussion. I've noticed this for quite a while and it's a bit annoying
In my opinion it would be better if the command was disabled for non helpers+ in python-general.

thoughts?

gritty wind
#

haha endless redirects

#

it's fine here actually

fallen patrol
#

O

gritty wind
#

Either channel would work for this type of discussion tbh

fallen patrol
wise oriole
#

its about the bot ig and vester suggested here

gritty wind
#

So back to the topic on hand

clever wraith
obsidian patio
#

Both places work. I think this channel fits

gritty wind
#

What is it usually used for in python-general?

#

Alrighty, the point I was getting at was

#

if it's used in helping people answer questions by linking to a module's pypi page

#

we can have an abridged version of it that gets sent in python-general, and the full version that gets sent in other channels

#

!pypi aioredis

stable mountainBOT
#
Author

Alexey Popravka

Summary

asyncio (PEP 3156) Redis support

License

MIT

gritty wind
#

For instance, we can have the title/link + summary

balmy sparrow
clever wraith
#

ok

gritty wind
#

which could look like

stable mountainBOT
gritty wind
#

I missed the logo, but oh well

stable mountainBOT
green oriole
#

We could have a cgabnel based cooldown

#

I wouldn't mind that

#

We should do that more actually

fallen patrol
vale ibex
#

!src embed

stable mountainBOT
#
Command: embed

Send the input within an embed to either a specified channel or the current channel.

Source Code
subtle kraken
#

that actually looks like int eval

green oriole
#

That's an int eval, yeah

gritty wind
#

smh no thoughts on the idea

fallen patrol
#

Wait how many people have int eval access? Mods++?

#

According to the privacy policy I thought it was 6 people

vale ibex
#

!src int

stable mountainBOT
#
Command: internal

Internal commands. Top secret!

Source Code
gritty wind
#

Does the privacy policy even mention that

vale ibex
#

Roles.admins, Roles.owners

fallen patrol
subtle kraken
#

I don't think privacy lists that

#

as the command doesn't really tell you anything you wouldn't otherwise have access to

vale ibex
#

I imagine the policy mentions people who have access to the database

subtle kraken
#

probs

#

Direct database access is only available to the dev-ops team, under 5 people.
Yup just direct db access is listed

#

that being said @patent pivot should update it to 6 now I imagine

patent pivot
#

wuz poppin

#

why 6

subtle kraken
#

we have 6 members in devops

patent pivot
#

it's 4

subtle kraken
#

!role Devops

stable mountainBOT
#
DevOps info
ID

409416496733880320

Colour (RGB)

#a1d1ff

Colour (HSV)

0.58 0.37 255

Member count

6

Position

72

Permission code

0

subtle kraken
patent pivot
#

true

#

only 4 have access

#

i will reword

subtle kraken
#

huh?

#

I imagine 3 owners for sure

patent pivot
#
  • scragly
subtle kraken
#

scrags?

patent pivot
#

wait who is in devops

subtle kraken
#

akarys

patent pivot
#

i think 1 is a bot lol

subtle kraken
#

well even so its not under 5 lemon_pensive

patent pivot
#

lol

subtle kraken
#

what is honcho pithink

patent pivot
#

kubernetes control bot

subtle kraken
#

okay

#

fair enough

green oriole
#

TIL this bot exist haha

patent pivot
#

doesn't do much yet

fallen patrol
#

But don't people who int e have access to the database?

#

Or is that where the abstraction comes in?

subtle kraken
#

python doesn't have direct access to database

#

it only operates via api which is on site

#

and api is limited to what moderators need from what I've seen

#

so data such as infractions

#

not much other than that

gritty wind
#

The API is publicly available if you really want to dig into what the bot has access to

fallen patrol
subtle kraken
#

roles screen

#

from settings iirc

patent pivot
#

yeah

#

lol

fallen patrol
#

I have the old one still

subtle kraken
subtle kraken
gritty wind
subtle kraken
#

probs canary has it already, if you are on stable unlikely that you can see it

gritty wind
#

It's available on stable

subtle kraken
#

not for me

gritty wind
#

through members filter

#

Was that from the roles menu, or the members menu Joe?

subtle kraken
#

roles

#

members doesn't look like that

fallen patrol
#

what is defcon?

#

raid protection I assume

gritty wind
#

Yeah basically

short snow
short snow
#

Is metricity database used anywhere in the bot?

clever wraith
fallen patrol
#

nice string

clever wraith
#

im dumb

short snow
#

pipenv run start?

#

Ah yes

#

hmmmm

fallen patrol
short snow
#

Reinstll six

#

You have got the old version of it most probably

clever wraith
#

Thanks, will try

clever wraith
#

Worked, thanks!

vocal prairie
vocal wolf
#

@clever wraith Greetings. Probably would be better to discuss it here.

clever wraith
#

hi @vocal wolf , thats probably a good idea.

vocal wolf
#

Are you sure you're on the right branch?

clever wraith
#

I've run pipenv run lint multiple times and it always returned ```
D:\sir-lancebot>pipenv run lint
Loading .env environment variables...
Check for merge conflicts................................................Passed
Check Toml...............................................................Passed
Check Yaml...............................................................Passed
Fix End of Files.........................................................Passed
Mixed line ending........................................................Passed
Trim Trailing Whitespace.................................................Passed
check blanket noqa.......................................................Passed
Flake8...................................................................Passed

clever wraith
thorny obsidian
#

!remind 9H check the branding issues

stable mountainBOT
#
Sure.

Your reminder will arrive in 9 hours!

vocal wolf
#

master?

clever wraith
#

earth_photos

vocal wolf
#

hmmm

#

it fails on my end, I wonder what you're missing

clever wraith
#

i made a commit trying to fix what happened on the actions end

vocal wolf
#

On your next commits, please describe what you've changed in the commit message.

clever wraith
#

oh sorry! I was kinda rushing whoops

vocal wolf
#

np :)

#

hmm still failed

clever wraith
#

alright, more fails im gonna try and fix it because my end doesnt care

vocal wolf
#

@clever wraith what program are you editing this bot with?

clever wraith
#

vscode

vocal wolf
#

hmmm

clever wraith
#

flake8 passed

vocal wolf
#

I think there's an autoformat feature with vscode, I can't remember how to use it though

brazen charm
#

What plugins do you see when you run flake8 --version

clever wraith
#

3.8.4 (mccabe: 0.6.1, pycodestyle: 2.6.0, pyflakes: 2.2.0) CPython 3.8.5 on Windows

#

I think this commit might have fixed

#

@vocal wolf failed again, im not sure why its so broken

brazen charm
#

Did you install the dev packages whole doing pipenv install/sync? That looks like it's falling back to your system flake8 as it's missing all the plugins

clever wraith
#

The only problems now should be ANN201: Missing return type annotation for public function and i dont know what that means

brazen charm
#

Well, since you're missing the plugins I'd check if you're running the correct flake8

clever wraith
#

what does ANN201: Missing return type annotation for public function mean

brazen charm
#

You need a return type typehint

clever wraith
#

yeah i think i fixed it

#

imma sleep now so ill fix in the morning

#

IT WORKED!!!

short snow
#

@clever wraith Gave you a review 😄

#

<@&267629731250176001>

#

Uhh that wasn’t needed ig

#

But yeah they are spamming across channels

sharp timber
#

!tvban 623004898694397978 14d spamming to get voice verified would defeat the point

stable mountainBOT
#

:incoming_envelope: :ok_hand: applied voice ban to @polar bone until 2021-03-17 05:00 (13 days and 23 hours).

short snow
#

Thanks!

subtle kraken
# short snow Is metricity database used anywhere in the `bot`?

Doesn't look like anyone answered that,
as far as I know, bot does not have any sort of access to metricity
However, site does give bot access to some data from metricity, which we need for moderation, specifically, it gives us total messages and message blocks
https://github.com/python-discord/site/blob/master/pydis_site/apps/api/models/bot/metricity.py shows what it exposes and how
https://github.com/python-discord/site/blob/master/pydis_site/apps/api/viewsets/bot/user.py#L244 is where it is then used.

Thats all I have seen at least and I don't think theres more to it

short snow
# subtle kraken Doesn't look like anyone answered that, as far as I know, bot does not have any ...

Alright thanks, i was just going through the issue on bot, and found this: https://github.com/python-discord/bot/issues/1359

subtle kraken
#

ammm not sure if that is possible currently without changing how @viscid badge works

#

pretty sure as soon as @viscid badge gets MESSAGE_DELETE event it removes the message from database iirc

cold island
#

It doesn't

subtle kraken
#

doesn't it?

cold island
#

It just flags it as deleted

subtle kraken
#

bit inefficient but okay then

#

no problem from me then

gritty wind
#

Rule 1 on deletions: you don't delete unless you are forced to

subtle kraken
#

well if one deletes their message we probs should honour their request and delete it from db too

#

¯_(ツ)_/¯

gritty wind
#

Hmm should we though

#

It is a message that was sent, and the DB is a record

cold island
#

We don't contain the actual message

subtle kraken
#

still doesn't sound right

cold island
#

And what you're saying goes against our logs as well lol

subtle kraken
#

our logs don't leave discord so it doesn't matter

#

while database is its own entity thus data manager of that is our devops team
Any logs within discord are still managed by discord

#

if someone deletes their message, they mean to delete it, not to flag it as deleted

gritty wind
#

Well that argument doesn't hold up legally, and it's really not up to the user

#

we use this data for various purposes in running the community

#

so we keep it on hand

short snow
#

Well I feel Senjan is right, but I dunno what really goes on inside either.

#
@commands.Cog.listener()
    async def on_typing(self, channel: discord.TextChannel, user: discord.Member, when: datetime):
        log.info(f"Typing .... on {when}.")
        if is_in_category(channel.id, self.in_use_category.id):
            self.last_typing_event[channel.id] = when
``` this is the right way to use on_typing right?
static canyon
#

Yep

gritty wind
#

So

static canyon
#

Although If I remember correctly it'll also trigger on dm typing so you probably want to filter that out

gritty wind
#

If that's for out bot, you can't actually use it

#

at least not right now

#

We don't get the event

#

Discord bug, so that may not always be the case

cold moon
#

Oh... I think this was meant for not closing help channels early

gritty wind
#

Yeah we discarded that implementation in the staff meeting

#

Or some staff discussion

#

primarily because it's 100% broken right now, and unreliable even when it works

short snow
#

ah ok.

static canyon
#

By the way for bot#1432 is it literally just the one line of code that needs to be changed?

dusky shoreBOT
static canyon
#

Frompy e.description = f"{misspelled_content.replace(command_name, similar_command_name, 1)}"topy e.description = similar_command_name

#

(Also removing the mispelled_content variable since it wouldn't be needed)

subtle kraken
#

we had a talk on whether or not we actually want to have it that way as it was supposedly used so people can copy paste the command with correct arguments and correct spelling however I haven't ever seen it be used like so

short snow
#

#bot-commands message delete this msg, i was just testing it.

#

someone did it, nvm

static canyon
#

Maybe we should implement a little bit of logic around it

#

If the command takes an argument then .replace (as we do currently) otherwise don't

vale ibex
#

Should we just use textwrap to shorten it?

static canyon
#

Since we get the commands.Command object so we could check that

short snow
vale ibex
#

There are no commands, to my knowledge, that take parameters >100 characters, so we could just wrap to 100 with an ellipsis placeholder

short snow
#

!raw can take more than 100 characters

#

the message link

patent pivot
#

Clarified things on the privacy front (see #changelog). We do retain metricity data when a user leaves the server because we have several uses for it, but now that's been made a bit more explicit in the policy.

subtle kraken
#

I think we probs should just change it to only display the suggested command name without the args

subtle kraken
vale ibex
#

Yea, I mean they still have their original message of they just scroll up

static canyon
subtle kraken
#

the talk we had was more concerning if it can just be master commit consider its comically small diff

short snow
#

what type of messages go to incident channel?

gritty wind
#

It isn't automated

#

if a helper+ feels something needs mod attention

#

they can put it in there

short snow
#

ah ok

#

and incidents archive?

gritty wind
#

Actioned incidents

subtle kraken
#

or rejected for that matter

short snow
#

meaning, if u add incident_actioned , it will move there?

subtle kraken
#

yes

short snow
#

ah ok ty

static canyon
#

And it has to be a mod+ adding it

subtle kraken
# static canyon ?

my English isn't too good, what I meant, when we brought it up it was a thing about just committing that change to origin/master rather than making a whole PR for it

static canyon
#

Right yea fair enough

#

Don't think I'm able to do that though

subtle kraken
#

I think only coredevs have write rights directly to the repo

static canyon
#

Yeah

#

So I guess I'll leave this then

short snow
#

since the incidents archive nor the incidents contain a message link

#

or i understood the issue wrong?

gritty wind
#

If I'm reading this correctly

#

when a helper+ posts an incident with a link to the message

#

automatically post the author ID

short snow
#

so if i post

#dev-contrib message
bot would post
Above message is authored by 386599446571384843
in the #incidents channel?

subtle kraken
#

more or less, yes

#

along with message content

short snow
#

oh ok

#

so i basically need to check if the message contains a link of a discord message or not

#

I can probably do this then lemon_pleased

static canyon
#
@commands.command()
async def pin(ctx, number: int, channel: Optional[discord.TextChannel]):
    channel = channel or ctx.channel

    pins = await channel.pins()
    if not pins:  # no pins in the channel
        ...

    elif len(pins) < number:  # there aren't enough pins
        ...

    else:  # valid number
        await ctx.send(pins[number-1].content)  # would actually be an embed```Would this be the very rough approach to https://github.com/python-discord/bot/issues/1357 ?
subtle kraken
#

looks about right

static canyon
#

What would we want inside the handling for when there's no/not enough pins?

#

Just a little embed saying like "there's no pins in this channel" / "there's only x pins in this channel"?

gritty wind
#

Did we decide that would be the final implementation instead of tags?

subtle kraken
#

not all pins are good tags

#

so yes I imagine

timid sentinel
#

There was a suggestion about having it search for some tags pins by text instead of by number

subtle kraken
#

wouldn't make any sense for the context of that command

#

unless you meant to say pins not tags

green oriole
#

I don't think that's a good ui to be honestly, but okay

#

Sending a jump link to the pin seems way better

static canyon
#

Yea

timid sentinel
gritty wind
#

I'm not sure how you'd even wrap embeds

green oriole
#

Maybe we can have the bot leave a jump link, but that would be somewhat useless

subtle kraken
green oriole
#

You have to remember the pin number, and I'm assuming that they will change every time we pin something else

static canyon
gritty wind
#

if you index from the begenning, it only changes when we remove pins

#

which we do

static canyon
#

The oldest pin = #1

gritty wind
#

so its kind of eh

static canyon
#

Oh yea true

gritty wind
#

unless we also store the index in something, that way it doesn't change

#

but I really don't get the whole idea

timid sentinel
#

Personally I think it would be neater to have them of tags, and could have some sort of namespacing on the tags so we can have channel specific tags without overlapping names (e.g. tags for a specific topical channel)

gritty wind
#

sounds like a dynamic tag system

green oriole
#

As we add more tags, that'd be something to look into

timid sentinel
#

Well currently we're avoiding adding some channel specific tags

gritty wind
#

I'm not too sure about it though

#

how would it work in help channels

green oriole
#

Nah, we said it was fine (having library specific tags)

gritty wind
#

do you have to prefix it with a channel?

green oriole
#

We could do that, or use a namespace related to the tag content

timid sentinel
green oriole
#

¯\_(ツ)_/¯

subtle kraken
#

pins aren't

gritty wind
#

Tbh that seems like the best solution here if people don't want to use the existing pin system

green oriole
#

I guess some of them wouldn't fit as tags either

gritty wind
#

the index system is kinda jank

subtle kraken
#

also pins are more dynamic than tags

#

esp in channel like #discord-bots there might be api change and you want people to know how to adapt to it from day 0
And not wait 5 days until a tag PR is written and merged

timid sentinel
#

Well, if it was really urgent then we could just use pins for them in the meantime, without a system for retrieving them, but most of the pins in discord.py now have been there for a while and will still be relevant for a while

gritty wind
#

I mean we don't pin too often tbh

#

Anyways

#

the only way I see the pins system working

#

is if the indexes never change

#

otherwise you'll just have people linking to wrong pins and that's not great

subtle kraken
#

lookup by text can work

gritty wind
#

It's a lot of implementation for very little reward imo

#

You also have to handle multiple formats, from text, to embeds, to possibly images

#

images obviously being unsearchable by text

subtle kraken
#

good point

#

perhaps then we could adjust our tags PR policy

gritty wind
#

I don't really think we can

#

Tags are messages that are at least semi endorsed by us

subtle kraken
#

well so are pins

gritty wind
#

So good review, good writing, and good content is mandatory

#

I don't agree that pins show as much endorsement as tags

subtle kraken
#

we take more people to review a pin than we do for tag

#

which is weird frankly

gritty wind
#

yet we don't hold them to the same standard

#

more people are just willing to review pins ig

#

we don't have a min or max number of reviewers for pins

subtle kraken
#

pins are held to higher standard if anything imo

short snow
#

how does this look?

#

for multiple

patent pivot
#

uhhh

#

do we have an issue for this

patent pivot
#

ah

short snow
#

the problem, is when u incident_actioned , the embed should also be sent to #incidents-arhive

#

but currently that doesn't happen

subtle kraken
#

I don't think embeds should be sent to archive

#

that'd be very spammy at best

short snow
#

oh wait, i need to comment on the issue

#

alright, then just delte them?

#

if actioned

patent pivot
#

yep

subtle kraken
#

yea

tough imp
#

you'll probably need to persist an incident -> embed(s) map in redis

short snow
#

yeah am doing that

#

a new redis cache?

#

and should i store the cache in a new file or just put it there?

hardy gorge
#

Just treat the RedisCache as any other kind of data type that you work with, except for initially assigning it to a class attribute of the Cog you're working on

#

After that, just use await self.your_cache_name.get and await self.your_cache_name.set and so on

short snow
#

yeah, i went through the help channels cogs and understood that

#

but where should i create the cache for incidents embed(s) maps?

vale ibex
#

In the cog init is what would make sense to me

#

Or even as a class param

#

Ahh yea, take a look at dm_relay or silence they both create the cache as class params

tough imp
#

it should be a class attribute as Ves says, it's documented in the async_rediscache.RedisCache class docstring

short snow
#

i made it as a class param, so need of class attributes right?

hardy gorge
#

You can't really use the __init__ to fill the cache or get the cache, as the access methods are fully asynchronous

#

You can schedule a task for it, though

short snow
#

Uhh i didn't understand ves

#

dm_cache = RedisCache() This is what is done when it is in class param, and namespace= is added when it is not in a class param. So what i understand, is that it gets the class attribute of the Cog automatically when set as a class param.

#

samething is said in the docstring of RedisCache ig

hardy gorge
#

I meant to reply to the suggestion Chris made about __init__

short snow
#

ohk

hardy gorge
#

You don't have to provide a namespace; it will determine it automatically

tough imp
#

what is a class param? I think we're mixing terminology here
when you assign the cache as a class attribute:

class SomeCog(Cog):
    cache = RedisCache()

it gets the namespace automatically

short snow
#

yes that's what i meant @tough imp

tough imp
#

explicit namespace is passed when it doesn't live on a class because then it cannot ascertain the namespace for you

short snow
#

thanks!

vale ibex
short snow
#

and i took it forward lemon_sweat

tough imp
#

it's fine ~ feel free to look at the cache's docs, they're well written and have examples

short snow
#

can i move add_signals to the class Incidents in incidents.py?

#

nvm it is not needed

#

Why do I get this?

#

when i have:

#

put it as:

tough imp
#

you cannot persist those types, it only supports the types listed there in the hint

hardy gorge
#

What kind of data are you looking to store?

tough imp
#

to persist a message, usually you will store its ID

short snow
#

the message by the helper+, and bot message like embed messages

#

i can do this then:

hardy gorge
#

Could you give a sample of the data that you're trying to store?

short snow
#
# RedisCache[discord.Message.id, List[discord.Message.id]]
message_link_embeds_cache = RedisCache()
#

yeah one minute

short snow
#

uhh so i can't even store a list in it, so i will need to .set() for each of them?

#

with same first param

hardy gorge
#

I'm trying to figure out your structure

#

You have a single message and you're trying to link it to several other messages?

short snow
#

yes

hardy gorge
#

And you'll need to make several of such lists?

short snow
#

yes

#

so that they can deleted when the incident is actioned or rejected, (the bot message link embeds won't be sent to #incidents-archive)

tough imp
#

hmm, isn't it possible to send multiple embeds with a single webhook message

hardy gorge
#

I'm not entirely sure what you're working on (haven't checked the issue), so I'm mainly going of your description of the kind of data storage that you need

#

It is; you can send a list of embeds with one message

tough imp
#

up to 10

#

that may be a more elegant solution

short snow
#

lemme send the code snipet

#

this is how it is sent.

#

I can make use of the paginator for this

#

so then it would be one message map to one message

subtle kraken
#

you could just use webhook and send up to the 10 embeds at a time

short snow
#

in teh reddis cache

#

Uhhh, wouldn't a paginator be better?

#

i don't see the need of webhooks here

subtle kraken
#

why'd you need paginator

#

webhook supports 10 embeds in same message with like 60_000 chars total allowed

short snow
#

Paginator would keep it to one message and clean

#

it wouldn't pollute the channel with a number of messages

subtle kraken
#

well webhook would keep it one message as well

#

paginator would also break easily

#

it would require both having very long wait time and it wouldn't even keep up between restarts so you'd lose all of the functionality the second bot goes offline

short snow
#

webhook would keep it to one message, i didn't get you.

short snow
#

what if someone has 11 links, how will you send them then with webhooks?

subtle kraken
#

unlikely we'll have more than 4 links per message

#

but in such case simply second webhook message should be fine

cold island
static canyon
# cold island I suggested an alternative solution yesterday, if you want to look for it. I'll ...

If you're referring to #dev-contrib message and the conversation around that, we just had a similar one again now.

It seems the main issue with the method proposed in the PR is that indexing of pins changes when the pin list of a channel changes, which we don't want.

The general consensus of how to solve this does seem to be what you said, aka some sort of text-matching. Whether that's through fuzzy or just a simple in or whatever.

TLDR; We want text-matching not index-matching

short snow
#

Uhh how do you send multiple embeds with webhook?

static canyon
short snow
#

alright

#

thanks

brazen charm
#

If the issue are indices, why not store a permanent mapping of names to message links, something like tags but instead of sending potentially big embeds it returns the link

cold island
#

That you have to go over every single pin and give it a name 😄

#

@static canyon if you are working on this you should make sure that the invoking user has access to the channel they want to get the pin out of

#

Or just disable it for private channels altogether

static canyon
brazen charm
#

There aren't that many pins that would need to be added

static canyon
#

And yeah I'd do the has permissions thing (easy enough to do)

cold island
static canyon
#

Granted probably not all of them would be linked to but that's the total

gritty wind
#

I think a text search would be very limited because there are a lot that don't even have text, and the ones that do are split out across multiple fields

brazen charm
#

Shouldn't restrict it too much if the api is used, matching text sounds like it could lead to unexpected results as parsing human text is not something that's exactly easy

woven iron
gritty wind
#

I can't tell if you want to fix it or not haha

#

Anyways, I'll approve it, under the assumption that you'll follow Xithirius/Den4200's suggestions

woven iron
#

lol

#

i wasn't sure if that was an either or kinda deal, gotcha

gritty wind
#

!pban 427858024200404995 Spammer

stable mountainBOT
#

:incoming_envelope: :ok_hand: applied ban to @nimble current permanently.

gritty wind
#

And feel free to drop in if you need any help

woven iron
#

It looks like ./pre-commit is running Flake8, can I trust that or should I be running it manually as well?

vale ibex
#

You can trust it, or run pipenv run lint to do it manually

brazen charm
#

They should produce the same results (with precommit running a few more things) as long as it was installed properly

gritty wind
#

You do have to install pre-commit to make sure it works though

vale ibex
#

pipenv run lint will lint all files, pipenv run pre-commit will just lint staged files

woven iron
#

gotcha, ty!

gritty wind
#

Hmm no

#

pre-commit just installs

vale ibex
#

of course, as Scal said, make sure you do pipenv sync --dev and pipenv run precommit to setup the hook

gritty wind
#

lint runs it though

vale ibex
#

I thought precommit installs and pre-commit runs

gritty wind
#

I think it would be pre-commit run

#

anyways, that's what lint does

#

Anyways, as long as you run one of these commands, things will be fine at some point haha

#

I think the contributing guide details the procedure

stable mountainBOT
#

@obsidian patio

It has arrived!

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

short snow
#

🎉 Done, now time to make the code more pretty and pythonic

short snow
#

cc <@&267628507062992896>

patent pivot
#

816650601844572212 @short snow

short snow
#

ty joe

stable mountainBOT
#

@thorny obsidian

It has arrived!

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

vale ibex
#

Do we need to worry about url injection for the http cog?

short snow
#

Joe forgot one important bug 🙃

green oriole
vale ibex
clever wraith
#

Hey @gritty wind , I don't see how my pr is in breach of point 2, I'm only embedding an image, not downloading it

gritty wind
#

Right, and I was confused about this for quite a while

#

But as far as I can tell

#

"download" is in reference to displaying the content of the images

#

And it just requires you increment a counter

#

so it's basically an extra request you should make when getting an image

#

Now why don't they do that on their end? Well I have no clue

clever wraith
#

This apparently counts views and it's what im doing, I think

gritty wind
#

When your application performs something similar to a download (like when a user chooses the image to include in a blog post, set as a header, etc.), you must send a request to the download endpoint returned under the photo.links.download_location property
This is what I was basing it off

#

The examples they give

#

An action “similar to a download of an image” can be thought of as an action where a user does something with the photo, usually inserting or setting it somewhere.

clever wraith
#

Okay, that kinda makes more sense now. Why don't they track it though? That's really weird

gritty wind
#

I honestly am not sure

clever wraith
#

I'll get implementing the count request if that's wrong

gritty wind
#

Here are the two points that imply we should be doing both

#
  1. All API uses must use the hotlinked image URLs returned by the API under the photo.urls properties. This applies to all uses of the image and not just search results. More info & examples →
  2. When your application performs something similar to a download (like when a user chooses the image to include in a blog post, set as a header, etc.), you must send a request to the download endpoint returned under the photo.links.download_location property. More info & examples →
#

What constitutes a download is unclear, but it generally seems to be embedding it

clever wraith
#

Sounds good, it seems that they're docs are rather contradictory

#

Alright, I've set up the request so it makes it and then just does nothing, I think that should be ok

gritty wind
#

I hope so

#

When the PR is ready, we'll see if they can give us a full token

clever wraith
#

@gritty wind sorry to bother you again, but I commited the start and the lint action says it slipped flake8 entirely for some reason, do you know why that happened?

vale ibex
#

Did you stage the change?

clever wraith
#

Yes, and pushed

vale ibex
#

Do you have the pre commit hook setup locally?

clever wraith
#

Yes

vale ibex
#

could you run pipenv run lint and paste the output here?

#

The action you linked failed on the trailing whitespace check

clever wraith
#

Huh

clever wraith
#

Editing on gitpod, says cannot start because --user installs are blocked

#

I'll try at home

#

I see why it's breaking

fallen patrol
clever wraith
#

I ran pipenv install and didn't get precommit for some reason

#

I had to manual install and gitpod doesn't like

vale ibex
#

pipenv sync --dev to install dependancies

#

then pipenv install precommit to install the hook

clever wraith
#

@gritty wind is there a discussion we can use for suggesting python facts?

#

or one we can create?

gritty wind
#

Hmm I'm not sure

#

I haven't looked into it

#

Do you have anything in mind?

clever wraith
#

like a github discussion

#

@gritty wind could we make one on the meta repo?

gritty wind
#

Ohhh that's @patent pivot's domain

clever wraith
#

ok

gritty wind
#

What was the issue you're working on again?

patent pivot
#

I'll make one

#

1

clever wraith
#

sir-lancebot#596

patent pivot
#

seec

dusky shoreBOT
patent pivot
#

remind me to unlock it after the feature is merged

subtle kraken
#

ah yes am used to only seeing stable links and occasional PTB's, good catch thanks, @fallen patrol

clever wraith
patent pivot
clever wraith
#

ok

mellow hare
#

Not entirely sure what I'm missing

green oriole
#

The redis endpoint isn't right

#

I assume you want to use the Docker redis?

mellow hare
#

I was trying to but I'm not married to it

green oriole
#

Alright, what do you have in the bot.redis section of your config file?

mellow hare
#
    redis:
        host:  "redis"
        password: null
        port:  6379
        use_fakeredis: false
#

I'm basing that off of the config that we have on notion

green oriole
#

Hmmmm

#

I am a bit clueless about this one

#

How are you starting your containers?

mellow hare
#

docker-compose up

green oriole
#

Can you try

docker-compose up -d redis web
docker-compose up bot
mellow hare
#

Sure, one sec

#

Same error

#

I'm not worried about it, I'll swap back to fake

#

Like I said, it was more because I wanted to try it

green oriole
#

Hmm okay

#

Docker networking can be so peculiar from time to time

mellow hare
#

True that

#

ooooo kay, same error even with fake

green oriole
#

Uh wat

#

Can you force your IDE to sync and try to launch with the --build argument?

mellow hare
#

So pipenv sync --dev and then what?

#

Or am I misunderstanding

#

Sorry, still not overly familiar with all this docker stuff

vale ibex
#

pipenv sync shouldn't be needed for docker

mellow hare
#

That would make sense

vale ibex
#

Do you have another redis container running?

#

Although i imagine that would produce a different error

mellow hare
#

Nope, the bot stuff is all I have spun up

vale ibex
#

Just to check, did you rename the file to config.yml?

green oriole
#

I meant hitting ctrl + s in the side to make sure that it did save the changes to your disk

mellow hare
#

Okay so

green oriole
mellow hare
#

We're going to assume that I'm an idiot because I named it .yaml instead of .yml. I'm now at least getting a different error at least

vale ibex
mellow hare
#

Well still getting a failure

vale ibex
#

new failures 🎉

mellow hare
#

Progress!

green oriole
#

Interesting

mellow hare
#

Rebuilding and trying again. I think I know what's going on this time

mellow hare
clever wraith
#

What's the problem?

green oriole
#

Can you try to launch the site first?

#

The bot is probably starting faster

mellow hare
#

Theeeeeere we go

gritty wind
#

It should be fixed if you run on latest version

mellow hare
#

Yeah, bot was loading before web was ready

clever wraith
#

Man, I'm glad I use fakeredis for my development

#

can someone review mr PR?

mellow hare
#

Oh no no, this was WITH fakeredis

clever wraith
#

sir-lancebot#586

dusky shoreBOT
clever wraith
#

oh whoops

mellow hare
#

And now for the true test

clever wraith
#

not this one

hardy gorge
#

fakeredis is pretty nice

clever wraith
#

sir-lancebot#596

dusky shoreBOT
mellow hare
gritty wind
clever wraith
hardy gorge
#

I did not write fakeredis

#

so it's not a brag

mellow hare
#

Fair

hardy gorge
#

I committed one thing to it

mellow hare
#

Therefore you wrote it

hardy gorge
#

haha

mellow hare
#

Obvs

clever wraith
#

Yeah

clever wraith
mellow hare
#

ConnectionRefusedError: [Errno 111] Connect call failed ('172.24.0.4', 6379)
It's still pitching a fit when I try to do the real container. But eh

#

Not a huge deal

clever wraith
#

Huh

#

sir-lancebot#1

clever wraith
#

Wow that's really cool

green oriole
clever wraith
#

bot#1

dusky shoreBOT
mellow hare
#

And that's even with spinning up redis first

green oriole
#

Hmmmmm

mellow hare
#

Well actually hold on

#

Let me spin up the redis by itself

short snow
#

Worked hemlock?

clever wraith
#

can someone review sir-lancebot#596

dusky shoreBOT
clever wraith
#

please?

short snow
#

@vocal wolf Welp. Am almost done with it.

vocal wolf
#

Alright

#

welp, next time make sure the issue is approved lol

short snow
#

It was told that if a issue is not having planning, it isnapproved

brazen charm
#

You should still ask to be assigned if you don't plan on the work potentially going to waste

short snow
# short snow for multiple

It is like this, but the response is a webhook. And it uses redis to map the author message and the webhook. So that it can be deleted when the infraction is mentioned or rejected

vocal wolf
#

Interesting

short snow
#

@clever wraith which editor are u using?

#

and also read the contributing guide it says not to do frequent pushes.

clever wraith
clever wraith
short snow
#

I recommend using a local editor.

#

like pycharm or vim.

#

and you probably would have to squash down the commits, we don’t want 10 commits jst fixing the lint issues (ask xith or scal about this maybe)

clever wraith
short snow
#

Linter is broken meaning?

clever wraith
#

the extra plugins for python discord did not install when pipenv install was run

short snow
#
# This will install the development and project dependencies.
pipenv sync --dev

# This will install the pre-commit hooks.
pipenv run precommit

# Optionally: run pre-commit hooks to initialize them.
# You can start working on the feature after this.
pipenv run pre-commit run --all-files

# Run the bot
pipenv run start
clever wraith
#

@short snow , I've made the requested changes!

short snow
green oriole
#

Fwiw doing frequent pushes is fine now, we have unlimited actions minutes

short snow
#

you ppl have github pro?

gritty wind
#

It's free for public repos

#

I think for OSS orgs in general

#

because we have private repos too lol

green oriole
#

I don't think we will pay 200 some euros per month for a GitHub org haha

short snow
#
def chunks(lst, n):
    """Yield successive n-sized chunks from lst."""
    for i in range(0, len(lst), n):
        yield lst[i:i + n]
``` If i want to add this function to `bot` (needed for enhancing incidents feature). where should i add it?
#

i need to break down embeds into list of 10, since webhooks only support 10 embeds at a time

green oriole
#

Isn't that an itertools function

green oriole
#

Maybe it is from the cookbook

short snow
#

uhh i don't remember

green oriole
#

But that'd typically go in the utils

gritty wind
brazen charm
#

more itertools should have it, which are in the bot iirc

short snow
#

should i pip isntall it or put it somewhere in utils?

gritty wind
#

If we already have more itertools, then just use it

#

otherwise, add it to utils

short snow
#

where in utils?

gritty wind
#

make a new function somewhere in utils, it's a general file

short snow
#

nvm we have it

brazen charm
#

The helper module under utils has functions like that for the future

short snow
#

question:
If i have the same first parameter and different second parameter for a redis cache what will happen?

#

what i want to do is basically, map the user incident message to the webhook message id. But in case of more than 10 links in the message, there will be more than 1 webhook msg. So how should i store it?

#

this is what i do now

#

since async redis doesn't support list

#

and someone including more than 10 message link in there incident is a really rare case, so am not sure if this is even needed

cold moon
#

Will this list get edited?

short snow
#

nope

cold moon
#

Then you can use comma-separated string

short snow
#

smart lemon_hyperpleased

gritty wind
#

(side note, but don't swallow exceptions like that. You could at least pass it to the log statement)

#

you can use exc_info kwarg iirc

tawdry vapor
#

log.exception implicitly logs the exception when it's in an except block

gritty wind
#

I still think it should be explicit

tawdry vapor
#

I disagree

#

It's documented behaviour and it's literally called log.exception

gritty wind
#

The explicitness makes it clear we are relaying the error back to the user, in case the content is changed

#

So if the log is moved, or it's level changed

brazen charm
#

It's used fairly extensively without exc_info all over the bot

tawdry vapor
#

I don't think it's necessary to be explicit. It's an established library, not some obscure function. Unless you've never had experience with logging, you will know that log.exception logs the exception.

fallen patrol
#

Which ones?

short snow
#

many

#
postgres_1  | 2021-03-04 07:11:12.896 UTC [35] FATAL:  no pg_hba.conf entry for host "172.19.0.5", user "pysite", database "pysite", SSL off
``` i get this on running the `bot`
#

and cuz of this the site fails, and hence even the bot fails

#

but i also get this:

web_1       | Waiting for PostgreSQL database.
web_1       | Database is ready.
web_1       | Applying migrations.
#

and later

#
web_1       | psycopg2.OperationalError: FATAL:  no pg_hba.conf entry for host "172.19.0.5", user "pysite", database "pysite", SSL off

....

web_1       | django.db.utils.OperationalError: FATAL:  no pg_hba.conf entry for host "172.19.0.5", user "pysite", database "pysite", SSL off
#

which then gives:

#
bot_1       | aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host api.web:8000 ssl:default [None]
bot_bot_1 exited with code 1
cold moon
#

Destroy web_1 and postgres_1 and recreate

short snow
#

prune it or compose it down?

#

done thanks

#

The only problem with it now, is that is really slow

#

i think it is problem with my internet tho

#

yesterday it was fast

short snow
#

welp

#

how do u run coverage tests locally?

#

am using pycharm

brazen charm
#

pipenv run test or in pycharm right click on the tests dir and run test/ run tests with coverage depending on what you want

short snow
#

ok thanks

#

i get the same error as stel i.e.

PermissionError: [Errno 13] Permission denied: '/home/user/PycharmProjects/bot/logs/bot.log'
``` lemme see what the did i the msg history
#

ah got it

#
/usr/lib/python3.8/unittest/mock.py:2030: RuntimeWarning: coroutine 'Infractions.apply_voice_ban.<locals>.action' was never awaited
``` hmmm i get this
#
async_rediscache.session.RedisSessionNotInitialized: the redis session has not been initialized yet.
``` how do initialize it?
short snow
#

should i use try...except to handle MessageNotFound or add a cog error handelr?

#

i get message not found even when the message is in the server

#

this is how i handle it

subtle kraken
#

whats incident in that case?

static canyon
#

@short snow your issue is likely that you're passing a Message instead of Context

cold moon
#

incident is message I think

static canyon
#

!d discord.ext.commands.MessageConverter

#

It takes ctx, thing_to_convert

short snow
#

am passing on on_message()
so i don't have ctx

static canyon
#

!d discord.ext.commands.MessageConverter.convert

stable mountainBOT
static canyon
#

!d discord.ext.commands.Bot.get_context

stable mountainBOT
#
await get_context(message, *, cls=<class 'discord.ext.commands.context.Context'>)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Returns the invocation context from the message.

This is a more low-level counter-part for [`process_commands()`](#discord.ext.commands.Bot.process_commands "discord.ext.commands.Bot.process_commands") to allow users more fine grained control over the processing.

The returned context is not guaranteed to be a valid invocation context, [`Context.valid`](#discord.ext.commands.Context.valid "discord.ext.commands.Context.valid") must be checked to make sure it is. If the context is not valid then it is not a valid candidate to be invoked under [`invoke()`](#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").

Parameters 
 • **message** ([`discord.Message`](../../api.html#discord.Message "discord.Message")) – The message to get the invocation context from.
... [read more](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.get_context)
short snow
deft patrol
#

Woah @vale ibex Congo 😄

#

I always get confused with Chrsij_ and Chrisjp

#

lol 😄

vale ibex
#

Hah thanks 😄

#

We're the council of Chris's

short snow
#

but all of them are awaited

#
    message_links = DISCORD_MESSAGE_LINK_RE.findall(message.content)
TypeError: expected string or bytes-like object
``` what does this mean? should i do `str(message.content)`?
#
    raise RedisSessionNotInitialized("the redis session has not been initialized yet.")
async_rediscache.session.RedisSessionNotInitialized: the redis session has not been initialized yet.

``` these are three things i get
deft patrol
#

LOL

vale ibex
#

ummm anyone know the magic words?

deft patrol
#

sure

vale ibex
#

Thanks, I was mostly interested in what .content behaves like

#

huh message.content says its a str

#

I would have fallen into the same trap 😛

short snow
#

damn, i need to edit the tests now

#

to intialize the redis cache

tough imp
#

content should be a string but perhaps in tests a Mock object gets in there

#

you can catch the error and print out message.content

#

to check what it is

#

for tests it may make more sense to mock the cache than to initialise it, I'm not sure if we have tests dealing with a cache somewhere

#

I'm not sure what the initialisation does but it may not even be possible when running tests

short snow
#

i need to add redis loop and create a redis session in the tests

#

most probably

vale ibex
#

Have you looked at how the other tests deal with redis?

short snow
#

yeah

#

new error

vale ibex
#

ah cool

short snow
#

do i need to add int() and str() while setting and getting @tough imp ?

tough imp
#

I don't know, I think the problem you're encountering is that in tests you're getting a Mock instance representing the message, and when you try to access e.g. message.id it gives you another Mock object instead of an integer, so the write to cache fails (I still think it makes more sense to mock the cache, btw)

#

this is just speculation though

#

if you want the mock objects that get passed in from the testing code to have e.g. an id attribute you have to set it yourself

#

if you're not sure what I'm talking about, try to isolate the test that is failing, and look at what it's passing in to mock a production scenario

#

it will mostly be instances of Mock or MagicMock

#

and you will see that the tests explicitly set attributes that should be available on those instances

#

if you try to access a non-existent attribute on a Mock, it won't raise an AttributeError (unless told to do so), but rather give you another Mock

short snow
#

Ok this is going above my head.

#

Uhh i think i am getting it now.

#

when the unit tests passes something to the cog, it is passed as Mock instance, and the redis cache doesn't support that.

tough imp
#

to demonstrate, here I make a Mock object and set an attribute colour using the kwarg:

>>> from unittest.mock import Mock
>>> 
>>> m = Mock(colour="blue")
>>> m.colour
'blue'
>>> m.size
<Mock name='mock.size' id='140289252559696'>
>>> m.size.size
<Mock name='mock.size.size' id='140289252560656'>

you can see that I can now access that attribute and get my value, but accessing an un-set attribute size doesn't fail, it produces another Mock instance that represents that attribute, and remembers some information about how it was used, so that you can make assertions about it

#

so if you're passing in e.g. a mocked message, and you want to write its id attr to the cache, you have to make sure that accessing that attribute will actually produce an integer, rather than a Mock obj, which cannot be serialized

#

however, another approach would be to also mock the cache, and then check that the message.id mock is what the mocked cache.set function receives

#

this way you can make assertions about the behaviour within the tested unit without depending on the implementation of the cache itself (because that's not what you're testing ~ you only want to test the code that you've written)

short snow
#

thanks i understood it now

tough imp
#

but I'm also not implying that you have to write these tests

short snow
#

<class 'unittest.mock.MagicMock'> the incident.id is of this type

#

uh no, i lost all my changes, pycharm collapsed, hyperlemon

short snow
#

I will have to read mroe on writing tests and on unit testing, so ignore the coverage fails for now

short snow
#

and it should have id attribute

dusky shoreBOT
clever wraith
clever wraith
clever wraith
green oriole
clever wraith
#

Ok good, thanks!

clever wraith
#

What did you think of the changes?

short snow
#

Still need to have a look maybe, kinda busy with my pr on bot and another side project

short snow
vale ibex
clever wraith
vale ibex
#

👍

clever wraith
#

If you're the Chris who reviewed my pr, I made the changes you wanted

vale ibex
#

Yea, i am. I'm just testing it locally now

clever wraith
#

Awesome, thanks!

vale ibex
#

Is it the unsplash access key or the secret key that's used for this?

clever wraith
#

Access key

vale ibex
#

Thanks

clever wraith
#

No prob

vale ibex
#

Have you seen this in testing?

#

For some reason, the first didn't embed an image

mellow hare
#

I've seen that with regular sent messages as well

clever wraith
#

Sometimes it's glitchy

vale ibex
#

Alright

clever wraith
#

Aorry

#

Sorry*

mellow hare
#

It's a Discord issue rather than an implementation issue

short snow
#

It is a glitch on your side chris most probably

#

discord is weird

clever wraith
#

Yeah, sorry

vale ibex
clever wraith
#

It doesn't happen too often

short snow
#

Not your fault, sorry is not needed

vale ibex
#

You can't be sorry for a discord issue 😛

clever wraith
#

🙃

#

for my pyfacts PR, i was thinking we could make the fact the title.

#

kinda like .topic

#

@vale ibex is this a good idea/

short snow
#

Yeah

#

uhhh no

clever wraith
#

That sounds like that was already the idea, you wanted the command to be .pyfacts?

mellow hare
#

I think it'd be a bit wordy depending on the fact

short snow
#

facts are too big

#

Topics are small

clever wraith
#

Oh that's what you meant

mellow hare
#

A title just saying "Python Fact" would be cleaner

vale ibex
#

@clever wraith Just FYI, our code reviews are usually done in 2 parts, first its a basic "Does this code look right" then we do local testing, so its common for some comments not to be raised initially 😄

clever wraith
#

Okay, thanks!!!

#

Hey, made the changes you wanted

short snow
#

Lint fails...

clever wraith
#

Noticed, I made the fix

#

Forgot the _ for the extra request

short snow
#

Why can we join media vc but not dev vc?

short snow
hardy gorge
#

What are you doing?

short snow
hardy gorge
#

Are you the first to write tests for something redis-related in the bot?

#

Or is that error not coming from your code?

short snow
#

it is used in silence too

hardy gorge
#

But you're introducing RedisCache for something, right?

short snow
#

Yeah

hardy gorge
#

Right, do you know if someone else is testing something that uses RedisCache somewhere?

#

Do they mock it or do they initialise the session?

green oriole
#

I actually just remembered that I am not on a wifi haha

mellow hare
#

HA

hardy gorge
short snow
#

kwzrd helped me with it

#

and i understood it

short snow
clever wraith
#

Alright, only one more approval!

hardy gorge
#

You'll need to make sure that the id attribute (which I think you're passing to redis) is an integer and not a Mock

#

You are passing the id attribute of a message, right?

short snow
#

Yeah

hardy gorge
#

The easiest way to do that is by providing something like id=<some int here> as a kwarg to MockMessage in those test methods

short snow
#

And the other ways?

#

Just curious

hardy gorge
#

create a MessageMock instance first, assign an int to the attribute

#
    async def test_process_event_confirmation_task_is_awaited(self):
        """Task given by `Incidents.make_confirmation_task` is awaited before method exits."""
        mock_task = AsyncMock()

        with patch("bot.exts.moderation.incidents.Incidents.make_confirmation_task", mock_task):
            await self.cog_instance.process_event(
                reaction=incidents.Signal.ACTIONED.value,
                incident=MockMessage(id=1),
                member=MockMember(roles=[MockRole(id=1)])
            )

        mock_task.assert_awaited()
short snow
#

Alright

hardy gorge
#

This should do it for the first test method

short snow
#

Alright thanks understood

hardy gorge
#

And the second one is very similar

short snow
#

also do i need to create tests for the message links case?

hardy gorge
#

We don't have a "tests are required" policy anymore, as far as I'm aware

#

but @green oriole knows best, probably

green oriole
#

As in you have to add tests to your feature, or we want all the tests to pass when committing?

short snow
#

Add tests ig

hardy gorge
#

create additional ones; if everything goes well, the current failures (or actually errors) are now solved

green oriole
#

We do not enforce those. That said, if you are creating a new critical feature and you want to add tests, you are more than welcomed to do so!

short snow
#

Hmm i will leave out tests for now since i have zero knowledge in that field maybe in future i can add them.

green oriole
#

No sweat, as long as you aren't removing tests with your PR, it is perfectly fine

short snow
#

Whoever wrote documentation for async rediscache. Awesome job lemon_hearteyes

#

It is really easy to understand it

clever wraith
#

so i took the fork of sir lancebot

#

how to run it?

vale ibex
#

(This is linked in the readme)

clever wraith
#

oh wow i got to install docker

#

okay thanks

green oriole
#

You can run it without Docker

brazen charm
#

You don't really need docker if you don't plan on using redis, using pipenv directly should be fine

clever wraith
#

yeah i had it for node stuff

#

i do have test server yes.

#

so i created one bot on my server. im really sorry im bit new to this stuff.
i added channels and role. what next?

#

.env stuff

placid ermine
#

Add the IDs of the channels and the roles to the .env

#

and your token

clever wraith
#

yeah just doing that

#

And server id

#

BOT_GUILD=ABCBBSBBS
thats correct format right?

trim cradle
#

@green oriole I believe I've figured out how to make a new flake8 rule that would check for the multiline implicitly concatenated string format you mentioned before.

green oriole
#

Oh nice

trim cradle
#

if there's consensus among the core devs that you want that, I can try to make time for it

green oriole
green oriole
#

You can directly ask, actually pithink

clever wraith
#

okay i made .env perfectly

#

except bot toke

#

so i have clientId, secret, public key

clever wraith
#

clientId right?

placid ermine
#

go the Bot tab first

clever wraith
#

Go into section bot and copy tokeb

placid ermine
#

it's explicitly named Bot Token

clever wraith
#

Token*