#dev-contrib
1 messages · Page 49 of 1
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.
That’s sick
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.
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
Well that's why I'm asking before I do
Where's this, in the git branch menu?
Ah, yeah, checkout isn't a rebase option per se
It just checks out the selected branch into your working directory
No I know that
No worries
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
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
Right
yeah, rebase cow onto master then
So the plugin is just a visual interface to git bisect run?
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
I clone new copy for each branch I use...
Like wait, a new copy of master?
A new clone I think
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
There is a PR for at least some of them
Gotcha
Might be a bit much for me to tackle but I at least am curious what I can do
You can just take a file and go for it
Ah true
Actually, a bigger file just mean more work, not a more difficult work
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
You could always write a test for a __init__ file haha
"Is it there? Yep"
token_remover seems quite straightforward if you want to go for it
Just out of curiosity, what are you working on?
What does it mean by watching a user when they're banned
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
So if you do watch someone, it sends all their messages to a specified channel/log?
Yep, that part is from an old version of the bot
Oh.
The issue is over a year old
Still fixing it?
No one got around to it
So I figured I'd pick it up and do it since it's fairly small
Can I see the current code used to watch people. See if I can try to find some things
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
Nope
Well
is a source of water
I guess so haha
I'll continue working tomorrow with SeasonalBot Space cog.
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.
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
Within a different cog?
What do you want to do?
You want to unwatch from another cog I guess
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
for reference, this is how to reference another cogs method
bot.cogs["BigBrother"].apply_unwatch()
You could use ctx.invoke for that too
it's not a command
Oh right
Well, you could directly call the command and leave more abstraction to the cog
Indeed it is not
We don't want to have to call the command
That's the point of why I suggested the helper
And I can't since I'm setting a separate flag that shouldn't go in the main command
bb_cog = bot.get_cog("BigBrother")
if not bb_cog:
raise Hell("We fooked up")
bb_cog.apply_unwatch()
Fair enough
Oh now that's interesting
just in case something weird happened and the cog isn't loaded
You have to use that exact error message though
there's multiple errors for a cog failing
nothing special though to the general situation
So nothing specific for "Cog failed to load inside of other cog"?
Don't think so
Time to go doc hunting
no
it's either KeyError (if you're using direct cog references) or get_cog returns None
Would that be an ExtensionNotLoaded() or ExtensionError() oh I gotcha
Ah gotcha
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.
only occurs on extension load, so they can't help you here
So do I just make my own Exception in this case or is there one that I should specifically be using
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
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
When the unwatch is supposed to occur?
Yeah. I'll mull it all over
Users are unwatched on bot restart iirc, right ?
I reckon very badly okay
Yeah, #mod-log makes the most sense
users are unwatched when we unwatch
I mean, the issue was about unwatching when they're banned, so not when you unwatch 
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
Yeah, mod-logs seems like the best option
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
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
There are
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?
@crude gyro mind looking at the questions here when you get the time ? https://github.com/python-discord/bot/issues/661#issuecomment-593660199
@brazen charm done
Thanks
@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
For space cog additional arguments, should I use argparse (SeasonalBot)?
A util for discord.py bots that allow passing flags into commands. - XuaTheGrate/Flag-Parsing
What kind of arguments the command can get?
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
Well, it depends on how you feed this arguments to the API, if there is a limited amount of topics...
Since they will be separated subcommands, you can specify the arguments for each commands
I think you should look the arguments up in a specific order
For parsing optional keyworded arguments, you can definitely write a helper, we do not need to introduce a new dependency just for that
ok
Or yeah, something like start=YY-MM-DDD keyword=mars could work
It would be pretty easy to parse too
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)
Can anyone give me regex code to identify python code
i tried this, but its not woring
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?
trying to paginate tags but this happens sometimes
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
will that work if it happens at different points on each page?
it won't unless if its possible to change max_characters on each page 
Sounds like you might need to subclass the paginator
sounds very complicated, lol
Alternatively, you could keep track of the code blocks
and close/open them yourself on each page they span
I checked if number of ```s is even in doc
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.
What isn't working about it?
How would you provide a date without sol? Or a rover without both of them?
Does discord.py support that?
And is that your message, or does it come from the framework?
I think I'll have to build another custom converter for this
@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”
OK
Be creative
You can also make it accept arbitrary amount of keyworded arguments
I made easy converter for this
@molten bough do you think it will be easier to just edit the .md files to tell the program where to turn the page?
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
That will require actually manually put them onto the .md file
yea
Which, yes, will break format on github
Keep track of the code blocks and open/close them yourself
You'll have to create pages yourself
Yep, you can do some algorithm for that
I did not understand
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.
ooh
well it needs to be smarter than that
so I have to go deeper into pagination
you need to be able to start the next page with the same type of code block
well you could probably subclass it
I'm not familiar with the current implementation but I expect it's not a huge modification
okay
https://github.com/python-discord/bot/blob/master/bot/pagination.py#L167
can anyone tell me where is paginator.pages defined?
probably in the parent class
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
Yeah, I see too no reason there
But there has to be a reason cuz the code is there, lol
anything in the blame?
Have core devs speak about https://github.com/python-discord/bot/issues/796 ? Will this get approved or declined?
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
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
Wait, where does that file go?
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)
Shouldn't we PR this in if it's going to be an issue for all Windows users?
Is sys.stdout.isatty = lambda: True really necessary on PyCharm? Does ticking the box to emulate a terminal not work?
If you pass isatty=True to coloredlogs.install(), does it fix it?
nope
This does make it a wee bit difficult to check over my PR
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
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
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?
That's dumb. I don't understand the point of setting it to True if it's going to use the auto detection anyway.
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
Okay and now my check functions are failing
Cool
Oh no wait, I don't have the right permissions
Rad
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
@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
Okay, thanks for letting me know 👍
Hey @tawdry vapor, sorry but which approach are you talking about here? https://github.com/python-discord/bot/issues/818#issuecomment-596152042
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
Okay, I don't think it was
https://pythondiscord.com/pages/resources/interactive/ I think one resource should be added there: https://www.codecademy.com/ Yes, this is paid but have really good courses
https://github.com/python-discord/bot/pull/817/files#r389313280 and https://github.com/python-discord/bot/pull/817/files#r389314551 @tawdry vapor I don't understand these reviews
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
I already fixed almost all tests, only post_infraction test is still not fixed due this is confusing. All there loop things etc.
My PR is a quick one @glass pecan - https://github.com/python-discord/bot/pull/823
Basically let you search tags via content, not tag name
@gusty sonnet quick question about this PR - this replaces the existing functionality then?
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
riiight.
okay, nice.
@gusty sonnet what editor are you using?
and do you use your editor to commit?
I'm using VSCode, I commit via github desktop for now, but I used to commit through git directly
vscode had a pretty nice git integration though
It does, I sometime use it as well
I use the desktop client for easier time browsing through PRs
VSC seems to keep a lock on the git files, which is kind of horrible for me
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
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
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
I see it - https://github.com/desktop/desktop/issues/2055 so the desktop client does not have it yet
But yes, I can see that it will be very annoying to read in the commit history, thank you @crude gyro
hm, that kinda sucks.
I would be exceeding 50 characters all the time if pycharm didn't stop me
You can set a right margin in the commit message window in PyCharm if you end up using it
haha, concurrent thoughts
That's not a bad idea haha
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
is 50 standard? i use 72 (pycharm default) and it always fits on github
The | is at the 50th, github desktop is really nice, it tries to scroll to the right too lol
Some of my commits are above 50 and doesn't wrap around like this
50 for description line, 72 for body
interestingly, my commit doesn't warn me lately
wonder if i messed up my settings somewhere
i tend to know by feeling anyway
mm ok
I wonder if I can setup a postcommit hook to warn me about too long messages
post-commit seems a bit late 
gitkraken will adjust font size so that if you set summary len != body len, the guide applies for both
thats super cool
I mean, no other hook have access to commit messages right?
at least i think thats how it work
git kraken is nice, but multiple times has throws settings away i've set in git cli
there's a commit-msg hook, akarys
so i avoid it
and yes you can set it up to check stuff like this
Oh nice
you could write a python script for the commit-msg hook if you wanted
it's fairly trivial to do
And non-zero does abort the commit?
yes
Perfect!
Hmm, VSCode git integration is not bad, I should try committing via its interface
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.
But I like being able to quickly select what lines to commit in github desktop too, what a dilemma
You can stage commit stash pop and everything you do in git
yeah, but staging specific lines
About VSCode, no it doesnt let me stage selected lines only
you can probably stage with gh desktop and then commit from vsc lol
@gusty sonnet
see gif
nice
Hmm, then goodbye github desktop!
yeah vscode's git integration is pretty noice
i don't use it a lot now that i use pycharm though
Okay this is really nice
yeah that's cool
but it didn't warn you that there's no blank line between dfescription and the rest?
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
Adding a blank line fixed that
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.
Okay, committing and pushing via VSCode is very nice, it does trigger precommit properly as well!
The only problem with vs code is the icons UI, or the sidebar in general, lol
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
The UI is a bit minimalist for me but it's still quite usable
is this still a go?
https://github.com/python-discord/site/issues/188
yes. it's on our roadmap for this year.
For some reason, @stable mountain didn't caught this attachment https://discordapp.com/channels/267624335836053506/587375753306570782/686266088773648400
Will it filter if I upload?
well well well
Oh well
Hmm, rip filtering
try upload another banned filetype, txt?
It was from my phone, I had a dumb script somewhere
ah
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.
oh
txt is filtered
There is a special case for py iirc, it might not be working from the phone
But it is pretty weird
there's supposed to be a special paste message, I think
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}"
)
config must be out
Hem's cat?
yes?
Is that actually hem's second account?
No, it's not
I'm on a computer, that's why I tried
This is just a random python file from the bot repository
Okay, any exception anywhere Joe?
Sentry hasn't reported anything
!int e ```py
print(message.filename.lower())
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'
images have names right
message.attachments[0].filename.lower()?
It should- Yeah
from the code file_extensions = {splitext(message.filename.lower())[1] for message in message.attachments}
yike
Whaat
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
so why does it not break elsewher
"fucked up" sounds a bit harsh
I did not mean that sorry
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
But it has to go through this line anyway
that line seems to work because it blocks everything else
it should work
!int e ```py
file_extensions = {splitext(message.filename.lower())[1] for message in message.attachments}
print(file_extensions)
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
it uses split extension to split it in name, extension
ah
os.path.splitext
!int e ```py
from os.path import splitext
file_extensions = {splitext(message.filename.lower())[1] for message in message.attachments}
print(file_extensions)
In [9]: from os.path import splitext
...: file_extensions = {splitext(message.filename.lower())[1] for message in message.attachments}
...: print(file_extensions)
...:
set()
wait no wait wait
i know the issue
!int e ```py
from os.path import splitext
file_extensions = {splitext(message.filename.lower())[1] for message in message.attachments}
print(file_extensions)
In [10]: from os.path import splitext
...: file_extensions = {splitext(message.filename.lower())[1] for message in message.attachments}
...: print(file_extensions)
...:
{'.py'}
yes, it should work, yeah
what's the issue?
blocked_extensions_str is undefined when the attachemnt is .py
right?
The log.info is the issue
yeah, nothing in logs
So yeah, this commit created this issue
https://github.com/python-discord/bot/blob/master/bot/cogs/antimalware.py#L41
this should be defined outside the elif?
Because blocked_extensions_str isn't defined, suhail is right
yeah
The error happen while the log formatting, that's why you don't have any log
Sentry said no?
it's beyond sentry, there is nothing at all in the logs
Does any traceback inside on_message functions are at least caught somewhere?
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
Because I think exception logging is only for commands, isn't it?
this is an exception though
on_message errors aren't caught in any on_command_error
^
which means they should print directly to stderr
Comment line 58 is also wrong btw
why
Do you have any traceback from a cog listener in the log and/or sentry?
no
It isn't an offending message?
Fair enough
offending is not just like fuck you lemon, offending is just the problem causer or displeasure
Okay, didn't know that
I was still on the French definition of offending haha
Well, the token remover didn't caught this one too, I wonder if it should actually catch it https://discordapp.com/channels/267624335836053506/267624335836053506/686275279928557588
lol
Haha
it doesn't look valid
No
Okay fair enough
colons aren't allowed in tokens afaik
there's also three periods
i see only two in this
yeah
ah I panic removed it
better safe than sorry 😂
let's disable all messages to prevent token sending
each channel has a slowdown of 1 day
and messages can only be a single character long
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
april fools?? 
nah
@tawdry vapor when you have time, can you please specify and give any simple examples for post_infraction test?
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
@gusty sonnet Take a look at this ^
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
- Full match command name
- Full match tag
- Fuzzy match tag
- Fuzzy match command name
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
Guys, what do you think I should do about this one? https://github.com/python-discord/bot/pull/617#discussion_r388145839
OK, now I understand what I need to do in post_infraction test. Now I must just brainstorm how to do this lol.
https://github.com/python-discord/site/issues/188
can I work on this after my current PR is merged(bot repo)?
@eternal owl Maybe you should post this to issue too?
I think I should discuss first
, the staff might have a plan
There was a discussion quite some time ago, about using google calender for this
But when someone post that he want to work with it before you get assigned, you may lose your work...
really old, lemon was there too
But there was a convo about this long time back
a short one
Was that for the website itself or for internal use?
website, about that issue
Right
@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.
So, not to make the calendar
Just integration so people can events to their personal calendar
An integration
i can't see that old msg
yeah you cant @eternal owl sorry
thanks!
The entire thing could probably be powered by gcal to be honest
although that might make management trickier
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.
I don't think it does support that
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?
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)
history isn't that nice through discord
That too, yeah
@cold moon I don't understand your question
and you can see upcoming stuff far into the future as it's planned
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?
if anyone could chime in for some consensus on the optional channel arg here https://github.com/python-discord/bot/issues/661#issuecomment-596131825, holding back a few things for that
@tawdry vapor
Just set the side effect to none
But how I can do this during executing function?
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
@cold moon I think side effects takes an iterable of side effects, which will supply one side effect each time the callabe is invoked.
Oh, nice. Thanks
Check the docs, I haven't used it like that in a while
!docs get unittest.mock.MagicMock
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.
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)
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?
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
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
I still don't see a reason for an intentional permanent hush
No yeah, if something isn’t in sync, it could be pretty bad
Moderation actions have never taken more than like 5 minutes to sort out
But what if the bot reboot while the hush is active?
intentional
But we aren’t talking about perma hush 
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
https://paste.pythondiscord.com/tesimulake.py I need some help here: How should I assign status code to response that this don't raise error and something is wrong with add_user part of this code. Return wrong result.
Okay okay
This post_infraction is making me so angry that I want destroy my computer...
Pro tip : don’t do that
I know, just all this loop, error handling etc...
So you want a status code that doesn’t raise an execption, but does what?
AttributeError: 'list_iterator' object has no attribute 'status'
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.
the permanent hush doesn't bring that much complexity into the command if that's a concern
I imagine it would be handy to have a temporary hush of undefined length, though
which is basically the same thing
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.
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
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.
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?
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.
I must think about this.
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
It doesn't need to remain part of the issue if it makes things far more complicated than they need to be
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?
My test bot is so jacked up and I don't know how to fix it
https://paste.pythondiscord.com/ukuyarewis.py I have no idea why it keeps failing to sync the roles or recognize that I have the proper roles
Should I just reclone the repo? Anyone know off hand if that would help?
Doesn't recognize me hitting it
Do you have the devcore role?
Core Developer you mean? Yeah
some of the config values were renamed, not sure if that could be or is the issue here but changed those?
Is your config using the correct IDs for roles?
The welcome channel has an up to date config if you need it
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
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
Fair point
I'll unpin the one here and point people to the one on server.
I'm easily confused
@tawdry vapor That was it, thanks Mark
Np
It's weird, though. I'm fairly positive I double checked all the role IDs
Some constants were renamed
Ah that would be it then
Usually adding a hyphen or adding an s to the end
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
Done that before, I feel your pain
I think this is not place where speak about it
oh yes
are you lost perhaps?
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?
Dealing with conflicts is just part of the fun
Rebase vs merge won't get you less conflicts in most cases
It should avoid layering over the commits from the other branch, yep
They were there, but I flipped the target branch around and back again
So, now it should be fine
the lemon tactic
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.
Ah I gotcha. So mainly just don't worry about it?
I just didn't want to do anything wrong
They doesn't show up now (they didn't for me yesterday too) so yeah, you don't need to worry about it
Gotcha gotcha
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
so this time, you don't worry about it. next time you fix it yourself, armed with this new knowledge. 
Armed to the teeth
And I finally have a couple moments so that I can actually test my PR
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)."?
"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
Debug mode does disable it I think
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
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"
True. I'll take a peek. I mean it'd be just as simple as not loading the verification cog, ja?
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
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...
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
I do but it'd be more like a Samuel L Jackson quote than something acceptable for here
"Shhh... no words.. just this moment"
"Shhh.. only mods now" sloth gif
the shh comes from mods with !shhh
https://github.com/python-discord/bot/pull/803#pullrequestreview-371411724
taking note from this issue, I will be removing the following ways of calling the command:
!tags get
-!tags show
-!tags g
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
Remember to also change the error handler fallback if you remove get
gotcha
thanks for leting me know!
I will just have to change this line
tags_get_command = self.bot.get_command("tags get")
_Time for the mind flex _
Do you have a link to the PR?
Yeah then you do have to keep the group
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?
debug is for logging interactions i think, with warning+ if something goes wrong
Gotcha
It’s probably easiest to think of trace as a supremely verbose debug
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?
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
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
Its name has a space between the words
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.
Np
@mellow hare trace logs should be exactly like that
and they are useful. sometimes.
I say leave'em
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
Are you refreshing the docs inventory rn?
The cog isn’t responding
!d list seens to work, but not !d set
Oh yeah, it does work thanks
I was going to create a PR to update the ytdl tag, but it will be a git mess no matter how I turn it, can I just push it to this PR? https://github.com/python-discord/bot/pull/803/
Branching from the existing PR shouldn’t be a mess
I don’t know what the alternative would be
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
Is it a fork?
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
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)
Are they really different?
The wording is a bit different, and then date of change
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?
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
Question. Can you rebase a branch from a different fork?
I guess GH doesn't let you fork a fork, weird
Or like
Either way, making it a mess is self-induced, just work with @eternal owl to accomplish the goal
you can fork a fork, unless you have a fork of the original repo as well
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
Rebasing isn't necessary
Well, I think I’ll just send him the patch, it will be easier
Gotcha
Collaborating with each other isn't any different than collaborating on the org repo
And rebasing can be done accross remotes yeah
There would be no problem if I was told earlier that there was another PR editing the tags cog, lol
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
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
Rohan’s PR add a place in the repo for the tags
That’s why I had to base the branch on that
Ahhh, nifty
I think I finally start understand how to test post_infraction function.
How's that?
I mean like how to test when: check does this called this when this
Right right
I found a fun bug haha
@green oriole submit an issue or PR to https://github.com/seejohnrun/haste-server
I think the issue is partially because of iOS too, I had some similar issues in the past, do you still care about it?
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
I read too fast, I though it was your github my bad
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 >>>> ?
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
the pathlib is needed
sure, that comes from you branch
What are all of the symbols for?
<<<, >>>>, ===
it's git showing you which parts comes from where
Gotcha
should I remove those?
all that should be deleted
Interseting
@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
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
OK
Well, that's not the last returned value by the POST request?
No, it's side_effect
side_effect takes precedence over your return_value
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?
Think only logging checks for something like that after it was removed from main
You can search for places where the constant is used
I can, but I don't know what constant it is
I know a good place to look for it
Huh, that's not even what I thought the debug trigger was based on.
Fair enough I guess
Used a bit more around the antispam but guess you know what it's called now
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
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
@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.
i prefer the former with a trailing comma - if you're going for a nicer diff, might as well
although when possible, just avoid the from imports altogether
from random import choice is ugly.
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
from bot import constants
I'd also recommend the single from import
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
because constants.Roles has better readability than Roles
Agreed
Why CI test fail but my local test success?
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
But my local tests don't fail!
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.
I know, but I get no traceback in my local copy.
I'm just relaying what it's saying
@clever wraith, these are the commands
@tawdry vapor So I need to change moderation utils.py ?
Yes
OK, I'll do this quickly
👍
@tawdry vapor Done now
@cold moon have you manually saw the pictures for mars command ?
What you mean manually?
Curiosity have the best afaik . But lacks the quantity
Like saw how many images are you getting
Or what image looks like
@clever wraith Have you looked over the code or are you just asking?
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.
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
Is this a NASA API thing or us
Nasa api
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
There are other people in the world, who might find looking at dirt on another planet interesting
opened up https://github.com/python-discord/bot/pull/812 if anyone wants to take a look through the weekend, not sure if the tests are up to the standard
There is also no incentive for NASA to continue improving the APIs if nobody is using them
So no, it shouldn't be scrapped
@woeful thorn Quick note: https://github.com/python-discord/seasonalbot/pull/364#discussion_r392393767 You can't get anything from API without date.
Yes, that's why I suggested a default
But what should default? Minimum date? Maximum date?
Randomize it ?
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
Cool
Going sleep soon
[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?
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
@clever wraith Not good channel for this...
Detection is hardcoded to the python language
probably not a good idea
I'd ask in #python-discussion
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
I mean.. It is a valid python code
You just have some one object lists and some assignments
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
WTF I should do: TYP101 Missing type annotation for self in method? flake8
Provide a type annotation for self in the method?
class ClassName:
def func(self: "ClassName"):
...
This shouldn't required, this never throw this