#dev-contrib

1 messages · Page 121 of 1

slow steppe
#

*bot

vocal wolf
#

explain.

slow steppe
#

That's the whole point

vocal wolf
#

lmao

slow steppe
#

You had that coming

sleek steppe
#

.wa short define

dusky shoreBOT
vocal wolf
#

very nice

slow steppe
#

That's too much effort

#

Wolfram has everything

#

Look I'll gladly write it all if y'all don't want to

gritty wind
#

There is a side to contributing that’s often forgotten. Writing code is usually the smallest part, the rest is in review and maintenance.

If you’d like to get discussion on this, feel free to open an issue on the repo

vocal wolf
#

Where would you get the definitions from?

gritty wind
#

Though it feels redundant given wolfram

slow steppe
brazen charm
#

the bot doesn't really need yet another module that would just expose some web api

thorny obsidian
#

@vocal wolf I want to make an issue for an .epoch commands, which given a date/time or a duration (i.e. 40M (from now)) will spit back out the unix/epoch time to use the discord timestamp feature. Would that be lancebot?

vocal wolf
#

that would be lancebot indeed

thorny obsidian
vocal wolf
#

yes

#

lmao

#

I am not Xith a bot, therefore I don't know specific epoch times off the top of my head.
well yes of course the current time is about 1626461022.831569

patent pivot
#

so

#

as far as I can see

#

multiple processes in snekbox is not harmful from a killing pov

#

they do seem to get killed off

#

I just need to check how memory limits are applied, if it's one per child proc it complicates things

green oriole
#

Mmmmm I remember issues I found with child procs, but never really tried them

#

Will have to look into it

#

We probably also want to mount everything but the python binary in noexec

rotund light
#

can someone give me an example of epooch?

wild prism
rotund light
wild prism
#

it's another name for Unix time, which is the number of seconds since the new year started in 1970 in UTC

#

it's a handy way for computers to represent a particular time without ambiguity

rotund light
#

ohh now i get it

#

so..kutiekat is saying to change this epooch time to standard time right?

wild prism
#

what she wants is a command that gives you the epoch time for a given date-time

cold island
#

This allows you to do something like: <t:1626481254>

#

