#dev-contrib

1 messages · Page 49 of 1

crude gyro
#

this should've been in the plugin description, though

#

there's just a url

molten bough
#

Oh, yeah, I'm sold

#

that's super easy

crude gyro
#

as someone on a big team with very good unit test coverage who sometimes needs to fix problems created by large merges, this is basically a godsend

#

but I bet it could be used even for stuff like pydis repos

#

a nice tool to keep in your toolbox for a rainy day.

green oriole
#

That’s sick

crude gyro
#

another tip - bisect can run any executable, and doesn't care whether it's a unit test or not. it only cares if it exits on 0 (if the code is good) or anything else (if it's bad)

#

so you can do git bisect run <some_executable> and literally check anything at all. it doesn't even have to be if something is broken in your code. for example, if you had a sqllite database tracked in your repo, you could be making DB lookups to try to track down when the database was in some specific state - maybe to recover lost data. You could figure out on which commit your bot had 100 commands. anything you can imagine.

#

so you can use bisect in kind of interesting ways by exploiting this.

mellow hare
mellow hare
#

Alright, question. There's two rebase options to quickly use in PyCharm:
Checkout and Rebase onto Current
Rebase Current onto Selected
I'm having trouble understanding which is which

molten bough
#

I honestly never use rebase

#

broken far too many repos in my time haha

mellow hare
#

Well that's why I'm asking before I do

molten bough
#

Where's this, in the git branch menu?

mellow hare
#

Yeah

#

Bottom right hand corner and all that

molten bough
#

Ah, yeah, checkout isn't a rebase option per se

#

It just checks out the selected branch into your working directory

mellow hare
#

No I know that

molten bough
#

Oh right, I see

#

misread

mellow hare
#

No worries

molten bough
#

So if you rebase current onto selected, for example

#

if you're on, for argument's stake, feature/cow

#

and you rebase onto selected, selected being master

#

then you're changing the base of feature/cow to master's latest commit and then replaying your commits on top of that

#

the other option is the exact opposite

#

it would check out master, change the base to the latest commit of feature/cow, and replay master on top of it

mellow hare
#

Okay, that's what I thought

#

What I would want is putting the cow on top of master, so it'd be the first one, ja?

#

Checkout and Rebase onto Current

molten bough
#

No, rebase current onto selected

#

you're updating cow to master's commits, right?

mellow hare
#

Right

molten bough
#

yeah, rebase cow onto master then

mellow hare
#

Okay gotcha

#

Sheesh, these things always trip me up

molten bough
#

I can't get ln's arguments right

#

:>

green oriole
#

So the plugin is just a visual interface to git bisect run?

molten bough
#

one that integrates with IDEA run configs

#

yep

green oriole
#

Okay

#

Didn’t know about bisect run, the pro git book doesn’t talk about it, that’s sad

#

Thanks lemon for the catch up lesson too haha

cold moon
#

I clone new copy for each branch I use...

green oriole
#

What?

#

Why

mellow hare
#

Like wait, a new copy of master?

green oriole
#

A new clone I think

mellow hare
#

Oh of the whole project?

#

Wild

#

Oh huh, do we not have any tests made for the infraction stuff?

#

I might tentatively tinker with that next

woeful thorn
#

There is a PR for at least some of them

mellow hare
#

Gotcha

woeful thorn
mellow hare
#

Might be a bit much for me to tackle but I at least am curious what I can do

green oriole
#

You can just take a file and go for it

mellow hare
#

Ah true

green oriole
#

Actually, a bigger file just mean more work, not a more difficult work

mellow hare
#

True, but time is also a factor since I do most of this at work

#

And I don't want to hold back something that could be done quicker

green oriole
#

You could always write a test for a __init__ file haha

mellow hare
#

"Is it there? Yep"

green oriole
#

token_remover seems quite straightforward if you want to go for it

mellow hare
#

I'll worry about that after I finish this

#

One thing at a time

green oriole
#

Just out of curiosity, what are you working on?

mellow hare
modest otter
#

What does it mean by watching a user when they're banned

mellow hare
#

So we have a system where we can mark people to have their messages relayed to a channel to monitor for bad behavior. If they're permanently banned, we no longer need to watch for them, so ideally we'd want to have them removed from that list as well

modest otter
#

So if you do watch someone, it sends all their messages to a specified channel/log?

mellow hare
#

Any in this server yes

#

It's helped us remove disruptive users in the past

modest otter
#

Also in the GitHub link

#

The line 141 link dosen't work

mellow hare
#

Yep, that part is from an old version of the bot

modest otter
#

Oh.

mellow hare
#

The issue is over a year old

modest otter
#

Still fixing it?

mellow hare
#

No one got around to it

#

So I figured I'd pick it up and do it since it's fairly small

modest otter
#

Can I see the current code used to watch people. See if I can try to find some things

mellow hare
#

Sure

#

It'll be the ones for watchchannel.py and bigbrother.py

#

talentpool is a similar concept (relay messages of a user to a staff channel) but it's used for watching potential Helper candidates

green oriole
#

Nice nice

#

talentpool only relay messages inside help channels iirc

woeful thorn
#

Nope

green oriole
#

Well

glass pecan
#

is a source of water

green oriole
#

I guess so haha

cold moon
#

I'll continue working tomorrow with SeasonalBot Space cog.

hardy gorge
#

Hey @cold moon, just so you know, no one's rushing you to work on these features. It's nice for us to know that someone's still actively working on the feature they said they were working on, but I've seen you post quite a few messages almost apologizing that you had other things to do. You don't have to and it doesn't really matter if something is done tomorrow, next week, or next month.

#

We just appreciate that you're working on things.

mellow hare
#

Dumb question: So I've now got apply_watch() and apply_unwatch() methods in the BigBrother class. I'm not exactly sure how to use those methods within a different cog's class

#

Or if I do know, it's not coming readily to mind

green oriole
#

Within a different cog?

#

What do you want to do?

#

You want to unwatch from another cog I guess

mellow hare
#

Call BigBrother's apply_unwatch() in - right

#

Or you know what

#

I may have thought of this backwards

#

And these should be functions not methods

glass pecan
#

for reference, this is how to reference another cogs method
bot.cogs["BigBrother"].apply_unwatch()

mellow hare
#

Oh that's what I needed

#

Cheers

green oriole
#

You could use ctx.invoke for that too

glass pecan
#

it's not a command

green oriole
#

Oh right

mellow hare
#

They're helper methods yeah

#

Sorry, I know I'm asking dumb stuff

glass pecan
#

it's not dumb

#

in fact, it's better to use this instead of what i said

green oriole
#

Well, you could directly call the command and leave more abstraction to the cog

#

Indeed it is not

woeful thorn
#

We don't want to have to call the command

#

That's the point of why I suggested the helper

mellow hare
#

And I can't since I'm setting a separate flag that shouldn't go in the main command

glass pecan
#
bb_cog = bot.get_cog("BigBrother")
if not bb_cog:
    raise Hell("We fooked up")
bb_cog.apply_unwatch()
green oriole
#

Fair enough

mellow hare
#

Oh now that's interesting

glass pecan
#

just in case something weird happened and the cog isn't loaded

woeful thorn
#

You have to use that exact error message though

mellow hare
#

Sure

#

Is there a cog failed to load error?

#

I guess there would have to be huh

glass pecan
#

there's multiple errors for a cog failing

#

nothing special though to the general situation

mellow hare
#

So nothing specific for "Cog failed to load inside of other cog"?

green oriole
#

Don't think so

mellow hare
#

Time to go doc hunting

glass pecan
#

no

#

it's either KeyError (if you're using direct cog references) or get_cog returns None

mellow hare
#

Would that be an ExtensionNotLoaded() or ExtensionError() oh I gotcha

glass pecan
#

extension are different

#

they have:

mellow hare
#

Ah gotcha

glass pecan
#
        ExtensionNotFound
            The extension could not be imported.
        ExtensionAlreadyLoaded
            The extension is already loaded.
        NoEntryPointError
            The extension does not have a setup function.
        ExtensionFailed
            The extension or its setup function had an execution error.
