#dev-contrib

1 messages · Page 57 of 1

patent pivot
#

You can't make an inventory for any package

#

We don't make the inventories

green mesa
#

Then how py bot does scraping of docs?

brazen charm
green mesa
#

Oooo

brazen charm
#

if coc.py doesn't have that inventory the doc cog can't do anything with it

green mesa
#

How can I check that

patent pivot
#

and we can add them with

#

!doc set

stable mountainBOT
#

Missing required argument package_name.

#
Command Help

!docs set <package_name> <base_url> <inventory_url>
Can also use: docs s

*Adds a new documentation metadata object to the site's database.

The database will update the object, should an existing item with the specified package_name already exist.

Example:
!docs set python https://docs.python.org/3/ https://docs.python.org/3/objects.inv*

green mesa
#

So can I store this data in db

#

Like bot make inventory url and store in db and when someone fire command bot look there

patent pivot
#

you need to find the inventory URLs, but yes

brazen charm
#

If they don't have the inventory then your choices are pretty much only getting the urls for every symbol yourself or redesigning the whole cog

green mesa
#

Actually I love to do programming but I am a very big noob and where I live programming is not so appreciated I don't know y so sorry if I disturb you much ,I only have this server to clear my doubts

clever wraith
#

!issue #419

#

!issue 419

#

.issue 419

dusky shoreBOT
clever wraith
#

@patent pivot where can these emojis be found?

patent pivot
#

hmmmmmm

clever wraith
#

?

#

the pr emojis

patent pivot
#

I know

#

I was looking for them

clever wraith
#

oh

#

can i use them in my bot

patent pivot
#

uhh

#

probably

clever wraith
#

k

patent pivot
#

right click > copy link > save image

clever wraith
#

wow

#

i can save em?

patent pivot
#

I don't see a reason why not

brazen charm
#

Would some stats be wanted for the doc (something like fetched package) joe? slowly reworking parts of it so can throw those in

patent pivot
#

oh that'd be super dope

#

yeah

#

hmm you know

#

maybe we could do the whole symbol

#

flask.Response or whatever

#

docs_fetches.flask.Response

#

@brazen charm

brazen charm
#

Stat for the individual symbol counts?

patent pivot
#

because if we want total number of flask we can do doc_fetches.flask.*

#

hmmm

#

let me see

brazen charm
#

There's a lot of individual symbols that'd can potentially be fetched, not familiar with the stats but could that be an issue?

patent pivot
#

shouldn't be, I'm just going to check

#

the thing I'm not so sure about is nesting

woeful thorn
patent pivot
#

ahhh

clever wraith
#

nice

#

thanks @patent pivot @woeful thorn

cold moon
#

I have 2 ideas for PyDis GitHub bot: (Note: Both suggestions is for Contributors in this server only. Giving these permissions to everyone will be too risky to be abused, but I think Contributors is enough trusted for these.)

  1. Make possible to add some labels with defining them in title of issue/PR. Example: [level:0][planning][area:api,moderation] My issue should add these labels to issue/PR (don't add planning to PR, in PRs WIP should available). This should not apply to all labels, like priority is something that users can't measure themself I think. After applying labels, this should edit title and remove labels from there.

  2. Add possibility to self-assign to issue with attaching [assign] at start of comment. This should not do this when some user is already assigned. This should automatically assign WIP label too.

brazen charm
#

The titles would be way too messy with that info included

cold moon
#

I mean, title should automatically edited after labels added by bot.

patent pivot
#

@cold moon I like the ideas

#

not so sure about the [assign]

#

i like the natural language bots

#

like

#

I would like to work on this issue.

brazen charm
#

Title changes will be kept in the PR so I don't think putting it there if it's deleted right away would be nice

woeful thorn
#

It's also totally non-discoverable

tough imp
#

I wonder whether it'd be possible to automatically transfer area tags from the linked issue, if there is one

#

but I guess there can be multiple

cold moon
#

Maybe yes verbose version for assigning is better

#

Maybe for @dusky shore there should available [season:<season>] label assigning, when SeasonalBot will use GitHub bot too in one day.

patent pivot
#

SeasonalBot does use it

#

It's currently down because I upgraded to macOS Big Sur and I'm just going to deploy it to K8S instead of set it up locally

#

I also think labels is something that core devs should be assigning kind of

#

since things have been mislabelled before where people don't get the labels and such

#

and it's kind of the purpose of this chat to communicate with core devs

#

pinging a core dev and asking for an assignment of labels is fine if we haven't already got to it

green mesa
#

How bot decide we are talking asking about discord or datetime like !d discord.clinet or !d datetime😅

brazen charm
#

As I mentioned, it uses the pregenerated inventory those doc pages provide. That's then parsed into the inventories dict of the cog. For example the entry for discord.Client looks like this "discord.Client": "https://discordpy.readthedocs.io/en/stable/api.html#discord.Client"

#

The packages aren't differentiated, it's just one big dict of symbols

green mesa
#

Ok

green mesa
#

Means bot only need this url = https://discordpy.readthedocs.io/en/stable/api.html/objects.inv and it breaks when command is fired plz correct if I am wrong

brazen charm
green mesa
#

I meant it breaks into base url and package name auto?

brazen charm
#

with the site set up, you use the commands joe has shown above to add the inventory url and that adds all the symbols to the dict

green mesa
#

Ty

clever wraith
#

@green mesa help me yaar

green mesa
#

Ahhh actually u have to ask for help in help section

clever wraith
#

ok

green mesa
#

This is dev contrib channel

clever wraith
#

anyway, we're from same area, where coding isn't much know

#

lol

green mesa
#

Plz read the topic

clever wraith
#

yes

#

@green mesa DM me when free

gusty sonnet
#

@clever wraith We don't encourage helping 1v1 via DM, you can definitely get one of the free help channel / ask in a topical chanel, that way others who have similar questions can benefit from the conversation as well

clever wraith
#

@gusty sonnet it's not for help, he's my friend

gusty sonnet
#

I assumed that you needed help from your message. If you ever need help for specific python question, please do ask in the server instead

cold moon
#

One more suggestion about GitHub bot. Not high-priority, but maybe good:

  • When user who don't have write access approve PR, bot should give approval too. Currently core devs have to force-merge PRs, because not enough review, but this will remove it. Also maybe this help to display better in GitHub UI.
patent pivot
#

We don't need to force merge, another core dev adds an approval

split nexus
#

Yes, I got the seasonalbot running on my Raspberry Pi. Took me 'only' two days...

green oriole
#

Yeah, it is a bit hard to setup on arm devices

cold moon
#

And Apple is moving computer to their own ARM processors...

green mesa
#

One question y bot don't have discord module in eval

#

😅

cold moon
#

!eval command have no external dependencies

brazen charm
#

It does have some libs, but there wouldn't be much use from the discord package

patent pivot
#

yeah it can't interact with discord so

patent pivot
green oriole
#

!eval command have no external dependencies
@cold moon we so have some, on top of my head, I think they are numpy, scipy, networkx, pandas and forbiddenfruit available in the container

patent pivot
#

yeah

cold moon
#

Oh

patent pivot
cold moon
#

I have currently some ideas about @stable mountain aliases (what is currently in Aliases cog) rework to custon decorators and I hope I can open issue later today.

tawdry vapor
#

I think there's already a proposal

#

And an issue

brazen charm
#

@patent pivot so for the doc stats, should it be package.symbol or just package ? You mentioned something about nesting problems but I'm not familiar with the stats to know what those could be

patent pivot
#

package.symbol was dodgy yeah, just package will do

brazen charm
#

Would that be a counter increment or a gauge?

patent pivot
#

counter would probably be best

brazen charm
#

Does the actual number matter here, or just their relative increases? Or did I misunderstand that

patent pivot
#

I should probably reword that

#

In our case at least, I think counters can be thought of as things that will always increase, as opposed to gauges which fluctuate

#

counters can still be used to fetch totals by using the integral function in graphite, which is what I do for things like message count

#

accuracy is less important and it takes a bit less storage space

#

we use gauges for stuff like guild member counts or statuses

#

counters for pretty much everything else

#

Gauges are a constant data type. They are not subject to averaging, and they don’t change unless you change them. That is, once you set a gauge value, it will be a flat line on the graph until you change it again.

Gauges are useful for things that are already averaged, or don’t need to reset periodically. System load, for example, could be graphed with a gauge. You might use incr to count the number of logins to a system, but a gauge to track how many active WebSocket connections you have.

#

Counters are the most basic and default type. They are treated as a count of a type of event per second, and are, in Graphite, typically averaged over one minute. That is, when looking at a graph, you are usually seeing the average number of events per second during a one-minute period.

brazen charm
#

are their names from the inventories fine or should it use the ones they have in the api?

In [2]: self.bot.get_cog("Doc").rs
Out[2]: 
{'Django', 'Flask', 'Kivy', 'Matplotlib', 'NetworkX',
 'NumPy', 'Pillow (PIL Fork)', 'PySide', 'Python',
 'Python Arcade Library', 'Requests', 'SciPy', 'aiohttp',
 'dateutil', 'discord.py', 'more-itertools', 'pandas',
 'urllib3'}

These are from the inventories I have locally

patent pivot
#

hmmm

#

ideally they should be all lowercase, alphanumeric with _

brazen charm
#

!d

#

right, can the names added by admins be assumed to not contain spaces etc.?

patent pivot
#

I'll check

#

yeah

brazen charm
#

alright I'll pass those lowercased then

patent pivot
#

most of the time we use the import name

prisma path
#

Joe, are you maintaining your own k8s cluster on bare metal?

patent pivot
#

@prisma path for what? pydis or personal?

prisma path
#

Well both, but I saw your screenshot from pydis :-)

