#dev-contrib
1 messages ยท Page 55 of 1
Wouldn't it be duplicated later, when you merge your branch?
no, because a commit that contains changes that already exist is not a commit
Good then
a pull request where all the changes have already been merged cannot be merged, because it contains no commits
basically the changes themselves are the thing
it's a bit weird, but it's a good system
Certainly eliminates redundancy
very resistant to duplicates
so when you cherry pick from me and your thing gets merged to master, and I want to merge into master, it will just not list that commit in my pull request
and that's great! I didn't want it anyway
it was messy and had many changes to f-strings
Well, flake8 doesn't have anything to do with redis, so
Maybe it should be in its own PR?
Because it doesn't have anything to do with regular expressions either.
i'm thinking that the pin is too lax if we get issues like this
yeah I agree
There's no guarantee that with a stricter but still flexible pin, like "~= 3.7.9", these things don't happen.
Simply because not every maintainer cares that much about versioning
But, it will probably help
do flake8 versions follow Python versions or is that coincidental?
Not that I know of
I'm not sure, it did not do that in the past
e.g. there was Py3 support before 3.0.0 and 3.0.0 dropped support Python 3.2 and 3.3
3.3.0 added support for Python 3.6
So, it does not look like they have a history of "minor version of flake8" follows "minor version of Python"
There would have certainly needed to be updates for 3.6 and 3.8, though
Since both introduced pretty significant syntax changes with f-strings and the walrus
Coo coo cajoo
just saying hi
and I am running some into some issues on running the bot on windows, and wanted to see if anyone else is having those issues, so we can patch them
What kind of issues?
If you have a home build, you should take a look at the pins 
About Redis, we should use https://github.com/aio-libs/aioredis for async support. I think this is not hard to implement this to current base.
@cold moon it is
we had a discussion about this in the last staff meeting
think about how stuff is currently implementing, you can implement dict behaviour but there is no such thing as an asynchronous dictionary
await self.cache["key"]
is ugly and
await self.cache["abc"] = "abcdef"
is impossible
so as Ves says a rewrite is required, likely one that switches things out for methods like .get(key), .set(key, val) and basically wraps all the builtin redis defaults with automatic namespace generation
There's also the question of which async-redis package to use
There are a few different ones available
It also means that we'll probably be better off implementing iteration with a different tactic (as opposed to what we're doing now)
One fetch of the entire name space and then return an iterator over that
Unless we start working with massive caches and want to be able to fetch them one item at a time, but I kinda doubt that
Yeah, we won't be able to use mutable mapping anymore so it'll basically be wrapping whatever redis library we use and the redis commands for hashes (which implements the most important ones already like keys, values, items, membership, etc.)
We'll also probably drop the JSON stuff
Since using different keys is safer and won't cause race conditions
if we used JSON we'd have to use an async lock for every key
Why?
Isn't the race condition between one fetch and another fetch, not the non-async JSON parsing we do in between?
We could still have fetch_a, fetch_b, post_a, post_b race conditions with a single value
just ask the GIL
Or do you mean if we fetch and post back whole dicts?
It's a bit of the same problem, but we're less likely to get it with single values with the things we're currently doing
but things like counters (for custom ratelimits and what have you) could very well suffer from the same race condition
I think aioredis is best choice, because this have most active development when I googled
It's one of the packages we've discussed, but aredis seems to have more active development
aioredis officially doesn't support Python 3.8, but I'm not too worried about that
right we could still have single value race conditions, but it's much more likely to happen with json stuff
It just seems like they never got around to testing it for 3.8
@patent pivot Yes, you're making more values independent from each other
What data is planned to be stored in redis? Just out of curiosity
- help channel claimants
- unanswered help channels
- maybe cooldowns
- maybe posted news items
Things like channel->claimant and "answered"-channel caches
Probably more things that need caching, like non-default settings values for our bot
(DEFCON comes to mind)
yeah
https://github.com/python-discord/bot/issues/717 this is too something for Redis (amount of OT name uses)
hmmmm
isn't there a site PR for that though
and it does seem like something the site would like to know about
we can't just reroll until we find a combo of 3 which aren't used
I have PR for it. I mean like for these announce messages.
I'll have a look now
@tawdry vapor Addressed reviews in @stable mountain repo PRs 950, 945, 956
About Redis, when PR get merged maybe we should get docs page about using this?
probably.
Hey, @cold moon, are you here?
Yes @hardy gorge
I've been reviewing your PR for the tag tests, but there's a bit of an issue with the approach you've taken. Almost all of your tests rely on the production data (the actual tag files we have) to do their tests, even those looking that search tag content for terms or test the fuzzy matching method. This means that if changes are made to these tags (maybe one is deleted) or new tags are added that come up for these search terms, the tests will start failing.
One general principle in testing is to never rely on actual live, production data to do the testing. Instead, you create test data that you control.
That isolates the methods we're trying to test from the accidental/temporary state of production data
The way it could be done here is to create a "test data" folder with a few test tags in it.
That way, we can ensure that we know what all the functions should return, regardless of the actual tags we have or don't have in production.
No, at line 11 I have CACHE variable what overwrite loaded tags
hmm alright
I missed t hat
It still present for the first test method
but less severe
Yes, this use this to test loading
Yes, but it depends on the production data and it doesn't actually test that we're getting the right names/content
I still think that a better way of doing this is to ensure that the tests do not parse production data, but rather work from a test data directory
Because each time your setUp method runs, it will parse our production data
Alright, I got in the wrong mindset after reading the first test method, which does still depend on production data, and missed the monkeypatch cache you did
Hmm, maybe I should patch this so this don't load production data? And in it's own tests, I should patch classes/functions inside it?
It would be good enough if you could somehow point the cache loader to test data
You can do that by patching the Path-call in here to return a Path-object pointing to a test data dir: tag_files = Path("bot", "resources", "tags").iterdir()
That way, you could also validate that we actually create the right titles for tags and extract the right contents
Something that you now can't do because the production data is dynamic
(You only validate that the keys are present in the cache)
Okay, I try to fix this
@hardy gorge About that prefix issue, maybe I should import FOOTER_TEXT from tags file. Then when anyone change this, then test don't start failing instantly.
That could be a solution, yeah
I didn't dive too deeply into how to solve it
It's just that having a few custom, but valid settings in config.yml shouldn't result in tests breaking
On our shared dev server, most of the core devs use a bot with a personalized prefix to avoid 10 bots responding at once
How to patch class so during instance creation this return specified instance?
You can patch the class object itself
!e
from pathlib import Path
from unittest.mock import patch
with patch("__main__.Path") as m:
m.return_value = "hello"
print(Path())
@hardy gorge :white_check_mark: Your eval job has completed with return code 0.
hello
Thanks. I pushed changes @hardy gorge
print("hello")
from pathlib import Path
from unittest.mock import patch
with patch("__main__.Path") as m:
m.return_value = "hello"
print(Path())
!e
You are not allowed to use that command here. Please use the #bot-commands channel instead.
Hi , (unable to proceed ) where/how do i enable the developer mode & go to the User Settings ?
it's the gear down at the bottom left
the rest of the instructions should be clear enough i think
@lament totem
@sullen phoenix thanks !
Hi , Trying to run "pipenv --three sync"
Gives me the following error, how can i tell VSC to use my environment "discord-dev" which contains Python 3.8 ?
as long as 3.8 is available, it should create it for you when you make your pipenv initially
maybe the --three flag made it default to your system py3 instead of the one required by our pipfile?
try pipenv --rm to remove and then just pipenv install
essentially a pipenv reinstall
try
pipenv --rmto remove and then justpipenv install
@crude gyro there is no output on console , is that normal ?
not really, no
in my experience, using the in-editor consoles for this sort of thing is a bit hit and miss
maybe just do it in a normal terminal
i ran pre-commit run --all-files.
this error is present before i even stage any change. is something wrong ?
most likely your editor is not respecting the line endings we want
and has changed them to windows-style line endings
is there a way to fix them real quick ?
when you do git status, have those files changed?
nope
the linter runs on local files, not the latest commit
so what is the fix for my issue ?
i am fairly new with dev-contrib, all the hooks , linter & flake8
@tough imp i guess you are right ! i just found all the files were modified
"show_line_endings": true
include this in your sublime settings profile
you should then see the chosen line endings in bottom right
if you click it (for me it says Unix), you can choose which to use
it's probably saving files with windows endings (crlf)
but our projects use the unix ones (lf)
@tough imp Thanks ! no issues now
perfect
where can i find the value for env variable --->> SEASONALBOT_ADMIN_ROLE_ID ?
CHANNEL_ANNOUNCEMENTS as well
You need to create the roles and channels in your server
i already have
then with the dev tools enabled you right click on them and select copy id
role and channels both
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.
@brazen charm Thanks able to copy the ID's
getting the following error when i run - pipenv run start
yeah we have a PR open to fix that but it's not merged yet
you want to go on that line and specify encoding="utf-8" in the open call
it fails because on windows the encoding defaults to something else and that one resource file contains something weird that won't open
wait, it doesnt show the line where you need to specify the encoding
1 sec
it will be this line
change it to p.open(encoding="utf-8") locally and it should open
PR is here, we should probably work to get this merged soon if any core dev is around: https://github.com/python-discord/seasonalbot/pull/413
looks like it already has 2 approvals but I cannot merge it
maybe later today
change it to
p.open(encoding="utf-8")locally and it should open
@tough imp works !! my bot is connected.
So one question , what can i do or what i can i use it for ?
You can see all the issues at https://GitHub.com/python-discord/seasonalbot/issues
@patent pivot what i meant was...
Lets say we have build the application "calculator":
we we can do is :
Add
Subtract
Multiply
issues(features) would be :
divide
can't add Floats
etc etc
So i meant to ask was... what can i do with seasonalbot ?
AprilFoolVideos
.fool
Get a random April Fools' video from Youtube.
AvatarEasterifier
.avatareasterify [colours...]
This "Easterifies" the user's avatar.
Battleship
.battleship
Play a game of Battleship with someone else!
BeMyValentine
.bemyvalentine [user] [valentine_type]
Send a valentine to user, if specified, or to a random user with the lovefest role.
Bookmark
.bookmark <target_message> [title=Bookmark]
Send the author a link to target_message via DMs.
just run the .help command in #sir-lancebot-playground and you'll see
in my server you mean ?
anywhere that you have an instance of seasonalbot
seasonalbot is pretty heavily tied into this server, so not all features will work on other servers
(or at least on a server not setup like this one)
is there a list of things i can try with seasonalbot ?
where can i find it ?
yes, the .help command
run it in #sir-lancebot-playground or in your own servers #sir-lancebot-playground and you will see a list of all features
Amazing! @patent pivot can see the list of things i can try !!
one more thing ! so i see the python-news channel... is that a seasonalbot too ?
that is not seasonalbot no
that is @stable mountain
you can subscribe that to your server but that has a more complex setup
oh ! that will be such a drag... but worth trying the complexity and get to learn new things i suppose
you'd need to run a copy of our site as well locally
which wouldn't be too hard with the docker compose I don't think
docker is out of my scope ! don't have a professional version of Windows
the site is amazing though !
how does the help bot work ?
most of the amazing stuff is in @stable mountain ?
seasonalbot contains our fun commands which don't require lots of infrastructure, python handles the heavy lifting
help channels, moderation, antispam, off topic names, reddit, reminders, snekbox, stats and verification are all handled by Python
@patent pivot Thanks for all the briefings ! ๐ guess i will look into seasonalbot functionality first then move to @stable mountain
Sure
Are you planning on contributing or running it on your own server?
Python is very locked into a Python Discord-like server, so it'll be harder to run that
@patent pivot planning to contributing ! was speaking to Leon, he kind of got me motivated into the contribs
Ah for sure for sure, then yeah, the issues pages on any of our repositories details the specifics of what needs addressing, if you need any help or clarification feel free to drop a message on the GitHub issue or here and a core developer will get you an answer
I rebased my clone of my bot repo fork and this have now some commits from python-discord/bot repo master branch and this want to push them. Will these show up in PR?
@patent pivot Haven't been into any of the github contributions... this would be my first ! hence you will see lot of questions from me ๐
@cold moon the PR on github shouldn't show commits that are already in the target branch
if I understood you correctly
if you rebased though you will probably have to force push
since the histories have diverged
so I dont know actually
I try to force-push. Let's see. Next time I use merge. Much simpler
I'd advise you against force pushing if you dont know what the outcome will be
Oh, I did normal push and when I compare, I see only these commits that I made.
if you want to merge upstream master you can always throw away your local branch and start afresh with what's in the remote
alright, sounds like it worked then
other than .help & everything in the 11 page bot commands , what else can i try ?
ok I have to look at the encodings PR
i was having a quick look earlier but didn't submit anything. there's a few opens with the encoding missing and the example in the doc string of bot.utils.persist.make_persistent should be updated to include the encoding as well
awesome ๐
Hi , can i get started with issue #398 or are there steps to follow before i take it up ?
.issue 398
it looks like the issue hasn't been approved yet
Looks like @cold moon was also interested in taking that one
if you can't find any issues that you're interested in, feel free to open a new one with an idea
https://github.com/python-discord/seasonalbot/issues/377 sounds nice, it has the wip label but don't see any assignments
sure ! @sullen phoenix
let me have a look @brazen charm
So for the issue 337 - the output expected is title & link(as in image or the link to the image) ?
the output should be the image itself - or a direct URL that will embed in a way that shows the full image
the best user experience is to read the comic right here on Discord
not to have to click a link
docker is out of my scope ! don't have a professional version of Windows
@lament totem I made a small tutorial about how to run the site on windows home, it has been integrated inside the setup guide, but Iโd recommend you to read it there https://gist.github.com/Akarys42/989dcfa41536c9f3b15c844ea4f04d72
I need help with testing redis
I want to test the PR with the real deal redis, not fakeredis
The service in docker-compose isn't publishing the port so I'm starting it like this instead docker-compose run -d -p 6379:6379 redis
hm
Now I have an auth issue
2020-05-24 16:22:39 | asyncio | ERROR | Task exception was never retrieved
future: <Task finished name='Task-24' coro=<Bot._create_redis_session() done, defined at /home/mark/repos/python/bot-pydis/bot/bot.py:51> exception=AuthError('ERR Client sent AUTH, but no password is set')>
oh right
I don't know what to put for a password
that's a bug then
we should allow for a password not to be set and not send auth if it isn't present
That's just a code thing regarding how the pool is created then?
yep
aioredis expects a password in the REDIS_PASSWORD env var and won't tolerate not having one I guess
and redis is erroring because it's sending something or other
though I wonder what it is sending
I think i have it set to an empty string, the env var
I can try, but I think the config tests will then fail which is annoying
ah right yeah
But you're right, unsetting the env var does work
Which types does redis support as keys?
Is it the same types it supports for values?
just strings
Alright
everything is a string in redis
Oh yeah
Maybe our thing supports diff types for keys?
I wonder cause the trace logs are showing typestring prefixes even for keys
Right, yeah, maybe lemon did add that
Wow these trace logs he added are great
All the logging I wrote for my test is made redundant
async def get(self, key: RedisType, default: Optional[RedisType] = None) -> RedisType:
"""Get an item from the Redis cache."""
await self._validate_cache()
key = self._to_typestring(key)
thanks, I think that was ks's suggestion
but uh
maybe you can add exposing the port to the docker compose?
it's reaaally easy.
I described the process to Ves a little higher up in this chat
so there's a guide up there.
It's marked as required in the config and the config tests will complain if it isn't set
Oh it isn't required in config
Well, the tests complain anyway
the tests are a bit picky like that. they complain because None isn't a string
and because Optional isn't allowed in dataclasses
which is annoying
but we should probably make empty string work
I think empty string works for fakeredis but for real redis it might need None
We can add like password=password if password else None
so worst case scenario, maybe you can coerce empty string password to..
yeah that.
and that might solve it.
But the real fix would be to make the config and/or its tests stop being annoying
Ok well I will just make this fix for now cause I don't feel like fucking with config code
but..
mine is real redis setup
and I use empty string in config
and it works
so I am a bit confused
oh maybe you did empty string env var?
I did empty string in config.yml
@tawdry vapor can you try the latter?
Yeah, i had the env var set to an empty string in the dotenv file
I will try your suggestion
yeah, I think that works. not really sure why though.
No, that does not work
the fuck
Same error ERR Client sent AUTH, but no password is set'
redis:
host: "localhost"
port: 6379
password: ""
use_fakeredis: false
okay. it does work for me but I am running the bot through docker compose
Yeah, that is a difference though I do not see why it would affect this
that shouldnt matter, yeah.
You didn't mess with the redis container and configure a pw for it?
Well, we can also pass it a custom config to set a password https://hub.docker.com/_/redis/
Redis is an open source key-value store that functions as a data structure server.
I'd rather avoid that though
I don't think we even have persistence enabled for redis in docker compose so there's no benefit to using it over fakeredis
yeah, I just wanted a real redis for writing it.
I think using fakeredis to test is totally fine.
there is persistance across bot restarts with docker redis, of course.
just not across redis restarts
it's persistent, just not guaranteed persistent
well I think Mark means we have no volume for it.
ah right
so if we rebuild it all is lost
Yes that is what i mean
should make one then
If you restart the container data is lost
Youรค're right, sorry for using poor terms
i meant if you delete the container and make it again
yes.
Like if you docker-compose down, which deletes the containers
ah right yeah
anyway I don't think a volume is really relevant
not even sure local redis docker compose is relevant?
since fakeredis totally is fine.
Well, I guess. But it was easy to add to docker-compose so it's there if someone wants it
yeah
We would have to document it though -.-
it was. it's fun to add a whole service with two lines of yaml
Or just say "use fakeredis. if you wanna use redis in docker compose you're on your own"
yep
the redis option is tricky and will not work on windows at all.
well.. it might. but it's not worth the trouble.
I don't want to have a broken redis in docker-compose though. I mean this regarding the password. you say it works if the bot runs via compose too which is weird
So I think we should still fix that
yeeeaah I'm not sure what that's all about.
hard for me to fix though because I am not having the problem
but if you figure it out, a fix would be very welcome
So how about password=password if password else None and calling it a day? Does anyone see a harm with this line?
The only issue I see if someone sets their redis password to an empty string, if it even supports that
But screw them if they do that
redis will support it but that would be silly
yeah. fuckem and their law
we could add a courtesy log
I reaaally don't see the point. nobody is ever gonna try to set up redis.. probably. at least not after we tell them they don't have to.
the thing I wish we had was local dev autodetect
so that we didn't need that use fakeredis config value
if constants.Redis.password == '':
log.info("Redis password was an empty string; setting it to None.")
password = None
else:
password = constants.Redis.password
sure sure. works for this guy right here.
And yeah, that fix works
cool.
nice
I will also add a comment explaining why we do this actually
I always say funky fresh
but I have realized recently
that in terms of odor, those kinda mean the opposite thing
and I don't know if that's okay
I am a bit offended.
hashtag gareths grumblings
now I'm the gareth
good god.
uhhhh
lmfao
a null value in yml?
it's not just null?
uhh
or none
no it's null and ~
>>> yaml.safe_load("test: null")
{'test': None}
>>> yaml.safe_load("test: ~")
{'test': None}
never seen tilde used like that. cool.
no, that's problematic.
Tell people to use null for pw in config
or just literally not setting a key
because it will fail the test
because it typechecks
sadface
and None is not str
Ok that makes sense
that is a cleaner solution imo
I didn't think about it
Well we can get around to that some time
yeah
We need to re do the entire thing honestly
I would at least like to see optional support though
Cause a re-work is gonna take even longer to happen
mvp optional is just telling the typechecks constant test that None is an acceptable type too
probably a oneliner
then missing env vars (which are None) will not fail tests, neither will literally setting null
which would be nice
since redis pw looks for env var, that means we can just not have that config in config.yml
and it will be None
pretty clean
Is it an issue with yaml parser or just our tests for it?
well we can't put a type like Optional[str] in the dataclass
it's not supported
or the NamedTuple.or whatever it is.
so if we wanna allow it, the tests will just have to permit it
Ok, so just a test issue
should be.
I was basically hoping I don't need to touch the metaclass
you most likely don't.
I very much doubt it.
it's not that scary though
I think it's something I wrote back in the day
or, at least that I designed
someone else probably committed it
maybe ELA
but that whole metaclass design is very oh hey, look, metaclasses wtf is this, look, I barely knew how they worked
so it can't be that scary
Alright I am looking at the test
I think I can fix it
or at the least, skip the test like we do with list and dict
๐
I mean fixing the test rather than working around it by adding some borderline hack to set the password to None
`Kind of
if getattr(annotation, '_name', None) in ('Dict', 'List'):
self.skipTest("Cannot validate containers yet.")
So the ez fix is to add optional to that tuple
But I'm gonna see if I can actually validate optional
hnnnmmmmmmmmmmmm
I just need to figure out how to get the type inside the brackets
I think Optional will be rejected at a lower level
before tests even run
but that would be veeery nice.
I do think it's probably acceptable to just implicitly say that everything is optional, though
if we must
but actually supporting Optional would be nicest
oh okay
that's awesome
then we can actually add real support for it.
maybe
that'd be a killer fix.
100% an improvement
Oh yeah I forgot optional is just an alias for union with none
Glad I have a debugger to show me this
So I can add union support!! wow amazing
I wonder why the typing lib doesn't support isinstance checks for unions
And all attributes are private or even double underscored so
that would be nice.
This is a real pain to try to get the actual types out of the union
that's kind of a shitty interface that doesn't easily expose that
mmmaybe.
No I don't think they're gonna help
Oh neat
Thank you very much
I was just about to figure out how to access __args__ lmao
Like, with the name mangling shit
haha, yeah. figured they would have an easier way
found it in the typing docs
they have a whole bunch of helpful methods in there
fyi
I don't think I will add support for lists/dicts because it gets complicated if they are multi-dimensional
Sure, why not
but I'm not sure what a list or dict looks like in yaml either
i mean don't we have lots of lists
is it just that they're not typechecked?
I believe this is a list
modlog_blacklist:
- *ADMINS
- *ADMINS_VOICE
- *ATTACH_LOG
- *MESSAGE_LOG
- *MOD_LOG
- *STAFF_VOICE
It's a dict key that has a list as its value
yeah exactly
Well, I'm not sure how to check if a type annotation is one dimensional
Cause there are a bunch of different sequence types
check if any of its args are containers?
Well, if we limit ourselves to only list and dict then it's feasible
that's what I was thinking
I think using any other annotation would be wrong anyway since yaml cannot return that
yes.
so only lists and dicts that don't contain other lists and dicts.
not sure yaml really supports multidimensional lists either
so it's not that much of a cop-out
lol
Have to account for something like Union[List[int], Dict[str, int]]
And if we have Union[List[List[int], other shit] then I have to check in the union too that there aren't multidimensional containers
It took me long enough to realise there's probably a library for this
And sure enough
So we can just use that for a proper solution
Well maybe
I don't know if it will play well with our metaclass
Also, we this is designed for runtime while we want to check in tests
Maybe they have an internal api we can use in tests
pydantic is primarily a parsing library, not a validation library. Validation is a means to an end: building a model which conforms to the types and constraints provided.
In other words, pydantic guarantees the types and constraints of the output model, not the input data.
Ok then
For now I will just add optional support. I don't think trying to validate containers and such ourselves is wise
This is obnoxious they need to fix this https://youtrack.jetbrains.com/issue/PY-30425
not testing related,although I suppose you could use it for that too
it's for when you need to permanently monkeypatch some function inside of some package you're using
How can I switch to a branch which is on the main repo(pydis bot repo) when I am on the forked version? I used to work on the branch restricted_tags but after removal of direct access to contributors, I have to work on the forked version.
you'd need to do git fetch upstream <branch> and then checkout to it
assuming you have an upstream remote set to the main repo
okay
I think I should open a new PR?
?
updated the branch by pulling from master and also resolved a conflict(hopefully)
The base branch on PyDis should be master though :)
Since it's a pretty minor conflict do you want me to resolve it for you @eternal owl
Sure @gusty sonnet, and thanks!
About https://github.com/python-discord/bot/issues/717 , I think this should use Redis to storage usage counts. Only thing is that, is there any way to run script that fetch all audit log from this server and add this to redis and only once?
There's no reason to do this with redis when we can do it on the backend just fine
yeah that's silly. if we want information about the otname usage we should solve it on the site
redis is for temporarily caching stuff
not for permanently storing the entire audit log
I mean like name: count
yeah, no. you should not rely on redis data being permanent. that's what postgres is for
redis can be cleared at any point.
don't store stuff there if you cannot afford to lose it
Okay
if we want the number of times a otname has been used, we can make a migration for the site that polls the audit log via the discord API and figures it out
and then we can store that information there
where it belongs
yes, to find the number of times an otname has ever been used
if we wanted that - it's mentioned in the issue
riiiiight
but it's still solvable with a simple migration and some discord api magic
audit logs will not work at all
we can only filter by user and action (Python, channel update) and there are hundreds of those a day from the help system
yeah, so it'll be hundreds of thousands of items
Oh, and I just found that we are not able to get ALL Audit Logs. Only some months
yeah, audit logs just are too volatile for this sadly
but that's okay
it'd be a fun feature anyway if we just start counting from the day it gets merged
Then we can start from 0
but I still think we should solve it on the site, not the bot
yeah
the site manages the otnames, makes no sense to put the data anywhere else.
should be added to off topic record
I think only thing is announcement message that should be done in bot.
where is the choice for the next-up names made, is it in bot? or does the site only send the 3 chosen names?
it's in the site.
the bot just asks for otnames
yes, it is trivial
make a new model to store otname metadata, add a migration for the new model, start storing data in it when we use the otname endpoints
done
I have PR for fair selecting otnames https://github.com/python-discord/site/pull/348
can't we add a col to off topic names
New column will be much easier
sure, if we just need count that's fine
creation date we might actually already have in the site I think
it's very hard to store things without getting that for free
Django generally likes to have it.
Just we have to find way to fetch it.
hmm. I might be wrong
yeah okay
but then we'd just have to initialize it to todays date
and add real dates for all future otnames
which kinda sucks a bit
๐ญ Maybe we should create new mixing for models that contains created and updated fields?
yeah, I actually don't hate that idea.
There's only 590 names, time to get someone to search through chat history
lmao
haha, just search for when they were first added
god damn, if only discord search had a real api
we could easily solve that problem
I mean, it sounds like a joke but it honestly wouldn't be that many if we just had like 6 people participating.
I could do 90 searches in like 20 minutes
stick all the datetimes into a google sheet.. we'd have it banged out in no-time.
hahaha
If they aren't picked that day they get their weight increased by 1, and if they were picked it drops to 0
But that's a lot of updating in the DB for something silly like this
I think you're talking about something different than us
possibly about rotating otnames
we're talking about backfilling creation dates
Ohhh okay
huh yeah, ot name table really does just have a name
yep
yeah
what do you think of ks's idea to introduce an abstract base class or a mixin or something to add creation date and updated date
I think I'm just obsessed with self balancing randomness.
And yeah, I like that idea as well
yeah that sounds good to me
I'm not sure about adding it to every single model or anything but at least to the otname one
Not impossible for us to write an int eval script to find the dates they were added
with most ORMs that's just what has been default, I'm surprised
how would we go about that?
actually I'm pretty sure that would be impossible
how thouggh
by what, searching the history of every single channel?
requesting the entire message history?
discord would ban the bot most likely
that would block the bot for days
Unless we pulled in Joe's bot
it's 8,5 million messages
I think if we really wanted to solve it, it'd be better to just ask 5 staffers to do it manually
I'd join.
boring manual labor while in a voice chat for half an hour
If I wasn't tied up with this database migration I could
and we'd be done
I guess I could when I'm at home
Would we just want dates or dates and time as well?
dates
If everything is in one channel, a script would do it
It's not
Or the bot logs perhaps?
Damn
Do you keep them forever?
we don't keep logs that far back
If we had a number of staff members volunteer I could partition the OT name table
Swap server with guild and local with server
Send out the call to arms
I'm sure we've got plenty of board folks
they wouldn't be able to see most of the otname creations
they'd be in mods+ channels, a lot of the time.
sometimes even admins+
It'd have to be a group of admins then yeah. I'll join the crusade when I get home from work then
I'm just thinking out loud here, not suggesting we need to get started with this immediately
Fair enough
We could have an approximation with the action log though
what action log
you mean the audit log?
The thing logging name changes, is that the audit log?
nothing logs name changes. except the audit log, which doesn't store them forever.
that gives us usage, not insertion time
That's why approximation
Sometimes it's just better to roll up our sleeves and just trudge through it
I do think we used to log the namechanges every night somewhere
I thought you had a log for channel names changes
one of the logs has that
yeah #mod-log has these
we could get a rough count from that
on a subset of the names
around 96K messages in that channel.
Well, I think the first usage time would be enough, wouldn't it? And you could scrap that with a bot
Entirely possible we have some that have never been used
first usage time isn't enough imo
^
i'm picking them at random from the DB and there are ones 2 months out
and that's a low figure
First otname change log was in 2018-11-23. in:mod-log after: 2018-11-23 has around 28K messages
I've got one here added in October 2019, it was first used in 27th February 2020
first usage won't cut it
not sure I care that it's inaccurate.
if we iterated those 28K to fetch first-time use, count, and then made everything else count 0 and created datetime.datetime.now(), we'd have some cheap, free seed data
What's the main purpose of having the creation dates?
I'd rather have no data than wildly inaccurate data
yeah #mod-log has these
@crude gyro
That specific one you picked was a manual change I made when we hit 50k
just as an anecdote
It could just be
Channel name changed to ot0-channel-name. This named has been picked 42 times and was first used on Jan 1st 1970.
Instead
wait no
we suppress anything else
that only showed up because the bot didn't do it, right?
The bot's embeds were always glitchy
I think the count data would be decent from iterating like that.
We had a time when the bot changed the channel names like 20 times in a second because we had those timing issues
And now, it typically only posts one out of three channel name changes
and @green oriole makes a pretty good point about how "was first used on <date>" being roughly just as interesting as when it was created.
We had a time when the bot changed the channel names like 20 times in a second because we had those timing issues
@hardy gorge
this is true, that makes the count data kinda fucked, actually
let me check the ratelimits
yeah, I think that glitch ves mentioned, which was there for a long time, is a dealbreaker
so fuck iterating that channel
and the fact that it typically only posts one of the three changes per day now
and I don't know why
we could just not show any date
or make creation date nullable
and show it only for ones that have it?
yes
ratelimits are too mad for iteration
we could still do count, just starting at 0
yeah
It's a fun thing, but it's not mission critical to have historical records
Feature-introduction-forward seems fine to me
so, feature forward and nullable ctime, have the bot only display ctime if it's there. and no dumb manual search party
waste of manpower
or skip ctime entirely? what do you think
Well, I don't see why not for have it for newer otn, it is basically free
because people would go "why is it so inconsistent"
but I don't really know either, I don't mind either way
delete all off topic names ๐
@cold moon I think we should get your off-topic derandomizer PR merged, and then we can add this creation time and count stuff after that - maybe you'd like to handle that too?
I've left a full review on https://github.com/python-discord/site/pull/348 for you so we can get it merged.
I don't really care for or having anything against having creation times
I guess it could be fun
yeah sounds fine
OK, I'm gonna make fixes tomorrow. Gonna go sleep soon
sounds good.
@crude gyro I addressed reviews
nice. will take a look soonish.
Hello <@&295488872404484098>!
We've just merged an important update to @stable mountain that includes some changes that you need to be aware of if you're currently working on or planning to work on the bot.
-
The merge includes a re-lock of the dependencies, so be sure to run
pipenv sync --devif that's needed for your setup. Some of our linting dependencies have been updated in this relock and added some additional linting rules (such as not allowing f-strings without placeholders in them). Be sure to run pre-commit and/or lint with the new settings in place. -
The update introduced support for Redis, an in-memory datastructure store and caching system. It is not necessary to run Redis locally (although, if you're running the bot using the docker-compose that will be automatically taken care of it); you can use "fakeredis" instead. To do this, you have to add these lines to your
config.yml:
# You probably already have a `bot` section
# add a `redis` section to the existing `bot`
# section.
bot:
redis:
use_fakeredis: true
- if you need to use the redis caching database for a feature, please take care to read the docstring of the RedisCache class in
bot.utils.redis_cache. It explains how you can use it. Do make sure that you actually need it for your feature and if it's the appropriate place for your data. For data of greater value, the Postgresql database remains the database to use. Don't hesitate to contact a PyDis Core Dev if you're confused.

https://github.com/python-discord/bot/issues/856 I think this should use Redis for storage of every user last display name alert sending time.
I don't understand why we need the last display name
I think it is about the cooldown between notifs
Yep Akarys correct
We don't need to store names then
userID: last_sent_notification_iso
I've just rewritten the privacy policy to try avoid storing personal data where not needed, and I don't think this is needed
right, that is fine
You juset need a cached dict id -> last_time thanks internet
as long as there is no PII I'm fine
But should this use on_message or on_member_update?
on message as lemon says
I see your reasoning for on_member_update but we have no interest in moderating users that are not active in the community
I just mean can I do this or I have to wait until label get removed?
I'll assign it to you now, if we have implementation issues we can put them on the PR
Thanks
I don't know if this is previously considered or not, but it would be cool to not to post mails if they start with Re: to #mailing-lists
@bronze hare yeah I think it's proposed, not sure if we have an issue yet
but if anyone wants to add it feel free
I couldn't figure out how to do this issue - I think it's too far beyond my current level. I'll look for another more beginner-friendly one - could it be unassigned from me? Thanks :)
https://github.com/python-discord/seasonalbot/issues/174
Nice
@solemn cliff sorry for the delayed response - looks like you were already unassigned from the issue by another core dev, so no worries
however, if there is anything you need help with, you should feel free to reach out
we can help you get started or answer any concerns you may have
@tough imp There will be not everyone ping spam in mod alerts because this don't mention everyone
the problem isn't necessarily the ping, but let's imagine that a spambot comes in and trips the displayname filter
if we begin processing 10 messages before the first finishes and has a chance to write to the cache, the subsequent events won't know that they shouldn't send the alert
and the mod alert channel will get spammed by the bot
whats even worse is that this can also get our own bot ratelimited, which makes it unable to continue responding to an attack
for these reasons I think we should be careful
Okay, so I should put whole this function to asyncio.Lock?
@solemn cliff sorry for the delayed response - looks like you were already unassigned from the issue by another core dev, so no worries
alright thanks!
https://github.com/python-discord/bot/pull/875 got overwritten by #866; not sure what the proper way to fix this would be so sending it here (tried cherry picking the original commit for a pr but it looked weird... and not sure)
Just create a new commit.
If you really wanna figure out how to use mine then go for it but it doesn't really matter
@gusty sonnet did it show any conflicts when you merged 866?
I didn't see rohan push anything to fix conflicts
Alright, opened a pr with from the branch I had the cherry pick in
I think Shira manually resolved the conflict in that PR
It's in the latest merge commit
Managed to mess up the message in a merge commit after battling with pycharm and git for a bit, should I amend that? https://github.com/python-discord/bot/pull/927/commits/ed9e1de6d9b47fe616f00e5fcf324e4c6574a49e
Well, nothing to see here
Uh oh what did I do haha
@cold moon FYI I will have to approve this tomorrow cause I still need to test locally and it's already late here
ok
Hi , i had a query (Related to issue 377 )
i have the img url so :
trying to use
async with self.bot.http_session.get(url) as r:
json_data = await r.json()
my response is not gonna be json , can i use "r.content" ?
tried to do the above but i get
im_data = await r.content
TypeError: object StreamReader can't be used in 'await' expression
You should get a ClientResponse object and you can use the methods/attributes it provides: https://docs.aiohttp.org/en/stable/client_reference.html#aiohttp.ClientResponse
What kind of content do you expect? Bytes? a string?
I think you're requesting an image (going by the "img url" line) and you probably need the bytes for that
You can read those in with https://docs.aiohttp.org/en/stable/client_reference.html#aiohttp.ClientResponse.read
@hardy gorge Sure ! will check , Expecting Bytes.
Hi ,
The issue 377, i believe i have finished the proposed implementation.
So , what needs to be done next to merge ?
@lament totem you'll need to open a pull request
https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request
https://www.youtube.com/watch?v=rgbCcBNZcdQ
Create a pull request to propose and collaborate on changes to a repository. These changes are proposed in a branch, which ensures that the master branch only contains finished and approved work.
In this brief video I demonstrate the basic process of submitting a pull request on GitHub.
Thanks !
@tawdry vapor What GitHub logo I should use?
OK, thanks
should the !shhh/silence command also remove reaction perms if the channel has it
Hi All,
I wanted to know how this is implemented or to be implemented -
Your commit will be rejected by the build server if it fails to lint.
This is in the rules (5th Point) ! so just curious how you guys are doing it !
is it a like a custom setup that needs to be done in Git ? or what is it ?
It's done using continuous integration
One of the tools used is called flake8 and it's in charge of checking over your code - we call that a linter
When you push code to the repository (or a pull request), flake8 is automatically run against it using the CI system they have set up
Which could be Azure pipelines or GitHub actions depending on the project I think
It's remarkable how inconsistent embeds are... working on the second point in https://github.com/python-discord/bot/issues/878
Making the relative hyperlinks in the doc output actually work ends up not displaying inline codeblock on mobile, but hyperlinked `text` shows up. Do you think that looks alright or should codeblocks just be stripped away when the result tag is a hyperlink since that doesn't need them anyway?
Ends up like this, desktop client works fine
@tawdry vapor Source command reviews addressed
@tawdry vapor I'm at this point now https://pythondiscord.com/pages/contributing/hosts-file/#windows-macos
But no such command. Where was I supposed to run it? inside the container? that's a later step though...
I think the docker-machine comes with the toolbox if you got it through that
but you can try the 192.168.99.100 ip (should return an error page when you go to the socket you specified)
ModMail, as a user, is probably not in your cache and mentions in an embeds won't fill the cache automatically, unlike mentions in a regular message. At least, that's what I think it is.
Maybe @patent pivot has another perspective
yeah it's totally a caching thing
Discord on mobile is notorious for showing @invalid-user at every turn
particularly inside of embeds
@patent pivot works as intended ๐
nice
I still think we should keep regex. It has cool features not present in re, and it is better at handling catastrophic backtracking (it has a timeout feature!).
cloudflare has left the chat
Yes, this is not so plain anymore
It would be nice to include some regex examples too, from official ones, like the email regex
@patent pivot I completely forgot they existed haha
named groups would be pretty cool, I try advise everyone use them where possible
Noice
doesn't support everything though since no % or whatever and I got lazy and handed it off to someone else to fix lol
That reminds me of my 230 chars datetime regex haha
oh akarys why
The code jam qualifier haha
docker-compose build just froze my laptop, thank you docker-compose
lol
https://github.com/Akarys42/code-jam-6-qualifier/blob/master/qualifier.py#L6 the bad guy is here hehe
Maybe you could use the VERBOSE flag?
I commented every line >.>
Yeah, but there was a reason why I couldn't use it, I don't remember which tho
I think there was something about spaces or so
!e
import re
r = re.compile(r"""
(
hello # greeting
| world # the entire world
| \d+ # a number
| a[ ]+b # a and b separated a bunch of spaces
)+
""",
flags=re.VERBOSE
)
print(r.match("hello123worlda b"))
@celest charm :white_check_mark: Your eval job has completed with return code 0.
<re.Match object; span=(0, 20), match='hello123worlda b'>
That's ugly though
I don't see how this is worse than
r = re.compile(
(
r'('
r' hello' # greeting
r' | world' # the entire world
r' | \d+ ' # a number
r' | a[ ]+b' # a and b separated a bunch of spaces
r')+'
),
flags=re.VERBOSE
)
most editors will highlight the regex properly
sublime
vscode
Ah yeah, because of the closure you need the []
That's just because verbose regex ignores whitespace, and you have to mark specially
or you can use \s for any whitespace character
I usually put [ ] instead of because can be easy to miss
I'm still not 100% sure I read of a satisfying reason as to why this isn't being executed in snekbox, can anyone clarify?
The original concern was catastrophic backtracking but the regex module seems to prevent that and has timeouts
however I do still somewhat worry about things
I think with the refocusing of snekbox to contain multiple evaluation systems regex is something we could look into
Does it support codeblocks too btw?
Regex compiling is safe AFAIK, if the timeout is set
yeah, with catastrophic backtracking being prevented it does seem pretty safe
I'm personally on the opinion that any unrestricted user input to a state engine is inherently unsafe, and should be sandboxed
but that's just me and my paranoia
I do share the feeling
Wouldn't be hard to just have some template code where the regex would be placed that would be sent to the current snekbox api, bit slower than running it directly but eval is fairly fast
Like, call the !e command?
Maybe this would be a good use case for a backtracking-free engine, like RE2 by Google
Yup
yeah just construct the code to run from input and then send it to snekbox like !e does
I don't hate that idea
Bindings for the RE2 engine, I think it might be worth looking into this, it has a completely linear execution time https://pypi.org/project/re2/
I'm not sure we should use re2, if we move to snekbox I don't even think we should use regex
I think that the usage of this will be demonstrating re most of the time, and sometimes it may be useful to demonstrate the pitfalls of the module
@celest charm Looking through the PyPi article, it's saying that if there's something that the re2 library doesn't handle, it falls back to the re lib
So it's sort of compatible
I like RE2 idea
I don't even think we should use regex
@patent pivot ... How?
the regex module
I think that the usage of this will be demonstrating
remost of the time, and sometimes it may be useful to demonstrate the pitfalls of the module
@patent pivot can't react in this channel, but i agree with this
@green oriole I'm proposing if we move to snekbox we should move back to re, because I don't care about catastrophic backtracking in snekbox
I think it should be done in snekbox for the ability to use re and it's full behaviour
yep
Ah, the current implementation doesn't the standard stdlib implementation
@crude gyro the proposed regex commands currently run regex on the bot
now obviously we've had our runins with unsafe regex before
which regex commands
nix's codeblock stuff
@celest charm has PRd some regex commands
to demonstrate regular expressions
Getting the pr link