mellow hare
#

Right

#

I didn't see anything saying cog by name so I wasn't sure

glass pecan
#

only occurs on extension load, so they can't help you here

mellow hare
#

So do I just make my own Exception in this case or is there one that I should specifically be using

green oriole
#

I mean, I don't think you really want to raise an exception, you'd just want to notice the end user that it failed

mellow hare
#

Yeah I suppose

#

Oh actually... would a mod-log message make the most sense upon failure?

#

Sorry, I get really chatty when I'm trying to work something out

green oriole
#

When the unwatch is supposed to occur?

mellow hare
#

Yeah. I'll mull it all over

green oriole
#

Users are unwatched on bot restart iirc, right ?

#

I reckon very badly okay

#

Yeah, #mod-log makes the most sense

mellow hare
#

No they're not unwatched on a bot restart

#

Or at least they shouldn't be

patent pivot
#

users are unwatched when we unwatch

green oriole
#

I mean, the issue was about unwatching when they're banned, so not when you unwatch lemon_pleased

mellow hare
#

Correct

#

However if it fails to load the cog so that it CAN unwatch them when they get banned

#

That's the question I was asking

#

Because I'm snagging the cog so that I can use its method

green oriole
#

Yeah, mod-logs seems like the best option

mellow hare
#

Actually... I kind of feel like there's things missing from the mod-log....

#

Like I'm positive there's been more infractions than it's currently showing

green oriole
#

Or the place others error messages goes that I wouldn't know about

#

Ah

#

I mean, there is an infraction number on every embed

#

You can just see if there are some missing numbers

mellow hare
#

There are

green oriole
#

Ah

#

Are they related in any way, like they all are issued by the same person or bot, or of the same type or something?

brazen charm
crude gyro
#

@brazen charm done

brazen charm
#

Thanks

valid quest
#

@gusty sonnet My bad i wasn't working on the pr

#

What is a good way to check if the user is a mod?

#

I'll look up at the checks

#

Aight

cold moon
#

For space cog additional arguments, should I use argparse (SeasonalBot)?

green oriole
#

What kind of arguments the command can get?

cold moon
#

From ELA in PR review:

The NASA Image API supports quite a few search options, including a free text search, keyword search, description search, and year start/end constraints

green oriole
#

Well, it depends on how you feed this arguments to the API, if there is a limited amount of topics...

gusty sonnet
#

Since they will be separated subcommands, you can specify the arguments for each commands

green oriole
#

I think you should look the arguments up in a specific order

gusty sonnet
#

For parsing optional keyworded arguments, you can definitely write a helper, we do not need to introduce a new dependency just for that

cold moon
#

ok

green oriole
#

Or yeah, something like start=YY-MM-DDD keyword=mars could work

#

It would be pretty easy to parse too

cold moon
#

OK, I'll try

#

And when anyone have time, I fixed my .help command PR

cold moon
#

also, maybe is better let .space nasa command other search parameters to new issue, due this have these massive amount. I think better is when I add plain text search only currently (all other subcommand ill do myself)

eternal owl
#

Can anyone give me regex code to identify python code

#

i tried this, but its not woring

brazen charm
#

You need a quantifier on the dot and use the modifier that causes it to match newlines ( or use something different).
What is it for?

eternal owl
#

so if I can know the length of the python code in the static file, then I adjust the max_characters paramter on the paginate method

molten bough
#

will that work if it happens at different points on each page?

eternal owl
#

it won't unless if its possible to change max_characters on each page pithink

molten bough
#

Sounds like you might need to subclass the paginator

eternal owl
#

sounds very complicated, lol

molten bough
#

Alternatively, you could keep track of the code blocks

#

and close/open them yourself on each page they span

brazen charm
#

