#dev-contrib
1 messages · Page 67 of 1
Oh, @crude gyro thanks. I just finished renaming guides -> content/article(s).
.issue 796 bot
@surreal gulch Sorry about missing that solution last time around and giving it now instead. One extra commit hahah

@green mesa ^
https://github.com/python-discord/site/issues/406 But does that mean that Jams management will be not on site?
yes.
😭

This doesn't mean that it won't happen; just that it will probably be a separate app/microservice
We're planning on making some major changes to our back-end, as we're not quite happy with our current deployment automation scheme
Hi, this time I'm trying to run the bot and site in docker, and the bot is unable to connect to api.pythondiscord.local. I assume this is because my hosts file is not configured correctly? I set the urls up to point to localhost when I set things up to run natively before.
Can you access the website in your browser?
I believe you need to point them at docker's default ip (should be in your hosts file somewhere), I also needed to run the services on 0.0.0.0 isntead of localhost
@tawdry vapor Yes
Via the pythondiscord.local domain?
Yep
Ah should be something else then if you can connect to it
Do you have the bot configured to use http instead of https?
Yes
Did you include the port in the site domain?
Yes
Hey, can someone check this when they have the time? It already has one approval and we've thoroughly gone over it https://github.com/python-discord/seasonalbot/pull/465
urls:
# PyDis site vars
site: &DOMAIN "pythondiscord.local:8000"
site_api: &API !JOIN ["api.", *DOMAIN]
site_paste: &PASTE !JOIN ["paste.", *DOMAIN]
site_staff: &STAFF !JOIN ["staff.", *DOMAIN]
site_schema: &SCHEMA "http://"
What is it failing with?
Hmm well if they're both in docker then you may need to be connecting via web:8000 instead of the domain, since web is the name of the website service in docker compose
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host api.pythondiscord.local:8000 ssl:default [Connect call failed ('127.0.0.1', 8000)]
``` for example
That is surely the problem
@tawdry vapor Running both in docker is sort of made out to be the recommended option in the setup guide. I would've thought other people would run into this frequently.
Because the bot and site are separate containers, so the bot doesn't consider the site to be on localhost.
Yeah the guide says "If running the webserver in Docker, set it to "web:8000"."
We're working on making this easier
I think our bootstrap project should have a short questionnaire that asks if you're using docker and whatnot, so it can automatically set the right values.
What do you mean by bootstrap project?
It's basically something that sets up everything for a contributor, including a test server on Discord
(it doesn't exist yet)
Ah, I see.
That certainly would be nice, setting up a complete test server is no joke.
the test server setup is going to be super handy
.issue 481
This should be a fairly quick review
Sorry vest 😅
First the command should remain the same, then it should be rewritten
This was supposed to be an “add one line” fix 😂
The loop would be kinda ok without the spaces, but the rstrip at the end makes it feel patchy
I don't like the rstrip much either, even though I used one in my suggestion too
feel free to get rid of it
the original code using a 1, 6 range is totally a bug, by the way
that would not be a full set
Yep. I’ll finish it tomorrow. In your proposal, the rstrip is probably not even needed
yep
Yeah
and they prob won't change it because it's backwards incompatible
Sadly, yeah
@crude gyro would you mind if I force push the changes tomorrow, so we can get rid of this back and forth history?
it doesn't bother me if you force push to this branch, it also doesn't bother me if you don't.
Okay. I’ll probably fix this history, then
I don't really care about linear history
but in this case, it also won't do much damage if you rebase, so
knock yourself out
Yeah. We’ll see tomorrow
How does Github handle review comments when you rebase? We use Bitbucket at work and rebasing annihilates comments, so we don't allow rebasing feature branches once the first review comment has been posted.
Xithrius assigned it to you
@lime mural the issue has planning label not approved label
So xithrius asked me to hold up until the label changes from planning to approved
@obtuse arrow not sure. I assume they could disappear
Maybe I’ll just let it be 3 commits and be done with it
They also disappear in GH
Well, maybe if you load up the specific commit (which now isn't tied to any branch), then you'd still see the comments.
Would someone care to explain to me the bot's actions during the lemon pinging 90k people incident.
Like why did it mute so many members, what triggered it and what would happen if the rule was triggered.
If u can answer my question pls ping me
also the does the bot's mutes us if we send 10 lines in 10 seconds?
Config explains it all https://github.com/python-discord/bot/blob/master/config-default.yml#L329
let me look at it
The newline rule triggers at 100 lines in 10 seconds
Our file naming scheme is simple
welll I did, but I did not know it contained the rules
And github allows you to search for keywords in code
for mutes and other stuff
Actual code that takes action is in rules directory afaik
well i wouldn't understand it anyway lol
Reading code, running it and modifying it is a good way of learning
kinda depends on the person dont u think.
Also it says burst, what does that mean?
That’s an English word. Feel free to check in a dictionary or with some translator
It doesnt really depend on the person unless you mean it depends whether or not the person is willing to do it to learn
I meant how ther person learns
Base to learn programming is reviewing code of others in all fairness
You dont learn much just from theory
I see, it hasn't been much since I started programming so that's most likely the reason of my ignorant
@nocturne hare https://github.com/python-discord/seasonalbot/pull/479#discussion_r499364930 how can i do this, i am confused on this part as Linepaginator only takes max lines and max length
and if i use LinePagintor.paginate i need to pass ctx also
Sure, they way would have to make those functions send the message. But I'll admit I thought linepaginator was a bit more.. class-y, and not so static. So you can disregard that comment
What’s that?
.issue 208
That’s interesting
Maybe a field saying which LGBTQ+ community they “are in”?
at footer?
or will i add one field
LGBTQ has more community?
i thought its one community and tim cook is member 
one more question will i mention born date and stuff?
I think that would be interesting
just came to know Tim Cook real name is Timothy Donald Cook
Wait what? Really?
yes @obsidian patio
how about this
in footer i think i can mention Member of LGBTQ+ family
Nah, I think there are enough information like that
Maybe awards isn’t really interesting
Just remember that short and readable info is key
Where are you getting the info from?
There should be more games in seasonal bot. If I can i will try to add it. but how do suggest something that can be added?
to bots
Is this info not available from some api, instead of having a bunch of different jsons for each command the bot implements?
Make an issues on the seasonablbot repo, and have it approved. Then you can work on it, or have others do it @late wolf
@nocturne hare i am fetching from json i am not able to find any api for this
Where are you getting the info from?
The Python Bot has anti raid right?
yes
!src AntiSpam
Cog that controls our anti-spam measures.
@late wolf
I don't want the code. I want to know like what it does and what triggers it
I mean, the code is the best way to learn that. It isn't an ```py
if user.is_spamming():
await user.ban()
well i can code it myself though, i just wanna know it's features
If you’re looking to make an anti-spam bot, I think #discord-bots or a help channel would be appropriate
i am not, i am askking the feature of the anti spam for the python bot
like what triggers it and which situations does it consider as "raid"
and what does it do in those situations
there are many rules, see https://github.com/python-discord/bot/tree/master/bot/rules
compare message content to previous messages with a count in a time frame, with more
alongside that there are rules which are not public knowledge.
Without going into too much details, the cog takes each filter, defined by a config entry and some code in the rules folder, gather the last x messages the filter wants, run it, and if it returns true, it mutes the user
ok
Replying to @short snow about https://discordapp.com/channels/267624335836053506/635950537262759947/762622646558130176
i like that too but that much info is not enough i guess
compare message content to previous messages with a count in a time frame, with more
Oh ok I get it. How many same messages have to be sent to be considered as raid?
That threshold is in the bot repository
ok
and frankly, I don't want to be throwing around the ins and outs of our anti-spam system to a user who isn't willing to read the code, sets off some alarm bells
sorry
I just wanna do something similar to the bot that's why I am was asking for the details
I did not mean anything bad, it was not that I wasn't willing to read the code it was that I did understand it.
That's why I was asking.
i am about to push a cool new thing to the forms app
no
public repo
i will do that
but I will be adding lots and lots and don't want to spam
about to open PR™️
okay just awaiting code security
how this looks
hey joe, how about having a link to the official pydis website on the forms website?
yeah
we will
I don't think it needs to be super prominent, but we can have some copy at the top or put it in a footer
alright
it's fairly evident what the app is for when you reach it — I don't expect SEO to be wild on this
okay deployment is live
Python Discord Forms is the surveying system for the Python Discord server.
(only form that is supported right now is ban appeals, even if you visit another one, there is no backend yet and the loading time is faked to demo that SWEET SWEET ANIMATION)
that is inline fields
Oo the loading animation, damn
🥺
I uh
stole it from NPM lul
nice package called react-spinners
I might try to do that with css and js
Spinner!
embed.title = f'__{pl}__'
embed.description = self.pride[pl]["About"]
embed.add_field(name="__Known for__", value=self.pride[pl]["Known for"], inline=True)
embed.add_field(name="__D.O.B and Birth place__", value=self.pride[pl]["Born"], inline=True)
embed.add_field(name="__Awards and honors__", value=self.pride[pl]["Awards"], inline=True)
embed.set_thumbnail(url=self.pride[pl]["url"])
i am using fields
we're getting seasonalbot ready for discord.py 1.5 with this PR: https://github.com/python-discord/seasonalbot/pull/478
if anyone wants to help out, you can do that by either thinking about whether there's any functionality that would break with the proposed Intents setup, or you can test your favourite features to see if they work
i am confused with what are intents 
intents are like
a way of telling Discord "send me info about this, not about this"
so by disabling the presence intent, you don't get any updates when a user changes their custom status or goes online or offline
there is a list of possible intents at https://discord.com/developers/docs/topics/gateway#gateway-intents
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
ty
and the relevant events that are tied to them
i am looking for this type of explanation only ty
👍
Sorry If I am being annoying about this, I really am.
But I had a quesiton.
When multiple users send the same message does the channel get silenced or does every single person who has sent the message gets muted?
burst_shared mutes users, not channels. moderator silence channels with !shhhh
ok thx
we need Intents.all() right i dont know what we need to change more in cog?
the approach taken is that we create an Intents instance with all options enabled, and then manually disable those that we don't want
this means that e.g. because of intents.bans = False, the bot will not receive any ban events
for seasonalbot? totally
for seasonal bot bans can be false
to see which intents are available, you can look here: https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents
it also very conveniently lists what they affect
ok tnx
I need to make a PR to reduce the seasonalbot message cache
Do you think it would be possible to filter out the hyperlinks in the !docs command, or make them clickable?
Take a look at this embed: https://discordapp.com/channels/267624335836053506/343944376055103488/762671164723036170.
There's a random 4 in it, because on the docs website, there's a footnote in the documentation: https://docs.python.org/3/library/stdtypes.html#str.lower.
Not sure what it's based on, but maybe just make it a hyperlink as well?
Shouldn't it automatically send as a hyperlink, though?
It works for other documentation pages.
!d discord.TextChannel
class discord.TextChannel```
Represents a Discord guild text channel.
`x == y` Checks if two channels are equal.
`x != y` Checks if two channels are not equal.
`hash(x)` Returns the channel’s hash.
`str(x)` Returns the channel’s name.
`name` The channel name.
Type [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.8)")
`guild` The guild the channel belongs to.
Type [`Guild`](#discord.Guild "discord.Guild")
`id` The channel ID.
Type [`int`](https://docs.python.org/3/library/functions.html#int "(in Python v3.8)")
`category_id` The category channel ID this channel belongs to, if applicable.
Type Optional[[`int`](https://docs.python.org/3/library/functions.html#int "(in Python v3.8)")]
`topic` The channel’s topic. `None` if it doesn’t exist.
Type Optional[[`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.8)")]... [read more](https://discordpy.readthedocs.io/en/stable/api.html#discord.TextChannel)
Is that an issue with Python's formatting or the docs themselves?
The URL is [4](https://docs.python.org/3/library/stdtypes.html#id15) for the str.lower docs.
!source docs
Lookup documentation for Python symbols.
I'm thinking it's an issue with the markdown converter.
Nah, I might just be right
this is the source for the [4]
Return a copy of the string with all the cased characters [4]_ converted to
lowercase.```
which is defined at the bottom
.. [4] Cased characters are those with general category property being one of
"Lu" (Letter, uppercase), "Ll" (Letter, lowercase), or "Lt" (Letter, titlecase).```
Looking at the href in the HTML, it looks like you're right:
I got the other link by right clicking on the 4 and selecting "Copy Link Address".
Could probably create the url based on it. I have 0 clue how the docs command works, but shouldn't be hard to prepend the url to the id returned from href
This is the part that actually gets the documentation: https://github.com/python-discord/bot/blob/c1582f1113cb2fa36c78f643f96e452702fd08ab/bot/exts/info/doc.py#L229.
The rest of the !docs command is just assembling the embed and error checking.
How to write django URL regex that allow subcategories (content/category/my-category/.../.../) this should allow unlimited categories.
1014 handles hrefs in the html and a bit more. Jus need to figure out the caching and think I'll mark it ready, leaving partial matches to an another pr
how many LGBTQ leaders are required to be present in json atleast
A good amount?
10?
30+ would be nice
lol
articles only showing 13
i am extracting data from this https://www.peoplematters.in/article/leadership/30-influential-lgbtq-leaders-part-i-26007 and wiki, this much is good?
.pr 479
need 1 more review on this
done
Ty
What is this about starting bot?
2020-10-05 17:28:04 | deepdiff.diff | INFO | jsonpickle is not installed. The to_json_pickle and from_json_pickle functions will not work.If you dont need those functions, there is nothing to do.```
@crude gyro Does content app need currently multi-level categories? This just need major refactoring that I don't currently want to do + don't have time to do. This currently support 1 level categories.
@nocturne hare if something blows up, then we have an issue
For real though, that's not a problem afaik
We don't use those functions
What are we using, I'm guessing, deepdiff for
Mod logs
mkai
Any reason those fields are underlined? Don't think that adds much beyond some visual noise
That's the style we are currently using for seasonalbot, if we do change it we would have to do that across the whole project
Is bot supposed to be LF or CRLF
lr afaik
;-; ran linter. it molested all files and their line ending
Weird
ye...
The git standard is LF as commit, checked out as you like
Well, it is CTRL + Z time
The linter converted the files to LF
What linter did that? Flake8?
Oh no
so, yeah.
Which ending is you OS using and which ending did it convert to?
Try setting eol to lf and autocrlf to input in the git config
hm 
Sounds about right lol
I might've picked up some format when inspecting source files of python
and flipping vsc out
I'm not sure if I'll be able to, not today for sure
Does anyone use pycharm's precommit with the projects here? I'm having trouble with it trying to get flake8 outside of the working environment for some reason and failing because it doesn't exist there
U can take your time Akrays🙂
This makes absolutely no sense. It fails the pre-commit because of inconsisten line endings, however it is converting one of the files to LF itself
Does anyone use pycharm's precommit with the projects here? I'm having trouble with it trying to get
flake8outside of the working environment for some reason and failing because it doesn't exist there
@brazen charm Doesn't work for me either, never figured it out
Worked for me on my previous install, but might've just had a global flake8 install then
Can anybody who know english lang well review my Content app how to write a article guide?
For anyone wondering... bot.py is LF, rest is CRLF... for some reason. According to the diff as well
The config vals I sent above fixed the line ending mess for me
Am i correct in assuming that settings.py populates settings.html through the context passed?
in site
.issue 393 site
Bot added needs 1 review label, but this needs 2.
I know one of the tests lints the code, but what does the other one do? Why are there two?
I think this is how Azure works
But why dewikification branch have old version of pyyaml? I used latest version in my branch and now these are conflicting
Not sure that quite explains it
so
I think this Seasonal Bot work will only success, when all it's children success. Seasonal Bot (Lint & Test) is child of Seasonal Bot, and in theory there may more children.
yeah
best way to think of it is ```
Seasonal Bot
|-- Lint & Test
now, on PRs that is the only check we run
but on prod release
Seasonal Bot
|-- Lint & Test
|-- Build and Deploy
Hey joe, how familiar are you with site code? 
What is Test?
Run tests?
Yeah, should be running tests?
Do we even have any tests set up for seasonalbot?
Probably not, it's probably a copy of the config for bot/site or some other template?
@crude gyro Does content app need currently multi-level categories? This just need major refactoring that I don't currently want to do + don't have time to do. This currently support 1 level categories.
@cold moon
I don't remember the specification for the issue you're working on having anything about multi-level categories.
I don't think it really even had anything about categories at all
Hmm, ok. And the Build and Deploy part? Is that the second one shown in the PRs?
The one which only says Seasonal Bot?
No, that's a 3rd step for when it's being deployed
runs the build step and deploys to the hosting service.
(not that i know much about this process, just assumptions from other projects I work on)
OK, this support one level categories to make this look better. But now PR have conflicts and I don't know how to solve Pipfile.lock conflicts @crude gyro
Build and Deploy should only run for when it's actually deployed. I don't think we do a test build without deploy.
Basically, it's this step:
- job: build
displayName: 'Build & Push Container'
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
dependsOn: 'test'
steps:
- task: Docker@2
displayName: 'Build & Push Container'
inputs:
containerRegistry: 'DockerHub'
repository: 'pythondiscord/seasonalbot'
command: 'buildAndPush'
Dockerfile: '**/Dockerfile'
tags: 'latest'
We should GitHub Actionify that
that's a special build called "why the hell are we using Azure DevOps"
basically there's absolutely no reason there should be two builds, but because Azure, we're doing it anyway.
it'd be fixed by moving to actions
@crude gyro do you think this works with first the docstring and then a comment?
HAhah alright. Seems like GH actions is the future, at least here
you don't really need that comment, I mostly added comments to my example code for your benefit
Yeah. But do you think it would work?
sure
your syntax highlighting has docstrings and block comments the same color
mine doesn't.
generally speaking it's fine
Can I make config file for https://github.com/marketplace/actions/flake8-action for bot/seasonalbot/site?
no. We already have a linting workflow for django-simple-bulma that we will be using on those repos.
it looks like this https://github.com/python-discord/django-simple-bulma/blob/master/.github/workflows/lint.yml
we can't use flake8-action because we need to honor the pre-commit
Also, I'd appreciate a review for https://github.com/python-discord/site/pull/407, if anyone has time to look at it.
How will we auth with admin. Via the pinned credentials?
The only thing they'd be able to authenticate into would be the admin pages, and there's no real use for granular ACL in there. It might as well just be a simple login.
Okay I did my research
Also lemon, I did find a way to use a flake8 action with pre-commit. I used that technique for rattlesnake
Turns out there's a way to disable hooks with pre-commit via CLI args
@cold moon I resolved your conflicts now.
I have concept for improving reviewing process: I think review process should have 3 labels: grammar ✔️, code ✔️, functionality ✔️ and I think this will help reviewers to see what is already checked and what is not.
Thanks
How will we auth with admin. Via the pinned credentials?
@tawdry vapor
either that or you can make yourself a user and just put that in your password manager
I just don't think it's worth having 2000 lines of code complexity just so we can OAuth into the django admin pages
Depending on the direction we take, there may not be a lot going on in that admin anyway
but that's future talk
not that far int he future. Aperture has already taken the lead on seeing if we can move the API into a separate app.
Was this message view/notification stuff only used by allauth to indicate when a user has logged in or out?
it was used by the wiki for a lot of those pages
that was its primary use
but yeah, only really by allauth after we got rid of the wiki
@crude gyro About content system, with new system, headers can't be made links anymore, otherwise HTML generated IDs mess up. Just found this.
headers being links is hideous anyway.
I've been saying for over a year I want us to have a feature to hover instead.
the use of making the headers links is a way of getting the URLs that point to these IDs
but hoover sounds nicer
I guess it would still suffer from the same problem ks has found, though? (I don't quite understand the problem yet)
What's the issue with generating the links (we'd need to generate the URLs for a hoover as well)?
yeah I don't understand it either
(and yeah, I agree that the hoover is a million times better, as I did the last time)
the way Django docs does header links is what I want for us, ideally.
a nice little ¶ that shows up when you hover
it's gorgeous
In markdown, links is
[This is text](#this-is-text)
and then HTML ID will be this-is-textthis-is-text, because markdown2 parse this so.
The idea is that the links should be auto-generated, not inputted by the user, ideally
Is there no option for that?
No, I mean
## This is header
then this automatically get ID this-is-header
right
Well, we could write a bit of javascript to add that hoover effect, if it's difficult with markdown
maybe even plain css
that's because you are using the header-ids extra, right?
Yep
we can easily write some code to generate those pilcrows with links to the id's.
I think we might need javascript
but that can be a separate issue
so just don't worry about it
@crude gyro Do you need to make a migration to remove the role mapping model?
Cause I got a warning when starting the site
uhhh. yes I think I do.
thank you
OK, then content system is ready for review
thanks @cold moon
I will take a look when I'm back to linux, and I'll also make that migration @tawdry vapor
just let me finish up in photoshop here
👌
That error may be more generally from all the stuff that's been removed on dewikification
Well no, it should run any new migrations to remove stuff if they exist. I don't know.
Hey, can someone check this when they have the time? It already has one approval and we've thoroughly gone over it days ago https://github.com/python-discord/seasonalbot/pull/465
If no one does, I will review it in 10h or so @ruby pulsar
Alright
Is docker-compose only used for local development in the site repo?
yep — we don't run in prod with compose
Cool
can anyone link me to the help channel part of the bot in github?
thanks
I wanna do something like that
except create the channel for someone if their DMs are off
We use html to create form or we use django forms?
@tawdry vapor About content app, is this okay to rename this to articles only at frontend, because I really don't want to remame everything again. Also I can add contributors too, because I found that this have to fetch last modified from github.
We use html to create form or we use django forms?
@green mesa you mean pydis forms?
PyDis Forms use React? I think
@neon garnet yes
Yep
Ok tnx
Why dont we do something with ml in bot?
Machine learning?
Yeh
Let me show u something real interesting
The bot is in js
We use this for war in game called coc it uses image recognition and gives yt searches as output
And it's very accourate
U can say 98%
We can have something like this in seasonal bot also 🙂
The backend for that bot seems to use a third party application
That's correct
It sends picture to site process it and then send the output
Python is known for widely used in ml field so we should have little features like this
It's not a little feature per se, plus, utilizing a third-party service like that for machine learning fails to achieve what I think you want it to do
Ss is just an example
If we're going to introduce ML to our bots, it would have to be handrolled for it to feel significant at best, the thing about it is that it requires a lot of time and additional resources
True😔
We may be able to use ML for statistics (and more graphs
) though, although that's just a concept

@patent pivot Have we ever considered that? or is it a bit out of scope?
ML is a maybe™️
If no one does, I will review it in 10h or so @ruby pulsar
@subtle kraken hey, no one did it, can you check it out when you have the time?
I will soon~ish
A word about ML: the dependencies are probably going to be pretty heavy, and you will need to store the data somewhere. Meaning if you were to train a model based on messages... you'd actually need to store those messages somewhere, which I'm not sure is ok by users or us
has indents already been applied on the current bot?
@stable mountain has intents
.pr 479
need 1 approval 
💀 🎃 🍬 how those the bot react this mesaages and why?
bcz of halloween
🥇 @crude gyro: 1
🥈 @lapis phoenix: 1
🥉 @surreal gulch: 1
Candies will randomly appear on messages sent.
Hit the candy when it appears as fast as possible to get the candy!
But beware the ghosts...
There's no rush for the PRs, the repos are active so someone will get to it when they have the time
main thing is i wnt my pr to get merged in this month only
Is the embed alright on other clients? Android doesn't seem to like it
discord android bug
Taking up something like 3 full screens without content
yeh it solves the issue
Doesn't do anything
try to scroll down and then up
i mean opposite way
warnings.warn('Using slow pure-python SequenceMatcher. Install python-Levenshtein to remove this warning')```
i dont know y but i am getting this warning again and again
ok
@ruby pulsar have you tested the command with different inputs? (valid and invalid)
can we add an alias .pickup for .pickupline command, it is too long too type? thnx
.pr 485
@patent pivot can u add hacktober accepted label on this pr also 
Done
ty
Although the whole repo is tagged hacktoberfest, you don’t need the individual labels
oo
akrays i asked for label to start mature time early
bcz it dont start unless u add label or merge it
So, I noticed hackstats command for the seasonal bot does not check if the repo was tagged with hacktoberfest or if the PRs were tagged with hacktober-accepted
now my all 4 pr are done
Good job dude
So, I noticed hackstats command for the seasonal bot does not check if the repo was tagged with hacktoberfest or if the PRs were tagged with hacktober-accepted
u need to usehacktoberissuescommand @sour sierra
Well thats not what i meant-
welp yeah I know
It shows 3 repos for me, which should actually be 0
Because none of them are valid ones, as these repos are NOT tagged with hacktoberfest
We don’t have updated the command yet afaik
Yeah I saw an issue and a PR which talks about filtering out spam and invalid tags
Could anyone with access to the YouTube API token for @dusky shore have a look at this?
.issue 450
Seems like it may be an issue with an invalid token
where have you seen this error, and do you have the full traceback?
in production it gives
bot.exts.evergreen.snakes._snakes_cog ERROR: Unhandled tag command error: Command raised an exception: KeyError: 'items' ('items')
No full traceback in the logs, that makes me sad
yeah, the cog has its own error handler that loses the traceback
it could be an expired token, looks like the response doesn't come as expected
it tries to log the response but fails before that
@green oriole mind taking a look whenever you're available? not sure if you saw it
https://github.com/python-discord/bot/pull/1212
Alrighty, I saw that but I didn't have time to review it yet, will do
ah, no problem then
Yeah. Since it seems to work for them, as long as a valid token is entered, I’m just confused why it would suddenly fail for us, though @tough imp
the error in the issue is different to the one that makes the command fail in production
I imagine you will get the None error if you don't set the env variable in .env
but it's difficult to tell because there is no line number or traceback
Can you try witha seemingly valid random token?
in production it dies on a KeyError on line 1092, but it doesn't log the response, so we'd need to replicate the call it's making to see what the response is and why it fails
Honestly, it may be easier to just disable the command. I don’t think it’s really used either way
At least I haven’t seen anyone using it (except myself testing it)
Well, it would be a shame to remove it, it is from one of the first jams
Yeah I saw an issue and a PR which talks about filtering out spam and invalid tags
@sour sierra @green oriole that was from me and 2 approvals but no one merged it yet
Can you link it please?
Either way, I think we should disable it (if there’s a good way to do that). No need to have a non-working command available to run
@green oriole we two were the reviewers 👀
I assume that was part of my spam to your email ;))
Hahah yep!
That’s annoying
Let’s unload the entire snake cog /s
Also, in my testing, there was a TypeError (NoneType). Maybe that was the absence of an API key, while we’re receiving another issue in the production @dusky shore
As kwzrd noted, it’s on this line (I’m talking about the actual @dusky shore now):
data = response['items']
To me, it seems like it’s just an API change or something that lets the request get through and possibly gives us a return value of some sort
@tough imp what do you think?
as I said, we need to see what the response is, otherwise it's just guessing
the response could be telling us that the token is expired
I don't have a (or the) youtube API token that I could try right now
Yeah. True
@green oriole it's pr 475
.issue 475
It changed a lot since your approval tbh
relevant_links = {link: value for link, value in zip( article_result["metadata"].get("relevant_links", "").split(","), article_result["metadata"].get("relevant_link_values", "").split(","))}
What I have to change to make this return empty dictionary when any of relevant_links or relevant_link_values is empty strings?
Sounds like you can add an if any(s for s in relevant_links) block beforehand
Actually, this was simple: generator if check.
Can someone take a look at issue 486 I just created and validate it?
Done
Sounds like you can add an
if any(s for s in relevant_links)block beforehand
Isn't that justany(relevant_links)?
Why when I add new environment variable to site and define this default in settings inside environ.Env, this uses default, but I have defined environment variable?
Like
env = environ.Env(
DEBUG=(bool, False),
SITE_SENTRY_DSN=(str, ""),
SITE_REPOSITORY_OWNER=(str, "python-discord"),
SITE_REPOSITORY_NAME=(str, "site"),
SITE_REPOSITORY_BRANCH=(str, "master")
)
# Information about site repository
SITE_REPOSITORY_OWNER = env("SITE_REPOSITORY_OWNER")
SITE_REPOSITORY_NAME = env("SITE_REPOSITORY_NAME")
SITE_REPOSITORY_BRANCH = env("SITE_REPOSITORY_BRANCH")
And then when I use this
from django.conf import settings
print(settings.SITE_REPOSITORY_OWNER)
then this still print out default, but I have it defined as environment variable.
Looks like that this is just not finding it, because when I use printenv, this is not listed there, but all other values in same .env file is there
I wasn't passing these environment variables to container, this is solved now
Content/Articles app now fetch contributors and last modification date from GitHub API.
Now I only have to write tests for them
But this I can do tomorrow
Because this takes time, and I don't like writing unit tests anymore...
@crude gyro Content/Articles app now supports last modified and contributors getting with GitHub API, but in order to test it currently, you have to define SITE_REPOSITORY_OWNER=ks129 and SITE_REPOSITORY_BRANCH=guides-app environment variables.
Would you guys mind if I grab these two?
https://github.com/python-discord/site/issues/397
https://github.com/python-discord/site/issues/398
I know the latter is still labeled planning, but I'm pretty far along with a draft for a solution
Currently, our site only uses the main site database in our postgres. For the Voice Gate project, we will need to be able to retrieve data from another database in the same postgres server - the me...
Something up with azure?
@obtuse arrow check with @patent pivot, he's overseeing that project. I think it sounds great that you grab those.
All fine by me, let me know if you need information on how the Metricity thing should work but otherwise go ahead
Cool. I'll push my PR soon and you can let me know if it's deviating a lot from what you had in mind.
👍
I don't know what the metricity schema actually looks like so I created a mock one and kinda just guessed.
hmmmmm
@obtuse arrow so the aim of this is to return a message total
which means the query is somewhat like SELECT COUNT(*) FROM messages WHERE author_id='165023948638126080';
Ah, right
Yeah, I see now. I was a bit distracted by lemon linking to the user model.
Ok, let me give it another go.
Like that?
You have to do some digging to get the right types for the schema
Or just ask joe to export it for you 😄
For example db.String in sqlalchemy maps to varchar. There's no length specified, which is valid for postgres.
Makes it work with any size
Pretty sure db.JSON maps to the json type in postgres
I read the docs for gino, and it made it sound like it would map dynamically to an appropriate type for the given db, so I kinda gave up there and just guessed.
But I'll fix those things for now. @patent pivot a schema export sounds nice though.
sure thing, one sec
metricity=# \d messages
Table "public.messages"
Column | Type | Collation | Nullable | Default
------------+-----------------------------+-----------+----------+---------
id | character varying | | not null |
channel_id | character varying | | |
author_id | character varying | | |
created_at | timestamp without time zone | | |
Indexes:
"messages_pkey" PRIMARY KEY, btree (id)
Foreign-key constraints:
"messages_author_id_fkey" FOREIGN KEY (author_id) REFERENCES users(id) ON DELETE CASCADE
"messages_channel_id_fkey" FOREIGN KEY (channel_id) REFERENCES channels(id) ON DELETE CASCADE
metricity=# \d users
Table "public.users"
Column | Type | Collation | Nullable | Default
--------------+-----------------------------+-----------+----------+---------
id | character varying | | not null |
name | character varying | | not null |
avatar_hash | character varying | | |
joined_at | timestamp without time zone | | not null |
created_at | timestamp without time zone | | not null |
is_staff | boolean | | not null |
opt_out | boolean | | |
bot | boolean | | |
in_guild | boolean | | |
is_verified | boolean | | |
public_flags | json | | |
verified_at | timestamp without time zone | | |
Indexes:
"users_pkey" PRIMARY KEY, btree (id)
Referenced by:
TABLE "messages" CONSTRAINT "messages_author_id_fkey" FOREIGN KEY (author_id) REFERENCES users(id) ON DELETE CASCADE
@obtuse arrow
Great, thanks.
By the way, I'm leaning more towards only returning what we need rather than the whole table
We have the flexibility to change our API down the road if needed
Also, should I create these schemas in their entirety in init.sql right now? I will need to add channels as well in order to declare the foreign keys in that case.
I don't think it's necessary for local testing of #398, but I don't know how you want to scope #397.
I think it should be the same idea - just add what's needed right now for the endpoint
I would much prefer that as well. It's easy to add onto the script as needed down the road.
Fixed.
I'd like to wrap the raw SQL queries to the metricity db in an abstraction. It would make it easier to write a unit test, and I think it would be neater in general. Should I put it with the models?
Hmmmm that sounds suitable
but I'm not entirely sure, Django ORM is not my speciality
Sure about what?
about where things like that go with Django
Ah, yeah, well, I guess raw SQL queries kinda violate the Django model in the first place.
I guess I could create an entirely separate directory if that feels better.
so.. I tried to run pipenv run precommit like a good boy, and it's telling me
pre-commit installed at .git\hooks\pre-commit```
Is that right?
yeeep
now when you commit, it'll lint your code before allowing you to actually commit
if the lint fails, it won't let you commit
interesting
so that's a thing. Seems like this message is scheduled even when the command fails
It might be just this specific case though
Might not be something worth dealing with even
it probably isn't worth it, yeah
antivirus
aborted the precommit
'flake8' is not recognized as an internal or external command, operable program or batch file. I thought this was supposed to be part of the environment?
Did you create the venv and install the dependencies?
Yeah, I have the bot running on the test server
Are you running the git command from within the venv?
Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project.
So I assume that yes
is that from pycharm by chance?
Did you activate the venv in your shell?
I tried to commit with git tortoise. I assume that's the issue?
Pycharm seems to have the same issue where it's running outside of the venv and getting precommit from somewhere else.
Not sure here, but how does the precommit config work? With the pipenv run flake8 entry I'd have thought that it shouldn't even try to resolve flake8 as a batch command
@brazen charm Does it do that even when the project interpreter is set as a venv interpreter?
Yes, have the bot set up as a normal pipenv project. Run git hooks from pycharm fails with the flake8 getting not recognized, but works fine from the activated environment in the terminal (and manual pipenv run flake8 works from just the dir)
Well, it's plausible that the git plugin isn't aware of pipenv I guess.
Since the former is not Python-specific.
I'm not very familiar with it, but have no idea why it's trying to run flake8 directly when the config does it through pipenv
Has anybody been able to run the the site unit tests in Pycharm?
I get ```
RuntimeError: Model class django.contrib.contenttypes.models.ContentType doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
Ok, just had to set the settings file in the run configuration
@green oriole for PRs opened before 3 oct the old rules still apply
@green oriole but for after, the PR must: not have invalid or spam, must be in a hacktoberfest topic repo (unless hacktoberfest-accepted)
nvm i've just commented that on the pr
@patent pivot Could you please mark my SeasonalBot PRs with "hacktoberfest-accepted"?
https://github.com/python-discord/seasonalbot/pull/482
https://github.com/python-discord/seasonalbot/pull/483
https://github.com/python-discord/seasonalbot/pull/484
done @flat marsh 🙂
Thanks a bunch!
having a look at the metricity PR now, dem 😃
$ curl -H "Authorization: token [redacted]" http://api.pythondiscord.local:8000/bot/users/165023948638126080/metricity_data
{"verified_at":"2020-09-12T02:31:51.295812","total_messages":37}
works with the metricity tables!
Yeah, I tested it 🙂
ahh rock solid, wasn't sure if you'd made the tables yourself or used metricity 😄
what is api.pythondiscord.local custom entry in hosts?
yep
Oh, wait, now I get it. No, I didn't use metricity.
That's great that it works though.
ok
Though, it should've, since the test database aligned with your schema export.
For testing
gotcha
okay so
there are some edge cases I wanted to handle
there may be a point where when metricity restarts it doesn't capture a verification date for some users, since they verified while the bot was offline
in those cases I think we can probably just ignore the verified constraint and just return a date 3 days prior so that the criteria is met
there may also be points where a user exists in api_user from @stable mountain but has not yet appeared in the metricity database, which leads to responses like:
{"verified_at":null,"total_messages":0}
hmmm
I'm trying to think of the best way to handle these things
Won't it return 404 if the user is not in metricity?
hmmm
maybe I actually did have an entry for this user
hah, yes
I did
hmmmm
no wait, no it won't, it'll 500 if the user doesn't exist
because it attempts to fetch from api_user, succeed, and then try to unpack data["verified_at"], = cursor.fetchone()
I should probably handle that
yeah should just be a none check on cursor.fetchone()
I'm gonna write some unit tests, I will make sure to cover this case
awesome stuff
But it will have to be tomorrow, my baby-watching shift is over and I'm going to bed.
sounds good, nice work on this!
Thanks!
What is the purpose of big brother channel?
It's where messages of users are relayed
Moderation purposes
Anyway, this PR needs reviews. It's been sitting around for many months https://github.com/python-discord/bot/pull/886
Your reminder will arrive in 8 hours!
Should I go with list or set? If set, then I need to convert the dict to a tuple
You don't need to store the entire user in the set
Just the ID
Oh this is something else
Let me see
I thought this was about the site api
okay
Yeah, you can use lists for these two ```py
users_to_create = set()
users_to_update = set()
alright 👍
also updated_fields = {} should contain the user ID too
async def _get_users(self):
query_params = {
"page": 1
}
while True:
res = await self.bot.api_client.get("bot/users", params=query_params)
for user in res["results"]:
yield user
if not res["next_page_no"]:
break
query_params["page"] = res["next_page_no"]```
this is the async generator I made, quick thoughts?
I think you could have used a recursive approach still but iterative is absolutely fine too
Or is there that weird thing where async generators can't use yield from?
ye i tried yield from, didn't work
like yield from res["results"] event
Shame
does yield from make anything better? just curious
It's just shorter syntax than having a loop in this case
oh
async def _get_users(self):
query_params = {"page": 1}
while query_params["page"]:
res = await self.bot.api_client.get("bot/users", params=query_params)
query_params["page"] = res["next_page_no"]
for user in res["results"]:
yield user
Pretty sure this will work
oh cool
i pushed changes to the site PR, just gotta change the tests on the bot PR, and everything should done i guess
You still haven't caught IntegrityErrors
I've seen it done in other serialisers (not necessarily in our site) before, so it may be important
IIRC we have had 500 errors due to constraint violations, and DRF doesn't properly catch IntegrityErrors on its own.
actully, duplicate ID are already cought
Are there no other constraints in the DB for the table?
there are, but the error message automatically is sent
Maybe it's fine. I just thought it'd be a good safety thing, cause getting 500s is weird for this. However, like I maybe mentioned, this should probably be solved with a more global approach, like a custom error handler. So it could be considered out of scope.
if I provide an invalid discriminator, the response is 400
i guess this line serializer.is_valid(raise_exception=True) handles that
it sends a 400 response
we had to check for duplicate IDs by adding ignore_conflicts=True because I had to define the ID field in the serializer explicitly as mentioned in the docs, and that id field has no unique constraints
I do see an error in sentry for an IntegrityError for off topic channel names
For a null constraint violation
So it is possible
But it looks like DRF has handlers for most things
I think it handles validators like validators=(MinValueValidator...) fine
yep
Okay let's leave it for now and address it down the road if needed
example
Regarding docs, you should add one for the 404 status code as well
And this line at the top multiple users with the same id in the request data will raise an error. is redundant since you already documented it under the status codes section. Also the first word isn't capitalised but you should remove the whole line anyway.
"if multiple user objects with the same id is given" should say "are given" since "objects" is plural, verb must agree with the plurality
right
@crude gyro could you give the dice command another review (preferable approval👀)?

how does the seasonal bot and python bot show "SeasonalBot is typing" after you send a command?
thanks @glass pecan
in the bot tests, when I do
print(type(guild.get_member(43)))
print(type(guild.members[0]))```
I get `<class 'unittest.mock.MagicMock'>` for the first, and I get `<class 'unittest.mock.MockMember'>` for the second. Not sure whats going on here, but shouldn't both be the same?
here guild = self.get_guild(fake_user())
it uses MockGuild()
@eternal owl do u have emojis at your server?
Bcz if no emojies are found it fetches emojis name from server
I have 0
That's y its showing that embed
u can try here
It will show the available emojies category
Ye, we can avoid that embed by checking if there are any emojis present in the first place
Why are all the __init__ files empty?
Init files are used to mark python modules
huh?
packages*
but why leave them empty
Ye packages to be exact
I don't think server will remove all emojies at once
Bcz init file helps to load the package and we run python bot file as package
It's more of an edge-case for newly-made servers that want to deploy @dusky shore
how, it is empty?
https://discordapp.com/channels/267624335836053506/635950537262759947/763347759330885652
If anyone knows why this is happening, please ping me
@subtle kraken
Here's your reminder: ^.
[Jump back to when you created the reminder](#dev-contrib message)
Can anybody review https://github.com/python-discord/site/pull/395/ ? This PR is quite simple, but this have to get merged before I can start working resources.
12 files, +170 -0 is definitely not quite simple lol
I mean that this is just plain HTML + everything Django app stuff (and most of adding is in HTML file).
i dont know y but pipenv dont raise error locally for missing annotation
Oh shit. I just found out that GitHub Codespaces will be not free after beta.
Nope, but it is really cheap
No when you don't have fixed monthly income.
Ah, I know this feeling haha
@eternal owl I heard you were a bit confused about the mocks?
yes
In general, the mocks do not have the promise of returning a mock of the right "type" when you call a method on them. There's no "deep inspection" going on to try and guess which return mock type would be appropriate. This means that whenever you call an attribute of one of our mocks, you typically either get an AsyncMock (for things that should be awaitable) or a MagicMock.
If you have a method that should return a specific mock type, you'll need to set the return_value yourself.
There are a few exceptions, like if you look at the MockContext, then the most commonly used attributes are assigned an explicit mock type in the __init__
class MockContext(CustomMockMixin, unittest.mock.MagicMock):
"""
A MagicMock subclass to mock Context objects.
Instances of this class will follow the specifications of `discord.ext.commands.Context`
instances. For more information, see the `MockGuild` docstring.
"""
spec_set = context_instance
def __init__(self, **kwargs) -> None:
super().__init__(**kwargs)
self.bot = kwargs.get('bot', MockBot())
self.guild = kwargs.get('guild', MockGuild())
self.author = kwargs.get('author', MockMember())
self.channel = kwargs.get('channel', MockTextChannel())
So, here, the bot, guild, author, and channel attributes will have a default value of the appropriate mock type (unless you specify an explicit one in the __init__
right, the return_value is helping
🎉 I found why .snake video command is not working and PR is coming soon
@green mesa Pull your pr before making any edits to it, I merged master into it
@cold moon what’s the issue about?
i already pushed the changes
I merged master 2 minutes ago
urllib.parse.query convert spaces to %2520%, but YouTube API don't know how to parse this and then this can't return result. When I use urllib.parse.query_plus, then this replace spaces with + and this YouTube API supports. @obsidian patio
When I change this to it, everything works well
Oh really? That’s a simpler issue than I’d anticipated
This was just about adding some debug prints and googling.
@nocturne hare ok emoji command is waiting in another pr by Atie
making changes rn
PR opened
@cold moon Where is the YouTube API key entered?
I assume I need to get one to test it
You have to get it from console.developers.google.com and then add this as YOUTUBE_API_KEY env. Make sure you get API key not OAuth2 keys. @obsidian patio
Alright. Where is the YOUTUBE_API_KEY env found?
What? Just set key from API Console to .env
.pr 475
Azure is having a stroke since a few days
When we do the !user it shows the date it joined, you guys store the date that we join right?
It should be part of your user, not something we store afaik
I don't know for sure, but we try to store as little as possible. If the api provides it, i dont see areason to store it
right, I thought we needed the date and the time that they joined for that command
oh @eternal owl u got the tests working
@late wolf yes finally !
@tough imp Do you know exactly where https://github.com/python-discord/seasonalbot/issues/450 error is raised?
I think one way to avoid KeyError is use response.get("items", [])
I think that's a completely separate issue
I think this error is raised when you don't specify the API key in .env, but it's hard to tell because there is no traceback or line number
@obsidian patio can you confirm?
When I didn’t specify the API key, I simply got a TypeError regarding a NoneType
This error: https://github.com/python-discord/seasonalbot/issues/490 can only occur in one place, because we see the key it's trying to use, so we can infer the line number
When I use a valid key, there are no issues present
Yes, so looks like #450 need to be fixed by somebody who have access to environment variables.
Yes, I think so too
I'll unlink this issue
your PR is fine, but won't solve the keyerror
I'll make quick fix for it with get
that would be good, yea
but I think we will need someone with the devops role
cannot ping the role 🙁
Pushed KeyError fix
@tough imp why not just ping the devops people
Yeah, Discord permissions system, especially for pinging is nightmare
I meant pinging the people manually
There are 4 devops people, you could make a manual role ping lol
Exactly what I was talking about
@tough imp sup?
which one?
youtube
I cannot see the response we get from the api
so its a guess
but the cmd works with a valid key
.snake video
I can give more info later, Im buying bread right now
Ah, alright
Both @stable mountain and @dusky shore seem to have the same YT API key
if it works for bot, then I'm not sure why it doesn't work for seasonalbot
Do we use any feature on @stable mountain that requires a YT token?
I can't think of any
I'm not sure, that's why I was asking if anyone knows that
I'll try looking at the developers panel
I can’t think of any either. Could you try searching the repo for the keyword?
YOUTUBE_API_KEY
Should exist somewhere in the code, if it’s used
.snake video
Bothrops alternatus, conhecido popularmente como urutu, urutu-cruzeiro, cruzeiro e cruzeira,é um réptil ofídio da família Viperidae, a mesma da jararaca, cascavel e surucucu, que ocorre no Centro-Oeste e no Sul do Brasil, como também no Uruguai, Paraguai e Argentina. É classif...
Is that better?
What did you change?
I've enabled the YouTube Data API in our Google Developers Console and changed the API key to a key that was actually listed under our account
Not sure what it was using in the past, but I wouldn't be surprised if it was a key that used to belong to someone's personal account
Oh, really that simple?
@tough imp once you're done breading, could you check if everything works now? I've swapped the old API key out for a brand new one and enabled the YouTube Data API in our Google Console.
yes yes
thanks Ves
But does this mean that my PR is useless?
You’ve been buying bread for 45+ minutes. Must be a fancy sort
Tsk tsk tsk, you need to pay more respect to the bread, young one
can I make a command to transform text to yoda-like speech?
Haha, that'd be fun
should I submit an issue?
Sure
Yoda?
Sure, have fun, but I'm not sure about the implementation though
How do you detect which part of the sentence is what?
About something like this i'm thinking.
I think list of words can help
can I make a command to transform text to yoda-like speech?
Yeh
ok
why is there a new dev-contrib?
It’s a voice channel
Yep
do you have to have a contrib role
Only for contributors. Check #changelog
also how did u get the lovest role
o i see
I control him though
true is that