(assuming you're not on iOS)

wild prism
#

it's not super simple though, because the date-time is relative to a timezone, so you'd need to know the timezone to calculate the epoch time

cold island
#

wdym

#

!e
Why not:

from datetime import datetime
print(datetime.utcnow().timestamp())```
stable mountainBOT
#

@cold island :white_check_mark: Your eval job has completed with return code 0.

1626481471.142881
rotund light
#

so @cold island the dateandtime is given by the user right?

cold island
#

yes

wild prism
cold island
# cold island yes

You can look at examples in the bot on how we usually accept such an argument

rotund light
cold island
#

Hmm actually

#

It handles durations and UTC datetimes

#

Why not just assume UTC?

short snow
thorny obsidian
cold island
#

Noice

#

Akarys will be delighted

short snow
#

iPad

#

Mac also, dunno about mobile

rotund light
vocal prairie
rotund light
balmy sparrow
#

The timestamps seem to work on iOS mobile as well

obsidian patio
#

July 20, 2021 08:42 PM

balmy sparrow
#

There's some specific format for it

#

I'm not sure what exactly, just remember it sorta looks like what you get doing \:emoji:

obsidian patio
#

Ah

fervent sage
tough imp
#

can confirm timestamps work on iphone now

gritty wind
#

Hmm, not seeing updates on the store or anything

vale ibex
#

probably gradual roll out

fallen patrol
gritty wind
#

latest and latest
14.6 & 80.0 I think

tough imp
#

my Discord is 82.0

#

that'll be it

gritty wind
#

That seems to be latest on the store, not sure why I’m not getting an update in that case

#

Alright, feel free to push forward in that case

vale ibex
#

Pushing an update to apple/google stores don't hit all regions at the same time

#

I've found it can take >a week sometimes for apps in multiple countries

green oriole
#

Timestamps are rolled out everywhere? lemon_hyperpleased

rotund light
#

wow how do u guys get so advance ?

green oriole
#

What do you mean by that?

#

:(

rotund light
green oriole
#

Haha, reading source code is a very good way to learn some specific tricks

brazen charm
#

Most of the code is also decoupled so it's not as hard as it looks at first glance

short snow
#

If you are taking about the docs code then you are probably right, pokenmonmaster

short snow
#

Whats the reason for putting python-dotenv = "~=0.17.1" in dev deps in bot?

patent pivot
#

in prod we don't use dotenv

short snow
#

ah ok

patent pivot
#

prod env vars are injected by k8s (through docker env vars)

cold island
green oriole
#

Yep, we will see when it is ready to merge if it has been rolled to every region

#

It will probably take more time for us to review than for the store to roll out, or we can wait once it is ready

patent pivot
#

@tawdry vapor @glacial veldt investigating multiprocs on snekbox, limits are certainly shared somehow, my test script is ```py
import os
from multiprocessing import Process

items = [1, 2, 3, 4]

def func(item):
a = "A" * 30_000_000
print(f"PID: {os.getpid()} - Processing: {item}")

if name == 'main':
procs = []

for item in items:
    p = Process(target=func, args=(item,))
    p.start()
    procs.append(p)

for proc in procs:
    proc.join()

for proc in procs:
    print(proc.exitcode)
#

killing is a little bit inconsistent, with the same limits sometimes one gets killed, sometimes two, etc.

#

testing how zombies are handled now

#

as far as I can see, things do get killed

green oriole
#

Now my question is can you spawn a thread under another CGroup

glacial veldt
#

As in running a process in one !e consumes a resource from all other concurrent !e calls?

patent pivot
#

uhhh

green oriole
#

Nah, we create a new cgroup for each eval

patent pivot
#

child procs shouldn't be able to spawn into a different cgroup

green oriole
#

Bear in mind that I don't know much about cgroups

#

But iirc fork() gives you the option of selecting a new cgroup?

#

Will that mean you have two cgroups under one process

patent pivot
#

forked procs by default are going into the same cgroup ```
root@snekbox_dev:/Users/joseph/Desktop/Python/snekbox# cat /sys/fs/cgroup/memory/snekbox-040de838-6259-4414-abc6-a2c61e27d8a8/NSJAIL.57/tasks
57
60

#

fork does not give you any options

#

a process shouldn't be able to rehome itself in the pids or memory cgroups because we don't mount /sys/

#

okay — as far as I can see multiple processes seems to be safe within snekbox, so I'm going to open a PR to bump max PIDs to 5

#

updating some tests now

#

this is my revised unavailable test ```py
def test_subprocess_resource_unavailable(self):
code = dedent("""
import subprocess

        # Max PIDs is 5.
        for _ in range(6):
            print(subprocess.Popen(
                [
                    '/usr/local/bin/python3',
                    '-c',
                    'import time; time.sleep(1)'
                ],
            ).pid)
    """).strip()

    result = self.nsjail.python3(code)
    self.assertEqual(result.returncode, 1)
    self.assertIn("Resource temporarily unavailable", result.stdout)
    self.assertEqual(result.stderr, None)
green oriole
#

Looks good

patent pivot
#

@tawdry vapor I believe this tests multiproc resource limit sharing, just asserting that one of the child processes is SIGKILL'd ```py
def test_multiprocess_resource_limits(self):
code = dedent("""
import time
from multiprocessing import Process

        def f():
            object = "A" * 40_000_000
            time.sleep(0.5)


        proc_1 = Process(target=f)
        proc_2 = Process(target=f)

        proc_1.start()
        proc_2.start()

        proc_1.join()
        proc_2.join()

        print(proc_1.exitcode, proc_2.exitcode) 
    """)

    result = self.nsjail.python3(code)

    exit_codes = result.stdout.strip().split()
    self.assertIn("-9", exit_codes)
    self.assertEqual(result.stderr, None)
#

will commit now

tawdry vapor
#

Yeah looks good enough

patent pivot
#

pushed

patent pivot
#

!eval ```py
from multiprocessing import Process

def f():
print("1234")

proc_1 = Process(target=f)
proc_2 = Process(target=f)

proc_1.start()
proc_2.start()

proc_1.join()
proc_2.join()

print(proc_1.exitcode, proc_2.exitcode)

stable mountainBOT
#

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

001 | 1234
002 | 1234
003 | 0 0
patent pivot
#

sweet

#

cc @glacial veldt, up to 5 procs in snekbox now

glacial veldt
#

Nice tyvm

rotund light
brazen charm
# rotund light Mhmm for some people like experienced

I mean, the files themselves are easier to understand, but the bot as a whole is not as complicated as it may seem from the amount of code it has because the features more often than not don't interact with other code. But there are some features which are complicated and need to use things like scheduling

glacial veldt
#

!e

import anyio.to_thread

async def amain():
    await anyio.to_thread.run_sync(print, "hello")

anyio.run(amain, backend="trio")
stable mountainBOT
#

@glacial veldt :white_check_mark: Your eval job has completed with return code 0.

hello
glacial veldt
#

embarrassing xD

#

Thanks muchly!

#

!e
I wonder what happens if I use too many threads?

import anyio.to_thread
import time

async def amain():
    async with anyio.create_task_group() as tg:
        for i in range(6):
             tg.start_soon(anyio.to_thread.run_sync, time.sleep, 3)

anyio.run(amain, backend="trio")
stable mountainBOT
#

@glacial veldt :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 9, in <module>
003 |   File "/snekbox/user_base/lib/python3.9/site-packages/anyio/_core/_eventloop.py", line 56, in run
004 |     return asynclib.run(func, *args, **backend_options)  # type: ignore
005 |   File "/snekbox/user_base/lib/python3.9/site-packages/trio/_core/_run.py", line 1932, in run
006 |     raise runner.main_task_outcome.error
007 |   File "<string>", line 7, in amain
008 |   File "/snekbox/user_base/lib/python3.9/site-packages/anyio/_backends/_trio.py", line 141, in __aexit__
009 |     raise ExceptionGroup(exc.exceptions) from None
010 | anyio._backends._trio.ExceptionGroup: 2 exceptions were raised in the task group:
011 | ----------------------------
... (truncated - too many lines)

Full output: https://paste.pythondiscord.com/qagikodiva.txt?noredirect

glacial veldt
#

Interesting

fallen patrol
#

@patent pivot why use tox.ini for isort and not pyproject.toml for king arthur?

patent pivot
#

because then I can store isort & flake8 alongside one another

fallen patrol
#

what is the advantage to that?

#

asking because I'm configuring a toolchain right now

patent pivot
#

well, when you call flake8 it is also checking with isort that imports are compliant

#

because I use flake8-isort

fallen patrol
#

have you ever looked at using flake9 which is it a fork of a flake8 that adds pyproject.toml support?

#

!pypi flake9

stable mountainBOT
patent pivot
#

I try not to use those wrappers that add a minor feature because then it relies on the downstream keeping up to date

#

also I don't think the author of that package has conducted themselves very appropriately

patent pivot
#

so for now, it's fine in tox.ini

patent pivot
fallen patrol
#

ah

patent pivot
#

corrected, but not a great look

fallen patrol
#

(can black go in tox.ini too?)

patent pivot
#

no, pyproject is the future

fallen patrol
fallen patrol
patent pivot
#

maybe? I mean they have an open issue for it, so we'll just see

fallen patrol
#

ah

patent pivot
#

i need more things to add to king arthur i am going to brainstorm

fallen patrol
#

one last question~

#

you can call isort [tools.isort] or [isort] in tox.ini?

patent pivot
#

think it has to be tool.isort, no idea

fallen patrol
#

because the code jam called it [isort] and i think it worked

#

interesting

patent pivot
#

maybe

#

¯_(ツ)_/¯

green oriole
patent pivot
#

yea

green oriole
#

Oh events would be nice too

patent pivot
#

yeah I'm considering loading events into loki

rotund light
#

what does snekbox do?

patent pivot
#

snekbox is our evaluation application

#

when you run eval snippets with !eval

#

we don't want to run snippets on our bot because obviously that's dangerous, so we use snekbox which isolates user code safely and executes it

#

!e print("hello")

stable mountainBOT
#

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

hello
rotund light
#

Lol didnt see that 😅

remote wigeon
patent pivot
#

+1

#

loki is fun

remote wigeon
#

the metrics you can generate with it are op af

patent pivot
#

ya

remote wigeon
#

now im just annoyed that the brew formula for timescaledb is broken

#

been tryna test some shit

rotund light
#

Is there any way we can run the bot without docker?

surreal venture
surreal venture
short snow
surreal venture
#

Broken link

rotund light
short snow
#

remove the 6

surreal venture
short snow
#

poetry run task start

rotund light
#

On windows wont work

#

Poetry not found

gritty wind
#

Make sure to install it first

#

Pip install poetry

rotund light
#
Grafana Labs

Loki is a horizontally-scalable, highly-available, multi-tenant log aggregation system inspired by Prometheus. It is designed to be very cost effective and …

short snow
#

Yes you can run the bot without docker but that would make it a bit complicated making you setup postgres and site as a must, and snekbox if you want eval and redis if you want persistence across runs (it would use fakeredis if not)

#

it is ran on the system

gritty wind
#

Then install deps via
poetry install

#

This is all documented in the getting started guide

short snow
#

as a cluster component

gritty wind
#

Which you’ll really need if you plan to start contributing

rotund light
gritty wind
#

It mentions that that’s optional, and describes how to do it locally

surreal venture
rotund light
#

Down the docker line yeah I saw that and I ran that too but yeah obvio didnt work cause I didnt install

surreal venture
#

Just intall poetry first

rotund light
#

Gotcha thanks

surreal venture
short snow
#

i saw you ran sirlance a while back, how did u do that without poetry pithink docker?

short snow
#

yes

rotund light
#

I ran that with docker

short snow
#

ah

rotund light
#

But apparently idk what's happening to my laptop

short snow
gritty wind
#

If you’ve got docker, I’d recommend you at least use it for the site

gritty wind
rotund light
gritty wind
#

Does docker desktop start?

rotund light
#

Nope

short snow
#

sudo systemctl status docker.service try that, wait you are on windows, whats the alternative scal?

rotund light
#

Sudo wont work on windows

short snow
#

yeah i dunno win alternative

rotund light
#

docker

surreal venture
short snow
#

no i am checking if the docker service is running

surreal venture
short snow
#

yeah

rotund light
#

@short snow u on linux ?

short snow
#

yes

rotund light
#

That's why xd

short snow
#

systemctl show --property ActiveState docker see this, got from so

rotund light
#

Xd currently on phone

#

But idk which application to blame for my screen flickering

short snow
#

screen flickering 👀 i don't think that is a applicatin issue, probably your screen probablem

#

connect it to a monitor with HDMI or whatever and verify that ^

rotund light
#

Yup it happened before but I got to repair before

short snow
#

if you don't have monitor just use your tv

#

ah

rotund light
#

Idk what happened this time

#

But one thing it solved when I restarted my laptop

patent pivot
rotund light
#

Lol at first I thought loki from marvel

#

Btw what's redis ?

#

Found while reading the website

green oriole
#

Technically it is Loki from the Norse mythology :P

green oriole
rotund light
rotund light
green oriole
#

Yeah, it is a service, just like postgres or so

#

You can run it in a container

rotund light
#

Ah databases

rotund light
green oriole
#

I don't know much about Mongo, but I think so? Don't quote me on that though lemon_sweat

rotund light
#

Its something like this @green oriole

green oriole
#

Hmm Mongo seems more like JSON, you can have nested types - dictionaries inside dictionaries

#

You can't really do that with redis

#

At least not natively

rotund light
green oriole
#

Sure, the gist of redis is this:

> set mykey somevalue
OK
> get mykey
"somevalue"
```Set a key, get a key
#

Everything being extremely fast even if you have thousands of keys

rotund light
#

Ah now I get it

#

It's like whole bunch of dictionaries

green oriole
#

It also supports some more fancy stuff, like expirations, lists, sets..

#

It is one big dictionary, yes

short snow
#

redis is in-memory database

rotund light
green oriole
#

Haha, Redis do think like that

rotund light
#

Are all the files in bot directory like main.py and those files for proper working of cogs and resectriction or for any other purpose?

#

Like we can just do the basic way load the cogs

gritty wind
#

The init and main do call a few preparation functions such as databases, redis, and other startup stuff

#

The cogs after that are mostly modular

green oriole
#

All of our cogs can be loaded separately, but we always need the main files

rotund light
#

Ooh now I get it

dapper viper
#

hi all

patent pivot
#

if people wanna see something cool

#

😄

vocal prairie
#

Woah, that's pretty cool. Fancy new github features

fallen patrol
#

what happened to @stable mountain (#dev-log)

cold island
#

We were stressing the bot a bit, should be fine now

quartz berry
#

wow l

trail pilot
#

Uhh..?

green oriole
#

Yeah, you haven't updated the channel IDs

#

You have to set environment variables for them, if they are available

sleek steppe
#

You don't need to change most of them

trail pilot
#

Ah alright, that makes sense

viscid coral
#

I did this fork thing on github

stable mountainBOT
#

bot/exts/utils/utils.py line 53

@in_whitelist(channels=(Channels.bot_commands,), roles=STAFF_ROLES)```
static canyon
#

All you need to do is update that line to channels=(Channels.bot_commands, Channels.discord_py)

#

As far as I can tell anyway

#

@viscid coral ^

static canyon
cold island
viscid coral
static canyon
viscid coral
#

From my own forked repo?

static canyon
#

If you go to the top of the file there's a pencil you can use for editing (greyed out for me because I'm not logged in)

stable mountainBOT
#

bot/exts/utils/utils.py line 53

@in_whitelist(channels=(Channels.bot_commands,), roles=STAFF_ROLES)```
cold island
#

Although the proper approach is to edit it locally and make sure it works

cold island
#

So if anything it will be on their fork

viscid coral
#

So if I edit it on my fork

#

What than?

static canyon
#

If you'd like I can do this one and then explain what I did for next time (because I'm honestly not too sure myself) @viscid coral

static canyon
#

That's saying what the command does; I'd link it to why it needs to be allowed in #discord-bots specifically

viscid coral
#

To add rections?

static canyon
#

Possibly lead it with "In order to add a reaction in discordpy, we need the emoji's unicode. For most emojis...."

#

And the lack of space before the ( bothers me lol

#

them( --> them (

viscid coral
static canyon
#

I'd also edit the end slightly to "The best replacement for it is the !charinfo command, which currently isn't allowed in #discord-bots but I feel should be for the above reason" or something like that

static canyon
viscid coral
#

Oh lol

#
In order to add a reaction in discordpy, we need the emoji's unicode. For most emojis.... For most emotes/emojis we can do \:emoji: , but for some of them (such as numbers or letters) this option is not possible. The best replacement for it is the emoji unicode, which can be easily shown in charinfo command.```
static canyon
#

For most emojis.... For most emotes/emojis we can do :emoji:

#

Remove the leading "For most emojis..."

viscid coral
#
 In order to add a reaction in discordpy, we need the emoji's unicode. For most emotes/emojis we can do \:emoji: , but for some of them (such as numbers and letters) this option is not possible. The best replacement for it is the emoji unicode, which can be easily shown in charinfo command. The best replacement for it is the charinfo command, which currently isn't allowed in discord.py, but I feel should be for the above reason.```
I am not the best in English lmao
static canyon
#

(such as numbers or letters) -> (such as numbers and letters) (or --> and)

#

And you have "The best replacement for it..." twice

#
In order to add a reaction in discordpy, we need the emoji's unicode. For most emotes/emojis we can do `\:emoji:`, but for some of them (such as numbers and letters) this option is not possible. The best replacement for it is the `!charinfo` command, which currently isn't allowed in discord.py, but I feel should be for the above reason.
short snow
#

👀 Just open the issue who is gonna look at the grammar, if the core devs understand the issue that's enough shrug

viscid coral
static canyon
#

True lol

static canyon
#

Now then

viscid coral
#

Now the entire fork thing

green oriole
#

Oh hey, is that you? 😄

viscid coral
#

Oh hey

static canyon
green oriole
#

I am guessing you want to be assigned to the issue?

#

You can edit from GitHub, it will create a fork automatically

viscid coral
green oriole
#

yep

viscid coral
#

Oh great, so now I should edit what needed?

viscid coral
stable mountainBOT
#

bot/constants.py line 437

discord_py: int```
green oriole
#

Yeah, that's the constant

viscid coral
#

But what to edit there?

#

They all look the same format

#

I need to remove it?

green oriole
viscid coral
#

I press it in it says 404

static canyon
#

Then bot/exts/utils/utils.py

green oriole
#

ah, it is a capital i, not an l

viscid coral
viscid coral
green oriole
#

Yep, you want to add the channel to in_whitelist.channels

#

.. that's what you just did

viscid coral
#

Oh so it's ready?

green oriole
#

okay 😄 can you remove the last comma and commit?

static canyon
viscid coral
#

I did the commit

stable mountainBOT
#

bot/exts/utils/utils.py line 52

@in_whitelist(channels=(Channels.bot_commands, Channels.discord_py), roles=STAFF_ROLES)```
static canyon
#

Yep

green oriole
#

That should be good, you can open a PR now

static canyon
#

(Make sure to add "solves [#yourIssueNumber](linkToIssue)" to the PR message)

viscid coral
#

What to do here?

viscid coral
green oriole
#

huh, interesting

fervent sage
#

it works for me

green oriole
#

click compare across forks

viscid coral
#

This is what happened when I pressed the link Akarys sent

fervent sage
green oriole
#

on the left select python-discord/main and on the right NIRDERLi/main

#

Yep, that's what you want

fervent sage
#

thats right, now you just click create

viscid coral
#

Ok

#

Where should I write wat TizzySaurus said?

#

After I press create pull request?

green oriole
#

In the PR body, yes

static canyon
#

In the box that shows when you press "Create pull request"

green oriole
#

FWIW Closes #1684 is enough

#

You don't have to link it manually

viscid coral
static canyon
#

Just Closes #1684 works apparently

viscid coral
#

Oh just Closes #1684 ok

fervent sage
#

Closes #1684 is enough, github will automatically link the issue

static canyon
#

And then describe the commit you made I guess (add support for !charinfo command in #discord-bots)

green oriole
#

and a sentence or two describing the change and why

viscid coral
#

Seems like it is in the title

green oriole
#

you don't have to be as descriptive as in the issue

fervent sage
#

the whole body could be Closes #1684 - added discord.py to the channel whitelist for charinfo

viscid coral
green oriole
#

perfect

viscid coral
#

Oh ok

#

I am creating the pull request now

#

Was it already approved?

fervent sage
#

shipit is a 10/10 emote

green oriole
#

Now we just wait for linting

viscid coral
#

Thank you @green oriole , @static canyon and @fervent sage for the help!

fervent sage
#

why are there no smile emojis that arent creepy or outright terrifying lol

viscid coral
#

lol you're right

fervent sage
#

woo charinfo in ~1 min

viscid coral
#

So you can use it there now?

green oriole
#

It should be live in a couple of minutes

viscid coral
#

Oh ok

green oriole
#

You will see a message in #dev-log saying the bot started

viscid coral
#

Like that one?

fervent sage
#

yup

viscid coral
green oriole
#

Also @fervent sage, would you have, by any chance, a minute or two to spare? :3

fervent sage
#

sure!

viscid coral
#

Thank you for the help!

green oriole
fervent sage
#

anything to take my mind off the oppressive heat lol

green oriole
#

thank you sir

#

@vocal wolf hold on

vocal wolf
#

?

green oriole
#

not sure if timestamps have rolled out everywhere on iOS yet

fervent sage
#

they should be out on all platforms, if people update to the latest version

green oriole
#

Heyo @gritty wind, do you have access to discord timestamps yet? <t:0:R>

vocal wolf
#

oh lol

green oriole
#

Scale didn't have the update last time

short snow
#

yeah they have rolled out

green oriole
#

The new version is live, just not everywhere last time we checked

fervent sage
#

<t:1:R>

viscid coral
#

<t:1:R>

#

Cool, but how can I utilize it to time I want

green oriole
#

Yep, you have to paste a Unix timestamp

short snow
#

Bump, vco's commit reminded me of this

green oriole
#

Done transferring, feel free to add priority tags if you wish alec

fervent sage
#

hm that reminds me of something i was thinking of, so we all know the .github command is kinda useless now that we have inline resolving, so my proposal is that we make it focus on one PR or issue and provide extra detail, like who authored it, when it was created, and the thing that reminded me, its tags

short snow
#

i feel like none of the two issues are part of the quackstack repo as they are related to ducky_australia which are part of branding

#

aren't accessories, just emotes

green oriole
#

but the PRs will be made to Quackstack

short snow
#

do labels have a hierarchy like discord-roles?

fervent sage
#

iirc it depends on the order they're applied

short snow
#

we could put the embed colour as the priority level or maybe ^^?

#

like priority level have some colour but parse them and put accordingly?

fervent sage
#

we cant guarantee it will have a priority

short snow
#

if none, then just keep it blank

fervent sage
#

imo we should put the colour of the 'thing'

#

so an open issue is green, closed is red, etc. for prs

short snow
#

uhh, like GitHub issues are orange, prs are green when opened?

#

ok maybe

vale ibex
#

😄

#

the last letter changes what it looks like

green oriole
#

Sweet

gritty wind
viscid coral
rotund light
#

guys i am making a pokemon game

#

just letting u know before i can push

#

||and have to live up to my username 😂 ||

fervent sage
#

If it's related to a pydis bot you need to make an issue and have it approved by a core developer before adding features to the bot

fervent sage
rotund light
#

okay making one

weary pumice
#

i want to start contributing to sir lancebot

#

i just need to follow the instructions and choose an issue or?

#

or is there something else i must do beforehand?

brazen charm
#

That's mostly it, set the bot up, pick an issue, get assigned and work on it

weary pumice
#

ah that is quite nice

wild prism
weary pumice
#

allright

#

well i dont really know what the bot does tbh, im just in for some python experience

#

taking a break from my main lang and exploring some other langs

gritty wind
#

100%

vale ibex
#

Just remember us when you're famous

weary pumice
#

😳

#

he has vector in dirac notation for profile pic?

#

he must be based

rotund light
viscid coral
#

Permission for what?

fervent sage
rotund light
gritty wind
#

Anyone play around with the new issue template features?

#

It seems contact info overrides any other templates

#

Can't figure out how to get everything to show up

#

I take that back, it seems to be the blank issues flag that does it

#

hmm that's not it either, I've removed the entire file lol

short snow
#

how do u make one? I cannot see any place in the UI to do so? just write the yaml and push it?

gritty wind
#

It'll prompt you in various places, such as the settings tab, but you can also just push it

gritty wind
#

That's nice and all, but it really doesn't solve the problem lol

#

I figure it's because I was testing on a repo that doesn't have it enabled

#

I'll push it to the actual forms repo and see how that goes

green oriole
#

templates are opt-in waiting list beta, so if you aren't in it, that ain't going to work

short snow
#

Re: pixels#122

Nice idea but wouldn't this increase the moderation task on the API, basically say a use authenticates himself with Google, Discord, and GitHub, so he has 3 accounts. If you want to ban him, you would need to get his other two accounts too which can only be done through email checking on the three accounts, (which wouldn't really be liked by many, storing their emails). I can only see this way to completely ban a user from the pixel API from all their accounts.

dusky shoreBOT
vale ibex
#

If we were to go ahead with this issue, all of the authentication methods would point to the same user

short snow
#

According to the status:WIP I think this was discussed in the pixels dev channel so I didn't take it up on the Github issue and rather asked it here.

Umm how would you point to the same user?

green oriole
#

We would require you to link your Discord account when activating the other auth methods, I'd say?

short snow
#

Oh i didn't think of that, that could be a nice way

green oriole
#

Like, you must get a token from your browser first for OAuth, I'm pretty sure. We could have an /activate_token endpoint that will make your OAuth code start working but for that you need a Pixels token to perform the request.

brisk brook
brisk brook
#

Also you may be confused with the scope of the issue, I don't mean adding several ways for someone to get a pixel token. As in having sign up with GitHub, sign up with Discord, sign up with Google.

I mean that there should be several ways for someone to interact with the pixels API. So we may have JWTs (like now), username + password type of thing, OAuth2, and other interesting technologies.

#

I hope that cleared it up for you

patent pivot
#

@tawdry vapor how realistic is it to enable /dev/shm in snekbox

#

multiprocessing and a few other async tools rely on shared mem

tawdry vapor
#

If we can find a way to set limits on it then we could enable it

#

It was disabled due to an exploit that allowed using unlimited memory

patent pivot
#

ahh

#

yeah that rings a bell

#

hmm so

tawdry vapor
#

There might be a cgroup for it, IDK

patent pivot
#

the mount would look like ```
mount {
dst: "/dev/shm"
fstype: "tmpfs"
rw: true
}

tawdry vapor
#

But it is separate from the normal memory one

patent pivot
#

so we just need to figure if nsjail can limit the sizes of the tmpfs' it allocates

tawdry vapor
#

I think that is all you have to do, yes.

patent pivot
#

I'll have a look into it, thanks for confirming

#
--tmpfsmount|-T VALUE
    List of mountpoints to be mounted as tmpfs (R/W) inside the container. Can be specified multiple times. Supports 'dest' syntax. Alternatively, use '-m none:dest:tmpfs:size=8388608'
#

size arg indicates it supports a limit

#

it might be as simple as throwing size in that map? huh

tawdry vapor
#

Perhaps. I never used that before.

stable mountainBOT
#

config.proto lines 41 to 42

/* E.g. size=5000000 for 'tmpfs' */
optional string options = 7 [default = ""];```
patent pivot
#

yep, just stumbled across that myself

#

will give it a test locally to verify it behaves as expected, since we're only doing 2 parallel execs we can safely allocate 50mb per execution for shared mem

tawdry vapor
#

So that's like 200mb total for memory?

#

50+50 for each gunicorn worker

#

Plus whatever the Falcon app uses

patent pivot
#

yep, 200mb total possible for executions and then just overhead

vale ibex
green oriole
#

!server

stable mountainBOT
#
Server Information

Created: <t:1483877013:R>
Voice region: europe
Features: WELCOME_SCREEN_ENABLED, BANNER, ANIMATED_ICON, RELAY_ENABLED, VIP_REGIONS, DISCOVERABLE, INVITE_SPLASH, THREE_DAY_THREAD_ARCHIVE, NEWS, COMMUNITY, PREVIEW_ENABLED, PARTNERED, VANITY_URL, PRIVATE_THREADS, MEMBER_VERIFICATION_GATE_ENABLED, SEVEN_DAY_THREAD_ARCHIVE
Roles: 86
Member status: status_online 48796 status_offline 181374

Members: 230170

Helpers: 121
Moderation Team: 33
Admins: 15
Owners: 3
Contributors: 39

Channels: 292

Category: 32
News: 8
Staff: 69
Stage_Voice: 1
Text: 174
Voice: 8

green oriole
#

Look, I am a good dev now

vale ibex
vocal prairie
vale ibex
#

That's what ctx.guild.region returns

vocal prairie
#

I wonder why Discord does that

vale ibex
#

We could capitilise I guess

green oriole
#

Let's capitilise it

vale ibex
#

these are the possible values

green oriole
#

I don't think I have any right to joke on spelling now lemon_zipped

vale ibex
#

with there being some with underscores, not sure just capitilising will make it better

green oriole
#

I guess you don't always capitalize enum options

vale ibex
#

Also, I guess we're not important enough for vip_amsterdam sadge

green oriole
#

Why aren't we on VIP regions actually?

vale ibex
#

They've been phased out

#

partners and verified servers are upgraded to a high bitrate on all regions

green oriole
#

Interesting

summer garden
wild prism
#

nice

vale ibex
#

Lmfao @green oriole

green oriole
#

What again

vale ibex
#

Did you also struggle and do it via Web ui?

green oriole
#

I don't want to grab my laptop again

vale ibex
#

I did the same

green oriole
#

Yea

#

Haha

#

We have two PRs

#

Great

vale ibex
#

Oh yea

green oriole
#

I trust yours more than mine

vale ibex
#

I would lol

green oriole
#

Oh actually, I can't approve

vale ibex
#

I had to make 2 branches because of autocorrect lol

green oriole
#

Haha

vale ibex
#

I had to load desktop version on my phone to approve it

green oriole
#

Yay, that's probably the most risk I ever took to make a PR

vale ibex
#

Lol

green oriole
#

Glad it is merged

patent pivot
#

hmm, I can't find a great way to figure out if /dev/shm limiting is working

#

well

#

when I try this poc I get exit code 135

nsjail conf:

mount {
    dst: "/dev/shm"
    fstype: "tmpfs"
    rw: true,
    options: "size=12"
}

python:

            from multiprocessing.shared_memory import SharedMemory
            try:
                mem = SharedMemory('test', create=True, size=128_000)
                mem.buf[:128_000] = bytearray([1] * 128_000)
            except FileExistsError:
                pass
#

but it seems to have to be significantly higher to trigger it

patent pivot
#

hmm, if I try ```
mount {
dst: "/dev/shm"
fstype: "tmpfs"
rw: true
is_bind: false
options: "size=10M"
}

and ```py
            with open("/dev/shm/test", "w") as f:
                f.write("H" * 15_000_000)

I get Traceback (most recent call last):\n File "<string>", line 2, in <module>\nOSError: [Errno 27] File too large\n

#

which seems promising

#

and now with multiprocessing shm I can reproduce that ```py
from multiprocessing import shared_memory
shm_a = shared_memory.SharedMemory(create=True, size=15_000_000)
shm_a.buf[:15_000_000] = bytearray([1] * 15_000_000)

#

my guess is that the tiny byte limits aren't enforced by the kernel

#

I'm going with 40mb of shm

#

hmmm

#

hmmm

#
Traceback (most recent call last):
  File "<string>", line 8, in <module>
  File "/usr/local/lib/python3.9/multiprocessing/context.py", line 119, in Pool
    return Pool(processes, initializer, initargs, maxtasksperchild,
  File "/usr/local/lib/python3.9/multiprocessing/pool.py", line 242, in __init__
    self._task_handler.start()
  File "/usr/local/lib/python3.9/threading.py", line 892, in start
    _start_new_thread(self._bootstrap, ())
RuntimeError: can't start new thread
#

I wonder what limit this is

#

okay so

#

it's the PIDs limit

#

because even with pool size two multiprocessing seems to be trying to spawn over 5 threads?

#

okay, because it allows mp.Pool to work, I'm going to set the PIDs limit to 6

tawdry vapor
#

Is it related to

processes is the number of worker processes to use. If processes is None then the number returned by os.cpu_count() is used.

#

How reliable is setting it to 6? Ideally we should understand why 6 works

sharp timber
#

!e print(import('os').cpu_count())

stable mountainBOT
#

@sharp timber :white_check_mark: Your eval job has completed with return code 0.

2
sharp timber
#

There are three handler threads within Pool(), 2 PID's for the pool threads, and presumably one more for the main thread

#

!e ```py
import multiprocessingimport multiprocessing
import threading

if name == "main":
multiprocessing.set_start_method('fork')
pool = multiprocessing.Pool()
print(threading.get_ident())
print(pool._worker_handler.ident)
print(pool._task_handler.ident)
print(pool._result_handler.ident)
print(pool._pool)

#

Won't run cause shm isn't enabled rn I think?

#

My machine gives:

#
4445253128
123145553616898
123145570406402
123145587195906
[<ForkProcess name='ForkPoolWorker-1' pid=1129 parent=1113 started daemon>, <ForkProcess name='ForkPoolWorker-2' pid=1130 parent=1113 started daemon>, <ForkProcess name='ForkPoolWorker-3' pid=1131 parent=1113 started daemon>, <ForkProcess name='ForkPoolWorker-4' pid=1132 parent=1113 started daemon>, <ForkProcess name='ForkPoolWorker-5' pid=1133 parent=1113 started daemon>, <ForkProcess name='ForkPoolWorker-6' pid=1134 parent=1113 started daemon>, <ForkProcess name='ForkPoolWorker-7' pid=1135 parent=1113 started daemon>, <ForkProcess name='ForkPoolWorker-8' pid=1136 parent=1113 started daemon>]
#

4+workers

tawdry vapor
#

What determines cpu_count in our prod env?

#

I think what we would need to do is check the configured PID limit and override it if it's insufficient for creating a pool

#

By comparing the config against 4 + cpu_count

#

That being said, I also don't want to force users to allow a high PID count. Maybe there needs to be an optional argument to enable what I described above.

patent pivot
#

!int e print(import("os").cpu_count())

stable mountainBOT
#
In [1]: print(__import__("os").cpu_count())
4```
patent pivot
#

that's interesting

patent pivot
#

diff CPU count in snekbox

stable mountainBOT
#

@clever wraith :white_check_mark: Your eval job has completed with return code 0.

2
brisk brook
#

Wat

eternal owl
cold island
#

Hmm the new native relative timestamps lack granularity. I want to know how many parts of a year passed, and not just full years

#

!server

stable mountainBOT
#
Server Information

Created: <t:1483877013:R>
Voice region: europe
Features: THREE_DAY_THREAD_ARCHIVE, PRIVATE_THREADS, MEMBER_VERIFICATION_GATE_ENABLED, ANIMATED_ICON, PREVIEW_ENABLED, VANITY_URL, PARTNERED, WELCOME_SCREEN_ENABLED, INVITE_SPLASH, RELAY_ENABLED, DISCOVERABLE, COMMUNITY, BANNER, VIP_REGIONS, NEWS, SEVEN_DAY_THREAD_ARCHIVE
Roles: 86
Member status: status_online 50455 status_offline 180164

Members: 230619

Helpers: 121
Moderation Team: 33
Admins: 15
Owners: 3
Contributors: 39

Channels: 293

Category: 32
News: 8
Staff: 70
Stage_Voice: 1
Text: 174
Voice: 8

cold island
#

As far as I'm aware there's only one format for relative time

green oriole
patent pivot
viscid coral
patent pivot
vocal wolf
#

Early devops hour with joe?

#

Hello yes

twilit juniper
#

kinda

#

but it's just him shit posting

vocal wolf
#

understandable

twilit juniper
#

I mean it's joe what do you expect

vocal wolf
#

I expect it.

#

I can't english either

twilit juniper
#

Same

clever wraith
#

is this the text channel for the dev-voice channel?

clever wraith
fringe sphinx
#

the inside of joe banks is abusive lemon_angrysad

vocal wolf
#

dev voice happens so little that there isn't anything else

twilit juniper
#

Yeah and it's not open to all people all the time

vocal wolf
#

@clever wraith so forgetting is just you segfaulting

twilit juniper
#

Just Contributes I think

clever wraith
#

so this is a rare privilege!

slow steppe
vocal wolf
#

@vale ibex I shall review your PR this instant, if you are awake.

brisk brook
#

Dereferenced NULL pointer

vocal wolf
#

the sir lance one

fringe sphinx
patent pivot
fringe sphinx
#

my easter egg submission is unbeatable

slow steppe
#

No mine is

fringe sphinx
clever wraith
#

damn, this is hella intresting and I have no idea what's going on

slow steppe
#

Vco said mine is the best therefor it is

fervent sage
fringe sphinx
fringe sphinx
slow steppe
#

I'll dm it

vocal wolf
#

There's a lot of people here. You know what this means.

#

tryhard triage time

fringe sphinx
#

ttt

vocal wolf
#

yes

clever wraith
#

what's the issue btw?

vocal wolf
clever wraith
vocal wolf
#

we are

#

I just need to allocate issues/PRs to different people

fringe sphinx
#

ok it is a beautiful easter egg

vocal wolf
#

@hollow cedar I knew I recognized your voice lol

#

I didn't see your name though so I thought I was going crazy

fringe sphinx
#

I've never heard their voice

clever wraith
#

this is great, there's so much going on

fringe sphinx
#

i wish I could listen in lol

#

can someone transcribe everything for me

vocal wolf
fringe sphinx
#

transcribe it in multiple lines

clever wraith
#

hahaha

fringe sphinx
#

🙄

#

get creative

vocal wolf
#

@wild ridge greetings.

fringe sphinx
#

why are they called pull requests? aren't they really push requests?

#

anyone can pull

#

but you need to request to actually make changes

fervent sage
#

youre requesting to pull your code into the main branch

fringe sphinx
#

but isn't that pushing your code

vocal wolf
#

nah

#

if you're main

#

and there's a different branch

#

you're pulling the other branch toward you

clever wraith
#

it doesn't happen until you're pulled in

fringe sphinx
#

but I'm not main

fervent sage
brisk brook
#

NDA vs. Freedom of Speech

#

Who would win?

vocal wolf
#

Alright

#

here's another PR for review

fringe sphinx
#

because you're doing it

fervent sage
#

no cause youre not

#

youre requesting

hollow cedar
fervent sage
#

for someone else to pull it

fringe sphinx
#

this is so confoozling

vocal wolf
#

hello @mellow hare

fringe sphinx
#

hi

slow steppe
#

@patent pivot would you use this as your Mac terminal theme?

clever wraith
#

is there a description here of the tech stack that powers the discord server?

vocal wolf
#

@vale ibex sir-lancebot#790 merged. Thank you @fervent sage for the review.

dusky shoreBOT
vocal wolf
#

lmfao

mellow hare
#

Hi Xith

fringe sphinx
fervent sage
#

yes

mellow hare
#

You're awesome

#

That is all

fringe sphinx
#

oh

vocal wolf
#

:D

fervent sage
#

youre cool

mellow hare
#

I mean that's objectively false

vocal wolf
#

I was literally about to ask you to review stuff hem

#

are you available for that

mellow hare
#

Which stuff?

vocal wolf
#

infraction type stuff

mellow hare
#

I can try to be yeah

fervent sage
#

hem youre too hot and want the sun to go away

mellow hare
#

Just just toss me the pr

fringe sphinx
#

it's all part of his master plan

mellow hare
mellow hare
vocal wolf
#

@mellow hare (and anyone else, if you're up to it) bot#1682, bot#1680.

fervent sage
#

oh i thought i approved the second one a while back lol

fringe sphinx
#

I am bad at contributioning so that'll be a pass

hoary anvil
#

28 people in vc O_O

fervent sage
#

i tested and apparently forgot to approve

fringe sphinx
#

30

#

31

#

30

#

numbers be weird

hoary anvil
#

/O_O\

mellow hare
#

This is typically why I cap it at 25 in the other VCs

#

This is a special case going on

fervent sage
#

we shouldnt have changed the perms lol

clever wraith
hoary anvil
#

but at least it isn't windows

fringe sphinx
fervent sage
#

where is redis

fringe sphinx
#

getting dissed

#

again

#

redissed

clever wraith
brisk brook
#

The thing is, it's so easy to just gender someone correctly and it shows so much in terms of respect.

fringe sphinx
#

nope

hoary anvil
#

worked fine for me
depends on the linux distro, perhaps
or the pc

vocal wolf
mellow hare
#

Dude and yall

fervent sage
#

yes, if im understanding right

#

you can add multiple remotes and pull/checkout from any

slow steppe
clever wraith
hoary anvil
fervent sage
#
git remote add <name> <repo>
git checkout my-remote-branch
fringe sphinx
vocal wolf
brisk brook
hoary anvil
fringe sphinx
#

it's hard, I tend to default to he/him/his too

slow steppe
fringe sphinx
#

but it's respectful

vocal wolf
hoary anvil
clever wraith
#

language is a weapon folks, learn how you're being manipulated, and navigate from there

patent pivot
#

let's try keep dev contrib on topic for dev stuff, we are in dev voice right now 😃

fervent sage
#

i dont have the mental capacity rn to explain git stuff sorry

clever wraith
#

might be a good idea to build another channel just for the meta for this one

fervent sage
mellow hare
patent pivot
#

cheers hem

mellow hare
#

But it's likely better to scoot down to the other channels

fervent sage
#

all the chatter belongs in the non dev vcs and vc chats tbh

mellow hare
#

Yes yes I know

patent pivot
fervent sage
#

x-test: b

#

success!

vocal wolf
#

how do you ping a voice channel again

fervent sage
#

#!

slow steppe
#

<#id>

thorny obsidian
#

@patent pivot maybe you want to disable devops alerts? =P

vocal wolf
#

an organized clusterfuck

mellow hare
vocal wolf
#

holy shit

#

@mellow hare Please review those PRs if you're able to. On a completely different note: morning.

mellow hare
#

Yes yes yes

vocal wolf
#

yes

#

@twilit juniper destroyed.

#

@fervent sage what's in the makefile lol

fervent sage
#

uh

green oriole
#

/shrug

#

I don't know the library

vocal wolf
#

understandable, have fun at <place>

vale ibex
#

It was a very nice place

#

It had sheep, cows and llamas

#

I had a burger for dinner and was wondering if it was one of the cows family

#

Gotta love British countryside pubs

vale ibex
#

Anyone know who NotFlameDev on GitHub is on here?

vale ibex
#

haha yea just saw that myself

#

already updated 👌

patent pivot
#

for what service

#

I will when I get time.

static canyon
dusky shoreBOT
stable mountainBOT
#

bot/exts/info/doc/_cog.py lines 341 to 347

if doc_embed is None:
    error_message = await send_denial(ctx, "No documentation found for the requested symbol.")
    await wait_for_deletion(error_message, (ctx.author.id,), timeout=NOT_FOUND_DELETE_DELAY)
    with suppress(discord.NotFound):
        await ctx.message.delete()
    with suppress(discord.NotFound):
        await error_message.delete()```
patent pivot
#

@clever wraith that's site

dusky shoreBOT
patent pivot
#

yeah it should just be that

#

it's just one instance on one node

#

no, one total

#

yeah

#

will get scraped

#

uhhh

#

yea

static canyon
# patent pivot yeah it should just be that
## towards top of file
DELETE_ERROR_MESSAGE_REACTION = '\u274c'  # :x:

...
# inside command
error_message = await send_denial(ctx, "No documentation found for the requested symbol.")

if ctx.message.mentions or ctx.message.role_mentions:
    await error_message.add_reaction(DELETE_ERROR_MESSAGE_REACTION)

    try:
        await self.bot.wait_for(
            'reaction_add',
            check=lambda reaction, user: reaction.message == error_message and user == ctx.author and str(reaction) == DELETE_ERROR_MESSAGE_REACTION,
            timeout=NOT_FOUND_DELETE_DELAY
        )
        
        with suppress(discord.HTTPException):
            await error_message.delete()

    except asyncio.TimeoutError:
        await error_message.clear_reaction(DELETE_ERROR_MESSAGE_REACTION)

else:
    await wait_for_deletion(error_message, (ctx.author.id,), timeout=NOT_FOUND_DELETE_DELAY)
    with suppress(discord.NotFound):
        await ctx.message.delete()
    with suppress(discord.NotFound):
        await error_message.delete()
```maybe something like this?
#

Not sure if the two suppressions are necessary in the else but the current code does 2 so just copied

static canyon
#

Does this look right for merging a PR from my fork to Pydis?

patent pivot
#

yep!

static canyon
#

Let's hope this works then lemon_grimace

#

Need to fix some linting

viscid coral
#

What does that mean?

placid ermine
#

that linting failed, specifically:

viscid coral
#

line too long?

#

Is that a thing

thorny obsidian
#

Black isn't compatible with our style guidelines. We do have a pre-commit hook people can use if they want.

viscid coral
#

Oh

#

How can I see the line that is too long?

gritty wind
#

Hey have a look at our contributing guide to learn how to setup all our tools (linting with flake, and pre-commit)

static canyon
#

Let's see if this works

#

God damn it

#

Don't understand that

#

Is there any error in the code?

#

Forgot to import partial

#

Missing a , now lol

vale ibex
#

You can do poetry run task precommit to install the pre-commit hooks

#

Assuming you have done poetry install already

static canyon
#

I really should be can't be bothered to set everything up on my laptop lol

#

Did on my PC and it was a real hassle for me

#

Can't figure out what's wrong now lemon_grimace

#

Not got any errors in my IDE

gritty wind
#

You have trailing white space on a few lines

#

Like:
‘print(“hi, notice the space after me”) ‘

#

I really wouldn’t recommend using the CI as your personal linter, it’ll probably be more hassle than it’s worth

brisk brook
static canyon
#

PyCharm

static canyon
gritty wind
#

That’s what the CI is saying currently

#

I’m on mobile so it’s a bit hard to pull the actual line

static canyon
#

Think I found one line at the end

gritty wind
#

If you run the hook locally, it’ll actually fix it for you

static canyon
#

I can't run it locally cause I haven't set it up

#

Can't find any trailing whitespace either

#

Gonna try setting everything up on my laptop

vale ibex
#

There's no rush on making these changes, if you wanted to wait until you were back at your PC

#

Also, if you run into any issues feel free to ask here

static canyon
#

I really can't figure this out

#

I've downloaded everything into PyCharm, and have installed dependencies via poetry

#

Then copy-pasted the code I committed into PyCharm and the only issues are ones that isn't really to what I did (e.g. Unresolved attribute reference 'trace' for class 'Logger' and Unresolved attribute reference 'endswith' for class 'ValidURL')

#

But if those are errors then why is the bot working right now?

brazen charm
#

They're not errors, just the static checker not understanding non type hint annotations and dynamic code

static canyon
#

Right, but then what's the issue with my code that's making the lint fail?

thorny obsidian
#

A trailing whitespace somewhere

static canyon
#

But there isn't one

#

I've even done a regex search

thorny obsidian
#

let me take a look

brazen charm
#

L471 and 472 have whitespace that shouldn't be there, maybe some others too

vale ibex
#

When you run the pre-commit hook, it fixes those for you, but doesn't stage the changes

vale ibex
#

so you it might look like there aren't any trailing spaces in your code because they've already been fixed by the hook

#

poetry run task precommit to install the hook

#

It'll run automatically on commit, or you can run manually by doing poetry run task lint

static canyon
#

God damn it more lint errors xD

vale ibex
#

Something that's really nice with GitHub, is that if a lint action fails, the lines will be highlighted in the files changed tab

static canyon
#

At least it says these ones

tough imp
#

You can also configure pycharm to strip trailing whitespace on each save

#

it's not something you should have to look for manually

static canyon
#

I202: Additional newline in a group of imports. 'from discord.ext.commands import BadArgument, Cog, Context, group, has_any_role' is identified as Third Party and 'from discord import Colour, Embed, Message, NotFound, Reaction, User' is identified as Third Party.
How do I fix this?

vale ibex
#

It doesn't like the blank line on line 16

static canyon
#

Wait sorry misread

#

I'll remove that

#

[flake8] F402: import 'group' from line 16 shadowed by loop variable
I can't find this "loop variable"?

#

Ah got it

#

Finally succeeded. Now need to make some changes

#

@brazen charm If I undo the "style changes" I'll have```py
def predicate_emoji_reaction(ctx: commands.Context, error_message: discord.Message, reaction: discord.Reaction, user: discord.User) -> bool:

#

I can do```py
def predicate_emoji_reaction(ctx: commands.Context, error_message: Message, reaction: Reaction, user: User) -> bool:

brazen charm
#

you can split up the definition

static canyon
brazen charm
#

the one other definitions in the cog use

static canyon
#

So I should keep the full thing with the imports?

#
def predicate_emoji_reaction(
    ctx: commands.Context,
    error_message: discord.Message,
    reaction: discord.Reaction,
    user: discord.User
) -> bool:```
brazen charm
static canyon
#

Yeah I'll make it a util

#

What would be a good function name?

#
                    with suppress(discord.NotFound):
                        await ctx.message.delete()
                    with suppress(discord.NotFound):
                        await error_message.delete()```and do we need two suppresses here?
tough imp
#

if you had:

with suppress(discord.NotFound):
  await ctx.message.delete()
  await error_message.delete()

the second delete will not execute if the first one fails

static canyon
#

Ah, I see

static canyon
brazen charm
#

delete_if_no_mention or something like that, I'm not particularly good at naming

static canyon
#

the pypi command and possibly others in the future also delete invalid invocations, we should extract this to an util function under utils.messages instead of only implementing the functionality for this cog.
So it'd be something like```py
async def delete_if_no_mentions(ctx, error_message):
if ctx.message_has_mentions:
# don't delete invocation message
# allow deletion of error_message through reaction

else:
    # wait then delete ctx.message and error_message```?
#

And should I make this a separate issue? (since is no longer strictly relevant to the "prevent ghost pings")

#

CC @brazen charm

brazen charm
#

I think doing a deletion under a mentions condition would be enough, as the caller can do its own wait_for_deletion on the bot response message. maybe don't need an util at all then, with just your if around the ctx.message deletion, although it would be a bit nicer

#

Unless I missed something and handling the reaction deletion on its own is required, didn't look into it in depth

static canyon
#

So might as well have it as part of the function

brisk brook
static canyon
#

That wouldn't necessarily work

#

Because what you delete after reaction is different to if there's no mentions

#
if message.mentions or message.role_mentions:  # has mentions
    if reacts:
       delete_error_message()
else:  # no mentions
    wait()
    delete_invocation_message()
    delete_error_message()
#

Maybe ```py
if has mentions:
if reacts:
return True
return False

wait()
delete_invocation_message()
return True
```then if it returns True, delete error_message

#

That could work

#

Or even```py
delete_invocation_message, delete_error_message = call_util_func()
if delete_invocation_message:
await ctx.message.delete()

if delete_error_message:
await error_message.delete()```

brisk brook
#

Wait now I am confused, what is the difference between the code you made and wait_for_deletion()?

#
async def wait_for_deletion(*args, **kwargs) -> None:
    """..."""
    if message.guild is None:
        raise ValueError("Message must be sent on a guild")

    if attach_emojis:
        for emoji in deletion_emojis:
            try:
                await message.add_reaction(emoji)
            except discord.NotFound:
                log.trace(f"Aborting wait_for_deletion: message {message.id} deleted prematurely.")
                return

    check = partial(
        reaction_check,
        message_id=message.id,
        allowed_emoji=deletion_emojis,
        allowed_users=user_ids,
        allow_mods=allow_mods,
    )

    with contextlib.suppress(asyncio.TimeoutError):
        await bot.instance.wait_for('reaction_add', check=check, timeout=timeout)
        await message.delete()

*truncated

brazen charm
#

as I understand it something like this should be enough. The error message should be deleted unconditionally as it won't ever contain mentions, and has no information beyond stating that the lookup failed

                    await wait_for_deletion(error_message, (ctx.author.id,), timeout=NOT_FOUND_DELETE_DELAY)
                    if has_mentions(ctx.message):
                        with suppress(NotFound):
                            await ctx.message.delete()
                    with suppress(NotFound):
                        await error_message.delete()
static canyon
#

This is what Akary's put. They suggested only deleting the error message if you react so went with that

#

The key thing is ctx.message doesn't get deleted when there's mentions

brisk brook
#

Ah! Okay I understand now

#
            if doc_embed is None:
                error_message = await send_denial(ctx, "No documentation found for the requested symbol.")
                await wait_for_deletion(error_message, (ctx.author.id,), timeout=NOT_FOUND_DELETE_DELAY)
                if not ctx.message.mentions or not ctx.message.role_mentions:
                    with suppress(discord.NotFound):
                        await ctx.message.delete()
                with suppress(discord.NotFound):
                    await error_message.delete()
            else:
                msg = await ctx.send(embed=doc_embed)
                await wait_for_deletion(msg, (ctx.author.id,))
#

Can't we just do that then?

#

Add an if-statement for deleting ctx's message only

static canyon
#

I think Numerlor wanted some of this as a util

brazen charm
#

it'd be nice if the conditional deletion was an util, but it's fairly short so not required. When I was thinking of an util I didn't realize we can just wrap it in a conditional

brisk brook
static canyon
#

Would we want Emojis.trashcan or Emojis.cross_mark?

brisk brook
#

I want to say the latter, but the former may be more fitting. Gonna double-check with how Emojis.cross_mark has been used previously.

static canyon
#

I'm thinking Emojis.cross_mark too

brazen charm
#

where would it be used?

static canyon
#

The reaction you use to delete error_message

sleek steppe
#

it should be a trashcan then

static canyon
#

We use ❌

#

(I think)

brazen charm
#

It's already a trashcan through wait_for_deletion

#

Your code doesn't need to touch that

static canyon
#

!pypi d

stable mountainBOT
#

Documentation generation that won't make you tear your hair out.

brisk brook
static canyon
#
error_message = ...

await wait_for_deletion(error_message, (ctx.author.id,), timeout=NOT_FOUND_DELETE_DELAY)

if not (ctx.message.mentions or ctx.message.role_mentions):
    with suppress(discord.NotFound):
        await ctx.message.delete()```so this should be what we want right?
brisk brook
#

You are accidentally closing wait_for_deletion() before all arguments have been passed

static canyon
#

yep

brisk brook
#

Ah, now that looks correct yeah.

static canyon
#

Also

#

Actually nvm

brisk brook
#

Push that and I'll review it