I checked if number of ```s is even in doc

cold moon
#

Please help with:

@space.command(name="mars")
    async def mars(self,
                   ctx: Context,
                   sol: Optional[int] = None,
                   date: Optional[DateConverter] = None,
                   rover: Optional[str] = "curiosity"
                   ) -> None:

I need this, that user need to provide sol or date, and rover is optional. How I can do this? This is not working.

molten bough
#

What isn't working about it?

cold moon
molten bough
#

How would you provide a date without sol? Or a rover without both of them?

#

And is that your message, or does it come from the framework?

cold moon
#

I think I'll have to build another custom converter for this

woeful thorn
#

@cold moon I didn’t say you had to add every single possible value the API accepts. The point is to make it something more than just “pick a random thing”

cold moon
#

OK

woeful thorn
#

Be creative

gusty sonnet
#

You can also make it accept arbitrary amount of keyworded arguments

cold moon
#

I made easy converter for this

eternal owl
#

@molten bough do you think it will be easier to just edit the .md files to tell the program where to turn the page?

molten bough
#

I feel like it would be better to make editing of the files as easy as possible

#

and if you're putting tokens like that in the markdown, they won't display properly on github

eternal owl
#

I mean just simple text like --

#

nvm, I think its gonna be ugly on github pithink

gusty sonnet
#

That will require actually manually put them onto the .md file

eternal owl
#

yea

gusty sonnet
#

Which, yes, will break format on github

eternal owl
#

you guys have any ideas?

molten bough
#

Keep track of the code blocks and open/close them yourself

#

You'll have to create pages yourself

gusty sonnet
#

Yep, you can do some algorithm for that

eternal owl
#

I did not understand

brazen charm
#

create one page, if the number of the backtick groups is not even cut it off

#

then create a second page from that point etc.

eternal owl
#

ooh

molten bough
#

well it needs to be smarter than that

eternal owl
#

so I have to go deeper into pagination

molten bough
#

you need to be able to start the next page with the same type of code block

eternal owl
#

understood now

#

So I can't use the pre-built pagination class for this?

molten bough
#

well you could probably subclass it

#

I'm not familiar with the current implementation but I expect it's not a huge modification

eternal owl
#

okay

eternal owl
brazen charm
#

probably in the parent class

eternal owl
#

nvm, i found it

#

yea, it inherits from discord.ext.comamnds.Paginator

#

din't see that

#
if reaction.emoji == FIRST_EMOJI:
    await message.remove_reaction(reaction.emoji, user)
    current_page = 0

    log.debug(f"Got first page reaction - changing to page 1/{len(paginator.pages)}")

    embed.description = ""
    await message.edit(embed=embed)
    embed.description = paginator.pages[current_page]
    if footer_text:
        embed.set_footer(text=f"{footer_text} (Page {current_page + 1}/{len(paginator.pages)})")
    else:
        embed.set_footer(text=f"Page {current_page + 1}/{len(paginator.pages)}")
    await message.edit(embed=embed)

I have a question and that is why are we sending a blank embed before actully sending the 1st page? Why don't we send the first page directly

#

I mean 4th and 5th line inside the if block

cold moon
#

Yeah, I see too no reason there

eternal owl
#

But there has to be a reason cuz the code is there, lol

brazen charm
#

anything in the blame?

cold moon
mellow hare
#

Okay this is weird

#

I'm getting an error when trying to load up my test bot

#
C:\Users\runner\.virtualenvs\bot-3yy1XfBm\lib\site-packages\aiohttp\connector.py:964: DeprecationWarning: The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.
  hosts = await asyncio.shield(self._resolve_host(
C:\Users\runner\.virtualenvs\bot-3yy1XfBm\lib\site-packages\aiohttp\locks.py:21: DeprecationWarning: The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.
  self._event = asyncio.Event(loop=loop)
From cffi callback <function _sock_state_cb at 0x000001EF17E67F70>:
Traceback (most recent call last):
  File "C:\Users\runner\.virtualenvs\bot-3yy1XfBm\lib\site-packages\pycares\__init__.py", line 91, in _sock_state_cb
    sock_state_cb(socket_fd, readable, writable)
  File "C:\Users\runner\.virtualenvs\bot-3yy1XfBm\lib\site-packages\aiodns\__init__.py", line 104, in _sock_state_cb
    self.loop.add_reader(fd, self._handle_event, fd, READ)
  File "C:\Program Files\Python38\Lib\asyncio\events.py", line 501, in add_reader
    raise NotImplementedError
NotImplementedError
brazen charm
#

you'll need to switch your event loop policy

#

I got this in sitecustomize.py to do that and fix colored logs on win

import os
if (mock := os.environ.get("BOTMOCKS")) and int(mock) == 1:
    import sys
    import asyncio

    # Mock isatty to get color from coloredlogs in pycharm builtin terminal.
    sys.stdout.isatty = lambda: True
    # Do not use ProactorEventLoop.
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

with a pycharm env variable passed accordingly

mellow hare
#

Wait, where does that file go?

brazen charm
#

in site-packages

#

it's auto executed when a script starts in that environment

#

(couldn't get usercustomize to work in a venv which I think is more supposed for that but this works)

tawdry vapor
#

Shouldn't we PR this in if it's going to be an issue for all Windows users?

mellow hare
#

Yes

#

Yes we should

tawdry vapor
#

Is sys.stdout.isatty = lambda: True really necessary on PyCharm? Does ticking the box to emulate a terminal not work?

brazen charm
#

not on win

#

you just get the raw escapes

tawdry vapor
#

If you pass isatty=True to coloredlogs.install(), does it fix it?

brazen charm
#

nope

mellow hare
#

This does make it a wee bit difficult to check over my PR

brazen charm
#

Didn't know about that kwarg and looks like that should work but can't find it being used anywhere in the code except the docstring

mellow hare
#

You'll have to spell it out for me since I haven't had my ADD meds today so I have very little focus

#

Sorry

brazen charm
#

it seems to be overriding it when true here

            # Disable ANSI escape sequences if 'stream' isn't connected to a terminal.
            if use_colors or use_colors is None:
                use_colors = terminal_supports_colors(stream)

Guess I'll make an issue because that doesn't seem intended

#

and use colors starts with the isatty kwarg

#

@mellow hare the sitecustomize?

mellow hare
#

Yeah

#

Sorry

tawdry vapor
#

That's dumb. I don't understand the point of setting it to True if it's going to use the auto detection anyway.

brazen charm
#

Guess they meant to use if not colors there because the docstring does suggest that it overrides the autodetection

#

Go to your venv's site-customize at C:\Users\runner\.virtualenvs\bot-3yy1XfBm\lib\site-packages, create the sitecustomize.py where you set the event_loop_policy like above

#

then pass BOTMOCKS=1 as an enviromental variable in your run config... doing other stuff in the file somehow broke pycharm's pipenv dependencies install for me so just an import and a check if the var is not set

mellow hare
#

Okay and now my check functions are failing

#

Cool

#

Oh no wait, I don't have the right permissions

#

Rad

mellow hare
#

Can't seem to get it to work by running the site separately or with running them both through docker-compose

#

Just keep running into walls

hardy gorge
#

@eternal owl I've just read back a bit and saw that you were implementing a whole new paginator feature. What's the idea behind this decision?

#

It sounds like a lot of work and potential headaches, but I'm not sure if we should ever use it.

#

Tags should never be longer than a single embed, IMO

#

In fact, I think that tags should always be relative short and to the point, although we could think of having more sizeable tutorials/explanation on the site's wiki

eternal owl
#

Okay, thanks for letting me know 👍

green oriole
tawdry vapor
#

The discussion may have not been public

#

@glass pecan and I discussed it mainly

#

I don't know if he formalised his plans inn writing

green oriole
#

Okay, I don't think it was

cold moon
tawdry vapor
#

Sorry I can't respond now. Just leave a comment on them asking for clarification

#

You'll need to specify what about them you don't understand

cold moon
#

I already fixed almost all tests, only post_infraction test is still not fixed due this is confusing. All there loop things etc.

gusty sonnet
#

Basically let you search tags via content, not tag name

crude gyro
#

@gusty sonnet quick question about this PR - this replaces the existing functionality then?

gusty sonnet
#

No, it adds more to it - by default !tag something search for something in each of the tag name

#

so if someone wants to search about something in the tag content instead, they do !tag search content

#

It's a subcommand of !tag

crude gyro
#

riiight.

#

okay, nice.

#

@gusty sonnet what editor are you using?

#

and do you use your editor to commit?

gusty sonnet
#

I'm using VSCode, I commit via github desktop for now, but I used to commit through git directly

glass pecan
#

vscode had a pretty nice git integration though

gusty sonnet
#

It does, I sometime use it as well

#

I use the desktop client for easier time browsing through PRs

green oriole
#

VSC seems to keep a lock on the git files, which is kind of horrible for me

crude gyro
#

okay.

#

well

#

try to keep the first line of the commit message to under 50 characters

#

github desktop might have a way to help with this

gusty sonnet
#

Oh, okay, github desktop does not warn me about this, let me fiddle with it and see if I can set a limit

#

Otherwise I'll measure the length before

crude gyro
#

if it's under 50, you don't get this ... split

#

so it's nicer to read in github

#

no big deal, just a tip

gusty sonnet
#

But yes, I can see that it will be very annoying to read in the commit history, thank you @crude gyro

crude gyro
#

hm, that kinda sucks.

#

I would be exceeding 50 characters all the time if pycharm didn't stop me

molten bough
#

You can set a right margin in the commit message window in PyCharm if you end up using it

#

haha, concurrent thoughts

gusty sonnet
#

That's not a bad idea haha

crude gyro
#

pycharm can set a margin for the body, yes.

#

and even wrap the text for you

#

so you can just type

#

and for the description line, it can warn you when you exceed 50

#

so it underlines the characters above 50 with red

tough imp
#

is 50 standard? i use 72 (pycharm default) and it always fits on github

gusty sonnet
#

The | is at the 50th, github desktop is really nice, it tries to scroll to the right too lol

green oriole
#

Some of my commits are above 50 and doesn't wrap around like this

crude gyro
#

50 for description line, 72 for body

glass pecan
#

interestingly, my commit doesn't warn me lately

#

wonder if i messed up my settings somewhere

crude gyro
#

chris beams 7 rules of good commits:

glass pecan
#

i tend to know by feeling anyway

tough imp
#

mm ok

green oriole
#

I wonder if I can setup a postcommit hook to warn me about too long messages

glass pecan
#

seems this was disabled

#

fixed now

crude gyro
#

post-commit seems a bit late lemon_smug

tough imp
#

gitkraken will adjust font size so that if you set summary len != body len, the guide applies for both

#

thats super cool

green oriole
#

I mean, no other hook have access to commit messages right?

tough imp
#

at least i think thats how it work

glass pecan
#

git kraken is nice, but multiple times has throws settings away i've set in git cli

crude gyro
#

there's a commit-msg hook, akarys

glass pecan
#

so i avoid it

crude gyro
#

and yes you can set it up to check stuff like this

green oriole
#

Oh nice

crude gyro
#

you could write a python script for the commit-msg hook if you wanted

#

it's fairly trivial to do

green oriole
#

And non-zero does abort the commit?

crude gyro
#

yes

green oriole
#

Perfect!

gusty sonnet
#

Hmm, VSCode git integration is not bad, I should try committing via its interface

crude gyro
#

The commit-msg hook takes one parameter, which again is the path to a temporary file that contains the commit message written by the developer. If this script exits non-zero, Git aborts the commit process, so you can use it to validate your project state or commit message before allowing a commit to go through.

#

I used a commit-msg hook in a previous job to validate whether the employees had remembered to write this signature we used to connect the commit to the git issue.

gusty sonnet
#

But I like being able to quickly select what lines to commit in github desktop too, what a dilemma

crude gyro
#

staging is very valuable.

#

does vscode have no way to do that?

gusty sonnet
#

You can stage commit stash pop and everything you do in git

crude gyro
#

yeah, but staging specific lines

gusty sonnet
#

About VSCode, no it doesnt let me stage selected lines only

crude gyro
#

then it's worthless

#

maybe with a plugin?

#

apparently it is possible

tough imp
#

you can probably stage with gh desktop and then commit from vsc lol

crude gyro
#

@gusty sonnet cuneiform_this see gif

gusty sonnet
#

Oh apaprently it is

#

I just found it too, too late lol

crude gyro
#

nice

gusty sonnet
#

Hmm, then goodbye github desktop!

glass pecan
#

yeah vscode's git integration is pretty noice

#

i don't use it a lot now that i use pycharm though

gusty sonnet
crude gyro
#

yeah that's cool

#

but it didn't warn you that there's no blank line between dfescription and the rest?

gusty sonnet
#

Apparently there is no such warning haha

#

Let me test and see if it comes out good

#

yep it all bundled into the commit message

#

Thanks @crude gyro - I never realize VSCode's git integration is already pretty nice

#

Specially after they made this possible to see the structure of the code.

crude gyro
#

yeah, that's nice

#

no problem

gusty sonnet
#

Okay, committing and pushing via VSCode is very nice, it does trigger precommit properly as well!

eternal owl
#

The only problem with vs code is the icons UI, or the sidebar in general, lol

glass pecan
#

never had an issue with them

#

i like the sidebar, and i like that icons are hideable

#

the entire bar is hideable also if you don't care for it

molten bough
#

The UI is a bit minimalist for me but it's still quite usable

clever wraith
#

I think i commented about this

#

yes i did

eternal owl
crude gyro
#

yes. it's on our roadmap for this year.

green oriole
patent pivot
#

huh that's odd

#

@green oriole can you test it for me?

#

try upload a py file here

gusty sonnet
#

Will it filter if I upload?

green oriole
patent pivot
#

well well well

green oriole
#

Oh well

gusty sonnet
#

Hmm, rip filtering

patent pivot
#

try upload another banned filetype, txt?

green oriole
#

It was from my phone, I had a dumb script somewhere

patent pivot
#

ah

stable mountainBOT
#

Hey @green oriole!

It looks like you tried to attach file type(s) that we do not allow (.txt). We currently allow the following file types: .3gp, .3g2, .avi, .bmp, .gif, .h264, .jpg, .jpeg, .m4v, .mkv, .mov, .mp4, .mpeg, .mpg, .png, .tiff, .wmv, .svg, .psd, .ai, .aep, .xcf, .mp3, .wav, .ogg, .md.

Feel free to ask in #community-meta if you think this is a mistake.

patent pivot
#

oh

green oriole
#

txt is filtered

patent pivot
#

well then

#

.py is not on the whitelist

green oriole
#

There is a special case for py iirc, it might not be working from the phone

#

But it is pretty weird

clever wraith
#

there's supposed to be a special paste message, I think

patent pivot
#

yeah special case

#
        if ".py" in extensions_blocked:
            # Short-circuit on *.py files to provide a pastebin link
            embed.description = (
                "It looks like you tried to attach a Python file - "
                f"please use a code-pasting service such as {URLs.site_schema}{URLs.site_paste}"
            )
clever wraith
patent pivot
#

config must be out

green oriole
#

Hem's cat?

clever wraith
#

yes?

green oriole
#

Is that actually hem's second account?

clever wraith
#

No, it's not

green oriole
#

Okay okay

#

Are you on a computer though?

rocky bloom
#

im on a computer

#

want me to test anything?

clever wraith
#

I'm on a computer, that's why I tried

#

This is just a random python file from the bot repository

green oriole
#

Okay, any exception anywhere Joe?

clever wraith
#

Sentry hasn't reported anything

patent pivot
stable mountainBOT
#
In [7]: print(message.filename.lower())
Out[7]: 
  File "/bot/bot/cogs/eval.py", line 168, in _eval
    res = await func()
  File "<string>", line 5, in func
AttributeError: 'Message' object has no attribute 'filename'
patent pivot
#

right

#

why

green oriole
#

Because it is an image

#

Python files does have a name

patent pivot
#

images have names right

green oriole
#

Wait no

#

You are doing it wrong

rocky bloom
#

message.attachments[0].filename.lower()?

green oriole
#

It should- Yeah

patent pivot
#

from the code file_extensions = {splitext(message.filename.lower())[1] for message in message.attachments}

rocky bloom
#

yike

green oriole
#

Whaat

rocky bloom
#

wait

#

that works

#

but that variable name is horrible

#

file_extensions = {splitext(attachment.filename.lower())[1] for attachment in message.attachments} is the same thing but wih a variable name change

green oriole
#

I think he blew up somewhere

#

Yes he did

patent pivot
#

so why does it not break elsewher

clever wraith
#

"fucked up" sounds a bit harsh

green oriole
#

I did not mean that sorry

rocky bloom
#

the way to test it is to upload two files in one message; one with .py and one with forbidden extension

#

see if it errors out or it just skippes the if

green oriole
#

But it has to go through this line anyway

patent pivot
#

oh wait I see how this is working

#

no this code works

rocky bloom
#

that line seems to work because it blocks everything else

hardy gorge
#

it should work

patent pivot
#

!int e ```py
file_extensions = {splitext(message.filename.lower())[1] for message in message.attachments}
print(file_extensions)

