#dev-contrib
1 messages · Page 79 of 1
Error:
raise ClientConnectorError(req.connection_key, exc) from exc
bot_1 | aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host api.pythondiscord.local:8000 ssl:default [None]
Ah okay
I think I remember the solution for this
Do you have changes in your config?
Like what all changes?
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://"
site_logs_view: !JOIN [*SCHEMA, *STAFF, "/bot/logs"]
paste_service: !JOIN [*SCHEMA, *PASTE, "/{key}"]
Right, so set site to web:8000
https://pythondiscord.com/pages/contributing/bot/#configure-the-bot
And I think it should be able to start now
Yay! It's online now 🥳
Now I can make changes to the bot for the purpose making contributions right?
Yeah, you should be good to go
Check the contributing guide on the repo to get you started
Thank you so much for guiding me and fixing my errors!
Lol docker can be a bit of a pain, but this should only be a one time setup hopefully
Hopefully yes 🙂
@gritty wind I've a doubt, like the pagination has been implemented but the response has been changed, so do I need to update the response or the tests?
After I say pipenv run precommit I get this error below. How can I fix this?
C:\Users\Ş. Evren Alhas\bot>pipenv run precommit Exception in thread Thread-4: Traceback (most recent call last): File "c:\anaconda3\lib\threading.py", line 926, in _bootstrap_inner self.run() File "c:\anaconda3\lib\threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "c:\anaconda3\lib\subprocess.py", line 1267, in _readerthread buffer.append(fh.read()) File "c:\anaconda3\lib\encodings\cp1254.py", line 23, in decode return codecs.charmap_decode(input,self.errors,decoding_table)[0] UnicodeDecodeError: 'charmap' codec can't decode byte 0x9e in position 9: character maps to <undefined>
Traceback (most recent call last): File "c:\anaconda3\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "c:\anaconda3\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Anaconda3\Scripts\pipenv.exe\__main__.py", line 7, in <module> File "c:\anaconda3\lib\site-packages\pipenv\vendor\click\core.py", line 829, in __call__ return self.main(*args, **kwargs) File "c:\anaconda3\lib\site-packages\pipenv\vendor\click\core.py", line 782, in main rv = self.invoke(ctx) File "c:\anaconda3\lib\site-packages\pipenv\vendor\click\core.py", line 1259, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "c:\anaconda3\lib\site-packages\pipenv\vendor\click\core.py", line 1066, in invoke return ctx.invoke(self.callback, **ctx.params)
File "c:\anaconda3\lib\site-packages\pipenv\vendor\delegator.py", line 248, in block stdout, stderr = self.subprocess.communicate() File "c:\anaconda3\lib\subprocess.py", line 964, in communicate stdout, stderr = self._communicate(input, endtime, timeout) File "c:\anaconda3\lib\subprocess.py", line 1317, in _communicate stdout = stdout[0] IndexError: list index out of range
tag me when you reply please
bump.
The safest way to find out is to try 😄
and about this?
another feature for bot, just like tldr pages, we can add this or the tldr one.
Can you link the line in the code?
@short snow it does work, findall just behaves differently
#bot-commands message
It only showed you the groups
ok thankyou!
@vocal wolf @green orioleMentioned all the requested changes!
Anyone ?
I can't be fully sure, but seeing that you're getting an error in your dependencies, it might be due to running in anaconda. Try to recreate the pipenv from your base python install
I haven't looked at your PR, but if the new response can still be used by our other apps such as the bot, update the tests. If not, you have to convert it to the format expected.
the initial response was an array but after pagination, the response is a dictionary and the result will be present under the results.
In this case, you definitely update the response, not the tests
and if you want the next infraction page you need to pass the limit and offset also
Okay, I'll update
It could be possible to have the bot automatically fetch the next batch when it runs out, but that would require more changes on the bot & site
cc @green oriole @cold island
if we were to do that, we might also be able to bring the limit back down to 50
(This isn't something you need to do in your PR, at least not yet)
This is the response after pagination
So the left part is to update the response as previous.
Yeah
thank you
Well, we would run into the same issue where the bot would try to retrieve 10k infractions and it would take ages
We use the paginator and fetch as needed
We only fetch 50 at a time, and move the offset if we need to fetch more
Or hell, we can probably simplify it by fetching enough for one page, and use the page number as offset
Though that would be way more requests than 50 at a time
Hmm I'm not sure we will ever read more than 100 infractions to be honest haha
how does self.bot.wait_until_guild_available() work? I am having an issue where the program is stuck on this line, i.e, guild is not yet ready/available for a long time
Are you using the staff test server?
Hmm, I believe you need to configure the guild ID in your env file
oh let me check that
yep, you are right
I remember changing servers
thanks a lot for your help !
If that doesn't work, could the cache just not be available
May be a good idea to log instead of just returning early when the ids don't match
works now
Do you mean new env?
Yeah, without using anaconda
Hmm.. Like having a timeout?
I was thinking of just doing a trace log in here https://github.com/python-discord/bot/blob/3d014d95f57633a2f8fdf40f61ed1b0ade7343dc/bot/bot.py#L239-L240 but logging the reason with a higher level if it isn't available after a set amount of time might be clearer
Sounds good to me
Yes
The docker compose sets up the site, as well as a few other pydis projects
But really you only need the web and postgres
so i just do docker compose-up after cloning the site?
and then i can work on the bot with (pipenv run start)
Yup, or you can use the docker compose of the bot
I personally use the site since I already have it cloned and can make modifications
If you don’t want to develop the site, you can just use the compose of the bot
ok, i will setup the site with docker, and use pipenv to work on the bot. Ty!
for most purposes you can use docker for both
docker takes time, so for development purposes i just use the normal way, and for others use docker
docker takes time
Not sure what you mean by that 🤔
hmm, like when u do docker-compose up, it takes ~10 min
It should only do that when building all the containers
Once built, you can rebuild only the bot one and be up in no time
so i do docker-compose up once again, it will be up in no time?
You can try it now 👀
ok, once school gets over, will do that
It shouldn't be very slow, but if you already have it set up with pipenv there's not much benefit from moving the bot to docker
I personally run the bot without docker, so I can get debugging with my IDE, but as long as the bot runs, do whatever you like
i will keep the bot on pipenv, but will do site on docker (would make it easier)
yeah site postgres and redis are easier with docker as you don't need to install all the services locally
i will just open a issue for this, wld be better
thanks for your time
Issues are generally better if you need discussion around a feature
Why did the bot send this message
#python-discussion message
out of no where?
Presumably someone ran a command and deleted their message
Can confirm
right
in one issue am assigned but its status is planning, so i should wait right?
.issue 568
Don't work on it yet, do you know why it is in planning@vocal wolf
Ah stupid question, it just wasn't approved
Can you approve it when you see this
done
the former
You can just make an error embed
but it will return a 404-not-found image, and there is no way to check if that matches with what the user gave
>>> import requests
>>> r = requests.get("https://httpstatusdogs.com/111")
>>> r.json
<bound method Response.json of <Response [200]>>
Hmmm... that’s a bit silly
Can just check for the redirect
how can we check that?
Use allow_redirect=False, or check the length of the Response.history attribute
It'll need a special case for the 404 return code but should be much simpler than querying the site for what they have available
yeah
that's what i meant here in the second option
Where does regex come into play here? Validate the status code with http, do the request, if 404 was not requested check the redirect and send an error if it redirected to the 404 page
async with self.bot.http_session.get('https://httpstatusdogs.com/') as response:
text = await response.text()
http_codes_dog = re.findall(r'<a href=\"(\d{3})-[^\"]*\"', text)
Parsing html with regex 
the only solution i cld think of
did you forget bs4?
should i use that?
Why not use bs4?
Can you find a restful api I like the other solution waaay more
I’d prefer to check if you have been redirected to the page
i don't like bs4 for this, mine is probably a better way than bs4
what about this?
that's what akarys says basically, but isn't that the more longer way.
i don't understand, why shouldn't the parsing html with regex solution be used?
It is way less error prone and probably easier to implement
Someone wanna link the html parsing copy pasta?
If the html changes, the code breaks
If you look at the website they just store the images like this, why not just try and fetch it directly? https://httpstatusdogs.com/img/503.jpg
You cannot browse this page at “stackoverflow.com” because it is restricted.
That’s the idea, but they will redirect you to the 404 image for non-existing codes
Depends on your accept header, I’m pretty sure
Parsing the html with regex wouldn't be a big problem as it's a small subset, but you're relying on the html being static and it'd need to be updated to be up to date in case of changes and the additional complexity around that imo outweighs the benefits of preventing occasional redundant requests
Checking the length of history is very easy though, why don’ we go for that?
@gritty wind
Why parse the html though
I'm making no-header get requests to the img url, and getting things back as expected
It either returns a page with a jpg and a content-type header, or it returns the 404 page
import requests
codes = ["400", "200", "602", "404"]
for code in codes:
page = requests.get(f"https://httpstatusdogs.com/img/{code}.jpg", allow_redirects=False)
print(page.url)
print("Image Found" if page.headers["content-type"] == "image/jpeg" else "404ed")
Actually went ahead and wrote it pretty much
import requests
import shutil
codes = ["400", "200", "602", "404"]
for code in codes:
page = requests.get(f"https://httpstatusdogs.com/img/{code}.jpg", stream=True)
if page.headers["content-type"] == "image/jpeg":
print(f"Saved Code: {code}")
with open(f"codes/{code}.png", "wb+") as file:
shutil.copyfileobj(page.raw, file)
else:
print(f"404 On: {code}")```
hmm, basically parsing the html with regex does that in a much shorter way.
I don't think we should rely on this, it sounds pretty much like an implementations detail
Why not check page.status_code
Hello!
Under Test Server and Bot Account in Sir-lancebot contributing guide, it says
4. Create the following roles:
@Admin
and under Environment variables, it seems ID of role Helpers is needed. So shoudn't @Helpers need to be added in Create the following roles?
Source: https://pythondiscord.com/pages/contributing/sir-lancebot/#working-with-git
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.
200 even when the page doesn't exist. Returns the 404 image by default
O.o
although that might not be the case if redirects aren't allowed? not sure I followed that far
Not allowing redirects didn't seem to do anything
If you are following the guide, you should have created your server using the template
Which creates all the roles and channels
If you don't use the template, you need to create it, yes
I get a 302 redirect when I hit the wrong image
>>> requests.get(f"https://httpstatusdogs.com/img/3.jpg", allow_redirects=False)
<Response [302]>
>>> requests.get(f"https://httpstatusdogs.com/img/302.jpg", allow_redirects=False)
<Response [200]>
We can also check response.url for the final url
and if it matches their 404 page we can discard it, perhaps
>>> requests.get(f"https://httpstatusdogs.com/img/3.jpg", allow_redirects=True)
<Response [200]>
>>> _.url
'https://httpstatusdogs.com/404-not-found'
I still don't understand why you would do that when you can check the return type :P
The redirect page, and the 404 page are text, the correct ones are images
Am I missing something
the status code sounds more reliable
Yes but "creating a server using template" is mentioned in https://pythondiscord.com/pages/contributing/bot/ and not in Sir-lancebot contributing guide. So if it's added in that guide too, it will be helpful for newcomers :)
I don't like relying on content-type as it's not something as nailed down as the status code or final url
They could, for example, start serving webp images, it's happened with other sites to me before
It is a good test check though, to make sure things are as expected
but for this we need the list of codes
Not really, you can replace codes with the user input
But yeah the status code might be a better bet
so i should use aiohttp to get the result rather than just putting the code in the link
and check for the response?
^ this pretty much. Replace 3 with the user input, and you'd get what you need
If the response is 200, you got an image. If it is a 302 you got a 404
so basically this
Probably should filter it to numeric and <= 4 digits for safety as well
It can pass through the same check as the cat command
to bot-commands to play with the cat command
it checks the codes against the http module's list of codes, here it needs the another check but still prevents the erroneous inputs
#sir-lancebot-playground message why was no error embed sent in this?
should i add another check for it to be less than 4 digits ( == 3 digits)
exceptions that aren't handled on @dusky shore aren't delivered to the user
oh, so that is only sent by bot
should i add that check to http_cat then?
while am doing http_dog?
the issue as to why it didn't send was due to the fact that embed title can only hold up to 256 chars, more than that will make discord return an exception
but sure I suppose
ok.
Isn't there some other caveat about the config file intended to solve aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host api.localhost:8000 ssl:default [None]?
oh it might be working now
I mean what is there to solve?
My bot instance isn't online.
Now I have
web_1 | January 27, 2021 - 17:31:29
web_1 | Django version 3.0.11, using settings 'pydis_site.settings'
web_1 | Starting development server at http://0.0.0.0:8000/
web_1 | Quit the server with CONTROL-C.```
which I think is what is expected, but the bot isn't online.
I'm running this on linux now btw.
!paste
is everything in docker?
I assume so.
You'd need to change the url in the config
to what
web:8000 iirc
Yeeep
why isn't the config file on notion already like that, then?
Yes
Nah, you can use docker everywhere
If you're running on docker you'd use web:8000 (because you didn't do hosts modification on your docker). If you are running on localhost, the site is mapped to pythondiscord.local (assuming you followed the guide)
Actually, localhost:8000 will work now
I'm also not clear on which host I'm updating
pythondiscord.local isn't mandatory now
Your system host, so it can "bind" pythondiscord.local to the site url so to speak
"system" doesn't appear in the config file.
System as in your OS system
but apparently you don't need to do that anymore, which is way easier usually
If it's accepting all hosts we should just get rid of the hosts file part and point at either localhost or host.docker.internal depending on how it's set up
I think linux hosts should be under /etc/hosts if you do want to go down that route
(if it isn't going through docker's names)
@trim cradle if you use docker, just replace localhost by web in the config file
all three instances of the substring "localhost"?
The other ones aren't mandatory for running the bot
Only the site is
So configure them if you want their features
Only the second one
(Redis can use fakeredis)
The first one should be redis and the last one should be snekbox
so change line 319 to read exactly site: &DOMAIN "web:8000" with no other changes?
Yesh
Yep
Alright, now I'm having a token-related error, so I'll regenerate those, I guess.
Why do we do all this btw? Can't we just make it one url, and bind the same ports on host and docker
That way it can all be localhost:8000
Woo it's online! Thanks @gritty wind @green oriole @brazen charm
Niice
Well, not really because of how the virtual Docker network works
I'll try to work out an easier method
Not if we use --net host 👀
I actually had to do that for metricity because
reasons
@gritty wind code has been pushed. Review the changes and let me know if something else needs to be changed.
You still have a problem with your imports starting on line 6
https://github.com/python-discord/site/pull/443/files#diff-9d0308e109cd6c4edf9d58d1c054daa10f3f84dd74ae4d2572adc9e194f726a3R6
If you are importing things over multiple lines like that, our code style would have you put each entry on a separate line
Like it was before your changes
You can see the full style guide here https://pythondiscord.com/pages/contributing/style-guide/
Same thing applies to line 13
This also seems to be an erroneous new line https://github.com/python-discord/site/pull/443/files#diff-215b87c752e5a7b58b8ec5d58accbdcf4ab3bd325a171301dd67c6ae4852f2b8R234
Someone more familiar with django will have to do the actual functionality review
thanks
@gritty wind can you have a look at c4 when you are free 
I had a look over it this morning, expect a review soon. I don't think I'll be requesting any more major adjustments, just a few minor notes here and there
That will have to come tomorrow though, it's kinda 2 in the morning here
#sir-lancebot-playground message no bot reply here, looks like it has caught an exception
Issues are turned off for that repo
> GET https://api.github.com/repos/torvalds/linux/issues/1
{
"message": "Issues are disabled for this repo",
"documentation_url": "https://docs.github.com/v3/issues/"
}
ah ok
Am loving reviewing the markov poem problem, and learning markov.
So in our bot/utils/extensions.py (suppose this file is A)
we have this line
imported = importlib.import_module(module.name)
And we are importing this file in our bot/exts/utils/extensions.py. (suppose this file is B).
Here A is importing B and B is importing A, but how do we avoid importerror?
I usually use a relative import in one of the two
I'm honestly not sure why that does break the circle, but hey
Huh?
My question was like it doesn't error out, how do we actually avoid that. not how to avoid it
sorry if i am not making sense
Ah, well, no idea haha
Huh?
Maybe even in the init if they are in the same module
So like file A and B both import from file C
No circular import
let me check if they both import from a common file
I’m saying they can if you need to share variables across both
I think you are misunderstanding me, should I rephrase my question again?
Yeah sorry. Wasn’t the problem with a circular import?
So in our bot/utils/extensions.py (Lets consider this file as A) we import all the modules from bot/exts to check if they have the setup function.
And, in our bot/exts/utils/extensions.py (Lets consider this file as B) we import bot/utils/extensions.py.
So file A is importing file B through importlib.import_module and file B is importing file A.
Because both of these files are importing each other this is supposed cause an ImportError because of circular import, but how come this doesn't cause an import error?
Was my question
Ah okay
This is the ext loader, right?
It doesn’t load any files that don’t have a setup method
But it still imports them
aight
Your reminder will arrive in 2 hours!
There's no circular import because importlib.import_module has a loop-breaking construction: if it's current importing a module that then is imported, it will instead return a reference to the currently-partially-loaded module
from imports don't permit this, and thus will error if there's a loop, but if there aren't from imports then python happily lets you do import a import b in two files. Keep in mind that if one of these is the main script, you can load your main script as the main module and the __main__ module (given it's named main.py), which is twice, compared to other modules, which will load once
Ah got it, so importlib.import_module doesn't actually import the module but give a refrence to it.
Thankyou
Right, if the module is already imported
Wdym by that
# pseudocode
def import_module(name):
if name not in sys.modules:
sys.modules[name] = empty_module()
actually_run_code(name, in=sys.modules[name])
return sys.modules[name]
Or, well, (edited)
😕
I missed a step, which si that the empty module is created before running the code
So, basically, at the very top of your code sys.modules["my module name"] exists
and thus, import my_module_name simply grabs that object that's there
Well this (<#dev-contrib message>) was all I needed to know, thx
@gritty wind
Here's your reminder: ^.
[Jump back to when you created the reminder](#dev-contrib message)
Good bot, go back to your hole

Any ideas about bot_1 | aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host api.localhost:8000 ssl:default [None] from bot in docker?
This looks like the relevant parts of the traceback bot_1 | File "/bot/bot/bot.py", line 79, in cache_filter_list_data bot_1 | full_cache = await self.api_client.get('bot/filter-lists') bot_1 | File "/bot/bot/api.py", line 80, in get bot_1 | return await self.request("GET", endpoint, raise_for_status=raise_for_status, **kwargs) bot_1 | File "/bot/bot/api.py", line 74, in request bot_1 | async with self.session.request(method.upper(), self._url_for(endpoint), **kwargs) as resp:
I'm guessing this is something to do with the site?
Sort of
The site is probably up
but the docker url would be web:8000
not localhost:8000
Ahh that's sorted it, I used the config from notion
That one assumes you're running the bot locally
makes sense
Maybe I'll just add a note now
it's in the contributing guide notes If running the webserver in Docker, set it to "web:8000"
I just didn't pay attention it seems 😄
Lol dw a lot of people run into similar problems
I've written it down now on the config
.issue 1375 bot
Would ArgumentParsingError be the best error to raise for this?
Since BadArgument sends the help embed too, which I don't think we want
or do we?
Hey, if you need help check out #❓|how-to-get-help . This channel is for discussions around the PyDis repositories.
I think we would want to send the help embed, because that's the default behavior for other conversion errors
for instance:
!remind u12ih3uh
u12ih3uh is not a valid duration string.
!remind [mentions]... <expiration> <content>
Can also use: reminder, reminders, remindme
Commands for managing your reminders.
Subcommands:
!remind delete <id_>
Delete one of your active reminders.
!remind edit
Commands for modifying your current reminders.
!remind list
View a paginated embed of all reminders for your user.
!remind new [mentions]... <expiration> <content>
Set yourself a simple reminder.
makes sense, then I think I've already got a fix 😛
pre-commit seems to be trying to force LF line endings, whereas all the others are CRLF
Should they be LF?
Ahh, must have been my global conf that force it on clone then
git config --global core.autocrlf true 
It'll revert the change to LF
but you can submit it with the files changed, and it won't show up by the time it gets to the repo
What I did when I was fixing it on mine was I pushed all my code
Copied the git folder
deleted, and recloned the repo with the updated config, and put the git folder back
yea, probably be the easiest. I'll do that too
kl
#sir-lancebot-playground message on game over, clearing the reactions would be a good idea
@gritty bolt check out your pr! Gave a review
i can delete .reddit msgs of others
Looks like another issue to be added to https://github.com/python-discord/sir-lancebot/issues/348
I'm not sure if we merged it, let me check
from bot import constants
from bot.constants import MODERATION_ROLES
hungh
oh i broke policy bot
what was the fix, close and reopen?
Though it is still errored
Error evaluating policy defined by python-discord/bot ref=master
refresh?
Alright, just gihub being slow then
thanks golang
Did it just put the entire program into the traceback
lmfao
it's just a long stack trace
so it seems to be a bug that sometimes GH API doesn't return the pushed date immediately after the push
so our infra is TOO FAST
Is there any pattern to the commits that can cause it?
This one seems to have been merging master into the branch
yeah I think I've seen it on a few master merges
Damn, we are too fast
ak please compliment my infra
thank you
Can we make it less good though?
:3
Actually I can do it
Yeah
Yesh
!help
Big Brother
!bigbrother
Monitors users by relaying their messages to the Big Brother watch channel.
!bigbrother unwatch <user> <reason>
Stop relaying messages by the given user.
!bigbrother watch <user> <reason>
Relay messages sent by the given user to the #big-brother channel.
Bot
!echo [channel] <text>
Repeat the given message in either a specified channel or the current channel.
!embed [channel] <text>
Send the input within an embed to either a specified channel or the current channel.
BotSource
!source [source_item]
Display information and a GitHub link to the source code of a command, tag, or cog.
BrandingManager
!branding
Manual branding control.
Clean
!clean
Commands for cleaning messages in channels.
In that case, can an admin try and delete mine
2 instances reported of the bot still allowing people to delete other's embeds in #helpers. Can anyone repro locally?
@gritty wind do you recall which file had functionality for that?
One sec
Paginated ones or normal?
the one that does not work as intended
one tag, one doc, and possibly one help
That's what I'm trying to figure out - which one doesn't work
either can work then
https://github.com/python-discord/bot/pull/1388 a review is needed for sanity reasons
Does the command error handler not handle exceptions raised by converters?
That error handler has a special case for errors from our API already
There is no converter here?
What? It's literally in converters.py and subclassing Converter.
I guess not, since the error raised by sentry https://github.com/python-discord/bot/issues/1375
Would've be handled by https://github.com/python-discord/bot/blob/master/bot/exts/backend/error_handler.py#L78
Cause it's wrapped in a ConversionError instead of a CommandInvokeError.
Ah
I think the better approach is to check the inner exception of the ConversionError too.
@vale ibex you probably want to add this to your current PR.
The current fix is too simplistic anyway, and it doesn't cover the other request done in the converter
It'd be nicer to take advantage of all of this
Actually looking at it, the current approach has something weird, where 3-4 minutes after the error is raised, it then sends the debug message bot.exts.backend.error_handler | DEBUG | Command infraction edit invoked by Chrisjl#2021 with error BadArgument: The provided infraction could not be found.
Ah, this seems to be a delay for other errors too, not just this 1
Updated the PR
.issue 1365 bot
Been working on this, it seems like the current impl errors if you give an ID of a verified bot. (575252669443211264) is an example ID of one.
It just needs a new emoji to be added for :badge_verified_bot:
What's the process for that?
If you need to add something to the config, add it, and possibly leave a message on the PR alerting people they need to add it to their configs
(also would be awesome if you update the test server config once its merged)
I think the question is how does the emoji actually get added
The answer is that you need to ask a staff member to do it, providing the emoji image if you have one
Isn't the verified sticker a default discord one on bot accounts?
Not all bots are verified
Yea, verified bots have this
Annoyingly its not an image I can just pull off discord, so I'm currently trying to find an image suitable for an emoji
It's just css + html
You could copy it over to a blank page and let the browser scale it up
the tick is an svg too 😛
Or maybe just zoom in
True, i'll give that a go
I could create the whole thing in SVG to be "proper" but we don't really need an SVG for this
Seems like Akarys is assigned to this. He might not mind, but for future reference you should assign yourself to issues before working on them to prevent clashes and two people doing the same work
no worries. As a helper you can assign yourself to issues without asking, just make sure it's not already taken
I'll leave it for now then, and just put my findings in the issue 😄
@kind flower i had to change it to or, since the
It has to be either in the categories
or
in the organisation
it can't be in both, so and won't fit
or would be perfect
but you are checking for when to not run it right? @short snow
or did I read the code wrong
if the message is in the whitelisted categories
or
if the message is in the whitelisted channels (i.e. only organisation in case of on_message)
then, u continue
else we don't run it
yes, after your latest commit it is correct, but it was not at the time of me leaving the review
also while I have you here, what I meant with PYTHON_DISCORD_REPOS is that the url does not mention pydis specifically, so personally I would either drop the formatting and just put it in the url from the start, or change the variable name to something more generic
PYTHON_DISCORD_REPOS = "https://api.github.com/orgs/{repo}/repos"
it should be
REPOS_API = "https://api.github.com/orgs/{org}/repos"
personally I think that is better
async with self.bot.http_session.get(PYTHON_DISCORD_REPOS.format(org="python-discord")) as resp:```
and this
can't type today
Will do that!
for on_message, it is in development, media, devprojects (Categories) or organisation channel
and for issue:
the original issue (#566) mentioned it should be limited to:
the organisation channel (551789653284356126)
the development category (411199786025484308)
the dev-projects category (787641585624940544)
the media category (799054581991997460)
it is in development, media, devprojects (Categories) or white_lsited_channels
well gtg. will do those changes, if anything else is there, just put it on the pr
@cold island the #Mod-tools and #mod-meta are channels right?
yes they are
We could whitelisted the whole category tbh (CC: @cold island)
(ping me when u decide what to whitelist.)
@gritty wind can we shift issues from one repo o another, do i need to close one issue and open on the sir-lancebot
No we can transfer it, if no one has any more concerns
ok, you can do that then ig.
donezo
ah that was fast
Yeah lol it is pretty much one button click on the github ui
nice, didn't know that
It's the first time I use it myself, pretty cool
Damn it, now I'll have to update my metricity container smh
lul
nothing much has changed
@short snow hey
can you test something
(cc @sharp timber)
can any regular member try hit the trashcan on this
!paste
it didn't do anything
cheers
mine worked but yeah
I've done plenty of testing on server, and off server, but even under the exact same conditions, I could not get it to replicate
#help-grapes message is the invocation that cancelled out
do we have any logs for this
Got a link to the source?
(Someone tried to use a tag on cooldown which is the 1 log)
You're either looking at the pagination source, or the docs/help/tag source
Pagination source:
https://github.com/python-discord/bot/blob/master/bot/pagination.py#L188
ty
And the tag invocation:
https://github.com/python-discord/bot/blob/master/bot/exts/info/tags.py#L268
Yeah, I can't find anything
The code is solid, and I can't repeat it on my smaller scale test server
So i'm thinking it's some oddity with discord, or the library
but I can't confirm
Is the or and not working as we would expect it to?
I tested, it is
Are we fucking up how ctx.author behaves?
Like, if we get a Userobject, will it always return true?
I also checked the mod roles on the deploy, and they work
I tested that specifically, and no it works as intended
That is to say, the check fails
hahahaha this is a conundrum
But why would it only fail sometimes 🤔
Hmm
Maybe something edits ctx.author
Hello :)
Hmm, let me get you a full invocation trace
Are we passing a mock author at some point, or something
Or are we just completely overlooking the issue?
We probably are tbh
Can we add some logging in there
if we log warnings for all invocations, we can check on sentry
Thank you Joe, I learned a new word today

No no, let's not use warnings
Does sentry log anything lower
Me too
Is there a way to reduce the grafana log level to trace?
nah
Sad
There is nothing being logged anyways
grafana just pulls out what is coming out of the pod
and the pod silently drops all debug & trace in prod
I wanted sentry specifically because it automatically gets all the defined vars
Hmm.. if we add an env var to configure this, can you temporarily force trace in prod?
Using sentry is pretty hacky
That would be a lot of logging while we wait for the error to happen again
it isn't reliably reproducible
we could middleground it and log info
Maybe some strange race condition?
I do wonder what shenanigans are we doing that paginator doesn't error out
cooldown, try #bot-commands
yeah i probably can
I saw a reaction
I deleted it
where is the root logging instance
bot.log?
how come we never restrict any of our paginators yet the paginator doesn't error out?
Does None have id attribute afterall?
Ah I see
!int e ```py
print(bot.log)
In [1]: print(bot.log)
Out[1]:
File "/bot/bot/exts/utils/internal.py", line 178, in _eval
res = await func()
File "<string>", line 5, in func
AttributeError: 'Bot' object has no attribute 'log'```
if not restrict_to_user: restrict_to_user = ctx.author
Yes?
I meant the bot.log module
If you make a command thorugh internal eval and the bot restarts does the command still presist or does it get lost?
the pagination does feel like bunch of spaghetti pieced together
lost
right
Some of it is years old ¯_(ツ)_/¯
Wouldn't logging.getLogger().setLevel(5) work @patent pivot?
I think scragly is rewriting the paginator
!int e ```py
import logging
logging.getLogger().setLevel(5)
In [4]: import logging
...: logging.getLogger().setLevel(5)
...: ```
and now we wait
but I'm p sure that wouldn't update the root logger
also fwiw the metricity PR works 👍
Nice
Can someone with Help Cooldown try trashcanning a message
It didn't seem to update the logging though
What are you guys hoping to see anyways?
can you send one
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
!paste
cooldown
ye so whats the issue?
nothing happened
sometimes it gets erased
Only admins, mods and owners are moderation roles
Help Cooldown shouldn't affect that
Do we at least know which commands are affected?
may I know whats wrong with the paste command?
Yes
all of them lol
there is a list of recorded instances in #dev-core
Trashcans seems to be working for some people when it shouldn't
Hmm okay
oooh, but it didn't work for me
cooldown @late wolf
it isn't reliably reproducible
2021-01-30 13:34:04 2021-01-30 13:34:04 | bot.exts.info.tags | INFO | Inheritanc-e ♦#1090 tried to get the 'paste' tag, but the tag is on cooldown. Cooldown ends in 32.5 seconds.
I was talking about the traschcan emoji
even though i had cooldown it didn't get deleted
The cooldown role was just a theory
^
The reason is currently unknown

It's not help channel restricted, probably
did you figure out why everyone can delete the paginator yet?
Mope
well
Yes, mope
by the code we set it so anyone can delete them
uh
Did we?
I think I found it
!e
no_res = (
True
or True and False)
print(no_res)```
@subtle kraken :white_check_mark: Your eval job has completed with return code 0.
True
with contextlib.suppress(asyncio.TimeoutError): await bot.instance.wait_for('reaction_add', check=check, timeout=timeout) await message.delete()
no_restrictions = (
# The reaction was by a whitelisted user
user_.id == restrict_to_user.id
# The reaction was by a moderator
or isinstance(user_, Member) and any(role.id in MODERATION_ROLES for role in user_.roles)
)```
That's expected though? If the user is the sender, it should delete
It looks good to me
Either the first line is true, or the second one
The conditions for deletion are: user_ is restrict_to_user or mod and member are true
Is something wrong here?
that code simply deletes when message is old so I'd doubt
Yes, but
it does
And doesn't .suppress() simply then skip the delete check?
why would it
once it does, it should delete the message
but the embeds are being deleted much earlier than expected
cause doesn't it jump to the end?
Return a context manager that suppresses any of the specified exceptions if they occur in the body of a with statement and then resumes execution with the first statement following the end of the with statement.
Once the timeout is done, that is the intended behavior
But the timeout is long enough that it shouldn't be the cause here
The timeout is 5 minutes though
Right, but, then, are tags getting deleted if they're too old?
okay am just pretty blind
sorry, they don't
the code only will delete message if check has passed and it did not time out
They aren't, the reported instance I've seen could happen up to a few minutes after they are sent
Well under the 5 minutes
Do we even call this function? I don’t think we do with tags
Mine happened in seconds
we paginate tags afaik
Yup, so the timeout isn't the cause
It would be constant otherwise
And more importantly, I don't think we would've seen this spike in reports because that behavior is unchanged
Did someone just intentionally erase my !paste spam or did they all just clear themselves?
because that was within one minute
#bot-commands
I don't mind, but I was wondering if it might somehow clash with us writing a channel name or something
Found a related issue
#bot-commands message
It has my reaction. I can't delete it.
Oh crap, I think I know what's wrong
lol they all gone
That’s a good point
@green oriole see me in #bot-commands to watch this?
!paste
!paste
Ughl
A single reaction erases all of the embeds
I wonder if its because you have moderation roles because it works fine for me
It's just erasing all of them
A single trashcan right now is erasing 10+ messages if a mod does it
And its also deleting them even if no trashcan emoji is added
The reaction message check has to be failing for this to happen
What happens to reaction.message if the message is deleted?
!paste
shit
it happens cross-channel
@patent pivot
!tags
also i can delete bast's tags command output
If only I had my test setup active, F**K
cross-channel huh
!paste
now that's weird
right that makes sense
lol
the event fires for all active ones for any emoji add 🤦♂️
I don't understand how
I guess a quick-fix would be to add a check that the message has the delete emoji from the author
lol
Are discord.Reaction instances being cached?
message x registers an event check
message y registers an event check
discord sends an event with trashcan emoji, and user of message x and y
We check the reaction.message.id against message.id
and message.id seems fine
if reaction.message is getting fucked up that would cause this
it isn't
the reaction.message is message x for x handler, and y for y handler
why, is a discord.py oddity probably
Well, the checks are passing, presumably
Ooooooh
Hm, let me..
that seems to be an issue with members intents (in dms), is it applicable here
1.6
I’ll push a fix to master, just need to add two parenthesis
Wait
?
Tbh what I think is going to happen is that we get used to it and then try to use it in channels where it's not whitelisted and eventually add all staff channels. But we'll see
This still doesn't explain it happening to helpers
Unless mod reactions delete all embeds on the server
Yep, a moderator reacting to any message will clear all the embeds on the server
It will reset when redeploying
did that actually work
only one way to find out
lol no i mean the log level
There was nothing to log anyways
we don't have any logging that details the wait for
Did you figure it out?
Nope
And yes
I have trace locally, and nothing shows up
What is it?
https://github.com/python-discord/bot/commit/ced0af2b2936b1fab4f5601bd7b1c00bbbd9130a Basically the moderation role bypassed the message id check
Well, I was looking in all the wrong damn places
If it proves to be too much if an issue we can just disallow it for everyone. Mods can delete any message anyway
Yeah, that's the bug alright
Its fine now
and python is back up, if anyone still wants to test it
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
!code
Yeah, confirmed fixed
Awesome!
Sorry, was not there.
all good!
Any confirmation on this?
Let's stick to the two channels
Ok.
We are having infra problems atm, thanks for the report
oh ok
.issue 1225 bot
What would be the preferred implementation for this?
I've found two possible solutions that seem correct
Well, what are they? 
in the issue
Hah sorry, they're in the issue
One is in the error handler, the other in the converter
Commented
Luckily that's the fix I still have stashed, so will just push it when I get home 😀
@vocal wolf will do that
huh?
don't see a reason why we can't allow the player to set the bot's token as well.
@gritty wind what do u mean by this? Is to check whether the emojis are not equal or ....?
I mean you can just allow the function to take two tokens, like you do with the player vs player
You can ignore the errors about http_session and trace. PyCharm just cannot figure out that they exist since the attributes are added dynamically to instances of Bot and Logger respectively.
thought so, i add them to my personal project too, and pycharm couldn't figure them out
Well the trace is a more complicated monkeypatch but the principle is the same
@vocal wolf question, do i default the language to python in cht.sh command, or ask user for it
default to py
ok
another question (sorry for disturbing.)
the default 404 Not Found looks like this: https://cheat.sh/python/abbbcccddddbbbee , and the response always returns status 200, so should i over-write this and let it display this
resp.status is a 200?
# 404 NOT FOUND
#
# Unknown cheat sheet. Please try to reformulate your query.
# Query format:
/LANG/QUESTION
# Examples:
/python/read+json
/golang/run+external+program
/js/regex+search
# See /:help for more info.
#
# If the problem persists, file a GitHub issue at
# github.com/chubin/cheat.sh or ping @igor_chubin
yep
always 200
uhhhhhhhh
i can check if it the response is starting with # 404 NOT FOUND and then send my own error embed
should we wait until this is fixed?
if it's a few months old then yeah we should implement our own way of detecting if a page cannot be found
make sure to include the issue in the PR
ok
Looks pretty good I'd say
should i put a cooldown on the command?
like 5/10 seconds
do we do that with other request commands?
lemme see
because I can't remember lol
alright dew it
Yo thanks. I had to meet a few school deadlines so I have been busy, but I will have time to look at them later today
And, what do you think of the bot?
i didn't get u
#sir-lancebot-playground message can we change the token and number colors?
my exams are coming near, so i wanna complete everything before 2nd Feb, Hence the prs are getting opened so fast.
also i won't be able to give much attention to them from 15th Feb to March 18th.
#sir-lancebot-playground message the pings are not being shown in a proper way
How are they supposed to look?
like my mention, it is not the code problem, but discords ig.
a better way is just their display names
You can't have mentions in embeds
I think its easier with mentions so we don't have to handle usernames, or nicknames or whatever
then how did my mention come? which didn't ping me
Mentions appear formatted but don't ping in embeds
but it is sometimes shown with ids, which is even more harder
.ttt log
see the first 1
The fix wasn't ported to sir-lance
and that's a problem on your end, probably need a cache refresh
ah ok
Chrisjil is ChrisLovering right?
That's me 🙂
ok. thanks for the quick review
and nice
that's a pretty good way using should do and could do
yea, I tend to use those, so that it sets the seen scene for the comment 😛
otherwise all my comments seem like they are things that must be done
Yea, and that's the big issue with should do/could do, everyone has different opinions on what is what
For sir-lancebot, if the api does not return a 200 status, what error should I raise?
What's the context?
Currently working on a valentines cog that returns a player a poem
From Shakespeare's poems
By using a Markov chain
The cog accesses an api that gives a list of rhymes for a given word
The cog will continue to sift through lines of Shakespeare's poems until it hits one has its last word inside the list of rhymes
But if the api is down, this shouldn't work
Is the only cause for an error if the API is down?
Well, it can technically work because there is a memoize function in place
No, there are other ways for errors to occur
async with self.bot.http_session.get(
website + word,
timeout=10
) as response:
if response.status != 200: # 200 means 'ok'
logging.warning(
f"Received response {response.status} "
"from: {website + word}"
)
raise Exception
curr_set = set(
data["word"] for data in await response.json()
if data.get("score", 0) >= min_score
)
rhyme_set |= curr_set
So I am planning to raise an error, where I have put Exception
So this stops the entire process and tells the user that the api is down and poems are harder to generate
Should I create a custom Discord error for this?
And catch it inside the cog_command_error?
Why this should raise error when API is down?
It's better to just send message about it to channel
I am not sure of a better of stopping the whole process than to raise an error
This check happens inside the get_rhyme function
But it's one function inside a nest of other functions
This function is supposed to return a rhyme_set, I suppose I could return None and bubble up the error to the function responsible for returning the user a poem
And instead return an error message
But I figured that raising an error would be cleaner
Hmm this seems like an error localized to the poem-generator, so it would make sense for the error to handled within the file
If we handled all errors in the error handler, we’d have a monolithic file
.issue 1373 bot Do we want to tell users that the command is on cooldown, or not output anything at all?
[404] #1373 Issue/pull request not located! Please enter a valid number!
.issue 1373 bot
I'd say not output anything to match the behavior of actually invoking the command
Alright, an easy fix for it was to change the return from display_tag to True if the command is on cooldown. It doesn't seem to have any side effects but it doesn't seem "right"
differentiating between not found, cooldown and success might require some sort of enum
Hmm if something matches a tag, we probably don’t want to even let it get through to the command sugegstor
wdym? py with contextlib.suppress(ResponseCodeError): if await ctx.invoke(tags_get_command, tag_name=tag_name): return -> ```py
with contextlib.suppress(ResponseCodeError):
await ctx.invoke(tags_get_command, tag_name=tag_name)
return
so it always returns early if the tag converter succeeds?
error_handler:168 for ref
This has the same effect as what I did, but we can keep the return for commands on cd as False
If the tag converter matches something, the intention was most likely a tag. In that case, we don’t really need to check for alt commands
I don’t remember the exact way it functions though, so I can’t say if that’s different from your solution
I think I prefer your proposed solution
Ahh, it looks like the tag converter just checks the tag name is a valid format, as opposed to an existing tag
Yeah the get function does the fuzzy matching
What I don’t remember if there is any way to check the fuzzy matching results without modifying the function
in a lot of places in the sir-lancebot code this happens:
def func() -> None:
return await ctx.send()
but it should be
def func() -> None:
await ctx.send()
return
It does the fuzzy matching in the block after, in error_handler. If the get function returns true though it quits early, so doesn't reach it
Can you link an example?
I'm feeling more like the get function should return true, even if the command is on cooldown
since it handles the cooldown itself anyway
and False is reserved for when there are no matches
Yeah that’s looking like the right move
Though it’s original intention was to indicate if something can be sent
And since it does the cool down checks internally “can be sent” also includes the cool down
@vale ibex here, got the old screenshot in my bin
With no headers
And i don’t see the need of line pagintor, just let is send plain text, and the bot can’t mention anyone , so the only problem is the content escapes the cod block, i could even add a fix for that using zero width spaces (that’s what it is called ig)
that was one interesting experience, trying to rebase my project and having almost every single one of the 190 commits to master conflict lol
i did a full rebase now but still this isn't working.....
not sure what is causing the commit fail
Ahh I see why now. because we're using a aiohttp.ClientSession() our user agent is actually Python/3.8 aiohttp/3.7.3
Yeah
Hmm, some core dev can just squash dev for u
You should just merge instead of rebasing new history
https://github.com/chubin/cheat.sh/pull/280 see if this ever gets merged 😛
there we go i think i managed to merge all the conflicts now
hmm flake8 is giving me trouble now. how does one use repr()?
as in like i'm trying to make a new tag, and i have a mix of single line and multi line code blocks
Can u show your repr code?
How did you create the tag? Did you make a new .md file in bot/resources/tags?
Those errors seem to suggest you created a .py file
yes a new .md
i did start the project quite a while ago but got off tracked by school so didn't have time to finish it
so i decided to pick it up and rebase to get all the ~200 missed commits to master (resolve merge conflicts)
you reckon the repr() is inside some other code?
I would say to revert the merge into your branch commit, or redo the pull request from a new branch
i was thinking about deleting the PR and branch and making a new branch from master yeah
the problem is not from your code, so i had say to leave that out
Yea, run git remote add upstream git@github.com:python-discord/bot.git then git fetch upstream then git pull upstream master
that should get you up to date
use https://github.com/python-discord/bot.git if you don't clone via ssh keys
which you should totally be doing

I just reset my main always, and then rebase it into my branch
since main has 0 commits anyways