patent pivot
prisma path
patent pivot
#

this deploys dashboard, updates things and autoheals your nodes for you

prisma path
#

Their prices are kinda reasonable actually.

#

I wanted to use k8s for my personal stuff too, but I only have 1 physical server 4Shrug

patent pivot
#

Yeah, I get most of my stuff through them and have never had a bad experience. I pay €7.99 for my Kapsule & I think €2.99 for my VPS

#

monthly that is

#

yeah I just run a single node kubernetes

prisma path
#

👍

clever wraith
#

is there something I'm missing about the bot's in_whitelist check?

#

even copying it basically verbatim doesnt work

crude gyro
#

gonna need more info than that, @clever wraith

#

but that check also had a decorator counterpart, and the deco is usually combined with certain constants so maybe those are the pieces missing

clever wraith
#

no i-- i kinda forgot to load my error handler

crude gyro
#

okay

clever wraith
#

honestly im learning some decent thing from that bot's code ^.^

crude gyro
#

good. that's a big part of the intention

neon phoenix
#

okay, so, i'm creating a discord bot heavily inspired on @stable mountain, and i'd like to know how more or less you save infractions like tempbans and tempmutes

#

i know they go in a database, but, how they are more exactly organized?

exotic ember
neon phoenix
#

oh thanks

#

i was diving into bot instead of site so i didn't notice it

#

well i think you didn't understood my question

#

imagine this is a table, right?

| ------ | ----- | ----- |
|        |       |       |
|--------|-------|-------|```
#

(sql)

#

how would be the infractions organized?

patent pivot
#
                                       Table "public.api_infraction"
   Column    |           Type           | Collation | Nullable |                  Default                   
-------------+--------------------------+-----------+----------+--------------------------------------------
 id          | integer                  |           | not null | nextval('api_infraction_id_seq'::regclass)
 inserted_at | timestamp with time zone |           | not null | 
 expires_at  | timestamp with time zone |           |          | 
 active      | boolean                  |           | not null | 
 type        | character varying(9)     |           | not null | 
 reason      | text                     |           |          | 
 hidden      | boolean                  |           | not null | 
 actor_id    | bigint                   |           | not null | 
 user_id     | bigint                   |           | not null | 
Indexes:
    "api_infraction_pkey" PRIMARY KEY, btree (id)
    "unique_active_infraction_per_type_per_user" UNIQUE, btree (user_id, type) WHERE active = true
    "api_infraction_actor_id_ed96dde9" btree (actor_id)
    "api_infraction_user_id_8714e9f5" btree (user_id)
Foreign-key constraints:
    "api_infraction_actor_id_ed96dde9_fk_api_user_id" FOREIGN KEY (actor_id) REFERENCES api_user(id) DEFERRABLE INITIALLY DEFERRED
    "api_infraction_user_id_8714e9f5_fk_api_user_id" FOREIGN KEY (user_id) REFERENCES api_user(id) DEFERRABLE INITIALLY DEFERRED
neon phoenix
#

thanks @patent pivot!!!

patent pivot
#

np

neon phoenix
#

so, as i see, basically each infraction is a table, right?

patent pivot
#

each infraction is a row in the table

neon phoenix
#

okay

patent pivot
neon phoenix
#

lol great example

#

well thanks @patent pivot!!! 😄

tawdry vapor
#

I wouldn't really recommend that

#

I don't think the current system is particularly great

neon phoenix
#

What's the hidden attribute on your infractions database?

#

I think it's set to True when you use shadow actions but I'm not sure

patent pivot
#

yeah, shadow infractions

neon phoenix
#

thanks joe sunglas

dull jetty
#

#ask-joe

neon phoenix
neon phoenix
#

Where can I find the public eval command? I found so far the internal one, on bot/bot/cogs/eval.py

sullen phoenix
#

it's in bot/bot/cogs/snekbox.py

brazen charm
patent pivot
#

having a gander

#

@brazen charm 👍

#

we are more than okay for RAM though. We have an alert set at 60% RAM usage and haven't hit that yet

#

last time we hit a RAM alert was when I started up a java application lol

subtle kraken
subtle kraken
#

Actually its probably possible to do it same way, still interested in the issue itself

exotic ember
#

if you have a solution proposal, it would be nice if you could comment on the issue itself

subtle kraken
#

More or less I got whole idea of code, and somewhat prepared code ready

green oriole
#

Oh hey, I've been doing the exact same functionality a few weeks ago for our kotlin bot

#

I've chosen to delete all the message posted between the clean invokation timestamp and the target timestamp

subtle kraken
#

I did some eval testing found a more-or-less perfect way of cleaning all messages from invocation till message ID/URL

#

Had 3 ideas out of which 2 worked and 1 for some reason would result in python process to hang completely

timid pebble
#

Hello guys

cold moon
#

I think maybe should @stable mountain paginator to python package in PyPi. This will make possible to use it for other projects. Discord.py's own menus have one big design problem: This don't remove reactions after moving.

hardy gorge
#

Our current paginator is a bit old as well and could use a redesign

scenic moth
#

the re-running functionality on the code evaluator is great, gj developers

green oriole
#

Glad you like it 😁

crude gyro
#

please only take this if you can solve it quite quickly.

rocky bloom
#

just to make sure, when !eval tries to circumvent filters, it sends a message to mods the same as regular filters do?

#

@crude gyro

brazen charm
#

I'm not very familiar with the filtering cog but I'd assume that should notify the mods

rocky bloom
#

yeah it does but like should it be the same message or a custom message saying that they tried to use !eval to circumvent it

crude gyro
#

@rocky bloom maybe a custom one

#

would be nice to have that bit of context.

rocky bloom
#

cool

crude gyro
#

important thing is that we are notified.

rocky bloom
#

also with the !raw command, discord.py's MessageConverter returns a BadArgument error with the error message containing the argument

#

so do i just use string formatting to format it out

woeful thorn
#

Just remove the formatting

rocky bloom
#

the formatting is currently await ctx.send(f"Bad argument: {e}\n") with e being the error text that the BadArgument is sent - changing that would involve changing all the BadArgument errors that are raised by other parts of the code

woeful thorn
#

Yes

rocky bloom
#

ok cool

crude gyro
#

just replace it with something generic.

#

Bad argument: Please check your input arguments and try again or something.

rocky bloom
#

ok cool

crude gyro
#

easy and straight forward and completely fixes the problem

rocky bloom
#

Also am I checking all !eval messages or just those from non-whitelisted channels/members?

crude gyro
#

a fair question. I suppose you can check it for only non-staff

neon phoenix
#

i'm implementing fetch & eval

#

but

#

there's a problem

#

you can only use fetch_message method on instances of discord.TextChannel

#

i need to crawl on all channels

hardy gorge
#

Are you working on a specific issue?

#

But it's not assigned to anyone yet and the labels say it's in the planning phase

neon phoenix
#

yeah

#

that one

#

but considering that there are +100 channels here

#

wouldn't be a huge performance issue?

hardy gorge
#

Alright, but you should first get yourself assigned to the issue and the issue should be fully approved/out of the planning phase

#

Do you have an outline of the implementation you have in mind to discuss in that issue?

neon phoenix
#

well

hardy gorge
#

I don't think the details as of yet are set in stone

neon phoenix
#

i have a simple idea on mind

hardy gorge
#

Yes, but you should probably get that idea into the issue first, before you start working on the implementation

neon phoenix
#

okay

#

in what format do i write a comment to an issue, im not a very formal guy and i suck at essays

#

please dont assign me to nothing for now :p

hardy gorge
#

We need to decide on an implementation before anyone can start working on it

#

So, if you have an idea for that, you should describe the idea and why you think it's a good idea to do it that way

neon phoenix
#

well my implementation is like this:

  1. convert code to an int
  2. if it raises ValueError, it's not an ID (go to 5)
  3. crawl on all channels to fetch the code using the message ID
  4. if the message is not found, return (if its found convert it to a valid format)
  5. execute it
#

i'm typing my implement here so we can discuss it better here

#

and it's a good idea my implementation because... there's no other way to do it meme

hardy gorge
#

You should add your idea to the issue, so it's documented and other people can look at it

neon phoenix
#

okay

stable mountainBOT
#

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

tawdry vapor
#

@celest charm Hey, why did you close your generator tag PRs? Are you still interested in adding that tag? I was just looking at stale branches to clean up.

celest charm
#

I don't remember. Probably I got something screwed up with git. Right now I'm busy, so I won't be able to work on it. But globally - yes.

tawdry vapor
#

Alright, I'll keep the branches around for now then.

#

@exotic ember since ks129 has a PR open for the source command, can I delete your branch? Sorry I didn't realise you had a branch for it when I unassigned you. At the time, I just noticed you had self assigned 5 months ago without any word since.

exotic ember
#

@tawdry vapor yaya go ahead, thats okay

vocal wolf
#

I'm having a bit of trouble getting my instance of seasonalbot to find any channel, in this server or on my own test with bot.get_channel. I feed it an ID, it always seems to return None.

I've made small changes to a branch in an attempt to fix the exploit, I just can't test it since I haven't figured out why it's not detecting channels as of now.
Here's the changes I've made off of the main branch to the mentions-fix branch:
Allowing only certien pings: https://github.com/python-discord/seasonalbot/blob/mentions-fix/bot/exts/christmas/adventofcode.py#L121-L125
Kwarg when contructing the bot for allowed_mentions: https://github.com/python-discord/seasonalbot/blob/mentions-fix/bot/bot.py#L206-L211

brazen charm
#

Assume you've changed the constants locally? You won't be able to get the channels from here unless you're working on the production instance

vocal wolf
#

When I worked with the bot I changed them locally within constants.py on my own server, along with changing environment variables within docker-compose.yml

green mesa
#

Hello coders
One question how mute or temp ban system work basically my question is about timing ,like timing is random or it decided through something?

#

Just a random question 😅

#

Or timing is upto staff to decide

tawdry vapor
#

It's an argument passed to the command

#

The staff decide it when they invoke the command

sullen phoenix
#

what good would it do if it was random lol

green mesa
#

Lol

sullen phoenix
#

but yeah, staff decides

green mesa
#

Then it will luck

#

1 year or 1 minute if we import random module hehehehehe

#

Ok ty for your answer @sullen phoenix

sullen phoenix
#

and Mark as well

green mesa
#

Yes @tawdry vapor ty too

#

Ty both of you

green mesa
#

Can we have channel for challenging question like we can participate there and py will give 10 random question which has to be solved in certain time duration

#

This will make beginners work in their basics

#

Bcz it's like a competition

#

We have almost everything in this server, if we have championship for coding it will boost interest of new coders

tawdry vapor
#

This isn't the right channel. Please use #community-meta for community suggestions

green mesa
#

Ooo sorry

#

Will I delete from here?

rocky bloom
#

Hi - I'm working on the PR #1032 of the bot repo and I'm not the most familiar with unit tests and I've had to change a couple of the !eval ones because they now call the Filtering Cog and I was wondering how to replicate the filtering cog in the unit test

crude gyro
#

how to mock it, you mean?

#

@rocky bloom

rocky bloom
#

yeah

crude gyro
#

so you need something Filtering-coglike for the test? Usually the easiest is for you to just create a MagicMock object

#

or, if possible, use the cog itself in the test.

#

that'll be most precise

#

but that's often wildly inconvenient

#

which tests are you changing?

rocky bloom
#

snekbox tests

crude gyro
#

yes. which ones.

#

give me something. an example of what you're trying to do

rocky bloom
#

test_send_eval is the main one and the others need to be changed accordingly

crude gyro
#

are you trying to change them so that they test if filters are run or what's the idea?

rocky bloom
#

currently they give out the exception TypeError: object MagicMock can't be used in 'await' expression

#

uh lemme get the full traceback

hardy gorge
#

If you want to mock a coroutine/awaitable, then there's an AsyncMock to use instead of a MagicMock

rocky bloom
#

ah

#

i'll post the traceback too just in case but lemme see what i can do

#
ERROR: test_send_eval (tests.bot.cogs.test_snekbox.SnekboxTests)
Test the send_eval function.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\suhai\AppData\Local\Programs\Python\Python38\lib\unittest\async_case.py", line 65, in _callTestMethod
    self._callMaybeAsync(method)
  File "C:\Users\suhai\AppData\Local\Programs\Python\Python38\lib\unittest\async_case.py", line 88, in _callMaybeAsync
    return self._asyncioTestLoop.run_until_complete(fut)
  File "C:\Users\suhai\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 616, in run_until_complete
    return future.result()
  File "C:\Users\suhai\AppData\Local\Programs\Python\Python38\lib\unittest\async_case.py", line 102, in _asyncioLoopRunner
    ret = await awaitable
  File "D:\Suhail\Documents\Python Discord\bot\tests\bot\cogs\test_snekbox.py", line 240, in test_send_eval
    await self.cog.send_eval(ctx, 'MyAwesomeCode')
  File "D:\Suhail\Documents\Python Discord\bot\bot\cogs\snekbox.py", line 217, in send_eval
    filter_triggered = await filter_cog.filter_eval(msg, ctx.message)
TypeError: object MagicMock can't be used in 'await' expression```
crude gyro
#