stable mountainBOT
#
In [8]: file_extensions = {splitext(message.filename.lower())[1] for message in message.attachments}
   ...: print(file_extensions)
   ...: 
Out[8]: 
  File "/bot/bot/cogs/eval.py", line 168, in _eval
    res = await func()
  File "<string>", line 5, in func
  File "<string>", line 5, in <setcomp>
NameError: name 'splitext' is not defined
hardy gorge
#

it uses split extension to split it in name, extension

patent pivot
#

ah

hardy gorge
#

os.path.splitext

patent pivot
#

!int e ```py
from os.path import splitext
file_extensions = {splitext(message.filename.lower())[1] for message in message.attachments}
print(file_extensions)

stable mountainBOT
#
In [9]: from os.path import splitext
   ...: file_extensions = {splitext(message.filename.lower())[1] for message in message.attachments}
   ...: print(file_extensions)
   ...: 
set()

rocky bloom
#

wait no wait wait

patent pivot
#

oh

#

no files im a fool

rocky bloom
#

i know the issue

patent pivot
#

!int e ```py
from os.path import splitext
file_extensions = {splitext(message.filename.lower())[1] for message in message.attachments}
print(file_extensions)

stable mountainBOT
#
In [10]: from os.path import splitext
    ...: file_extensions = {splitext(message.filename.lower())[1] for message in message.attachments}
    ...: print(file_extensions)
    ...: 
{'.py'}

hardy gorge
#

yes, it should work, yeah

patent pivot
#

what's the issue?

rocky bloom
#

right?

green oriole
#

Right, a return should be place after the embed code

#

No it shouldn't

patent pivot
#

wait

#

someone upload a py file, i'm watchingn logs

green oriole
#

The log.info is the issue

rocky bloom
patent pivot
#

yeah, nothing in logs

green oriole
#

So yeah, this commit created this issue

rocky bloom
green oriole
#

Because blocked_extensions_str isn't defined, suhail is right

patent pivot
#

yeah

green oriole
#

The error happen while the log formatting, that's why you don't have any log

hardy gorge
#

It should still raise an exception

#

I wonder what's causing it to not show up

green oriole
#

Sentry said no?

patent pivot
#

it's beyond sentry, there is nothing at all in the logs

green oriole
#

Does any traceback inside on_message functions are at least caught somewhere?

patent pivot
#

the last log on pdbot is:

2020-03-08 17:45:47 | bot.cogs.antimalware | INFO | User 'Akarys#2780' (407110650217627658) uploaded blacklisted file(s): .txt
green oriole
#

Because I think exception logging is only for commands, isn't it?

patent pivot
#

this is an exception though

rocky bloom
#

on_message errors aren't caught in any on_command_error

green oriole
#

^

rocky bloom
#

which means they should print directly to stderr

green oriole
#

Comment line 58 is also wrong btw

patent pivot
#

why

green oriole
#

Do you have any traceback from a cog listener in the log and/or sentry?

patent pivot
#

no

green oriole
#

It isn't an offending message?

patent pivot
#

it is an offending message

#

it violated the anti-malware triggers

green oriole
#

Fair enough

patent pivot
#

