#dev-contrib
1 messages · Page 88 of 1
Threads are processes!
the logo is not visible just
can you have the WTF Python Link be the actual link instead of having it below it
alright
and I don't think we need the examples but eh
But Python is just like any other process, so anything you could do by creating a new process you could just do from the Python process- maybe not easily, but you wouldn't want to rely on anything not being possible. So I guess limiting it to 1 PID is more of an extra layer of security than a core part of the sandboxing, and a limit of something like 10 should be fine?
I was mainly just asking because I was playing around with snekbox wondering if I could get plotly to work with it so i can make graphs, just as a personal project, but it requires another process. I'm not planning on using it elsewhere so it doesn't matter if it's not secure though.
hmmmmm
(we have them .cht too)
There are some things you'd need a new PID to start
so I wonder if we have any setuid binaries available
better?
!e ```py
... threads ...
@patent pivot :x: Your eval job has completed with return code 1.
001 | 09:45:43: Main : before creating thread
002 | 09:45:43: Main : before running thread
003 | Traceback (most recent call last):
004 | File "<string>", line 32, in <module>
005 | File "/usr/local/lib/python3.9/threading.py", line 874, in start
006 | _start_new_thread(self._bootstrap, ())
007 | RuntimeError: can't start new thread
there are easier ways to do threads, ya know 😛
I didn't notice that you edited at first, I was really confused about how on earth that would create threads
should i keep the examples or not scal?
I don't think you should, but I'm not the one reviewing your code
lol
unless I am 🤔
@patent pivot :white_check_mark: Your eval job has completed with return code 0.
sys.version_info(major=3, minor=9, micro=2, releaselevel='final', serial=0)
Joe is commanding python using his mind haha
Yeah we did update it
Well, it is automatically updating I guess
Yes, we should stay as close to releases as possible
(when it is released that is)
typically we've lagged behind a bit to allow dependencies to become compatible yeah
Rewrite all the dependencies into our code base 😔
my reasoning is that patma is a huge feature and I think eval is a good thing to showcase it
Yep
It shouldn't be hard to add support for another interpreter
It would be a 20 lines change
Famous last words
lol
But you should be able to download the release tarball, uncompress it during the Docker build and change which directory we are mapping to /bin in nsjail
A wild PR appears
@gritty wind should i set a env variable CHECK_CHANNELS, which would a boolean value, to check for chanels or not?
Just use the DEBUG variable
alright
@cold island how should i store the channel-cog map?
in a yml file like this?
channel
- cog
- cog
# Or maybe
cog
- channel
@gritty wind Yeah i understood that
I don’t think you should start working on this
Yeah it's gonna take a bit of discussion
Yeah i didn't start, i was just getting down some ideas on implementing it
Each cog will probably have its own channel constants, that's also in line with smartconfig
bot#1357 it's been a while since I've opened this, has there been any discussion/updates?
Seems pretty problematic to me since we sometimes remove pins, and then the whole numbering changes
👀
I do think the concept makes sense tho
it won't error- it'll give you an unexpected result, yes.
but i think the target demographic is more regular people
we know when pins get updated
I think zig is getting at muscle memory as well
do we? there's no message when pins get removed, and I don't expect that admins would make an announcement
i made this issue mainly because of how cluttered the pins in #discord-bots (where i spend most of my time helping) is
makes sense
me, and most of the other regulars there are pretty quick to catch up when pins get updated
I'm currently thinking of a larger solution that would be more work, but could work better in the end
its not unusual that many users say they just couldnt find a pin we were referring to, because of how many messages are pinned there
either a !tips id where the id refers to a database id of a specific tip for that channel
It just feels a bit... unreliable. I think named tags would be a better solution
Alternatively, something more reliable to find the pin you want
using a database to give a number to each pin, and that way, if a pin is removed, that specific number goes away but other numbers are unaffected.
Currently we've been wary about adding tags that are too specific to libraries, otherwise we'd end up with overlapping names and it can be more difficult to find one you want. Having channel specific tags could be an idea though..., or some other sort of namespacing.
that's why I'd made the issue in the first place, because of how we keep tags rather general
to make channel spepcific tags, I would make it a !tips command, with a parameter to search a specific channel if need be. Ex !tips #discord․py bot vs client could be used in #bot-commands , but !tips bot vs client in #discord-bots would only search #discord-bots
If I have to throw in a design suggestion, off the top of my hat:
!pin <query> - The query is matched against the first sentence in each pin. Most pins have a title, so you can search by keywords in the title. If the query matches a single pin, show it. If it matches several, let you choose which one somehow or ask for a better query
that could work
so !pin intents will give you the intents pin, because it has that word in its title
but not all pins in the other channels are formatted similarly
gtg
#async-and-concurrency off the top of my head
That's something we can address if it's an actual issue. But not all channels have a lot of pins
fair enough
am i overengineering a problem here though? in my defence, even though it is 2 seconds for me to go and pull the message from pins myself for someone, it adds up pretty quickly
Even with #async-and-concurrency, the pins have a starting sentence that you can use to search it, and it usually contains the purpose of the message
I don't know, it depends on how common it is. If other users feel like it would help them then I personally wouldn't mind it
we can wait for others' opinions then
i think being able to cross-post pins across channels is also rather useful
the !pypi command should be disabled in #python-discussion
the embeds are so big that they cover previous messages and make the process of having a conversation difficult especially if someone were to use it frequently in lets say, #python-discussion. I've noticed this for quite a while and it's a bit annoying
In my opinion it would be better if the command was disabled for non helpers+ in python-general.
thoughts?
O
Either channel would work for this type of discussion tbh
307
its about the bot ig and vester suggested here
So back to the topic on hand
could we use fuzzy matching?
Both places work. I think this channel fits
What is it usually used for in python-general?
Alrighty, the point I was getting at was
if it's used in helping people answer questions by linking to a module's pypi page
we can have an abridged version of it that gets sent in python-general, and the full version that gets sent in other channels
!pypi aioredis
For instance, we can have the title/link + summary
that would be the plan if we do it the way Zig said (by searching for keywords from the first line of the message)
ok
which could look like
asyncio (PEP 3156) Redis support
I missed the logo, but oh well
We could have a cgabnel based cooldown
I wouldn't mind that
We should do that more actually
👀 how the bleep did you send that without writing it?
!src embed
Send the input within an embed to either a specified channel or the current channel.
that actually looks like int eval
That's an int eval, yeah
smh no thoughts on the idea
Wait how many people have int eval access? Mods++?
According to the privacy policy I thought it was 6 people
!src int
Internal commands. Top secret!
Does the privacy policy even mention that
Roles.admins, Roles.owners
It does somewhere lemme find it
I don't think privacy lists that
as the command doesn't really tell you anything you wouldn't otherwise have access to
I imagine the policy mentions people who have access to the database
probs
Direct database access is only available to the dev-ops team, under 5 people.
Yup just direct db access is listed
that being said @patent pivot should update it to 6 now I imagine
we have 6 members in devops
it's 4
!role Devops
409416496733880320
#a1d1ff
0.58 0.37 255
6
72
0

- scragly
scrags?
wait who is in devops
akarys
well even so its not under 5 
lol
what is honcho 
kubernetes control bot
TIL this bot exist haha
doesn't do much yet
But don't people who int e have access to the database?
Or is that where the abstraction comes in?
python doesn't have direct access to database
it only operates via api which is on site
and api is limited to what moderators need from what I've seen
so data such as infractions
not much other than that
The API is publicly available if you really want to dig into what the bot has access to
👁️ what is that new menu, anyways?
I have the old one still
isn't it mostly done on /site 
rolling beta iirc
yesh the site-api
probs canary has it already, if you are on stable unlikely that you can see it
It's available on stable
not for me
Yeah basically
https://github.com/python-discord/bot/issues/1154 I have commented here, can anyonenanswer that.
Is metricity database used anywhere in the bot?
hey there, im working on sir lancebot and i ran the command only to get this huge bit of errors: https://paste.pythondiscord.com/icoquhoyiq.sql
nice string
im dumb
How are u running it?
pipenv run start?
Ah yes
hmmmm
wat what the solution?
Thanks, will try
Worked, thanks!
These issues on the branding repo should probably be closed:
https://github.com/python-discord/branding/issues/15
https://github.com/python-discord/branding/issues/19
https://github.com/python-discord/branding/issues/113 (This one is more recent, but it had to do with Valentines Day. You may want to keep it for next year, just putting it out there.
@clever wraith Greetings. Probably would be better to discuss it here.
hi @vocal wolf , thats probably a good idea.
Are you sure you're on the right branch?
I've run pipenv run lint multiple times and it always returned ```
D:\sir-lancebot>pipenv run lint
Loading .env environment variables...
Check for merge conflicts................................................Passed
Check Toml...............................................................Passed
Check Yaml...............................................................Passed
Fix End of Files.........................................................Passed
Mixed line ending........................................................Passed
Trim Trailing Whitespace.................................................Passed
check blanket noqa.......................................................Passed
Flake8...................................................................Passed
i sent it to master from the branch earth_photos i started
!remind 9H check the branding issues
Your reminder will arrive in 9 hours!
So what branch are you on currently?
master?
earth_photos
i made a commit trying to fix what happened on the actions end
On your next commits, please describe what you've changed in the commit message.
oh sorry! I was kinda rushing whoops
alright, more fails im gonna try and fix it because my end doesnt care
@clever wraith what program are you editing this bot with?
vscode
hmmm
flake8 passed
I think there's an autoformat feature with vscode, I can't remember how to use it though
What plugins do you see when you run flake8 --version
3.8.4 (mccabe: 0.6.1, pycodestyle: 2.6.0, pyflakes: 2.2.0) CPython 3.8.5 on Windows
I think this commit might have fixed
@vocal wolf failed again, im not sure why its so broken
Did you install the dev packages whole doing pipenv install/sync? That looks like it's falling back to your system flake8 as it's missing all the plugins
The only problems now should be ANN201: Missing return type annotation for public function and i dont know what that means
yes
Well, since you're missing the plugins I'd check if you're running the correct flake8
what does ANN201: Missing return type annotation for public function mean
You need a return type typehint
@clever wraith Gave you a review 😄
<@&267629731250176001>
Uhh that wasn’t needed ig
But yeah they are spamming across channels
!tvban 623004898694397978 14d spamming to get voice verified would defeat the point
:incoming_envelope: :ok_hand: applied voice ban to @polar bone until 2021-03-17 05:00 (13 days and 23 hours).
Thanks!
Doesn't look like anyone answered that,
as far as I know, bot does not have any sort of access to metricity
However, site does give bot access to some data from metricity, which we need for moderation, specifically, it gives us total messages and message blocks
https://github.com/python-discord/site/blob/master/pydis_site/apps/api/models/bot/metricity.py shows what it exposes and how
https://github.com/python-discord/site/blob/master/pydis_site/apps/api/viewsets/bot/user.py#L244 is where it is then used.
Thats all I have seen at least and I don't think theres more to it
Alright thanks, i was just going through the issue on bot, and found this: https://github.com/python-discord/bot/issues/1359
ammm not sure if that is possible currently without changing how @viscid badge works
pretty sure as soon as @viscid badge gets MESSAGE_DELETE event it removes the message from database iirc
It doesn't
doesn't it?
It just flags it as deleted
Rule 1 on deletions: you don't delete unless you are forced to
well if one deletes their message we probs should honour their request and delete it from db too
¯_(ツ)_/¯
We don't contain the actual message
still doesn't sound right
And what you're saying goes against our logs as well lol
our logs don't leave discord so it doesn't matter
while database is its own entity thus data manager of that is our devops team
Any logs within discord are still managed by discord
if someone deletes their message, they mean to delete it, not to flag it as deleted
Well that argument doesn't hold up legally, and it's really not up to the user
we use this data for various purposes in running the community
so we keep it on hand
Well I feel Senjan is right, but I dunno what really goes on inside either.
@commands.Cog.listener()
async def on_typing(self, channel: discord.TextChannel, user: discord.Member, when: datetime):
log.info(f"Typing .... on {when}.")
if is_in_category(channel.id, self.in_use_category.id):
self.last_typing_event[channel.id] = when
``` this is the right way to use on_typing right?
Yep
So
Although If I remember correctly it'll also trigger on dm typing so you probably want to filter that out
If that's for out bot, you can't actually use it
at least not right now
We don't get the event
Discord bug, so that may not always be the case
Oh... I think this was meant for not closing help channels early
Yeah we discarded that implementation in the staff meeting
Or some staff discussion
primarily because it's 100% broken right now, and unreliable even when it works
ah ok.
By the way for bot#1432 is it literally just the one line of code that needs to be changed?
Frompy e.description = f"{misspelled_content.replace(command_name, similar_command_name, 1)}"topy e.description = similar_command_name
(Also removing the mispelled_content variable since it wouldn't be needed)
we had a talk on whether or not we actually want to have it that way as it was supposedly used so people can copy paste the command with correct arguments and correct spelling however I haven't ever seen it be used like so
Yeah I haven't either to be honest
Maybe we should implement a little bit of logic around it
If the command takes an argument then .replace (as we do currently) otherwise don't
Should we just use textwrap to shorten it?
Since we get the commands.Command object so we could check that
https://github.com/python-discord/bot/issues/1154 well can someone respond to my comment here
There are no commands, to my knowledge, that take parameters >100 characters, so we could just wrap to 100 with an ellipsis placeholder
Clarified things on the privacy front (see #changelog). We do retain metricity data when a user leaves the server because we have several uses for it, but now that's been made a bit more explicit in the policy.
I think we probs should just change it to only display the suggested command name without the args
message links are in range of 82-87 chars
Yea, I mean they still have their original message of they just scroll up
yea true
If this is the approach we decide on I'd be happy to implement this real quick (seeing as it's only editing 2 lines)
the talk we had was more concerning if it can just be master commit consider its comically small diff
what type of messages go to incident channel?
It isn't automated
if a helper+ feels something needs mod attention
they can put it in there
Actioned incidents
or rejected for that matter
meaning, if u add
, it will move there?
yes
?
ah ok ty
Or 
And it has to be a mod+ adding it
my English isn't too good, what I meant, when we brought it up it was a thing about just committing that change to origin/master rather than making a whole PR for it
I think only coredevs have write rights directly to the repo
https://github.com/python-discord/bot/issues/1226 by this does it mean the logs for deleted message?
since the incidents archive nor the incidents contain a message link
or i understood the issue wrong?
If I'm reading this correctly
when a helper+ posts an incident with a link to the message
automatically post the author ID
so if i post
#dev-contrib message
bot would post
Above message is authored by386599446571384843
in the #incidents channel?
oh ok
so i basically need to check if the message contains a link of a discord message or not
I can probably do this then 
@commands.command()
async def pin(ctx, number: int, channel: Optional[discord.TextChannel]):
channel = channel or ctx.channel
pins = await channel.pins()
if not pins: # no pins in the channel
...
elif len(pins) < number: # there aren't enough pins
...
else: # valid number
await ctx.send(pins[number-1].content) # would actually be an embed```Would this be the very rough approach to https://github.com/python-discord/bot/issues/1357 ?
looks about right
What would we want inside the handling for when there's no/not enough pins?
Just a little embed saying like "there's no pins in this channel" / "there's only x pins in this channel"?
Did we decide that would be the final implementation instead of tags?
There was a suggestion about having it search for some tags pins by text instead of by number
wouldn't make any sense for the context of that command
unless you meant to say pins not tags
I don't think that's a good ui to be honestly, but okay
Sending a jump link to the pin seems way better
Also what would we do in terms of the really long pins? Sending the entire message may be deemed a bit "floody". Maybe a textwrap which then links to the original pin at the bottom?
Yea
yeah i meant that myb
I'm not sure how you'd even wrap embeds
Maybe we can have the bot leave a jump link, but that would be somewhat useless
I think both number and text could work then
You have to remember the pin number, and I'm assuming that they will change every time we pin something else
Maybe count from bottom so it doesn't change
The oldest pin = #1
so its kind of eh
Oh yea true
unless we also store the index in something, that way it doesn't change
but I really don't get the whole idea
Personally I think it would be neater to have them of tags, and could have some sort of namespacing on the tags so we can have channel specific tags without overlapping names (e.g. tags for a specific topical channel)
sounds like a dynamic tag system
As we add more tags, that'd be something to look into
Well currently we're avoiding adding some channel specific tags
Nah, we said it was fine (having library specific tags)
do you have to prefix it with a channel?
We could do that, or use a namespace related to the tag content
then why don't we just add the current pins as normal tags?
¯\_(ツ)_/¯
tags are expected to be of high quality
pins aren't
Tbh that seems like the best solution here if people don't want to use the existing pin system
I guess some of them wouldn't fit as tags either
the index system is kinda jank
also pins are more dynamic than tags
esp in channel like #discord-bots there might be api change and you want people to know how to adapt to it from day 0
And not wait 5 days until a tag PR is written and merged
Well, if it was really urgent then we could just use pins for them in the meantime, without a system for retrieving them, but most of the pins in discord.py now have been there for a while and will still be relevant for a while
I mean we don't pin too often tbh
Anyways
the only way I see the pins system working
is if the indexes never change
otherwise you'll just have people linking to wrong pins and that's not great
lookup by text can work
It's a lot of implementation for very little reward imo
You also have to handle multiple formats, from text, to embeds, to possibly images
images obviously being unsearchable by text
well so are pins
So good review, good writing, and good content is mandatory
I don't agree that pins show as much endorsement as tags
yet we don't hold them to the same standard
more people are just willing to review pins ig
we don't have a min or max number of reviewers for pins
pins are held to higher standard if anything imo
here
ah
the problem, is when u
, the embed should also be sent to #incidents-arhive
but currently that doesn't happen
yep
yea
you'll probably need to persist an incident -> embed(s) map in redis
yeah am doing that
a new redis cache?
and should i store the cache in a new file or just put it there?
Just treat the RedisCache as any other kind of data type that you work with, except for initially assigning it to a class attribute of the Cog you're working on
After that, just use await self.your_cache_name.get and await self.your_cache_name.set and so on
yeah, i went through the help channels cogs and understood that
but where should i create the cache for incidents embed(s) maps?
In the cog init is what would make sense to me
Or even as a class param
Ahh yea, take a look at dm_relay or silence they both create the cache as class params
it should be a class attribute as Ves says, it's documented in the async_rediscache.RedisCache class docstring
i made it as a class param, so need of class attributes right?
You can't really use the __init__ to fill the cache or get the cache, as the access methods are fully asynchronous
You can schedule a task for it, though
Uhh i didn't understand ves
dm_cache = RedisCache() This is what is done when it is in class param, and namespace= is added when it is not in a class param. So what i understand, is that it gets the class attribute of the Cog automatically when set as a class param.
samething is said in the docstring of RedisCache ig
I meant to reply to the suggestion Chris made about __init__
ohk
You don't have to provide a namespace; it will determine it automatically
what is a class param? I think we're mixing terminology here
when you assign the cache as a class attribute:
class SomeCog(Cog):
cache = RedisCache()
it gets the namespace automatically
yes that's what i meant @tough imp
explicit namespace is passed when it doesn't live on a class because then it cannot ascertain the namespace for you
thanks!
Yea, that's my mistake, I referred to a class attribute as a param
and i took it forward 
it's fine ~ feel free to look at the cache's docs, they're well written and have examples
can i move add_signals to the class Incidents in incidents.py?
nvm it is not needed
Why do I get this?
when i have:
put it as:
you cannot persist those types, it only supports the types listed there in the hint
What kind of data are you looking to store?
to persist a message, usually you will store its ID
Could you give a sample of the data that you're trying to store?
# RedisCache[discord.Message.id, List[discord.Message.id]]
message_link_embeds_cache = RedisCache()
yeah one minute
here my message is the first parameter, and the second is all the embeds sent my the bot
uhh so i can't even store a list in it, so i will need to .set() for each of them?
with same first param
I'm trying to figure out your structure
You have a single message and you're trying to link it to several other messages?
yes
And you'll need to make several of such lists?
yes
like 1 for every incident in #incidents
so that they can deleted when the incident is actioned or rejected, (the bot message link embeds won't be sent to #incidents-archive)
hmm, isn't it possible to send multiple embeds with a single webhook message
I'm not entirely sure what you're working on (haven't checked the issue), so I'm mainly going of your description of the kind of data storage that you need
It is; you can send a list of embeds with one message
not webhook.
lemme send the code snipet
this is how it is sent.
I can make use of the paginator for this
so then it would be one message map to one message
you could just use webhook and send up to the 10 embeds at a time
in teh reddis cache
Uhhh, wouldn't a paginator be better?
i don't see the need of webhooks here
why'd you need paginator
webhook supports 10 embeds in same message with like 60_000 chars total allowed
Paginator would keep it to one message and clean
it wouldn't pollute the channel with a number of messages
well webhook would keep it one message as well
paginator would also break easily
it would require both having very long wait time and it wouldn't even keep up between restarts so you'd lose all of the functionality the second bot goes offline
webhook would keep it to one message, i didn't get you.
ah yes
what if someone has 11 links, how will you send them then with webhooks?
unlikely we'll have more than 4 links per message
but in such case simply second webhook message should be fine
I suggested an alternative solution yesterday, if you want to look for it. I'll reply on the issue later
alright
If you're referring to #dev-contrib message and the conversation around that, we just had a similar one again now.
It seems the main issue with the method proposed in the PR is that indexing of pins changes when the pin list of a channel changes, which we don't want.
The general consensus of how to solve this does seem to be what you said, aka some sort of text-matching. Whether that's through fuzzy or just a simple in or whatever.
TLDR; We want text-matching not index-matching
Uhh how do you send multiple embeds with webhook?
await webhook.send(embeds=[list, of, embed, objects])```
If the issue are indices, why not store a permanent mapping of names to message links, something like tags but instead of sending potentially big embeds it returns the link
That you have to go over every single pin and give it a name 😄
@static canyon if you are working on this you should make sure that the invoking user has access to the channel they want to get the pin out of
Or just disable it for private channels altogether
Right now I'm not working on it because not 100% what the implementation method is, but I'm happy to work on it when we've decided
There aren't that many pins that would need to be added
And yeah I'd do the has permissions thing (easy enough to do)
It could work, feels less flexible though. A lot of the pins seem to have a title anyway
There's 110 pins across all topical channels
Granted probably not all of them would be linked to but that's the total
I think a text search would be very limited because there are a lot that don't even have text, and the ones that do are split out across multiple fields
Shouldn't restrict it too much if the api is used, matching text sounds like it could lead to unexpected results as parsing human text is not something that's exactly easy
Hey Everyone! I was hoping to get my feet wet w/ https://github.com/python-discord/sir-lancebot/issues/608 but it looks like I need to get it approved before I can open a PR. Could anyone help me with that?
I can't tell if you want to fix it or not haha
Anyways, I'll approve it, under the assumption that you'll follow Xithirius/Den4200's suggestions
!pban 427858024200404995 Spammer
:incoming_envelope: :ok_hand: applied ban to @nimble current permanently.
Alrighty, be sure to check out the contributing guide on the website (https://pythondiscord.com/pages/contributing/sir-lancebot/) to set up the bot
And feel free to drop in if you need any help
It looks like ./pre-commit is running Flake8, can I trust that or should I be running it manually as well?
You can trust it, or run pipenv run lint to do it manually
They should produce the same results (with precommit running a few more things) as long as it was installed properly
You do have to install pre-commit to make sure it works though
pipenv run lint will lint all files, pipenv run pre-commit will just lint staged files
gotcha, ty!
of course, as Scal said, make sure you do pipenv sync --dev and pipenv run precommit to setup the hook
lint runs it though
I thought precommit installs and pre-commit runs
I think it would be pre-commit run
anyways, that's what lint does
Anyways, as long as you run one of these commands, things will be fine at some point haha
I think the contributing guide details the procedure
@obsidian patio
Here's your reminder: Progress?.
[Jump back to when you created the reminder](#dev-contrib message)
🎉 Done, now time to make the code more pretty and pythonic
816650601844572212 @short snow
ty joe
@thorny obsidian
Here's your reminder: check the branding issues.
[Jump back to when you created the reminder](#dev-contrib message)
Do we need to worry about url injection for the http cog?
Joe forgot one important bug 🙃
What would an injection here be able to do?
Ah, we're converting the code to an int anyway, so that's not an issue
Hey @gritty wind , I don't see how my pr is in breach of point 2, I'm only embedding an image, not downloading it
Right, and I was confused about this for quite a while
But as far as I can tell
"download" is in reference to displaying the content of the images
And it just requires you increment a counter
so it's basically an extra request you should make when getting an image
Now why don't they do that on their end? Well I have no clue
When your application performs something similar to a download (like when a user chooses the image to include in a blog post, set as a header, etc.), you must send a request to the download endpoint returned under the photo.links.download_location property
This is what I was basing it off
The examples they give
An action “similar to a download of an image” can be thought of as an action where a user does something with the photo, usually inserting or setting it somewhere.
Okay, that kinda makes more sense now. Why don't they track it though? That's really weird
I honestly am not sure
https://help.unsplash.com/en/articles/2511258-guideline-triggering-a-download
this is the page fwiw
From what I'm seeing, they've got this as well:
https://unsplash.com/documentation#hotlinking
Documentation for the world's most powerful free photo API.
I'll get implementing the count request if that's wrong
Here are the two points that imply we should be doing both
- All API uses must use the hotlinked image URLs returned by the API under the photo.urls properties. This applies to all uses of the image and not just search results. More info & examples →
- When your application performs something similar to a download (like when a user chooses the image to include in a blog post, set as a header, etc.), you must send a request to the download endpoint returned under the photo.links.download_location property. More info & examples →
What constitutes a download is unclear, but it generally seems to be embedding it
Sounds good, it seems that they're docs are rather contradictory
Alright, I've set up the request so it makes it and then just does nothing, I think that should be ok
@gritty wind sorry to bother you again, but I commited the start and the lint action says it slipped flake8 entirely for some reason, do you know why that happened?
Did you stage the change?
Yes, and pushed
Do you have the pre commit hook setup locally?
Yes
could you run pipenv run lint and paste the output here?
The action you linked failed on the trailing whitespace check
Huh
Editing on gitpod, says cannot start because --user installs are blocked
I'll try at home
I see why it's breaking
Up to 93. "canary." and ids will be longer in about a year iirc, which is 3 more characters, so 96 o.O
I ran pipenv install and didn't get precommit for some reason
I had to manual install and gitpod doesn't like
pipenv sync --dev to install dependancies
then pipenv install precommit to install the hook
@gritty wind is there a discussion we can use for suggesting python facts?
or one we can create?
Ohhh that's @patent pivot's domain
ok
What was the issue you're working on again?
sir-lancebot#596
seec
@clever wraith https://github.com/python-discord/meta/discussions/93
remind me to unlock it after the feature is merged
ah yes am used to only seeing stable links and occasional PTB's, good catch thanks, @fallen patrol
by the way, how is it?
haven't had the chance to look yet
ok
Trying to re-setup my dev environment for the bot repo using docker. Running into this error for the bot container: https://paste.pythondiscord.com/apefuwaxoq.py
Not entirely sure what I'm missing
I was trying to but I'm not married to it
Alright, what do you have in the bot.redis section of your config file?
redis:
host: "redis"
password: null
port: 6379
use_fakeredis: false
I'm basing that off of the config that we have on notion
docker-compose up
Can you try
docker-compose up -d redis web
docker-compose up bot
Sure, one sec
Same error
I'm not worried about it, I'll swap back to fake
Like I said, it was more because I wanted to try it
So pipenv sync --dev and then what?
Or am I misunderstanding
Sorry, still not overly familiar with all this docker stuff
pipenv sync shouldn't be needed for docker
That would make sense
Do you have another redis container running?
Although i imagine that would produce a different error
Nope, the bot stuff is all I have spun up
Just to check, did you rename the file to config.yml?
I meant hitting ctrl + s in the side to make sure that it did save the changes to your disk
Okay so
It would have been under a different compose prefix
We're going to assume that I'm an idiot because I named it .yaml instead of .yml. I'm now at least getting a different error at least
I've had conficts when running lancebot+bot at the same time
that'll be it probs
Well still getting a failure
new failures 🎉
Progress!
Interesting
Rebuilding and trying again. I think I know what's going on this time
Nope, I'm still screwing something up https://paste.pythondiscord.com/jefodavoza.py
What's the problem?
Theeeeeere we go
It should be fixed if you run on latest version
Yeah, bot was loading before web was ready
Oh no no, this was WITH fakeredis
sir-lancebot#586
And now for the true test
not this one
fakeredis is pretty nice
sir-lancebot#596
humble brag
eval 👀
Understatement
Fair
I committed one thing to it
Therefore you wrote it
haha
Obvs
Yeah
The issue tracking command is pretty cool
ConnectionRefusedError: [Errno 111] Connect call failed ('172.24.0.4', 6379)
It's still pitching a fit when I try to do the real container. But eh
Not a huge deal
Wow that's really cool
Are you sure the container is running? Because it is finding the address
bot#1
Positive
And that's even with spinning up redis first
Hmmmmm
Worked hemlock?
can someone review sir-lancebot#596
please?
@vocal wolf Welp. Am almost done with it.
It was told that if a issue is not having planning, it isnapproved
You should still ask to be assigned if you don't plan on the work potentially going to waste
It is like this, but the response is a webhook. And it uses redis to map the author message and the webhook. So that it can be deleted when the infraction is mentioned or rejected
Interesting
@clever wraith which editor are u using?
and also read the contributing guide it says not to do frequent pushes.
im using gitpod
sorry I should batch better
I recommend using a local editor.
like pycharm or vim.
and you probably would have to squash down the commits, we don’t want 10 commits jst fixing the lint issues (ask xith or scal about this maybe)
i would normally but the linter is broken on local as well and i have the cloud set up so i can work when not at home
Linter is broken meaning?
the extra plugins for python discord did not install when pipenv install was run
# This will install the development and project dependencies.
pipenv sync --dev
# This will install the pre-commit hooks.
pipenv run precommit
# Optionally: run pre-commit hooks to initialize them.
# You can start working on the feature after this.
pipenv run pre-commit run --all-files
# Run the bot
pipenv run start
@short snow , I've made the requested changes!
Alright will have a look
Fwiw doing frequent pushes is fine now, we have unlimited actions minutes
you ppl have github pro?
It's free for public repos
I think for OSS orgs in general
because we have private repos too lol
I don't think we will pay 200 some euros per month for a GitHub org haha
def chunks(lst, n):
"""Yield successive n-sized chunks from lst."""
for i in range(0, len(lst), n):
yield lst[i:i + n]
``` If i want to add this function to `bot` (needed for enhancing incidents feature). where should i add it?
i need to break down embeds into list of 10, since webhooks only support 10 embeds at a time
Isn't that an itertools function
lol ok
Maybe it is from the cookbook
uhh i don't remember
But that'd typically go in the utils
grouper ~ half way down
https://docs.python.org/3/library/itertools.html#itertools-recipes
more itertools should have it, which are in the bot iirc
k thanks
should i pip isntall it or put it somewhere in utils?
where in utils?
make a new function somewhere in utils, it's a general file
nvm we have it
The helper module under utils has functions like that for the future
question:
If i have the same first parameter and different second parameter for a redis cache what will happen?
what i want to do is basically, map the user incident message to the webhook message id. But in case of more than 10 links in the message, there will be more than 1 webhook msg. So how should i store it?
this is what i do now
since async redis doesn't support list
and someone including more than 10 message link in there incident is a really rare case, so am not sure if this is even needed
Will this list get edited?
nope
Then you can use comma-separated string
smart 
(side note, but don't swallow exceptions like that. You could at least pass it to the log statement)
you can use exc_info kwarg iirc
log.exception implicitly logs the exception when it's in an except block
I still think it should be explicit
The explicitness makes it clear we are relaying the error back to the user, in case the content is changed
So if the log is moved, or it's level changed
It's used fairly extensively without exc_info all over the bot
I don't think it's necessary to be explicit. It's an established library, not some obscure function. Unless you've never had experience with logging, you will know that log.exception logs the exception.
many
postgres_1 | 2021-03-04 07:11:12.896 UTC [35] FATAL: no pg_hba.conf entry for host "172.19.0.5", user "pysite", database "pysite", SSL off
``` i get this on running the `bot`
and cuz of this the site fails, and hence even the bot fails
but i also get this:
web_1 | Waiting for PostgreSQL database.
web_1 | Database is ready.
web_1 | Applying migrations.
and later
web_1 | psycopg2.OperationalError: FATAL: no pg_hba.conf entry for host "172.19.0.5", user "pysite", database "pysite", SSL off
....
web_1 | django.db.utils.OperationalError: FATAL: no pg_hba.conf entry for host "172.19.0.5", user "pysite", database "pysite", SSL off
which then gives:
bot_1 | aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host api.web:8000 ssl:default [None]
bot_bot_1 exited with code 1
Destroy web_1 and postgres_1 and recreate
prune it or compose it down?
done thanks
The only problem with it now, is that is really slow
i think it is problem with my internet tho
yesterday it was fast
pipenv run test or in pycharm right click on the tests dir and run test/ run tests with coverage depending on what you want
ok thanks
i get the same error as stel i.e.
PermissionError: [Errno 13] Permission denied: '/home/user/PycharmProjects/bot/logs/bot.log'
``` lemme see what the did i the msg history
ah got it
/usr/lib/python3.8/unittest/mock.py:2030: RuntimeWarning: coroutine 'Infractions.apply_voice_ban.<locals>.action' was never awaited
``` hmmm i get this
async_rediscache.session.RedisSessionNotInitialized: the redis session has not been initialized yet.
``` how do initialize it?
should i use try...except to handle MessageNotFound or add a cog error handelr?
i get message not found even when the message is in the server
this is how i handle it
whats incident in that case?
@short snow your issue is likely that you're passing a Message instead of Context
incident is message I think
am passing on on_message()
so i don't have ctx
!d discord.ext.commands.MessageConverter.convert
This appears to be a generic page not tied to a specific symbol.
bot.get_context
!d discord.ext.commands.Bot.get_context
await get_context(message, *, cls=<class 'discord.ext.commands.context.Context'>)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Returns the invocation context from the message.
This is a more low-level counter-part for [`process_commands()`](#discord.ext.commands.Bot.process_commands "discord.ext.commands.Bot.process_commands") to allow users more fine grained control over the processing.
The returned context is not guaranteed to be a valid invocation context, [`Context.valid`](#discord.ext.commands.Context.valid "discord.ext.commands.Context.valid") must be checked to make sure it is. If the context is not valid then it is not a valid candidate to be invoked under [`invoke()`](#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").
Parameters
• **message** ([`discord.Message`](../../api.html#discord.Message "discord.Message")) – The message to get the invocation context from.
... [read more](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.get_context)
got it #discord-bots 😄
i still get this
but all of them are awaited
message_links = DISCORD_MESSAGE_LINK_RE.findall(message.content)
TypeError: expected string or bytes-like object
``` what does this mean? should i do `str(message.content)`?
raise RedisSessionNotInitialized("the redis session has not been initialized yet.")
async_rediscache.session.RedisSessionNotInitialized: the redis session has not been initialized yet.
``` these are three things i get
got fixed, added str()
LOL
ummm anyone know the magic words?
sure
Thanks, I was mostly interested in what .content behaves like
huh message.content says its a str
I would have fallen into the same trap 😛
content should be a string but perhaps in tests a Mock object gets in there
you can catch the error and print out message.content
to check what it is
for tests it may make more sense to mock the cache than to initialise it, I'm not sure if we have tests dealing with a cache somewhere
I'm not sure what the initialisation does but it may not even be possible when running tests
Have you looked at how the other tests deal with redis?
ah cool
do i need to add int() and str() while setting and getting @tough imp ?
I don't know, I think the problem you're encountering is that in tests you're getting a Mock instance representing the message, and when you try to access e.g. message.id it gives you another Mock object instead of an integer, so the write to cache fails (I still think it makes more sense to mock the cache, btw)
this is just speculation though
if you want the mock objects that get passed in from the testing code to have e.g. an id attribute you have to set it yourself
if you're not sure what I'm talking about, try to isolate the test that is failing, and look at what it's passing in to mock a production scenario
it will mostly be instances of Mock or MagicMock
and you will see that the tests explicitly set attributes that should be available on those instances
if you try to access a non-existent attribute on a Mock, it won't raise an AttributeError (unless told to do so), but rather give you another Mock
Ok this is going above my head.
Uhh i think i am getting it now.
when the unit tests passes something to the cog, it is passed as Mock instance, and the redis cache doesn't support that.
to demonstrate, here I make a Mock object and set an attribute colour using the kwarg:
>>> from unittest.mock import Mock
>>>
>>> m = Mock(colour="blue")
>>> m.colour
'blue'
>>> m.size
<Mock name='mock.size' id='140289252559696'>
>>> m.size.size
<Mock name='mock.size.size' id='140289252560656'>
you can see that I can now access that attribute and get my value, but accessing an un-set attribute size doesn't fail, it produces another Mock instance that represents that attribute, and remembers some information about how it was used, so that you can make assertions about it
so if you're passing in e.g. a mocked message, and you want to write its id attr to the cache, you have to make sure that accessing that attribute will actually produce an integer, rather than a Mock obj, which cannot be serialized
however, another approach would be to also mock the cache, and then check that the message.id mock is what the mocked cache.set function receives
this way you can make assertions about the behaviour within the tested unit without depending on the implementation of the cache itself (because that's not what you're testing ~ you only want to test the code that you've written)
thanks i understood it now
but I'm also not implying that you have to write these tests
<class 'unittest.mock.MagicMock'> the incident.id is of this type
uh no, i lost all my changes, pycharm collapsed, 
I will have to read mroe on writing tests and on unit testing, so ignore the coverage fails for now
so how do i pass this in as a int? Since incident is a MockMessage.
and it should have id attribute
i've been trying to get better at that, bad habit ¯_(ツ)_/¯
thanks!
for a second i thought you were self botting
That's not an issue, no worries
Ok good, thanks!
lmao
What did you think of the changes?
Still need to have a look maybe, kinda busy with my pr on bot and another side project
Question... ping me if someone can help me out with it
Is this cog specifically for easter?
I was told by @vocal wolf to put it in the Easter folder
👍
If you're the Chris who reviewed my pr, I made the changes you wanted
Yea, i am. I'm just testing it locally now
Awesome, thanks!
Is it the unsplash access key or the secret key that's used for this?
Access key
Thanks
No prob
I've seen that with regular sent messages as well
Sometimes it's glitchy
Alright
It's a Discord issue rather than an implementation issue
Yeah, sorry
It's not your fault 😄
It doesn't happen too often
Not your fault, sorry is not needed
You can't be sorry for a discord issue 😛
🙃
for my pyfacts PR, i was thinking we could make the fact the title.
kinda like .topic
@vale ibex is this a good idea/
That sounds like that was already the idea, you wanted the command to be .pyfacts?
I think it'd be a bit wordy depending on the fact
Oh that's what you meant
A title just saying "Python Fact" would be cleaner
@clever wraith Just FYI, our code reviews are usually done in 2 parts, first its a basic "Does this code look right" then we do local testing, so its common for some comments not to be raised initially 😄
https://pythondiscord.com/pages/resources/guides/code-reviews-primer/#our-code-review-process if you wanted to read more about it 🙂
We're a large, friendly community focused around the Python programming language. Our community is open to those who wish to learn the language, as well as those looking to help others.
Lint fails...
Why can we join media vc but not dev vc?
Ves i think you would be able to answer this.
What are you doing?
Are you the first to write tests for something redis-related in the bot?
Or is that error not coming from your code?
it is used in silence too
But you're introducing RedisCache for something, right?
Yeah
Right, do you know if someone else is testing something that uses RedisCache somewhere?
Do they mock it or do they initialise the session?
I actually just remembered that I am not on a wifi haha
HA
Take a look at this section for that file: https://github.com/python-discord/bot/blob/master/tests/bot/exts/moderation/test_silence.py#L14-L28
Oops
@hardy gorge i get this when i do that
kwzrd helped me with it
and i understood it
But this question remains
Alright, only one more approval!
You'll need to make sure that the id attribute (which I think you're passing to redis) is an integer and not a Mock
You are passing the id attribute of a message, right?
Yeah
The easiest way to do that is by providing something like id=<some int here> as a kwarg to MockMessage in those test methods
create a MessageMock instance first, assign an int to the attribute
async def test_process_event_confirmation_task_is_awaited(self):
"""Task given by `Incidents.make_confirmation_task` is awaited before method exits."""
mock_task = AsyncMock()
with patch("bot.exts.moderation.incidents.Incidents.make_confirmation_task", mock_task):
await self.cog_instance.process_event(
reaction=incidents.Signal.ACTIONED.value,
incident=MockMessage(id=1),
member=MockMember(roles=[MockRole(id=1)])
)
mock_task.assert_awaited()
Alright
This should do it for the first test method
Alright thanks understood
And the second one is very similar
also do i need to create tests for the message links case?
We don't have a "tests are required" policy anymore, as far as I'm aware
but @green oriole knows best, probably
As in you have to add tests to your feature, or we want all the tests to pass when committing?
Add tests ig
create additional ones; if everything goes well, the current failures (or actually errors) are now solved
We do not enforce those. That said, if you are creating a new critical feature and you want to add tests, you are more than welcomed to do so!
Hmm i will leave out tests for now since i have zero knowledge in that field maybe in future i can add them.
No sweat, as long as you aren't removing tests with your PR, it is perfectly fine
Whoever wrote documentation for async rediscache. Awesome job 
It is really easy to understand it
The contributing guide here explains it https://pythondiscord.com/pages/contributing/sir-lancebot/
We're a large, friendly community focused around the Python programming language. Our community is open to those who wish to learn the language, as well as those looking to help others.
(This is linked in the readme)
You can run it without Docker
You don't really need docker if you don't plan on using redis, using pipenv directly should be fine
yeah i had it for node stuff
i do have test server yes.
so i created one bot on my server. im really sorry im bit new to this stuff.
i added channels and role. what next?
.env stuff
yeah just doing that
And server id
BOT_GUILD=ABCBBSBBS
thats correct format right?
@green oriole I believe I've figured out how to make a new flake8 rule that would check for the multiline implicitly concatenated string format you mentioned before.
Oh nice
if there's consensus among the core devs that you want that, I can try to make time for it
Yep, that should go in the .env file
I'll ask, but I don't think that will be a controversial change
You can directly ask, actually 
okay i made .env perfectly
except bot toke
so i have clientId, secret, public key
go the Bot tab first
Go into section bot and copy tokeb
it's explicitly named Bot Token
Token*