right, so you are changing this test to check if filters are triggered?

#

I would suggest you don't do that, and instead write an additional test or two for that

#

but yeah, the AsyncMock may be what you need

woeful thorn
#

The changes broke the current tests

crude gyro
#

right, the filter_eval call is from inside snekbox, not from the test

#

my bad

#

well that error seems to be because ctx.message is a MockMessage which is a MagicMock subclass

#

to which the easiest solution is probably just to make ctx.message an AsyncMock that contains whatever you need it to contain

tough imp
#

it's not awaiting the message

#

looks like it's just trying to await some coro which is mocked with a MagicMock

#

maybe it wasn't a coro before? i haven't looked at the diff

rocky bloom
#

it didn't exist beforehand

tough imp
#

so to mock a coro you need to use AsyncMock, so that it can be awaited

crude gyro
#

I don't get it, why would filter_cog.filter_eval possibly be a MagicMock

hardy gorge
#

This is a newly written test, right?

woeful thorn
#

No

crude gyro
#

nope

hardy gorge
#

something has changed in the test file, because the line numbers don't match up

rocky bloom
#

i might have added an extra newline

#

by accident

hardy gorge
#

The line that's in the traceback is on line 236 in the current master

rocky bloom
#

lemme discard all changes and rerun it

woeful thorn
#

You can just get the same error message from the Azure build log on the PR

#

Which hasn't touched the test file

hardy gorge
#

Alright, I'm just trying to establish that I'm looking at the correct code

#

Okay

#
            filter_cog = self.bot.get_cog("Filtering")
            filter_triggered = await filter_cog._filter_eval(msg, ctx.message)
#