offending is not just like fuck you lemon, offending is just the problem causer or displeasure

green oriole
#

Okay, didn't know that

#

I was still on the French definition of offending haha

patent pivot
#

is it a valid token?

#

ah I panic removed it

glass pecan
#

lol

green oriole
#

Haha

glass pecan
#

it doesn't look valid

hardy gorge
#

No

green oriole
#

Okay fair enough

glass pecan
#

colons aren't allowed in tokens afaik

#

there's also three periods

#

i see only two in this

patent pivot
#

yeah

rocky bloom
#

ah I panic removed it
better safe than sorry 😂

patent pivot
#

let's disable all messages to prevent token sending

green oriole
#

Only mods can post

#

Seems like a fair security haha

patent pivot
#

DM mods your questions and answers

#

we'll repost in channels

rocky bloom
#

each channel has a slowdown of 1 day

#

and messages can only be a single character long

patent pivot
#

one day i'm going to add a slowmode to a random channel of 6 hours and see how long it takes someone to ask me about it

rocky bloom
#

april fools?? lemon_glass

glass pecan
#

nah

cold moon
#

@tawdry vapor when you have time, can you please specify and give any simple examples for post_infraction test?

valid quest
#

Hello, ive searched some places and tried many methods, Anybody got an idea how to get a misspelt command args and kwargs without splitting the message?

#

The Topic is about suggesting a misspelt command or tag

#

I would love to achieve a way to try suggest a tag first if no args or kwargs provided, and if args or kwargs are provided, try suggest a command first

#

I could split the message, but im looking for the best way to perform this, altough splitting is ok

#

Also, should tags be invoked when a Context has args and kwargs?

#

!mut @F4zi.#1107 123 shouldn't invoke a tag named mutable

#

While !mut should

valid quest
#

@gusty sonnet Take a look at this ^

green oriole
#

I mean, you can do !codeblock please use a codeblock

#

But the tag codeblock should trigger

#

I think you should just take the first argument and try to lookup in this order

  1. Full match command name
  2. Full match tag
  3. Fuzzy match tag
  4. Fuzzy match command name
brazen charm
#

Gonna be more complicated to do it like that, with tags being handled by the Tag cog and command completely with fuzzy and all

#

The error handler just passes it forward to the cog on commandnotfound

green oriole
cold moon
#

OK, now I understand what I need to do in post_infraction test. Now I must just brainstorm how to do this lol.

eternal owl
cold moon
#

@eternal owl Maybe you should post this to issue too?

eternal owl
#

I think I should discuss first pithink , the staff might have a plan

#

There was a discussion quite some time ago, about using google calender for this

cold moon
#

But when someone post that he want to work with it before you get assigned, you may lose your work...

hardy gorge
#

Google Calendar?

#

Do you have that discussion somewhere?

eternal owl
#

really old, lemon was there too

#

But there was a convo about this long time back

#

a short one

hardy gorge
#

Was that for the website itself or for internal use?

eternal owl
#

website, about that issue

tranquil topaz
#

this one maybe @hardy gorge

hardy gorge
#

Right

cold moon
#

@tawdry vapor I have (again) question about post_infraction test: How should I modify test's bot.api_client.post side_effect during calling function? Due this may call bot.api_client.post 2 times.

hardy gorge
#

So, not to make the calendar

#

Just integration so people can events to their personal calendar

#

An integration

eternal owl
#

i can't see that old msg

hardy gorge
#

It's in an archived channel

#

Thanks @tranquil topaz

tranquil topaz
#

yeah you cant @eternal owl sorry

eternal owl
#

👍

#

a screenshot, maybe?

tranquil topaz
#

yes working on it

eternal owl
#

thanks!

molten bough
#

The entire thing could probably be powered by gcal to be honest

#

although that might make management trickier

cold moon
#

One thing that should be added with Google Calendar too is countdown. This should be nice feature and I think Google Calendar will have feature this.

molten bough
#

I don't think it does support that

eternal owl
#

I have 1 question, that is : If the calendar is for events like code jam, then how helpful will it be as we have discord announcements?

molten bough
#

It allows people to set their own reminders

#

Also, it might be nice to have some way to add community events to it (or a separate calendar)

brazen charm
#

history isn't that nice through discord

molten bough
#

That too, yeah

tawdry vapor
#

@cold moon I don't understand your question

molten bough
#

and you can see upcoming stuff far into the future as it's planned

cold moon
#

Due post_infraction have loop that allow it's try again, how should I do that second time this will not raise error? Or should I remove this test case?

brazen charm
cold moon
#

@tawdry vapor

tawdry vapor
#

Just set the side effect to none

cold moon
#

But how I can do this during executing function?

green oriole
#

About the hush commands, does @Developers actually doesn't have send permission, or they just don't have view permission? Because we could sort them like this

hardy gorge
#

@cold moon I think side effects takes an iterable of side effects, which will supply one side effect each time the callabe is invoked.

cold moon
#

Oh, nice. Thanks

hardy gorge
#

Check the docs, I haven't used it like that in a while

#

!docs get unittest.mock.MagicMock

stable mountainBOT
#
class unittest.mock.MagicMock(*args, **kw)```
`MagicMock` is a subclass of [`Mock`](#unittest.mock.Mock "unittest.mock.Mock") with default implementations of most of the magic methods. You can use `MagicMock` without having to configure the magic methods yourself.

The constructor parameters have the same meaning as for [`Mock`](#unittest.mock.Mock "unittest.mock.Mock").

If you use the *spec* or *spec\_set* arguments then *only* magic methods that exist in the spec will be created.
hardy gorge
#

If side_effect is an iterable then each call to the mock will return the next value from the iterable.

#

@brazen charm I think that there's no reason to make the !hush command complex, if that's what you're asking. The only thing I'm slightly concerned about is that if that permahush options gets added, hushed channels may go unnoticed by staff since they should not be, well, affected by it. I also believe that hushing a channel from another channel leads to bad UX, as a channel will be locked without indication for the participants there. I think it's better for a mod to come in and visibly hush it.

#

(I can't log in to GH from here atm)

brazen charm
#

The permahush should be taken ccare of by the notifier that's set up when that is applied to a channel which triggers every 15 minutes.
For the channel I found it a bit conventient when testing but that's also not a real application with users around and probably used it thousand times more than it'd be used normally... and was often mixing up syntax but an opinion from others is nice before I scrap it and just use the context's channel

#

The main issue is when the bot goes down with hushed channels more so if there isn't a good way to discover the hushed channels...
Asked about this before but didn't really get an answer, when the bot restarts is it a "hard" restart or do cog unloads etc. get executed?

green oriole
#

The image has shut down, so the unload should be called, although there could be some cases where the bot got a hard shutdown, you should be able to handle that case I think

#

I think you should be able to get all the hushed channels, since the @Developers role should have send denied but have access to the hushed channel, and for channels like #announcements I don't know how it is setup but if you forbid send to everyone, put @Developers in not override mode and allow it to admins, it should be good

#

If it makes any sense

brazen charm
#

The public but not open channels were my concern in the comment addressing it, don't know the setup here if they can be differentiated from normal channels with an overwrite for sending on devs.
Keeping them as a constant and then removing from the list is a solution but that just sounds bad

woeful thorn
#

I still don't see a reason for an intentional permanent hush

green oriole
#

No yeah, if something isn’t in sync, it could be pretty bad

woeful thorn
#

Moderation actions have never taken more than like 5 minutes to sort out

green oriole
#

But what if the bot reboot while the hush is active?

woeful thorn
#

intentional

green oriole
#

But we aren’t talking about perma hush lemon_glass

woeful thorn
#

I can read

#

Are we not allowed to talk about more than one thing in here?

#

Given that Ves mentioned it 20 minutes ago I think it's pretty relevant

cold moon
green oriole
#

Okay okay

cold moon
#

This post_infraction is making me so angry that I want destroy my computer...

green oriole
#

Pro tip : don’t do that

cold moon
#

I know, just all this loop, error handling etc...

green oriole
#

So you want a status code that doesn’t raise an execption, but does what?

cold moon
#

AttributeError: 'list_iterator' object has no attribute 'status'

hardy gorge
#

I still don't see a reason for an intentional permanent hush
@woeful thorn

Some people were in favour for that in the issue for other types of situations. Personally, I think the situations mentioned (like an abused role ping triggering a flood of people) are utimately so rare (if they even happen) that I'm also not sure if it needs to be built into a command. WCS is that we have to toggle permissions for a channel manualy.

#

However, there were quite a few voices in favour as well.

brazen charm
#

the permanent hush doesn't bring that much complexity into the command if that's a concern

molten bough
#

I imagine it would be handy to have a temporary hush of undefined length, though

#

which is basically the same thing

hardy gorge
#

I don't see the semantic difference between the two

#

Anyway, I don't really mind either way

#

The only way I see to definitively store which channels are hushed or not with a command is by using persistent storage of some sort. I'm not sure what the best option for that is, as we could mark a channel on Discord (name suffix, marker role in permissions, I don't know; I'm not very creative today) or just store active hushes in our database like we do with other things that we want to persist throughout potentially unpredictable bot restarts.

molten bough
#

You would have to anyway, I'd have thought

#

Since not all channels have the same perms

#

You'd probably want to store the previous state

hardy gorge
#

If we somehow manage to hold onto which channels are hushed and we make sure that status can only be applied to channels where developers normally have "send messages" permissions, there's not much additional state to store.

cold moon
#

Is there any way to give post_infraction test making to someone else. I understand, what this function do, but I can't write test for this. After 2/3 days of working of this, I just can't continue. Can I address other tests reviews and will this currently get merged without post_infraction?

tawdry vapor
#

Have you considered rewriting the function? You are not bound to work with it how it is. Sometimes things need to be rewritten to become more testable.

cold moon
#

I must think about this.

brazen charm
#

there already is a check for making sure the channel doesn't already have turned off send messages (not against None if that should also be there)
But for persisting it in some way that sounds like a longer discussion... not persisting duration was a point in the issue

woeful thorn
#

It doesn't need to remain part of the issue if it makes things far more complicated than they need to be

brazen charm
#

it could be avoided by posting a list with the hushed channels on cog unload and then leaving it to the mods. Just can't really restore the full state of the permission overwrite if there was any, just set it to allow or the middle thing

#

Are the permissions set up in a way where that would make a difference?

mellow hare
#

My test bot is so jacked up and I don't know how to fix it

#

Should I just reclone the repo? Anyone know off hand if that would help?

hardy gorge
#

Did you confirm the syncers?

#

There should be a message for confirmation

mellow hare
#

Doesn't recognize me hitting it

hardy gorge
#

Do you have the devcore role?

mellow hare
#

Core Developer you mean? Yeah

brazen charm
#

some of the config values were renamed, not sure if that could be or is the issue here but changed those?

tawdry vapor
#

Is your config using the correct IDs for roles?

#

The welcome channel has an up to date config if you need it

mellow hare
#

Yeah I think I'll give that a shot

#

Didn't realize it was over there now, thought it was still in dev-core here

#

Sorry I keep pestering you guys with this

tawdry vapor
#

There is one but in dev core too but it's outdated by now

#

I figured it's easier to keep it in the test server

mellow hare
#

Fair point

hardy gorge
#

I'll unpin the one here and point people to the one on server.

mellow hare
#

I'm easily confused

mellow hare
#

@tawdry vapor That was it, thanks Mark

tawdry vapor
#

Np

mellow hare
#

It's weird, though. I'm fairly positive I double checked all the role IDs

tawdry vapor
#

Some constants were renamed

mellow hare
#

Ah that would be it then

tawdry vapor
#

Usually adding a hyphen or adding an s to the end

jade tiger
#

Have the way CI linters work changed? I can't seem to see the status of it and it's been 10min - either that or I'm blind

#

nvm i just needed to resolve merge conflicts. lol

mellow hare
#

Done that before, I feel your pain

flat escarp
#

oof

#

why is python so easy

#

...

cold moon
#

I think this is not place where speak about it

flat escarp
#

oh yes

glass pecan
#

are you lost perhaps?

flat escarp
#

oof lost

#

srry

mellow hare
#

Dumb question: If I rebase onto master, is this normal? Or should I not have rebased and just dealt with the conflicts when the time came?

molten bough
#

Dealing with conflicts is just part of the fun

#

Rebase vs merge won't get you less conflicts in most cases

mellow hare
#

But it should avoid that huge commit mess on the PR?

#

That was my main concern

molten bough
#

It should avoid layering over the commits from the other branch, yep

tawdry vapor
#

Looks fine to me

#

I don't see those commits

hardy gorge
#

They were there, but I flipped the target branch around and back again

#

So, now it should be fine

#

the lemon tactic

crude gyro
#

you should flip...

#

oh yeah

#

@hardy gorge sorted it out

#

thanks

#

@mellow hare sometimes a rebase (even a merge) can fuck up the github commit history. It doesn't actually contain those commits (since they already exist in the target branch), it's just a GitHub display bug. You can solve it by changing the target branch to something else and then changing it back.

mellow hare
#

Ah I gotcha. So mainly just don't worry about it?

#

I just didn't want to do anything wrong

green oriole
#

They doesn't show up now (they didn't for me yesterday too) so yeah, you don't need to worry about it

mellow hare
#

Gotcha gotcha

crude gyro
#

you do worry about it, cause it ruins the PR and makes it unreviewable

#

you solve it by changing the target branch to something else and then back

#

this time, ves did it for you

mellow hare
#

Ah, sorry

#

I'll know for next time

crude gyro
#

so this time, you don't worry about it. next time you fix it yourself, armed with this new knowledge. lemon_fingerguns_shades

mellow hare
#

Armed to the teeth

#

And I finally have a couple moments so that I can actually test my PR

brazen charm
#

What would be a good bot response after a channel was hushed/unhushed? Had for example this f"{Emojis.check_mark} {channel.mention} silenced for {duration} minute(s)." before but with the channel choice removed doesn't really make sense to include it in... something like f"{Emojis.check_mark} channel silenced for {duration} minute(s)."?

mellow hare
#

"This channel is now silenced for x minute(s)." maybe?

#

Something making it a bit more obvious that it is in fact this one that got hushed

#

Is there a setting or something to disable the initial Checkpoint message from being sent out when you load up a test bot?

#

Because that would be lovely

green oriole
#

Debug mode does disable it I think

mellow hare
#

It doesn't, I have that flag set as well as passing it on when I make the pipenv run start --debug

#

So it's both there and redundantly done in my .env

#

I mean it's not a huge deal breaker, I just feel bad for having that sent out every time

crude gyro
#

sounds like that should be handled by the debug flag, so if it's not, why don't you just add it?

#

it's okay to include those little quality of life changes in your otherwise unrelated PRs

#

we call those "kaizen commits"

mellow hare
#

True. I'll take a peek. I mean it'd be just as simple as not loading the verification cog, ja?

crude gyro
#

might be a little much.

#

I'd probably just silence the ping. we might wanna test that cog, right?

#

we used to have a bunch of cogs we didn't load in debug mode

#

but I think we stopped doing that since we're using a dedicated test server now and want the bot as close to the real thing as possible

mellow hare
#

True

#

Well before I think about that, I want to get my PR working, which it isn't

#

I'll have to look into that later, right now it's back to stuffing envelopes...

brazen charm
#

Anyone else got an opinion on the return message from hush? Like the idea of something along the lines of "This channel..." but not the wording itself

mellow hare
#

I do but it'd be more like a Samuel L Jackson quote than something acceptable for here

tough imp
#

maybe it could say "Shhh!"

#

i mean, not only

mellow hare
#

"Shhh... no words.. just this moment"

tough imp
#

"Shhh.. only mods now" sloth gif

brazen charm
#

the shh comes from mods with !shhh

eternal owl
#

so now we will be left with !tags to view all the available tags and !tags <tagname> for tag description

#

with aliases !tag and !t

brazen charm
#

Remember to also change the error handler fallback if you remove get

eternal owl
#

gotcha

#

thanks for leting me know!

#

I will just have to change this line
tags_get_command = self.bot.get_command("tags get")

eternal owl
#

Oh no, we got conflicts

#

the search by description for tags was merged first

green oriole
#

_Time for the mind flex _

eternal owl
#

I have absolutely no idea what to do now, lol

#

looks like I have to keep that group

green oriole
#

Do you have a link to the PR?

eternal owl
tawdry vapor
#

Yeah then you do have to keep the group

mellow hare
#

Alright, remind me: log.trace() is for showing how a program is progressing through its instructions, log.debug() is to let the debugger know something went awry at a certain point, but both only trigger if the debug flag is set when running the bot?

brazen charm
#

debug is for logging interactions i think, with warning+ if something goes wrong

mellow hare
#

Gotcha

woeful thorn
#

It’s probably easiest to think of trace as a supremely verbose debug

mellow hare
#

More like a road map than just road signs?

#

Telling you exactly every twist and turn rather than just when the next rest stop is?

#

I have no idea why I used that as my analogy

#

It won't harm anything if I start scattering logs across a file while I'm trying to figure this all out, right?

#

So long as I just remove them after?

tawdry vapor
#

If you took the time and effort to write logs then you should probably keep them. Though it may require more effort on your part to make them more presentable if they're going to be committed.

#

And no logging doesn't harm anything

mellow hare
#

They're not good logs, they're fairly like log.trace("Infraction is not None, carrying on")

#

It's just me trying to figure out what's going on. And I feel like they'll clutter up the code if I leave them

#

Some of which are redundant anyway, but I wasn't sure that they were

#

Okay, so I found the issue

#

bb_cog = self.bot.get_cog("BigBrother") for some reason this isn't grabbing the cog, so it's giving me None and therefore not going further to remove from the watch list

#

Not entirely sure what the best course of action is from here

tawdry vapor
#

Its name has a space between the words

mellow hare
#

Why yes

#

Yes it does

#

And that was it

#

Thanks Mark, I feel silly for missing that

#

Well it's functioning now. I'll clean it up more tomorrow.

tawdry vapor
#

Np

crude gyro
#

@mellow hare trace logs should be exactly like that

#

and they are useful. sometimes.

#

I say leave'em

mellow hare
#

Okiedokie

#

I'm trimming some of them down at the very least

#

Some of them were painfully redundant (as I learned while doing my testing) but some of them did help me figure out where the failure points were and what not

green oriole
#

Are you refreshing the docs inventory rn?

#

The cog isn’t responding

#

!d list seens to work, but not !d set

brazen charm
#

I think set has a conflict with yh command

#

Try d g set

green oriole
#

Oh yeah, it does work thanks

green oriole
woeful thorn
#

Branching from the existing PR shouldn’t be a mess

#

I don’t know what the alternative would be

green oriole
#

I can do that but the branch isn't on the pydis repo

#

So the PR would be in a separate repo, and it adds a new merge commit

mellow hare
#

Is it a fork?

green oriole
#

Yes, on rohan's fork

#

I can PR to his fork from the upstream, so once it is merged it will update the PR to the upstream, but it doesn’t sound very gitonic to me

brazen charm
#

Don't think it matters but mind that you used the UK TOS while the tag currently uses the US tos (which was updated in december)

green oriole
#

Are they really different?

woeful thorn
#

Why would that not be “gitonic”

#

It’s just a PR to a repository

brazen charm
#

The wording is a bit different, and then date of change

green oriole
#

I feel like it just creates a spaghetti history between two repos, but okay I’m opening the PR

#

Okay with using the UK ToS though?

woeful thorn
#

Why is it spaghetti history?

#

There's no reason you have to make it from PyDis

#

Fork his fork

#

Or just talk to him and ask him to do it

mellow hare
#

Question. Can you rebase a branch from a different fork?

woeful thorn
#

I guess GH doesn't let you fork a fork, weird

mellow hare
#

Or like

woeful thorn
#

Either way, making it a mess is self-induced, just work with @eternal owl to accomplish the goal

hardy gorge
#

you can fork a fork, unless you have a fork of the original repo as well

mellow hare
#

What I mean is can you like take a PR from say Iceman's fork and rebase that on top of the master from ours

#

I just wonder if that would mitigate any conflicts

woeful thorn
#

Rebasing isn't necessary

green oriole
#

Well, I think I’ll just send him the patch, it will be easier

mellow hare
#

Gotcha

woeful thorn
#

Collaborating with each other isn't any different than collaborating on the org repo

green oriole
#

And rebasing can be done accross remotes yeah

eternal owl
#

There would be no problem if I was told earlier that there was another PR editing the tags cog, lol

woeful thorn
#

You receive all the same notifications everyone else does

#

Conflicts happen

#

Regardless, I don't see how it's relevant to changing the content of an existing tag

mellow hare
#

That's still done manually in Discord, right?

#

I didn't think we had any place in the repo itself where we could change the tags

green oriole
#

Rohan’s PR add a place in the repo for the tags

#

That’s why I had to base the branch on that

mellow hare
#

Ahhh, nifty

cold moon
#

I think I finally start understand how to test post_infraction function.

mellow hare
#

How's that?

cold moon
#

I mean like how to test when: check does this called this when this

mellow hare
#

Right right

green oriole
patent pivot
green oriole
#

I think the issue is partially because of iOS too, I had some similar issues in the past, do you still care about it?

patent pivot
#

it's not ours

#

if you think it's a big enough of a bug, report it to the hastebin man

#

but it really is intended for desktop browsers so I think it would be closed

green oriole
#

I read too fast, I though it was your github my bad

eternal owl
#

thanks to @green oriole I have sorted out most of the conflicts but only 1 part left

#

should I remove the 1st import typing ... line and all the <<<<, ==== and >>>> ?

tough imp
#

seeing as the first from typing ... statement doesn't import anything that the second wouldn't you can safely delete it

#

you will probably want to keep the pathlib import though

eternal owl
#

the pathlib is needed

tough imp
#

sure, that comes from you branch

eternal owl
#

yea

#

what about the github syntax

mellow hare
#

What are all of the symbols for?

eternal owl
#

<<<, >>>>, ===

tough imp
#

it's git showing you which parts comes from where

mellow hare
#

Gotcha

eternal owl
#

should I remove those?

tough imp
#

all that should be deleted

mellow hare
#

Interseting

eternal owl
#

okay

#

done \o/

cold moon
#
@patch("bot.cogs.moderation.utils.post_user")
    async def test_first_fail_second_success_user_post_infraction(self, post_user_mock):
        """Test does `post_infraction` fail first time and return correct result 2nd time when new user posted."""
        await self.reset_mocks()

        payload = {
            "actor": self.ctx.message.author.id,
            "hidden": False,
            "reason": "Test reason",
            "type": "mute",
            "user": self.user.id,
            "active": True
        }

        self.bot.api_client.post.side_effect = [ResponseCodeError(MagicMock(status=400), {"user": "foo"}), None]
        self.bot.api_client.post.return_value = "foo"
        post_user_mock.return_value = "bar"

        result = await utils.post_infraction(self.ctx, self.user, "mute", "Test reason")
        self.assertEqual(result, "foo")
        self.bot.api_client.post.assert_awaited_once_with("bot/infractions", json=payload)

Please help with this. This is return None but should foo

green oriole
#

I don't know about it, but you should name the result of the function actual as it is the actual result get from the function, in opposition to the expected result, to keep a consistency between tests

cold moon
#

OK

green oriole
#

Well, that's not the last returned value by the POST request?

cold moon
#

No, it's side_effect

hardy gorge
#

side_effect takes precedence over your return_value

cold moon
#

OK, thanks. Finally thing is again moving 😋

#

IT'S DONE! Now I only need address review

mellow hare
#

I'm trying to hunt down where we set specific things if the bot is ran in debug mode

#

Is that done on a per cog basis or is there a central place where that's usually handled?

brazen charm
#

Think only logging checks for something like that after it was removed from main

woeful thorn
#

You can search for places where the constant is used

mellow hare
#

I can, but I don't know what constant it is

woeful thorn
#

I know a good place to look for it

mellow hare
#

Huh, that's not even what I thought the debug trigger was based on.

#

Fair enough I guess

brazen charm
#

Used a bit more around the antispam but guess you know what it's called now

mellow hare
#

I for some reason always thought it was based on actually telling it to do --debug or having a DEBUG value in the .env file

#

Shows what I know.

#

Guess I never thought to check if it was a constant as opposed to just a check on the .env or something. Thanks, @woeful thorn

mellow hare
#

Okay, last dumb question for now: There was a point where we were discussing how we should handle from imports that import multiple things. Was the preference to have it like:

from bot.constants import (
    Bot as BotConfig,
    Channels,
    Colours,
    Event,
    Filter,
    Icons,
    MODERATION_ROLES,
    Roles
)

or like

from bot.constants import (
    Bot as BotConfig,
    Channels, Colours, Event,
    Filter, Icons,
    MODERATION_ROLES, Roles
)
```?
#