bot here is mocked by a MockBot, which is a subclass of MagicMock. That means that any attribute accessed on bot will be mocked by MagicMock as well (unless otherwise specified), including the get_cog attribute. When that attribute is called, it will return another MagicMock (it's magic mocks all the way down).

#

That means that filter_cog will be a MagicMock

#

When you then access an attribute on filter_cog, that will be a MagickMock as well, which means that the _filter_eval attribute will be a MagicMock as well

rocky bloom
#

so shall i set get_cog's return_value to an AsyncMock?

hardy gorge
#

That would work, although a Cog isn't awaitable itself, so it doesn't strictly fit.

#

You could do this to make it more precise:

mocked_filter_cog = MagicMock()
mocked_filter_cog._filter_eval = AsyncMock()
self.bot.get_cog.return_value = mocked_filter_cog
rocky bloom
#

okay cool thanks :D

#

also this is a minor issue but whenever i run the pipenv run lint, i always get every file's line endings modified - is there any way to change that?

#

(since it causes all files to show up as modified in my git client)

crude gyro
#

you on windows?

rocky bloom
#

yep

crude gyro
#

you may have cloned it with windows endings. the solution would be to tell git that you want Linux line endings on that repo

#

I thought we already did that though

#

with like a .gitattributes file or something

hardy gorge
#

@rocky bloom Is the test issue solved?

rocky bloom
#

yep solved!

#

thanks so much for your help! i just committed it and seems like the tests worked!

hardy gorge
#

Oh, nice, good to hear.

brazen charm
#

I've got a function in 927 that I'd like to use in an another branch, but the commit that added it contains done other things so it can't be cherry picked alone. Should I wait for it to get merged or is there an another way of going about this?
Let me know if it's be more fitting in #tools-and-devops

crude gyro
#

@brazen charm one other way to go about it is to cherry pick it anyway and then write in the new pull request that #927 must be merged first, but it's a little messy

brazen charm
#

Not sure if lint would pass if I only cherry picked that

crude gyro
#

well, base yourself off that whole branch then

brazen charm
#

But htinking about it lint doesn't really matter for a wip pr

brazen charm
#

Could the current doc inventory names that use capital letters be changed to lowercase? joe mentioned that stats should be a-z_ and I'm logging the names lowercased, but that wouldn't change anything for digits etc. So I'm thinking of just restricting it when entered through the command

patent pivot
#

on it

#

hmmmm

#

I can't change it

#

raw SQL time sunglas

brazen charm
#

They're also addable through the site which doesn't seem to put in any restrictions, should I also look into changing that?

patent pivot
#

I don't think we have ever added them through the site, it'd be nice to have a validation but not required

brazen charm
#

I've never worked with django but I'll look at what I can do there

patent pivot
#

all are lowercase now

#

!doc help

#

wrong way

#

!help doc

stable mountainBOT
#
Command Help

!docs [symbol]
Can also use: doc, d

Lookup documentation for Python symbols.

Subcommands:

!docs delete <package_name>
Removes the specified package from the database.
!docs get [symbol]
Return a documentation embed for a given symbol.
!docs refresh
Refresh inventories and send differences to channel.
!docs set <package_name> <base_url> <inventory_url>
Adds a new documentation metadata object to the site's database.

patent pivot
#

!doc refresh

stable mountainBOT
#
Inventories refreshed
+ python, arcade
- Python, Arcade```
patent pivot
#

excellent

brazen charm
#

Thanks

tawdry vapor
#

Do we really need to use the site

#

Is a move to redis possible, or are the models too complex?

patent pivot
#

hmmmm

#

well

#

it's literally 3 columns

#

but I don't know how I feel about redis for persistence

green mesa
#

Y py bot don't send .TXT file when it's output is long?

#

Py bot can add paginaton by breaking output in pages and then adding paginator to it

crude gyro
#

Is a move to redis possible, or are the models too complex?
@tawdry vapor

no no, it's not about whether the models are too complex, it's about whether the data is disposable or not.

#

I don't think this data is disposable

#

we don't do backups of redis data, nor is restoring redis data from backup a good idea even if we did, because think about the help channels for example. We restore a redis snapshot and now suddenly we've time traveled back to a time where users are registered as claimants for channels they shouldn't actually own

#

if we keep using RedisCache for caching, the way we should, that means that the data often is tied to a particular point in time. It represents right now. And that's not compatible with a model of persistance and snapshots and backup restores. We'd have to start storing a bunch of timestamps and doing all sorts of integrity checks and so on, it's basically gross

#

so the easiest thing is to use Redis for temporarily caching disposable data, and use postgres for anything you care about persisting.

#

I think in time we should implement some sort of cache clearing strategy too, like if we have extended downtime (multiple hours), I think the cache should probably just be cleared when the bot comes back up for the sake of integrity.

green mesa
#

hello i how bot convert ISO time to utc

#

i check pybot repo but havent able to find anywhere

#

just curious to know

crude gyro
#

@green mesa for what command?

green mesa
#

temp mute

#

how py bot sends user muted for 1day 23h

crude gyro
#

check bot/utils/time.py

green mesa
#

ok ty

crude gyro
#

some of that also happens on the site side

#

... I think

#

might be wrong

#

hmm, actually maybe all of it happens on the site, lemme take a quick look

#

aha, right

#

we're doing it with the Duration converter in bot/converters.py. Most of the magic happens in its parent class, DurationDelta

#

essentially we have this regular expression:

duration_parser = re.compile(
    r"((?P<years>\d+?) ?(years|year|Y|y) ?)?"
    r"((?P<months>\d+?) ?(months|month|m) ?)?"
    r"((?P<weeks>\d+?) ?(weeks|week|W|w) ?)?"
    r"((?P<days>\d+?) ?(days|day|D|d) ?)?"
    r"((?P<hours>\d+?) ?(hours|hour|H|h) ?)?"
    r"((?P<minutes>\d+?) ?(minutes|minute|M) ?)?"
    r"((?P<seconds>\d+?) ?(seconds|second|S|s))?"
)

And then we feed that into a relativedelta.

#

@green mesa

hardy gorge
#

It's beautiful

green mesa
#

ohk

obsidian patio
#

I'd like to contribute to the bot, but don't have any real experience with GitHub. Do you have any good resources to recommend and could you help me get started with it in some way? I'm still not quite sure about the workflow

crude gyro
#

for learning the git cli, Corey Schafer has a great series https://www.youtube.com/watch?v=HVsySz-h9r4&list=PL-osiE80TeTuRUfjRe54Eea17-YfnOOAx

Git is the most popular version control system out there and for good reason. In this video, we'll go over the basics of what git is and how to use it within the command-line. There are several GUI tools out there to help you get started with git, but it can be extremely benef...

▶ Play video
#

for GitHub itself, well, all you need to learn is that workflow. Essentially to contribute to our bot you want to fork our repository, make a new branch on your fork to work in, and write your solution there.

#

then you open a pull request from that branch to our master branch

brazen charm
#

Are you using some kind of an editor with builtin version control tools? Most of the git(hub) stuff will be creating a new branch, switching around, commiting and pull/push

obsidian patio
#

I'm using VS Code

#

Thanks, I'll keep learning about git. I've seen Corey Schafer's videos before, so that looks promising

#

I'll follow the steps laid out in the article quite soon then, but how do I know what to work on? Do I check the issues tab on GitHub and just start creating a solution or is there something else that I should know?

green mesa
#

I have one question y we have ISO converter?

obsidian patio
#

If you know any good article or video explaining how the collaboration part works, I'd love to read/watch

green mesa
#

When we can easily use UTC one

#

Well u can fork and do a pull req

brazen charm
#

There are some issues available on the bot repos, for a start you can try something with the beginner or good first issue tags. If there's something you'd like to work on from the current issues then you can comment there and you'll get assigned if possible

crude gyro
#

I have one question y we have ISO converter?
@green mesa

if you're still referring to being able to do !tempmute 1H30M, why wouldn't we have that. it's easy and user friendly.

#

the alternative is to literally pass in an expiration datetime

#

otherwise I have no idea what you're asking.

obsidian patio
#

So, I'll have a look in the issues and comment that I'm up for solving the issue?

crude gyro
#

sounds good

#

there's like 150 open issues on bot, so I'm sure you can find something nice

green mesa
#

I also wnt to contribute but I don't have much experience in py 😐

obsidian patio
#

Perfect! And then, I'll fork the repo, develop a solution and create a pull request?

brazen charm
#

I didn't have all that much experience myself when I started contributing here, there are simpler issues around and other contributors or people in help channels can help if you get stuck on something

#

You'll want to fork it before that, as the bot requires a bit of setup to work including the site for most features

obsidian patio
#

Right. I read about that. Do I fork before I do the setup, or the other way around?

crude gyro
#

fork first

#

then get it running locally

#

so you can test

obsidian patio
#

Okay

crude gyro
#

the contribution guide for the bot I linked above is important in getting it running

#

once you've got a copy of the bot running on a test server and the console output isn't full of errors, you can make yourself a branch and start writing your contribution

#

remember to keep your commits small and atomic, and the commit messages descriptive and clean. Follow the 7 rules of a good commit message (google this term).

#

make sure your branch passes lint and tests

#

when everything looks good, open a pull request to us

green mesa
#

one question if I get stuck at somewhere while solving bot issue can I ask in helpchannel😊

crude gyro
#

and we'll review

obsidian patio
#

Thanks a lot. I'll take a closer look and get started

crude gyro
#

@green mesa depends how you're stuck. if you're stuck on a Python problem, of course you can. If you're stuck on something that's specific to our repo, probably best to ask in here

green mesa
#

Ok ty

brazen charm
#

The blame may offer some insight

patent pivot
#

yeah, checking it now

brazen charm
#

But last time I checked the paginator could use a small rewrite, if it didn't get one since then

near karma
#

Going to copy pasta for relevance:
Sorry guys. I'm looking at @stable mountain 's code, and I stumbled upon this bit in the paginator code:

            # Magic happens here, after page and reaction_type is set
            embed.description = ""
            await message.edit(embed=embed)
            embed.description = paginator.pages[current_page]

            image = paginator.images[current_page]
            if image:
                embed.set_image(url=image)

            embed.set_footer(text=f"Page {current_page + 1}/{len(paginator.pages)}")
            log.debug(f"Got {reaction_type} page reaction - changing to page {current_page + 1}/{len(paginator.pages)}")

            await message.edit(embed=embed)

(sic. indentaton). My question is, why do you guys first clear the embed, update th emessage with the empy embed, and then update it again and re-edit it? Should I open a help channel?

#

Oh, did it rended the embed wrong if it did not clear it first?

patent pivot
#

I guess so, but that was 2 years ago and it might be fixed now

near karma
#

Mhm. I've taken the liberty of copying the core mechanism of the paginator for my own bot, and the rendering seems ok?

sullen phoenix
#

@slow bone doesn’t seem to have this issue, we could probably update @stable mountain

patent pivot
#

yeah

near karma
#

\o/ Yay!

#

Thanks for your help guys

green mesa
#

DO we have games in seasonal bot?

tawdry vapor
#

Yes

green mesa
#

Which ones

tawdry vapor
#

Battleships and some quizzes

#

Maybe tic tac toe too. I don't remember

green mesa
#

Wow havent tried yet

#

And I chek the links which lemon shared and I think I can contribute on tic tac toe

tough imp
#

we have minesweeper

#

tic tac toe not merged yet

#

theres a PR for it

green mesa
#

I don't know what is PR new to GitHub 😐

#

Oonpull req

#

Oo pull req*

#

😅

#

Came to know by link

#

That guy made cool tic tac toe game

sullen phoenix
#

did you just...

#

did you open #1048?

#

@green mesa

#

or was that someone else 🤔

green mesa
#

No

#

I have a plan for bm command

#

We can do like this if we have a message like this

#

Hello h

#

How

#

R

#

U

#

Then if we do .bm no of message link of message to save as bookmark

#

Then it will be cool for bookmark

tawdry vapor
#

We already have a bookmark command

green mesa
#

Oo

#

@tawdry vapor working one?

#

Which things I can work on? Sorry new to git

tawdry vapor
#

Yes of course. We wouldn't merge a broken feature.

#

The bot is just down right now

green mesa
#

So how it's bookmark?

tawdry vapor
#

Let me see if I can get the bot back up and you'll see for yourself

green mesa
#

Ok ty

#

Well I scrolled up .bm works for only one line

#

What if user wnts to bookmark some code

#

Which is of 10 lines?

brazen charm
#

you can bookmark the starting message

green mesa
#

But isint it will be nice if .bm sends embed and at description it shows some code and in it

#

Not a single line

#

So like if I have list of 10 things I can bookmark it and it will show me in embed and add jump bck url also

sullen phoenix
green mesa
#

Wow

#

This is what i am talking about

rocky bloom
#

I don't know what's funnier

#

the fact that people bothered to troll in pr #1049

#

or the fact that the 3 lines they replaced every file with isn't actually python syntax

crude gyro
#

I'm not 100% sure if it actually works, but it ought to. A little hard to test stuff like this without just pushing it to production

#

which is fine for this particular repo

tawdry vapor
#

Yes, I'll have a look

#

Honestly I don't know anything about GH actions

#

What's the benefit of using a flake8 action?

#

Can't it just be invoked as a shell command?

#

It does fancy things like add annotations to your PRs inline.
Ok that's cool

crude gyro
#

maybe we should just remove django-crispy-bulma from site altogether

#

and archive the whole repo

#

nobody is maintaining it, after all

tawdry vapor
#

Perhaps

#

I think we only rely on it for the OAuth form on our site

crude gyro
#

yeah, for the account deletion form

#

pretty sure I could get that working with just plain django forms, or at least with plain crispyforms

#

I'm having a go at that right now but I'm not really sure how to get to that page on the dev site

tawdry vapor
#

I think OAuth is one of the things I couldn't get to work locally

crude gyro
#

yeah

tawdry vapor
#

Even on the master branch

crude gyro
#

I wonder if it's somehow disabled

#

@molten bough might remember

molten bough
#

I don't recall if I specifically used crispy for that

#

but it's a pretty simple form

crude gyro
#

no no, the question is "how the fuck do you test this locally"

molten bough
#

Oh, you want to test the oauth integration

crude gyro
#

not really, I just want to see that account deletion screen

molten bough
#

I made an oauth app on the discord developers site, you can have a redirect url under localhost

crude gyro
#

so I can remove all the crispy-bulma from it

molten bough
#

that's how I tested it locally

crude gyro
#

maybe I can just log in via /admin/login ?

molten bough
#

Yeah, that might work

#

it's been long enough that I can't remember if I checked for an oauth login specifically, but I highly doubt that I did

crude gyro
#

aha, yes.

#

that did work

molten bough
#

\o/

crude gyro
#

@tawdry vapor Okay, I'm opening a PR to site to remove django-crispy-bulma as a dependency

#

feels more reliable

tawdry vapor
#

Sounds good

crude gyro
#

once this is merged, we can probably go ahead with the Django 3.0 migration, right?

#

or are there any other blockers?

tawdry vapor
#

Not really but I do have a couple concerns

#

First are these empty list bugs

#

I've fixed two so far.

#

The other concern is django-environ. Many people saying that it doesn't support Django 3.0 but it seems to work when I tried it. I tried to ask for clarification on what doesn't work but never got a response.

#

@crude gyro so how do I test this delete form?

#

I logged in with admin then tried to delete my account

crude gyro
#

that is weird.

#

it worked fine on my end

#

but, hmm

#

okay, right, I think that's a bug

#

I will have to look at it tomorrow

#

feel free to leave a review, I think I might know why it's happening.

rocky bloom
#

do y'all mind if i test !eval filtering? i just wanna see if it works

#

but i don't wanna get infractions

crude gyro
#

has it been merged?

rocky bloom
#

just now actually

crude gyro
#

go ahead

crude gyro
#

@tawdry vapor I see now, it's because of django-crispy-forms itself. I'm getting rid of that dependency, too.

#

it's only used for account delete, so

#

kinda pointless

tawdry vapor
#

Ok it looks fine now

#

Did you test that the delete actually goes through?

crude gyro
#

yes

tawdry vapor
#

I kinda dont want to delete my admin account

crude gyro
#

it doesn't really delete the account

#

or, at least I don't think so.

#

I think it just deletes its connection to the discord user

tawdry vapor
#

Yeah it does

#

I tried it

#

Whatever, I'll recreate the containers

crude gyro
#

you're using docker-compose, right?

tawdry vapor
#

Yes

crude gyro
#

just docker-compose up --build should fix it then I suppose

tawdry vapor
#

Ah yeah it recreates the user each time it restarts

#

cool

crude gyro
#

oh yeah you don't even have to build

tawdry vapor
#

Alright you have my approval

crude gyro
#

isn't it just great to remove dependencies

#

such a relief

tawdry vapor
#

Is the 0.0.0.0 thing safe?

crude gyro
#

it's only there if DEBUG is enabled

#

so I would say yes

tawdry vapor
#

ah ok

#

Can't see that in the diff

crude gyro
#

yeah

#

it's convenient though, because when you spin up the containers via docker-compose it will link you to the site in the terminal output and it links to 0.0.0.0

#

so you can just click the link

#

<@&587606783669829632>

Easy review at https://github.com/python-discord/site/pull/368. This review gets us one important step closer to running Django 3.0 in production, which is a blocker for my whitelist PR, so I'd appreciate if someone has 3 minutes to spare for it

#

already tested by both me and Mark, so really just needs a sanity review

#

The other concern is django-environ. Many people saying that it doesn't support Django 3.0 but it seems to work when I tried it. I tried to ask for clarification on what doesn't work but never got a response.
@tawdry vapor

If you're worried about this, we could easily get rid of that dependency too

#

it's literally being used for 4 lines of code

#
env = environ.Env(
    DEBUG=(bool, False),
    SITE_SENTRY_DSN=(str, "")
)
#

that's all

tawdry vapor
#

Well, less dependencies is better

crude gyro
#

I don't fully understand this plugin but I suspect that's just default values

#

oh wait, it does something weird in addition to that. okay.

#

never mind

tawdry vapor
crude gyro
#

wait.. pathlib support - 2 as a way of moving up two directory levels?

#

news to me

#

that's pretty hot

brazen charm
#

I don't think that's from pathlib

crude gyro
#

maybe it's an environ thing then

#

yeah pathlib does not

tawdry vapor
#

I think it's broken if trying to read from a file

crude gyro
#

yeah

#

which we don't.

tawdry vapor
#

But we rely on pipenv to do this so we don't care

crude gyro
#

well, I do actually set my DEBUG env var in a .env file

#

but you're saying that pipenv will load that into the environment anyway

#

so it doesn't matter

tawdry vapor
#

Yeah pipenv reads .env

crude gyro
#

yeah

#

okay

brazen charm
crude gyro
#

then this doesn't affect us, if that's the only problem

tawdry vapor
#

I just realised how shit that issue is. Vague title, no description, no comment clarifies what's wrong

#

And just a bunch of thumbs up

crude gyro
#

yes

#

I'll take a look now, @brazen charm

#

okay @tawdry vapor, so the django-crispy-bulma blocker is gonna be gone soon, we don't need to care about django-environ, your last concern was something to do with.. empty lists? can you elaborate on that?

tawdry vapor
#

Some models that may need to allow empty lists might not allow them anymore

#

One of the commit messages had details

#

Need to go over and ensure FKs allow empty lists if they need to be allowed, since DRF fixed a big and now we have to be more explicit with allowing empty lists.

crude gyro
#

right, I remember running into that when I was migrating to Django 3 myself

#

but I think that's a problem you'd see at startup

#

not 100% confident though

#

but when I migrated, I just tried to run the app and it kept crashing with all the stuff I needed to fix. So fix, run again, fix, run again, fix, everything was fine

tawdry vapor
#

I don't think it'd be seen at start up

#

Not for our API at least

clever wraith
#

how does the bot keep anchors in the YAML file?

#

im assuming the config can be modified within the bot, right?

tawdry vapor
#

No, not really

#

It's technically possible with an eval but there's no "official" feature for modifying config values

#

Our config system is not that good. We want to re-do it

clever wraith
#

ah, ok. i have a yaml file, that can be roundtripped (ruamel.yaml), but i also want to use it in a config object, but i have no clue how i'd save it

#

guess i'll stick with accessing config values as a dict then

green mesa
#

Sorry if this is a stupid question I am new to git I am not able to find which issues are still open of seasonal bot I wnt to contribute to seasonal bot repo at beginner level

#

All issue seems to have been solved😅

tawdry vapor
#

Anything without the WIP label and/or someone assigned should be available

green mesa
#

Ok ty

neon phoenix
#

quick question: are you using psycopg2 or asyncpg?

crude gyro
#

for our site?

neon phoenix
#

site and bot

hardy gorge
#

Our bot does not communicate with the database directly

crude gyro
#

the site does, and uses psycopg2

#

or, well, it uses Django's ORM, and Django uses psycopg2

#

with Django 3.x well on its way into asynchronicity, though, it's quite possible that it will support asyncpg in the future

#

in which case we'd be happy to make use of that.

#

but right now there's no support

cold moon
#

This reminded me that Django will get async views support in this summer I think 🤩

green mesa
#

it will be cool if in resource page exercises will be added

#

can we have some?

#

😄

patent pivot
green mesa
#

ok ty

clever wraith
#

what's defcon and how is it used?

#

it looks like a server protection -- just autokicking new members?

patent pivot
#

@clever wraith autokicking new users

#

defcon of 1 day means any account with age <1 day is kicked

clever wraith
#

oh so thats all it is?

patent pivot
#

yes

sullen phoenix
#

soon™️ it will be much more

patent pivot
#

yeah

clever wraith
#

and i noticed its not normally supposed to be turned on manually ("only do this if you know what you are doing")

#

what triggers it?

patent pivot
#

it is turned on manually

#

!defon

stable mountainBOT
#

defconenabled DEFCON enabled.

patent pivot
#

!defoff

stable mountainBOT
#

defcondisabled DEFCON disabled.

patent pivot
#

¯_(ツ)_/¯

clever wraith
#

that line seems to imply there's an automatic trigger, and the manual one isnt normally supposed to be used

patent pivot
#

not sure how you are inferring that

#

the "be sure you know what you're doing!" is because it's... y'know... kicking our new users lol

clever wraith
#

well i just interpreted it as "only manually do this if you know what you're doing, otherwise let someone else handle it"

#

but that was when i thought it was more than just kicking new people

tawdry vapor
#

I need some advice on code I'm writing

#

I'm writing a decorator. It's meant to decorator instance methods.

#

The decorator relies on a dictionary existing in the instance. The dictionary is internal, as in, it's only meant to be used by the decorator.

#

What is a good design to ensure the dict will exist in the instance?

#

My first design is a mixin, but it feels clunky to have to subclass something. The decorator will also be misleading since it'll have to be a static method, but it would fail if ever called outside something that's subclassing the mixin.

#

My other idea is to "inject" the dict into the instance if it sees the attribute does not exist yet. However, I worry that being so inexplicit could lead to unexpected results for users unless they're familiar with the internals of the decorator.

#

I suppose it's not too much different than the mixin.

hardy gorge
#

I take it you're planning to use the same decorator on multiple methods of the class and they should have access to the same shared dictionary within each instance

tawdry vapor
#

Yes

#

It's basically going to be the locked decorator, but cross-function support

#

Locking by an ID

exotic ember
#

have your decorator access a property? any dictionary injecting would then be in your class instead (I have no idea if I understand your problem)

tawdry vapor
#

Sorry I don't understand the question

#

I'm considering create a dict of WeakValueDictionary as a module-scoped variable, rather than storing them in instances of classes. That way, this decorator could work across instances or even on normal functions.

#

Though I don't currently need it to support such feature

exotic ember
#

I was thinking having your locks be accessible through a property, and have the property deal with whether or not the lock exists

tawdry vapor
#

Doesn't the dict still need to exist though?

hardy gorge
#

I've made something similar for Rattlesnake, but that had the advantage of being bound to a Redisobject instance

#

That means the lock can be part of the thing it's trying to lock and the methods are decorated by a method on the cache instance

tawdry vapor
#

Do you all think having a dict of dicts is a good idea?

#

I'm playing with it right now

hardy gorge
#

Looking at your function, the point is to just cancel anything else decorated with the same id_ while something is already running

tawdry vapor
#

Yes

tawdry vapor
#

This is what I have now. Haven't tested any of it.

#

Don't know if what I am doing is stupid

#

Will call it for the night though

green mesa
#

How py checks for which lib we are trying to fetch docs?

#

Like it fetched !doc asyncio also

#

And !doc discord.ext.command also?

#

My question is how bot knows which tag belongs to which lib?

patent pivot
#

@green mesa well, you are providing the name no?

#

we pull the docs from several packages such as the stdlib, discord.py, arcade and so on

#

they publish their contents like "my contents contain a symbol called asyncio.sleep"

green mesa
#

Ok

brazen charm
#

Would this channel be alright for some design questions around code for a feature, or should I get a help channel?

crude gyro
#

no, that sounds fine for this channel provided it's a feature for one of our projects

brazen charm
#

Not workign code since some uneeded parts were deleted and otehrs weren't working to begin with, but for this method here https://github.com/Numerlor/bot/blob/0f6172846f6b54dd39ef95a86495180ac1d5a4d7/bot/cogs/doc.py#L386-L414 does this look as a viable approach (not minding the long lines)?
What I needed is the same behaviour that's in find_elements_until_tag for those 4 bs4 methods so I was aiming for something that's wouldn't just be copying the body, and keeping the caller interface clearer without the need to pass the methods itself; later I'm planning to move this to a separate class that would just do the parsing after I figure hwo one other thing should behave

#

And also wondering if the BS4FindManyMethod callback protocol looks okay

#

Maybe a normal factory would be better at this point to get rid of some of the parials and staticmethod calls but then I'm not sure if it should stay in the class where the methods are defined

tawdry vapor
#

This ultimately seems like a partial vs no partial question

#

The other way to do these is ```py
def find_next_children_until_tag(...):
stuff = find_all(...)
return find_next_children_until_tag(stuff, ...)

#

That's a bit more redundant but also more explicit than partials.

#

I think the partials are fine

#

Though the staticmethod stuff is a bit ugly

#

Not a big deal

#

I don't really know what BS4FindManyMethod is for.

#

That's kind of getting overkill for type annotations, considering this seems like an internal function currently

brazen charm
#

I think this looks a bit better

    def find_elements_until_tag_factory(func: BS4FindManyMethod):
        def find_elements_until_tag(
                ...,
        ) -> t.Optional[str]:
            """
            ...
            """
            ...
            return elements
        return staticmethod(find_elements_until_tag)

    find_next_children_until_tag = find_elements_until_tag_factory(functools.partial(BeautifulSoup.find_all, recursive=False))
    find_previous_children_until_tag = find_elements_until_tag_factory(BeautifulSoup.find_all_previous)
    find_next_siblings_until_tag = find_elements_until_tag_factory(BeautifulSoup.find_next_siblings)
    find_previous_siblings_until_tag = find_elements_until_tag_factory(BeautifulSoup.find_previous_siblings)
    find_elements_until_tag_factory = staticmethod(find_elements_until_tag_factory)

But as I said I'm not sure if the factory staying in the class would be nice.

Do you think a Callable with an explanation in the docstring would be good for the typehint? I wanted something that'd be clear but I don't think it particularly matters to the static checkers with bs4 not doing hints anywhere so it can just be explained or an alaised typehint

tawdry vapor
#

Yeah I think some documentation will be much clearer

brazen charm
#

I started the typehint as for a method that accepts the args for the instance and a limit that are used, but then it turned into a whole hint for the methods

tawdry vapor
#

It's a neat new feature but it seems overly verbose if you're not using static type checker tools

#

Well, technically your IDE is one but I mean something more like mypy

brazen charm
#

Which of the definitions would you say is the best all things considered; partial, normal wrapped funcs or the factory? the normal functions would look a bit nicer decorated with static methods isntead of being normal calls to it, but still feels a bit redundant

tawdry vapor
#

Why are the staticmethods needed?

#

Maybe you should just not define them in a class to begin with

#

Perhaps a separate module if it'd seem out of place

brazen charm
#

I was planning a separate class for the parsing side of the things that'd accept html and return markdown, but a module doesn't sound so bad either considering I was thinking it'd just be class/static methods

tawdry vapor
#

Then I don't think a factory is necessary

#

Also prefer the partials since it's less boilerplate

#

We're not writing a public library meant to be used by hundreds of people so it's acceptable to sacrifice docstrings for each partial

brazen charm
#

Only thing I don't particularly like about decoupling it is that I'll have to pass the aiohttp session to the parser if I want to cache soups with a simple cache

tawdry vapor
#

You could leave that one method that needs the session in the cog.

brazen charm
#

I think the tradeoff of passing it would be worth it here, because leaving it in also means parsing the URL in both modules or passing it along for resolving links and finding the symbol by id in the parser. So, don't particularly like it but it's probably better. But I'll get to that after figuring out other things

#

Thanks for the help

tawdry vapor
#

Np

hazy dune
#

Some heavy refinements are overdue for whitelisted and blacklisted things. e.g. a few sites that should be blacklisted:

nsfwyoutube
adf.ly
xxxvideos
any links ending in .onion

Blacklisted words:

Sucide (A typo of one of the words up there)
The n word (Like cmon guys this one was obvious)
Spacing out the letters like t h i s

Thanks, Galaxy.

kind flower
hazy dune
#

I was about to say xD

#

Ok, then the names of some parts of the male and female body should very much be added

#

And the name of the action they can do... (I’m trying to get the point across whilst still keeping this PG)

#

DM me if this was unclear or you need more obscure words

#

I too have a blacklist of my own

#

*on my bot

#

Also different variations of “grape without the g” should be added, such as adding an r, ing, s, or d on the end

#

Trying to keep this as PG as I can

#

It’s not easy

molten bough
#

Onion links shouldn't be banned wholesale imo

#

I mean sure there's some bad stuff on tor, but there's also Facebook and other legit sites

#

It'd be like banning .com

hazy dune
#

True, but .onion is quite a bit sketchier

#

Only a select few know how to access them

molten bough
#

It's mostly just hard to moderate I'd say

#

Yeah

#

Again, I'm not sure adf.ly is any sketchier than, say, bit.ly - it just also has an ad

#

And trying to maintain a comprehensive list of NSFW sites is.. well..

#

It's not gonna happen

crude gyro
#

Ok, then the names of some parts of the male and female body should very much be added
@hazy dune

..why?

hazy dune
#

Well, adf.ly is notorious for getting you to download viruses (it’s a common whole-screen pop up ads when you try downloading other things (most commonly seen when downloading OptiFine))

#

@hazy dune

..why?
@crude gyro they’re inappropriate

molten bough
#

I know adfly, although they've gotten better lately

#

But you know adfly isn't the only one

#

There's hundreds of domains

crude gyro
#

it's not our intention to moderate everything that's "inappropriate"

#

it's our intention to catch hateful interactions

hazy dune
#

This is true, but do you really want people talking about it in public chat?

molten bough
#

These lists already don't ban terms

#

They're alerts

crude gyro
#

they ping all the mods

molten bough
#

yeah

crude gyro
#

so that we can have a look at the conversation and determine whether we need to take action.

hazy dune
#

Well then I’m sure you would like (for moderation purposes) to be pinged when people start discussing it just to be sure.

crude gyro
#

many words that describe human anatomy would produce far too many false positives to be worth it

#

how often do you think dick is used on this server to refer to penis versus how many times it's used to refer to a person who is a bit of a jerk?

#

the latter is fine

#

we've added cunt to the list because it's considered a really, really bad word in parts of the world, but then you get australians who just use it to more or less mean "mate"

hazy dune
#

Oh.

molten bough
#

there's also a billion euphemisms anyway

#

it'd be pretty easy to get around

crude gyro
#

so, what we're interested in having on the list are words that are unequivocally bad

#

the n-word is a good example. We don't wanna see that in this community no matter what

#

unless you're posting kanye lyrics or something

hazy dune
#

Ok, is the s p a c i n g and st*rr*ng of the words still a good idea to add?

#

Or too far?

molten bough
#

I think the cog itself sanitises for that

hazy dune
#

I’m tempted to try (as I enjoy finding glitches) but the better part of me says it’s a bad idea

rocky bloom
#

plus in 99% of scenarios, a mod can make their own decision

molten bough
#

I mean, it's open source

hazy dune
#

Starts at line 263

#

Anyways

molten bough
#

Looking at the source, they expand spoilers

crude gyro
#

the word filter won't catch stuff that you've s p a c e d o u t, no.

#

we had an issue to do that at some point but I think we ran into more complications and edge cases than we thought were worth dealing with

molten bough
#

it's surprisingly difficult to do

rocky bloom
#

any word that bypasses the filters can be reported by others to moderators or even seen by one so it doesn't have to fit every scenario

crude gyro
#

generally speaking, anything that isn't caught by our filters is reported to us pretty quickly via @slow bone or by a staff member

#

but still, having the filter catch obfuscated tokens isn't a bad idea necessarily

#

if someone opened a really good pull request for it, we'd probably be happy to accept it.

#

but it's not as trivial as it sounds

molten bough
#

The kotdis bot just strips out markdown formatting chars, which seems to work fairly well

hazy dune
#

I seriously got staff’s attention today xD

#

That’s like... #6?

crude gyro
#

not that hard to get our attention

hazy dune
#

This is true

#

Ves, why are you the only owner not boosting the server?

hardy gorge
#

This is true, but do you really want people talking about it in public chat?
@hazy dune

I think our ideas of where the boundary of "appropriate" lies differs. We are a 13+ community, and parts of human anatomy, in either slang or a more conventional version, don't seem that inappropriate to me unless used very inappropriately.

crude gyro
#

Ves, why are you the only owner not boosting the server?
@hazy dune

technically @patent pivot isn't boosting it either, he gets free nitro because he's our discord partnership contact.

#

so we get a free boost

#

besides, we don't need the entire staff to boost

#

we have everything we need

rocky bloom
#

out of curiosity, who owns the server?

crude gyro
#

we get most of the boost features just by being a partner

#

joseph is currently the registered owner.

hardy gorge
#

And that goes for a few other suggestions as well: We're not trying to create an environment where everything is considered inappropriate and that's why we only filter very sensitive or inappropriate terms. In all other situations, it's up to a judgement of the situation. If something inappropriate happens, ping mods or report it to ModMail and we'll figure it out.

crude gyro
#

but in every other way than on the paperwork, all three of us do

hazy dune
#

Oh also happy Saturday

#

Wait hold on... when is the earliest time in the world right now?

#

Brb Google is calling to me

#

It’s hard to find because you don’t know if it’s 12 PM on Friday or Saturday

#

Ok so unless you live in Niue Time (GMT), then happy Saturday!

hazy dune
#

How has no one talked in here for hours?

hardy gorge
#

That looks like an astute observeration

hazy dune
#

I was concerned Discord wasn’t loading properly

celest charm
#

Reconnecting doesn't solve the problem

molten bough
#

hm, the None isn't something that showed up when I implemented this

#

but this would be difficult to debug without the database state, and I definitely should not have access to that

#

also, uh

#

how did you unlink your discord account?

#

that's not supposed to be possible without entirely deleting your account

celest charm
#

I meant that I logged out

molten bough
#

that's what I get

#

Ah right

#

Do you have a real name set on GH?

celest charm
#

nope

#

I am decorator-factory

molten bough
#

that explains the None, then

#

yeah

#

hm

celest charm
#

I don't see a reason to display the real name, just display the handle

#

(I remember how I'm called)

molten bough
#

I don't recall why I display the real name

#

it might have been a library thing, I'm not sure

#

but that's cosmetic, I'm more concerned about that 500

celest charm
#

Maybe there's some kind of error log?

hardy gorge
#

I haven't found anything overly exciting in the logs yet

#
[pid: 37|app: 0|req: 41762/59713] 162.158.88.49 () {70 vars in 1744 bytes} [Sat Jul 18 18:35:16 2020] GET /accounts/discord/login/callback/?code=...&state=... => generated 145 bytes in 491 msecs (HTTP/1.1 500) 6 headers in 239 bytes (1 switches on core 0)
[pid: 37|app: 0|req: 41805/59756] 162.158.88.49 () {72 vars in 1528 bytes} [Sat Jul 18 18:35:59 2020] GET /accounts/discord/login/callback/?code=...&state=... => generated 145 bytes in 204 msecs (HTTP/1.1 500) 5 headers in 154 bytes (1 switches on core 0)
celest charm
#

My IP starts with 178, if that matters

molten bough
#

Weird, you'd think there'd be a traceback

celest charm
#

maybe grep 178?

molten bough
#

I think it probably gets cloudflare IPs

celest charm
#

yep

hardy gorge
#

These two entries have the same callback code that you had in the URL in the address bar of your screenshot

celest charm
#

And there's no traceback?

tawdry vapor
#

If you're looking in Sentry, the error may be ignored.

#

Though 500s are ignored more so for the bot than the site

hardy gorge
#

There's nothing in Sentry, as far as I can tell, including ignored

#

The logs for site don't show a traceback to go with that 500

molten bough
#

Very odd

#

Do you think allauth is intentionally returning a 500, maybe?

tawdry vapor
#

Hey everyone. I implemented something to cancel other commands if a resource is already in-use. For example, it will cancel a delete if a reminder is in the middle of being sent or edited.

#

Should the commands be aborted silently?

#

Or should some message be sent e.g. "this resource is already in use; please try again later"

woeful thorn
#

Probably not silently

green mesa
#
c_time = datetime.utcnow()
print(c_time)
f_time = c_time+timedelta(minutes=mute_time)
print(f_time)
#

this is giving me current time in utc

#

but how py bot convert time in user timezone

patent pivot
#

it doesn't

#

it gives it to discord in embed time stamps sometimes and discord does the conversion

green mesa
#

but how it add time in description

#

its in description

tough imp
#

don't think thats in user timezone

subtle kraken
#

pretty sure its UTC based

green mesa
#

@subtle kraken thats in my timezone

#

IST

subtle kraken
#

according to source code it uses UTC

#

there is no way of even knowing timezone of a user

green mesa
#

i wnt to test again

#

can u mute me

#

and then unmute

#

i wnt to check once

subtle kraken
#

You can set up test bot and do that yourself, I don't apply false infractions

green mesa
#

well ok

#

i tried with bot

#

but that bot is giving time in utc

#

but embed.timestamp give time in user current timezone

subtle kraken
#

because what you sent in the screenshot is UTC based

#

Embed.timestamp is something local client formats to its local time

green mesa
#

so can i get time from this only

#

i dont wnt to add on embed

#

just time i need

tough imp
#

I dont think its possible to get another user's timezone, if thats what you're after

#

the conversion in the embed footer is most likely done locally

#

either way, the API doesn't expose such information about users

crude gyro
#

yeah, it's done locally

#

in the client

green mesa
#

means py bot also sends time in utc only

#

ok got u

green oriole
#

Seems like the cat n°418 is broken

#

.statuscat 418

brazen charm
#

It's not in the http module which is used to validate the codes

green oriole
#

That's a shame 😔

brazen charm
#

3.9 adds it fwiw

green oriole
brazen charm
#

How complete would you say commits should be? I'm reworking some of the main methods in a module. Replacing them all at once would be a big commit, although it would be still about one thing; but they also aren't really compatible with the new design so the code wouldn't work if I went in steps without introducing unrelated changes just for that

celest charm
#

http.cat doesn't support 102 and 103

#

also 203

#

boy, that site is incomplete

tawdry vapor
#

@brazen charm Speaking only for myself, I don't think it's necessary to ensure every commit works and runs. After all, you're in the middle of development. It's fine to commit incomplete work, as long as you could say some subset of that is complete for that commit.

#

Trying to make every commit work just adds too much overhead

#

Also, big commits are fine. Not everyone works incrementally. It just has to be within reason.

#

For example, I reviewed Lemon's PR today and he had a commit that added an entire cog with helper functions and some commands.

#

It could have been separate commits for each function, or maybe a separate one for all the commands, but ultimately, that doesn't have too much benefit and may be inconvenient for him to have worked like that.

brazen charm
#

I do prefer them more separate when changing things instead of only adding new ones as it provides the opportunity to exaplin them a bit with the changes grouped with only the relevant commit message

#

I think almost every commit I've done so far would work when checked out, at least as code if not functionally, but that would be a bit of a pita in this case.

green mesa
#

Can we have name of author who reply when modmail message bck

#

So we can know who replied to us

sullen phoenix
#

you will know who replies, unless they use an anonymous reply

#

or it's a close message

green mesa
#

i wnt to know of close message f1re

patent pivot
#

@green mesa kind of irrelevant information

#

we don't write the modmail bot so if you want that you can PR it to https://GitHub.com/kyb3r/modmail

green mesa
#

ok

#

i love this server and all bots this server got

#

i learnt py in this server only

subtle kraken
#

@cold moon Hi, I've noticed that your PR for 1.3.0 functionality update is still open, however it has conflicts, do you think you could resolve those conflicts so the PR is merge-able?

timid sentinel
#

I'm not sure why I am getting this error, Error: the command flake8 could not be found within PATH or Pipfile's [scripts]., when running the precommit hooks in pycharm for the bot

#

All the other checks pass, and everything else seems to work fine

brazen charm
#

Do you have it on path?

timid sentinel
#

running which flake8 in the pycharm terminal gives .../.local/share/virtualenvs/bot-r6FnQRJj/bin/flake8 So i'd assume that's what it should be using?

brazen charm
#

does pipenv run flake8 work?

timid sentinel
#

This is all it gives me```
$ pipenv run flake8
Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
Loading .env environment variables…

brazen charm
#

Is there a timeout after that where it's running flake8 or does it just stop at the .env?

#

Not sure what the issue could be, but maybe something with the virtualenv not being pipenv's environment that you got a notice for

timid sentinel
#

It pauses for a few seconds after Loading .env environment variables… and then just goes back to the prompt.

#

I'll play around with it for a bit and see

tawdry vapor
#

Yeah it's bugged for me and ves too at least

#

We had to edit the hook and set an env var

#

I think it was the ignore virtual envs one

#

It's cause pipenv fixed a bug we apparently relied on

timid sentinel
#

Ha, well it's nice to know it isn't just me

#

What did you edit in the hook?

#

Actually I think I've managed to get something working

tawdry vapor
#

I just did os.putenv to set that env var to 1

#

I think...

timid sentinel
#

Ok, I made the pull request, and I think I did everything right 🤞

#

Here's hoping I didn't mess up

subtle kraken
#

congrats on possibly having fastest approved PR

timid sentinel
#

OH yeah, that's just testament to the extremely high quality of the code I wrote

subtle kraken
#

@tawdry vapor just wanna confirm, ^ doesn't really matter does it?

timid sentinel
#

What did I do...

subtle kraken
#

missed analysis pithink

#

not exactly bad since github doesn't mark it as bad but it doesn't mark as good

tawdry vapor
#

No

subtle kraken
#

Will merge it then if thats okay by you

tawdry vapor
#

sure

#

I wouldnt bother with the merge commits

#

Not for something like this at least

subtle kraken
#

I like branches updated

tawdry vapor
#

I don't

#

Messy commit history

subtle kraken
#

so just merge it then in future?

tawdry vapor
#

It's already a mess anyway though

#

Maybe

#

Use your discretion

subtle kraken
#

will do so next time I suppose