I thought I remember it being the first since it made diffs lighter or easier to process or something?

#

Certainly less work to edit

#

Or is this one of those things that's covered in our style guide and I'm going to feel like an idiot when I go to look

woeful thorn
#

We don’t have a style guide (yet)

#

I prefer the former

crude gyro
#

@mellow hare there were strong opinions on both sides, but we didn't really decide what was best. You'll find plenty of both in our codebase.

#

I also prefer the former.

hardy gorge
#

I prefer the former as well

#

I don't like the latter, actually

tough imp
#

i prefer the former with a trailing comma - if you're going for a nicer diff, might as well

hardy gorge
#

but, I'm not going to die on this hill

#

yes, agreed

crude gyro
#

although when possible, just avoid the from imports altogether

hardy gorge
#

also agreed

#

or, keep one namespace here

crude gyro
#

from random import choice is ugly.

mellow hare
#

That's enough of a consensus for me. I think I was likely in the latter camp about a year ago. But I think as I've grown I've begun to understood more

hardy gorge
#

from bot import constants

crude gyro
#

yeah exactly

#

from bot import constants might be the correct solution here.

molten bough
#

I'd also recommend the single from import

mellow hare
#

I'll go ahead and tweak that then

#

It's part of the kaizen checkpoint reminder thing anyway, so it's a good time to address it

crude gyro
#

because constants.Roles has better readability than Roles

mellow hare
#

Agreed

cold moon
#

Why CI test fail but my local test success?

mellow hare
#

According to the error it's saying that the test_first_fail_second_success_user_post_infraction failed

#

Saying it was expected to be awaited once but it instead got awaited twice

cold moon
#

But my local tests don't fail!

mellow hare
#

Here's the traceback for it:

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.8.2/x64/lib/python3.8/unittest/async_case.py", line 65, in _callTestMethod
    self._callMaybeAsync(method)
  File "/opt/hostedtoolcache/Python/3.8.2/x64/lib/python3.8/unittest/async_case.py", line 88, in _callMaybeAsync
    return self._asyncioTestLoop.run_until_complete(fut)
  File "/opt/hostedtoolcache/Python/3.8.2/x64/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/opt/hostedtoolcache/Python/3.8.2/x64/lib/python3.8/unittest/async_case.py", line 102, in _asyncioLoopRunner
    ret = await awaitable
  File "/opt/hostedtoolcache/Python/3.8.2/x64/lib/python3.8/unittest/mock.py", line 1365, in patched
    return await func(*newargs, **newkeywargs)
  File "/home/vsts/work/1/s/tests/bot/cogs/moderation/test_utils.py", line 374, in test_first_fail_second_success_user_post_infraction
    self.bot.api_client.post.assert_awaited_once_with("bot/infractions", json=payload)
  File "/opt/hostedtoolcache/Python/3.8.2/x64/lib/python3.8/unittest/mock.py", line 2218, in assert_awaited_once_with
    raise AssertionError(msg)
AssertionError: Expected post to have been awaited once. Awaited 2 times.
cold moon
#

I know, but I get no traceback in my local copy.

mellow hare
#

I'm just relaying what it's saying

clever wraith
#

@clever wraith, these are the commands

cold moon
#

@tawdry vapor So I need to change moderation utils.py ?

tawdry vapor
#

Yes

cold moon
#

OK, I'll do this quickly

tawdry vapor
#

👍

cold moon
#

@tawdry vapor Done now

clever wraith
#

@cold moon have you manually saw the pictures for mars command ?

cold moon
#

What you mean manually?

clever wraith
#

Curiosity have the best afaik . But lacks the quantity

#

Like saw how many images are you getting

#

Or what image looks like

mellow hare
#

@clever wraith Have you looked over the code or are you just asking?

clever wraith
#

Asking

#

Cuz while i implemented that command it really lacked the quantity

clever wraith
#

The forst one .
You really think that is something cool ¿

#

First*

cold moon
#

I know, but I'm not going to change it in my code. This will be fixed when API fix this. I don't want add cam limits or something.

clever wraith
#

The other command
Apod
Nasa
Earth
Have a lot of things to post
Doesn't go same with this command

#

No i was thinking of scraping this command and doing other three

#

Cuz i don't believe they have time to work on API's when they have a lot of more important things to do

mellow hare
#

Is this a NASA API thing or us

clever wraith
#

Nasa api

woeful thorn
#

It might be helpful to read the PR first

#

So you know what is currently implemented

clever wraith
#

My point :
We should scrape the .mars command because of unavailiblity of variety of things that we can get.

Why I am saying this ?
Because I worked on this command and there is nothing really cool to show , sure if you like staring at sand.
I am also saying this cuz i am author of the Issue.
Also NASA have way more important work then adding pictures in API

It might be helpful to read the PR first
It is using the same API after all and i know that . and that API as a whole don't have that variety

Still as you say i am taking a look into PR

woeful thorn
#

There are other people in the world, who might find looking at dirt on another planet interesting

brazen charm
woeful thorn
#

There is also no incentive for NASA to continue improving the APIs if nobody is using them

#

So no, it shouldn't be scrapped

cold moon
woeful thorn
#

Yes, that's why I suggested a default

cold moon
#

But what should default? Minimum date? Maximum date?

clever wraith
#

Randomize it ?

woeful thorn
#

You know the minimum sol is 0 and the maximum sol is provided by the mission manifest

#

Seems like a nice range to pick from

cold moon
#

Okay

#

I'll do this tomorrow

woeful thorn
#

Cool

cold moon
#

Going sleep soon

sharp timber
#
[controls]
move_left=a
move_right=d
#

odd

#

Bug outside of this channel with the code paste suggestion functionality

#

seems it's confusing ini, works with rust?

tawdry vapor
#

Not sure how detection works

#

A workaround could be to ignore code blocks that have a different valid language set

#

I don't know. I feel like it should be language agnostic to some degree

cold moon
#

@clever wraith Not good channel for this...

sharp timber
#

Detection is hardcoded to the python language

#

probably not a good idea

#

I'm actually not sure--I don't recall this happening before, and the code I'm looking at with that message was last changed half a year ago

#

...wait

#

Found the bug: ast.parse() is the sole identifier used to determine whether code inside a code-block is intended to be python code or not

#

for my test case, it does not raise a syntaxerror, therefore the block gets printed

#

I'll write up a bug report

green oriole
#

I mean.. It is a valid python code

#

You just have some one object lists and some assignments

sharp timber
#

Exactly, which is why it's bugging. The markdown suggestion uses python code validity to test whether it was intended to be a python code block or not which it probably shouldn't. Regardless, there's code inside the bot already to test whether it's a python codeblock but it isn't being factored into the response behavior

It's got a route for if the block is valid python, but if it's a valid alternate language it falls back to responding rather than silence

cold moon
#

WTF I should do: TYP101 Missing type annotation for self in method? flake8

molten bough
#

Provide a type annotation for self in the method?

#
class ClassName:
    def func(self: "ClassName"):
        ...
cold moon
#

This shouldn't required, this never throw this