#dev-contrib
1 messages · Page 85 of 1
You could make some abstraction that would do all the error-handling, but maybe it's not really worth it
Another question @cosmic moat: you don't differentiate between an erroring result and an empty result. Is that intentional?
https://github.com/SuperMaZingCoder/sir-lancebot/blob/feature/youtube/bot/exts/evergreen/youtube.py#L126
This condition will catch both [] and None
yes
@cosmic moat You should also not load cog if token not provided in environment
@cosmic moat
class YoutubeError(IOError):
"""Something went wrong, and it's YouTube's fault"""
...
async def _request(self, url: str, description: str, /, **params: Union[str, int]) -> Any:
async with self.bot.http_session.get(url, params=params) as response:
if response.status != 200:
raise YoutubeError(f"{description} failed: status code {response.status}")
return await response.json()
async def get_statistics(self, id: str) -> VideoStatistics:
"""Queries API for statistics of one video."""
response = await self._request(
STATS_API,
"Getting statistics",
part="statistics", id=id, key=KEY
)
view_count = response["items"][0]["statistics"]["viewCount"]
like_count = response["items"][0]["statistics"]["likeCount"]
return VideoStatistics(view_count=view_count, like_count=like_count)
how do you like that?
it's quite nice, though, should each of those methods be in an error class?
and doesn't that catch the same things?
@cosmic moat no, the error class is just 2 lines, ... indicates some absent code
i.e. it should be in the cog class
It does have the same behaviour, just in a different way
ah okay
@cosmic moat You could also add a try-except around the async with that would catch all the errors. Another approach that I expressed above is to just leave it to the top-level, and not care about it
alright, i will be able to work on this later
is pride avatar blocking?
.src prideavatar
Yes it is
So is 8bitify, easterifier etc
they should all be put into executors
Care to raise an issue @clever wraith ?
sure
also, why is it creating a new session here? https://github.com/python-discord/sir-lancebot/blob/master/bot/exts/pride/pride_avatar.py#L149
I feel like having blocking image processing images as bad as it looks haha
We would at least need to make sure that only one instance of all avatar command can be ran at the same time
thats rather simple then
d.py has decorator to ensure that only 1 command can run at a time afaik
I think looking into that would be much better than blocking whole bot
yea @commands.max_concurrency(1, commands.BucketType.user)
I imagine a guild bucket is what we want
if we end up doing sir-lancebot#584 we should have that in and executor though, since it'll take longer than the normal processing
I'd guess default bucket won't hurt at all
True, not much difference for us
We can add a cog_command_error to the file too and catch commands.errors.MaxConcurrencyReached to output to the command invoker why their command isn't running
Maybe worth doing that at the bot level
Why do you think that?
Because our resources are far from infinite haha
I guess you could say that anything is far from infinite as much everything else
But yeah
Yep, we'll die a horrible death only a few decades from now, and in the coming years we'll be lost in time, like tears in rain...
but the limit does make sense
That would block each command individually, right? I think we should block every other avatar commands at the same time
Haha
Ahh right, then yea that would be more complex
we could then coupe them all into same group command
so group command applies concurrency limit
That's a good idea, I imagine there's a fair amount of shared code too
and to keep the posibility of being able to use command as .command and not .base command we could borrow Mark's implementation for that from @stable mountain
Mark did some magic for .base command being invokeable as .command iirc
That sounds good
Would that be something you'd want to implement @subtle kraken ?
Only asking because I've been looking for a slightly larger project to get my teeth sunk into and this sounds like fun
I wouldn't say so as am rather inconsistent with whatever am doing so that PR would possibly take quite bit of time under my name to get it done
Plus am being bit busy nowadays so feel free to do the coding if you so wish, I can always review it
Cool, I can draft an issue later this evening to get the specifics down
take your time, no rush
Where would I look for the thing you mentioned in @stable mountain ?
I think PR will explain it better than code could @vale ibex
https://github.com/python-discord/bot/pull/1124
it has all files relevant
mainly relevant are https://github.com/python-discord/bot/blob/master/bot/command.py
and the change it bot.py file
to add_command and remove_command
I imagine for the system itself, you need to port the class and those 2 methods
Hopefully that helps
I do recommend into looking most of the PR as it shows all the stuff that needed to be done & how to use it
actually
it is interesting if max concurrency will work on that
I dooo have slight doubts on its implementation to handle parent checks to be fair so that could be interesting
Yea, could do a small poc to make sure it'll work
would mean that you'd have to drop the root alias implementation or rework it so it supports parent checks
well, I wish you best of luck!
Thanks 😄
Can't this be implemented with a custom bucket instead?
Maybe not cause I imagine each max_concurrency decorator has separate state
I can't seem to find anything that suggests it can be on google
But also nothing to the contrary.
i finished the .pyfact command
but i need some more fax
should I make the PR now, then add facts later, or vice versa?
@clever wraith I guess you can make a PR now, and then we'll bikeshed intensely
ok
what's bikeshed mean?
Law of triviality is C. Northcote Parkinson's 1957 argument that people within an organization commonly or typically give disproportionate weight to trivial issues. Parkinson provides the example of a fictional committee whose job was to approve the plans for a nuclear power plant spending the majority of its time on discussions about relatively...
@clever wraith Discussing unimportant details when facing a conundrum
ok
what did @dusky shore bring? was that an automatic thing?
yeah, it's the .wiki command
I just erased the invoking messages, they were pretty noisy
ok
it would be much faster to send a link manually, but since this is #dev-contrib
ok
ok
🆗
.bm 810938851877978163
Who is working on getting all the image commands into one group and adding ccool down on it?
@vale ibex
@green oriole Pull request made for the above
Sweet
should be just one approval ig
Isn't it sir lancebot?
Also why are there a bunch of extra whitespace everywhere
I think code following docstrings is pretty standard
Yup, that's me. Once we've discussed it a bit and have a solid idea of what we want to implement I'm going to give it a go
Please add any comments you have to sir-lancebot#594 😄
ummm, lance bot? hello?
sir-lancebot#594
bot#1
He's taking lunch it seems
hmmm, is the tic tac toe thing in #sir-lancebot-playground blocking? 🤔
I don't think so yeah it is
Nah, it looks like ttt has some issues
not ttt, i think the quiz command
@dusky shore help command aint working?
#bot-commands message
bot#1
ok, it is ttt ig
Yea, looks like while a ttt game is in prog other commands are held in a queue
they may possibly time out afterwards too
I don't have time to investigate right now, anyone feel like raising a bug issue? 😄
lemme start tic tac toe once and then try
yes it is
hmm, maybe due to the reactions.
It looks like when multiple games a requested, they're put into a queue
I'd suggest seeing if you can reproduce the issue with just 1 game running, and none in the queue
probably easier on your own server
@surreal venture left a comment on the stackoverflow feature issue
Hey Xith, do you have a few minutes for this now?
Like, right now?
We'll have to do it another time, it's 6am and I'm embedded in bed
Sure thing
I’m free later today as well
Either way, enjoy your embedded-in-bed-ness
!otn a embedded-in-bed-ness
:ok_hand: Added embedded-in-bed-ness to the names list.
This is the context I found following the rabbit hole of replies #dev-contrib message
Okay I see
That’s an excellent point, we should totally discuss that
Not sure if I will be available today, but hey
I’ll try
Awesome! It’s a bit difficult to match all time zones, but luckily baguettes and IKEA are the same
@eternal owl commented on so pr
Otherwise, I should be free during most of this week for short meetings
I shall be free during the weekend too
Haha
You probably have a conflict with your local files, and whatever you’re trying to merge
ok
WHY DO I GET THIS WHEN TRYING TO COMMIT MY CHANGES?
bot/exts/evergreen/pythonfacts.py:15:60: ANN201 Missing return type annotation for public function
Because you're missing a return type annotation for public function
eg a function should say what it returns
def get_a_number() -> int:
OK
Specifically, the function in pythonfacts.py on line 15 needs one
what would it be for mine?
What does it return?
it sends an embed
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.
@commands.command(name='pythonfact', aliases=['pyfact'])
async def get_python_fact(self, ctx: commands.Context):
"""Gives a Random fun fact about Python."""
with open('bot/resources/evergreen/python_facts.txt') as file:
await ctx.send(embed=discord.Embed(title='Python Facts', description=f'**{random.choice(list(file))}**'))```
Is that all of it?
yes
Ok cool, so in python if a function doesn't have a return statement anywhere, it returns None by default when it gets to the end of the function
so add -> None: to the function signature
okie
I.E async def get_python_fact(self, ctx: commands.Context) -> None:
ok
These type annotations make it much easier for people reading the code to see what each function does.
So just by looking at that one line, you can see all of the parameters it takes, with their types and what the function returns
So that paired with the doc string on the line below should explain to anyone reading your code what that function does at a high level without the need to read every line in the function
ok
@clever wraith reviewed!
ok
@clever wraith no frequent pushes. read the contributing guide.
ok
eh, i swear i pressed the start review
Thanks
I can't really work rn
im travelling
oki
what is a user token?
In the context of #1421 it's the token your client uses to authorize with discord
If you're familiar with frontend logins at all, they are a common way to keep your user authorized, so they don't have to reauthorize for every request
https://github.com/python-discord/bot/issues/1421 is now critical.
If you have any suggestions, please speak up.
I'll add some to the comments. I also have time to work on this tonight if desired?
I can also work on it if you prefer, but I am not free until after tomorrow. So feel free.
@sharp timber the 2 underscore thing isn't true necessarily
At least it wasn't for my token
Hm, ok
yes, same here
Yeah, looks like mine doesn't have any rn
It detects normal format user tokens
Wait, how could one even obtain such token for a non-bot user?
From your discord client dev tools, token grabber, etc
By less than recommended methods
Basically there's zero good reason to have one these days
So the console stores both token types?
The console stores everything discord needs to run, which includes a user token. But user tokens have two formats, one for users without MFA, shared with bots, and a different one for users with MFA enabled
Okay, understood
I adjusted our bot token detector a few months ago to detect whether a normal formatted token is a user token or not, but I didn't want to scope creep and wasn't sure the limits on mfa tokens so I didn't add it. It also was prior to our change to the !user command to support users outside the guild, so it doesn't detect bot/nonnbot for out of guild users
So turning on and off 2fa resets token. Good to know. I didn't think it was changeable for user accounts.
It resets with your password as well, and presumably yet something else because I end up getting kicked from my logins sometimes for no reason
We can extract a user ID from a X.Y.X token straightforwardly enough, but there doesn't seem to be hidden lore on the mfa. format (not that I'd expect it), and it could be a truly random token as well, which would make that not really possible
We decode the other tokens for moderation purposes, but the removal can be done for all tokens anyways, even if we can't necessarily gauge moderation problems
Hi all. So I was wondering why ns_jail was used on snekbox. A similar api I use uses docker instead of ns_jail. The major difference is probably that this system runs multiple languages on Wine. So far, no one has broken out of the container to my knowledge.
Disclaimer, I'm not the dev of it but am working on v2 as my learner project. Yes, not the best idea. Yes, I'm actually doing other projects to learn stuff along the way.
Anyways, using docker, it seems that it would work well for the same purpose that ns_jail does. So why use ns_jail over docker or vice versa? Since snekbox does use docker, why does it also use ns_jail?
(@Mark#3118 because scaleios told me to ask you)
Yep that mention worked @tawdry vapor
Do please ping if/when reply, I have a hard time finding this channel 😓
Docker isn't intended to be a sandbox, first of all
I have a few questions about this but after this
Though it can be secured to some extent. It does used similar technology of the kernel as nsjail.
It does have wine on the inside as well. I know this isn't for security reasons but this should have an impact.
We also deploy everything with k8s, so the web server for the API runs in Docker too. To substitute nsjail for Docker and avoid imposing limits on the web server itself, we'd need a Docker-in-Docker solution or to spawn a new container for each code evaluation request.
I don't even know if k8s supports Docker-in-Docker, but it's generally not recommended anyway.
What is k8s?
Kubernetes
which is...?
A way to orchestrate containers. I don't think I am the best person to explain it. You should look that up later.
It's not really important to understand what it is for the purpose of this discussion. It's just the way we do deployment.
Ok
So with ns_jail, you could run multiple concurrent scripts without spinning up new containers?
Well, not directly. But it is just a process, so multiple processes could be used. That's more lightweight than a container.
However the disadvantage is that it can't interact with the file system
If you were making scripts that did that.
It can if you want it to
You can choose what gets mounted and whether its read only or read-write
But it would interact with the actual file system, not a cloned file system like docker.
You can set up your own chroot if you want
If you need an entire typical linux install then I suppose it's not really the right tool anymore
Which would then be docker
Maybe
Or something else entirely
But it's not what we need so we use nsjail
If you don't need an entire system you can use ns_jail
Can other languages be ran in ns_jail?
O
It's just for processes.
You run the process inside ns_jail
Yes
So it and docker aren't really comparable, kinda
One is nearly a clone of the filesystem and desktop and the other is a single process
Which is extremely different.
Actually, is this feature something we could implement as a filter_token filter @tawdry vapor ?
If it's just going to be a regex without any extra heuristics, then yes
That's what it will be, afaict
It will have false positives but since it starts with mfa I think it won't be as bad as the other token format
Thanks for the help, Mark 👍
They're similar since they use the same underlying technology, but they're intended for different purposes
It's just namespaces and cgroups fundamentally, and you could technically configure nsjail in a similar manner - it's just not nearly as convenient
So you log which tokens we send, and if they aren't mfa, decipher the ID of the user who they're for?
yes
Which means you could use both. Docker for scripts that need the filesystem, and ns_jail one's that dont
This is for a different thing, so it does make sense to include filesystem for some things, as it isn't for python.
Although I can't help but wonder if there's a different tool for actually running code that needs to use a clone of the filesystem.
We don't log by default, we only log any tokens we match, and only the ID + timestamp
Wdym match?
If we can extract a token from the message, we log the above properties
We don't log MFA though
because we don't search for it
At least right now
well, time to test the regex with a already defunct token
The module already has unit tests that do that
That's not
oh
One sec
This is the matching regex
([\w\-=]+)\.([\w\-=]+)\.([\w\-=]+)
It matches tokens in the format of ---.---.---
You can try it with a bot token for example
ah
https://github.com/python-discord/bot/blob/master/bot/exts/filters/token_remover.py
Here is the code for the removal
It's a bit stricter, because it does check to make sure the first chunk is an encoded ID, the second is a valid timestamp, and the last not a dummy value (Eg: xxxxxx)
If only the webhook checker was that sophisticated 😔
lol
@fallen patrol mind sending this: mfa.asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf here?
that checker failed.
Thanks, works
hm?
that checker only looks for the /webhook/ part of the URL iirc
Which makes it very hard to demonstrate that URL
/webhook/717983911824588862/386599446571384843_386599446571384843_386599446571384843
admin immune? here, I can dm you a token
yes?
@gritty wind, looks like you posted a Discord webhook URL. Therefore, your message has been removed. Your webhook may have been compromised so please re-create the webhook immediately. If you believe this was mistake, please let us know.
wow okay
#bot-commands
I'm trying to send the actual url itself haha
discord.c0m/api/webhooks/1/a
this would trip it off
without the 0 ofc
apparently it doesn't check client secrets
…what if its related to the secret when 2fa is set up?
that'd be a really, really bad decision and I doubt that's the case
i got some free time on tomorrow most probably, so would be great if someone can review connect4 and the ttt fix.
Can I trouble someone for feedback on sir-lancebot#594?
Done!
I think so, but that’s the point 
yea, that was my guess just wanted to double check before I raise a draft PR and start hammering the runner 😛
Github actions isn't limited for open source, so hammer it as much as you want 
😄
Raised a draft Pr for now, going to carry on over the weekend 😄
If anyone want to take a look and make sure my to do list isn't missing anything, it's sir-lancebot#597
sir-lancebot#595 needs the labels and a review should be quite short, not a big change, a small one
@short snow Was the visual change discussed?
The visual change was just to add a embed, akarys told it somewhere in this chat
Not about that, but it was said somewhere in this chat too, i think iceman or someone, not sure (to change the emojis)
Thanks will mention your changes.
also just a reminder u and ak have pending reviews on c4 pr
Were there changes on that one?
@gritty wind what emoji suggestion do u have for the ttt?
On what cloud platform are the bots and the site running?
Right I think they're one of the sponsors? Do they give you some referral code or something I could use to get some free credits?
Yup
It should be automatically added when you visit the website through the URL at the bottom of our site
3bc18ce876ff43ea31f201b91e8e119c9753f085
thanks :D
what is DEFCON settings?
Defcon is part of the suite that we use for raids and other attacks
Not being able to get the settings just means it had to fall back to defaults
what settings does it need? also isn't all that specified in the config.yml?
Config is good for constants
The defcon is set dynamically
The settings are things like day, and verification level
It's just a command that connects to the API and database
like it isn't able to establish a connection between the two?
Yeah if it can't connect to the API for whatever reason
then, shouldn't the status code be logged? It would make a quiet more clear i think
The new defcon implementation will have the traceback in it
oh ok
oh hell if I know lol
I mind the old ones less than the red ones on white backgrounds
hey can you explain how @stable mountain scrapping docs.python
!src d
Lookup documentation for Python symbols.
iirc its a term used by intersphinx to describe what is held about a specific package
hmm how can i get that inpvertry @vale ibex
The interpshinx inventory files provide a mapping of symbol names you use in the get command to urls where they are located, the bot then fetches the url and parses the information from there
that means i have to give time to make thi list
the inventories are usually located at the docs url/objects.inv, for example http://docs.python.org/3/objects.inv
@brazen charm this is in chiness?
‣灓楨确椠癮湥潴祲瘠牥楳湯㈠⌊倠潲敪瑣›祐桴湯⌊嘠牥楳湯›⸳ਹ‣桔敲慭湩敤景琠楨楦敬椠潣灭敲獳摥甠楳杮稠楬砊듚嶽阸緯㹿곅鹵曛늦穻鵪舻䲀ࢦ욈비跴낗렅壂쭎ࢎ폪稿솱撀潫휹쪪►孋喓笸볙Ɡ頼隯ᇿ뿽刷쟼ッﴑ翉톾瓢톇㲡ᆭᨷ翽ᄋﳳ槣ᓺ긾욞旳縨정䒑㬅䝃摺짅겊託재鳟瓫妲➭엣ᰢ㾯㲿靍ₛ최셦獴ဧ㒑슽㉠꾟羶꣒ꄔ友콎ꮁ褬䱘쉯ꝧ隀ꍀŗꫬ⨬阓↝䭎〻ᨪꨇ蟘퓠騔笔镍ᢧ鱤翅폐⬻뽌㥤庉ㅡ╾螰쎪펣闸䦤䩌荚ꏢ䣪튳聑늟觨ޖ抦ꪼ똏폽谎㇈䤤ݙ燩ୋ鬠近쬒设ᶘ蟙妗常ࣾ曥茶騵땭퇛Ợ࣓砰庸Ꮉ咘囍웱拋ਁ礌ᦀǦ쯦劉칩㧑킨굝̟硨㏈퓅㵦鱿䈾菃ꑒﺇ麶왯긏샏橘ട䍛姸軁阋ᷭᔑ班⋁溷ᖨ둾藝婻蓪휈䅸䩓䔸葈⒳❍⬬經⫅鐞ቅ捓毗욋⠱爦ዸဵ䳾柋撖肆蹳玎뎭䠙줅呟ᖌ則䌍퉔共鎐擙諚覯蕂䃣융查董뒽䒪皖ߓᯛᎩ땩陱х쪇㶲㓧휎☹➌坙⩐ꞟ턛ᆱ詻힂掔䗣砧ꬣꚤ꫶ﮡ낫목傝❮ꬺᦹ곫ᷞ碈䞪芚黀꺾ײַ鮺ᖟ鑃玶㕫緒풭脈녣괴낛妓砣꣓奸兔ᕙ剛娞㲳堷絏莜愓衑䋞들钍났䭰軺ಠ朹젧ꔶ꿝䱢칈㔫뼏苊罈౬폛㯜䟑㎪ᖗᢠ嶅ⴥ㴎薱⣅ꯐ셈鋴⤜а턻ㇹէ㧼峧夭㦀鵋擬簂ѱ앞‑⎋ᑀ䴇Ỹ믑⑆瑨햟ꌪ桳ɚ픊㨜ꔀ$쒥秐䈙颲滺唙毈硳賙ꂬ㋙空쯌ఓꎑ㏖ꯣ锬身㊛ᣖਲ䠟쫴쉓欏Ꞛꈤꋓ蕠긵Ⓢ䣱埥ꐈ贜恆쳑᧷〫ベꋏ쪂恵抒꼞掅ﶒ왇㏞娅䐌뤫쪵ϕ㢃⯢髍Ꮾɞ눟얉吧컘Ე铗䭀荄諟蒤䦃≔朗槽㤱抐睍잸泂텻⼀⒯꒘颴撥板᭞ﯟ⍝梣鄨畆舨浳ࢬ槔꙰禎᭡푝䚗䱂➡꿵쳦䃭蘻㺧滊睖檡ዑ媛㼉䪲頸ᾝ绉㗌蘍荅텋熰㏼쾆쥶뛾鏤⤬䣃敽㸊⬊썎峃䖾갴选「꜆䒶䭄䐿켻먋㹋ᐼ銪注ࣅ掠ୗ㒿礎✙섌ꖫ瞂摒葺沑塁愺詾硸월各﵅㶐葕蹽뺘⌡ꮏṣ烧ꯔ饔ꤝ뉀씸钴隆쟹庐᭬鄏䁦䨄檨⧃ᆍ㬨눢儭ﴓ䲰灐珆ꈽ䇁繡↦䤙뫃㣘䡆䈮ẉ粓勎扒㫲箥鴒謤㯙㛇ꏐˈ鬦⤷輑騮岶ᒔ䡪䑆臼儨讖鐪䗼ꘙ䷴貭㔃ピⴆ䐽ㆆ囝౻ṝퟴ뽍좏態霉뉩ᎍd爋㌌概抿≼롢輪㲩䲰鹦㗨蔑돶お굵㊨⣱ൺⰜ樻蹜婉ᦷ쬸蹝⊪镌ḡ讛帉㒘댋줵칃⊪௱虞鉩ṡ療ṵ摣⏍잇哵魷塰퍚骢Ԧ߲쁎聣撮ꔇ儊ᅴ⹔鼽⋠艢方儜뉰鍟㒝ﻹᜮ䈗ᡩ⡇ᬃ㡳앉擐彼ϕ엎聺伿傿켪鞪毃◈ఝ퀗걲䋇ꨌ硞ퟶເ帊런꘤恚⨒뽒먕杙ὑ릋㜺垰ꆚፅഗ勣㝂闸퀔㏄劵젞딁쾾䟨铗ꈨ㱤㣳난蓼✆兕츍굏➯쥻ҏ┗䚲謀悥햶苗蟝ⷭ⌿絤挒捨濺㹃⍫헶祜䀾㢻菫샴响쳭당奺竉䰕⬧䏛復馲⣺폠崰왬ﱱ栒虥႟䍞뚭㾋姆䦼富怙資ㆥ䡒싾牋ᇌ嵼䠤槲䅼㾲掦ꍌ쳘벟픚呫ꍤ⬺폠︠㟹棋닸蕴ቶᗓ뮢珁䜽顠䵚鋓ᾀ˰齁酐ᇪឃ예礣䁚⤼
see
As the header says, the file is compressed with zlib and is binary
@brazen charm ok now i understand what is inovertry
can you help me how @stable mountain search in that inovertry
?
Yes i guess its chinesse
#dev-log message
No, The api exposes all users names and stuff even if they aren't in the server.
That comment is more on the fact that if you (the user) don't have it in your cache, it will just show up as the id
I can probably find an example
@cosmic moat if you have time, do you think you can finish up the YouTube command?
Yep! I'll be working on that later tonight I assume
Thanks!
:D
grrr
it seems like @commands.max_concurrency() doesn't work with command groups as you'd expect
the command listed under the group decorator has max concurrency, but commands in the group don't
and if you put the decorator on all the commands, they don't share a bucket
How about implementing a custom dispatcher
Or didn't Mark have another suggestion as well
yea, I was looking into implementing a custom bucket, but they won't be shared across the root aliases
might give a custom dispatcher a go, would be simpler than making buckets+aliases work
I've done all the easy stuff at least now, they're all in 1 cog, sharing common code and running in executors
Hey Guys, I am currently trying to get myself involved into the discord bot. Now I took over the task to remove the trivia question with the Nile which itself is not that hard. Now I was trying to get the bot (or after that the original version) running on my testserver to see, if my changes work or if I messed something up.The problem is that I cant get the bot running. I already tried creating several venvs with pycharm and pipenv directly but whatever I do "docker-compose up" and "pipenv run start" just cause some errors I cant really solve 😩
Can you share some of the errors 😄
@gritty wind Sure, docker.errors.DockerException: Error while fetching server API version: (2, 'CreateFile', 'Das System kann die angegebene Datei nicht finden.')
[5148] Failed to execute script docker-compose; socket.gaierror: [Errno 11001] getaddrinfo failed
Ah, okay I think I know what this is
Could you post the rest of the error to make sure though
!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.
So the error you get from starting with pipenv is pretty common
It is due to not having Redis running
You can easily get around this by setting USE_FAKEREDIS to true in your env file
I'm trying to figure out the docker problem though
You mean the .env file I created for the bot with all the discord IDs ?
Yeah
@twilit pumice Your docker issue seems to be that docker isn't running why you try to run docker-compose
do you have the little whale icon on your task bar?
As Scaleios said, either you can set USE_FAKEREDIS is your env file and use pipenv or, if you want to use docker, you'll need to have docker running before you run docker-compose up
I managed to run 'pipenv run start' and got another cmd which says '(Bot)' at the beginning. What that it or how do I know it worked ?
Could you show the output?
(Bot) E:\Python\Projekte\Bot>
Alright, so that looks like the pipenv shell has started
have you done pipenv sync --dev?
Yeah all dependencies are up to date
Could you paste the full output from when you run pipenv run start?
including the command line
what about pipenv run python -m bot
C:\Users\Robin.virtualenvs\Bot-P_HbSUeV\Scripts\python.exe: No module named bot
(Bot) E:\Python\Projekte\Bot>
what is in your Bot folder?
ok, i missed that the git clone created another sub folder ^^
ahh that will make sense
yea, now that you're in the right folder, you will need to do pipenv sync --dev again
since pipenv creates a separate env for each folder its ran in
ok, done
is your .env file in the right folder?
yes
https://paste.pythondiscord.com/abapawevol.yaml something about an improper token
yea, seems like your bot token in your .env file isn't right
It seemed to have worked now because I got a message from my bot 👍
Cool
Make sure to run pipenv run precommit to install the precommit hook
this will make sure your code passes linting before you can pushcommit it 😄
Am i right that precommit and flake8 check the indentation and stuff of my code ?
yup
but does it also deal/change .json files ?
precommit is a script that run a bunch of linters, one of which is flake8
it'll deal with mixed line endings and other things
so yes, some linters will affect .json files
ok, thank you so far. I'll get back in touch if further help is needed. Have a nice day 🙂
No problem! Good luck 😄
What's the matter
if i search list docs on @stable mountain how he select which one to show from tree list
!docs list
class list([iterable])```
Lists may be constructed in several ways:
• Using a pair of square brackets to denote the empty list: `[]`
• Using square brackets, separating items with commas: `[a]`, `[a, b, c]`
• Using a list comprehension: `[x for x in iterable]`
• Using the type constructor: `list()` or `list(iterable)`
The constructor builds a list whose items are the same and in the same order as *iterable*’s items. *iterable* may be either a sequence, a container that supports iteration, or an iterator object. If *iterable* is already a list, a copy is made and returned, similar to `iterable[:]`. For example, `list('abc')` returns `['a', 'b', 'c']` and `list( (1, 2, 3) )` returns `[1, 2, 3]`. If no argument is given, the constructor creates a new empty list, `[]`.
Many other operations also produce lists, including the [`sorted()`](functions.html#sorted "sorted") built-in.... [read more](https://docs.python.org/3/library/stdtypes.html#list)
how he know that he have to show this one but meanwhile other two list are also in python docs
there are total 3
whose keyword is list
I think it just matches the first symbol with that keyword
yeah but all 3 got same keyword
Yes, it just finds the first one
oh
This is the relevant line
url = self.inventories.get(symbol)
hmm great let me try too
@gritty wind ```py
a = {"name" : "cool", "name" : "fool"}
print(a.get("name"))
You are not allowed to use that command here. Please use the #bot-commands channel instead.
Dicts don't have duplicates
a = {1 : {"name" : "cool"}, 2 : {"name" : "fool"}}
print(a.get("name"))
@sleek steppe ^^^
this give None
Update, it doesn't actually have repeats
And yeah, that of course gives None, it searches the top level keys
The inventories is a dict
It's None because there's no key called "name"
yeah when i convert inv to json it in that form
As for this, since dicts can't have duplicate keys the second one replaces the first one
So the get returns the second one
wait how to convert object.inv to dict as Isee bot is using from sphinx.ext import intersphinx
https://paste.pythondiscord.com/raw/ojasixaquc
These are all the entries with list in the python inventory
Only one them is exactly list
Right, but none of them are specifically list
Since list exactly matches one entry in there, that's the result
then how bot find correct one
Because there is exactly one item in there called list
can you send that here
It's right after xml.etree.ElementTree.tostringlist
I got that from the debugger running on my bot
But you should be able to parse sphinx output
I'm going through the code to find out how
i used this
and i convert it to plane and json i got these
xml.etree.ElementTree.tostring py:function 1 library/xml.etree.elementtree.html#$ -
xml.etree.ElementTree.tostringlist py:function 1 library/xml.etree.elementtree.html#$ -
xml.etree.ElementTree.xml.etree.ElementInclude.default_loader py:function 1 library/xml.etree.elementtree.html#$ -
xml.etree.ElementTree.xml.etree.ElementInclude.include py:function 1 library/xml.etree.elementtree.html#$ -
xml.parsers.expat py:module 0 library/pyexpat.html#module-$ -
this is when i convert plane
this is just a part ot it
{
"0": {
"name": "CO_FUTURE_DIVISION",
"domain": "c",
"role": "var",
"priority": "1",
"uri": "c-api/veryhigh.html#c.$",
"dispname": "-"
},
"1": {
"name": "PYMEM_DOMAIN_MEM",
"domain": "c",
"role": "macro",
"priority": "1",
"uri": "c-api/memory.html#c.$",
"dispname": "-"
},
"2": {
"name": "PYMEM_DOMAIN_OBJ",
"domain": "c",
"role": "macro",
"priority": "1",
"uri": "c-api/memory.html#c.$",
"dispname": "-"
},
"3": {
this when i convert to json
We store a map of the name to the URL
bot use json or plane?
CO_FUTURE_DIVISION c:var 1 c-api/veryhigh.html#c.$ - this to api/veryhigh.html#CO_FUTURE_DIVIDION
I'm not sure, that's just handled by the library
!remind 12h review 595 560
Your reminder will arrive in 12 hours!
Feel free to ask questions here or there, but please don't advertise your channel
Can anyone explain to me this
SPHINX_MOCK_APP = SimpleNamespace(
config=SimpleNamespace(
intersphinx_timeout=3,
tls_verify=True,
user_agent="python3:python-discord/bot:1.0.0"
)
)
It's pretty much an object that allows you to access properties with dot access
That snippet for example allows you to do something like SPHINX_MOCK_APP.config.user_agent
no i mean i try to found those tls_verify and other but they are not on sphinx
They are read and set dynamically from a config file
Sphinx is not really meant for what we use it for in the docs command, it is meant to be an app that integrates with your code
That being said, I'm pretty sure you can still see the actual config class if you dig into the sphinx code
Yes
nice
hey @gritty wind ```py
if symbol in self.inventories:
group_name = group.split(":")[1]
symbol_base_url = self.inventories[symbol].split("/", 3)[2]
if (
group_name in NO_OVERRIDE_GROUPS
or any(package in symbol_base_url for package in NO_OVERRIDE_PACKAGES)
):
symbol = f"{group_name}.{symbol}"
# If renamed `symbol` already exists, add library name in front to differentiate between them.
if symbol in self.renamed_symbols:
# Split `package_name` because of packages like Pillow that have spaces in them.
symbol = f"{package_name.split()[0]}.{symbol}"
self.inventories[symbol] = absolute_doc_url
self.renamed_symbols.add(symbol)
continue
this is answer of my previous question
how @stable mountain find which one to show from those three lists
For any given inventory, there is exactly one resource with the given symbol
That part of the code just checks if you passed an inventory, for example discord.py, and if so, it searches d.py symbols instead of python
now i understand i am just tell you
Ah right, thanks
the correct answer of my question
is this so if anyone else ask show him this
:D
Now i need help with ther thing
!df
how @stable mountain do this
!df
This is part of the error handler
Unable to convert 'did you mean' to valid command, tag, or Cog.
Well, it's mostly just us doing a fuzzy search on the functions of the bot
If one matches, it is added to the list
!src error
Unable to convert 'error' to valid command, tag, or Cog.
oh
Hello peeps, I've started working on a troubleshooting guide for the bot projects. I've collected some of the most common issues, and tried to list their most common fixes.
I'm looking for feedback on the errors and fixes I have right now, and any errors you believe should be added. The formatting does not matter right now, as it will all be migrated elsewhere once it's ready.
https://gist.github.com/HassanAbouelela/878b6ffcb82c15ae410ee0c063c3f6f4
is it for the bot specific?
Your reminder will arrive in 4 hours!
Is a tag on the difference between instances and classes planned?
https://github.com/python-discord/meta/discussions/86 shows all tag suggestions we have had thus far
That's a rather short thread
well it also links to old thread
its all community suggestions not our plans
anyone is free to implement tags
and this is a long thread haha
I think I'll suggest one on this then
how to make my code like this repo
i mean manages like this one
my code looks like this spaghetti
@vocal wolf @green oriole do you have time now? Or maybe later today?
I'm about to go to bed
It will have to be later for me too
Alright
Some time between 1pm and 5pm UTC is fine for me, not sure for @vocal wolf
That’s fine with me too
I'm UTC - 8, anytime after 11am (my time) is fine for me
These next few days are going to be a bit hard for me to find time since I have midterm stuff
I see
I should be able to find some time though
So 5pm should be fine, right? Disclamer, I probably messed up the calculation
cough time and date dot com
Is it 10am UTC right now?
Yes
10:24 am UTC
hmmmmmmmmmmmm
I think 5 pm UTC would be 9 am for you Xith
I'd really like to put time into this meeting, but I won't be able to until after monday
by time I mean like many hours
Maybe we could start off with a few minutes to set a general direction soon, and see if we get more time later on
If we start at the 5pm I will be able to stay for one hour
Next week should be fine for me too
By next week do you mean the weekday or weekend?
Would you mind if we pushed to tuesday?
Works for me
If we did the meeting at 9pm my time I'd be running on very little sleep from tonight and nights before
Is this the direction meeting for the bots?
that's the motivation
iirc yes and also #779073065560703007
If it is, I’d like to drop by for a while, but don’t schedule around me
I have no idea what this is about tbh
@obsidian patio do you object?
Mainly because I don’t have a schedule
Because you have one now? 👀
exactly
I mean you do show up at predictable times
is dev-bounty board the thing i had suggested in meta, or related it. since the name sounds like that
Are regular users able to see the bounty board?
Nope
Just staff
ah
Well +-
Alright
Basically, it is a board with our top priority issue, which kinda went dead right now
meeting pushed to tuesday to avoid sleep deprivation (don't want it to happen again)
Sure thing, good luck with your finals
One final ping before I go off to bed
@green oriole @gritty wind @obsidian patio Meeting is now on Tuesday. Enjoy your weekend.
Sweet
@short snow
Here's your reminder: https://gist.github.com/HassanAbouelela/878b6ffcb82c15ae410ee0c063c3f6f4.
[Jump back to when you created the reminder](#dev-contrib message)
It’s spring break, so that’ll work perfectly fine for me
!remind 4H do it 
Your reminder will arrive in 4 hours!
- and contribs
sick
Is scal joining too?
Aah, I see
Yeah, true. Would be fun
@vocal wolf @green oriole @gritty wind Tuesday (23 feb) at 17:00 (5 pm) UTC
Does this work for you?
yes
Awesome, want me to send you an invite to a calendar event?
Perfect
I think you can modify the event. Feel free to add any details or change the event name to something more fitting
can I come
Of course! Want me to invite you to the event?
Done
Cheers!
Sounds good, can you send me an invite too please?
Sure thing—got an email?
Thanks!
lets spam someone's mails
What are you meeting for? 🤔
Dev bounty board discussion as per the discussion (above).
Scaleios the gist looks good, maybe i can try see if i catch some other issues while running them. Also in the docker command, you say just to run docker, maybe you can mention how to run docker. @gritty wind
!remind delete 1539,
Converting to "int" failed for parameter "id_".
Are there any examples of custom dispatchers in lancebot/bot I could use as reference?
I'm trying to add concurrency to a group of commands, so that they share a limit & queue
You can look at discord.py's cooldown decorator or the lock decorator in the bot
Fundamentally you need some kind of global mapping to make the decorator work across separate commands
I'll give that a look, thanks
@eternal owl
Here's your reminder: review 595 560.
[Jump back to when you created the reminder](#dev-contrib message)
chop chop
Hello folks, if you are looking for a good first issue to get started with our Django website, here is one: site#445
It does include a patch with hopefully all the needed changes already
Thanks for giving it a look, by docker, do you mean this one?
Hey Guys, does anyone of you use PyCharm and the implemented git functions for cloning, committing and pushing or in general for contributing ?
I do, what's up
i use pycharm but for git stuff i use Github desktop... don't really like how Pycharm does things
I finally managed to create a push request after several problems with the virtual environment used after cloning the repository and I also had difficulties using git and I just wanted to see if anybody had any tips. It was quiet annoying to switch between ide and different cmd for git ^^
I'm not sure what you mean by that, was the pre-commit failing?
I made sure i would lint before committing. For example after cloning the repository into my projects folder it started to use venv of another project and i wasn't able to change it. Another issue was that I then used the cmd of git to create a new branch and committed the changed file in there. I then tried to use pycharm for the push request but it did not even detect the other branch 😩
If you have the venv running already, you can type deactivate to exit it. For being unable to find the git commit, I guess was it in the same project? If it was, it should just be able to read it directly
I'll try it in my next contribution. Thanks for your time
Feel free to drop a message here if it doesn't work
Are non staff members not able to commit directly to our repositories?
(namely sir lancebot?)
You have to fork and then make a PR from that fork (which is still my preferred method)
Though they can review
ah
If I run the command git branch -va, the trivia branch on this repository isn't listed, even though I added it as a remote named arez https://github.com/Arez1337/sir-lancebot/tree/trivia
yes
Hmm let me think
On windows and mac you'd just start up hub
what do you do on linux
systemctl?
you can use the github cli, that's what i do gh pr checkout <pr number> and gh pr list to list all the prs
and then you can commit i think
not sure
ohh, never mind it was for non staff
You don’t need to ping specific users for that, people will see and give their input.
And i personally don’t like that feature.
A lot of core devs watch this channel
I don't think having the bot automatically reacting to messages starting with I'm is a good idea
It will be way too spammy
doesn't sound like a feature that fits this server
That sort of "spammy" feature is not something we usually pursue
It will still be spam in those channels
Other examples include a counting channel
I don't understand what you mean? It's a feature that achieves nothing but spam. A game, utility feature, or seasonal cog are the sort of things we add to the bots, and I don't see how the bot echoing the message back can be a useful feature
It sounds like a fun project, but doesn't really fit a server with 150k members
Devops are on it, get back to you in a few
Python is returned
Oh ok.
You can’t really see the bomb in here, maybe put some other emoji, or implement s bomb emoji on our own
💣
I imagine this is an artefact of downsizing the pfp to 1024x1024
Bot down, check #sir-lancebot-playground
i dunno copying message link is not working on ipad
@short snow seems to be working on some commands at least #sir-lancebot-playground message
Are there any errors coming from lancebot?
I'm not able to reproduce the issues coming from the help command locally
On the guide to set up the bot https://pythondiscord.com/pages/contributing/bot/, Configure the bot step 6 says
Set urls.site_api to whatever value you assigned to urls.site with api prefixed to it, for example if you set urls.site to web:8000 then set urls.site_api to api.web:8000.
in config-default.yml it already says site_api: &API !JOIN ["api.", *DOMAIN], so am I right in thinking this step is unnecessary and could be removed?
I think so
Never mind, I was using the config-default of a very out of date fork smh lol
Nah now it's site_api: &API "pydis-api.default.svc.cluster.local"
Just slow
Maybe there are more blocking commands out there
I've got this to put pfp modifiying cogs into executors https://github.com/python-discord/sir-lancebot/tree/Enforce-image-processing-concurrency
I haven't PR'd yet as I was going to implement the concurrency limit too
we could PR this early though?
i guess https://github.com/python-discord/sir-lancebot/pull/597 is easier to see, rather than the branch
I'm gonna head off for the night now anyway, lmk if you want me to clean it up and PR early
I can just make another branch for the concurrency stuff
👍
Who is the point of contact if I am able to implement the system we discussed in the staff meeting today? It's something I'd rather spend time doing than the other things I need to do (school, job hunt) but I don't remember if there were any other takers during the meeting.
Which idea?
rotating topic discussion channel
Right, that would be Kat
@thorny obsidian has someone else indicated that they want to do this? ^ (the infrastructure for the rotating topic channel)
nope, not yet!
do you have the spec that you want written down anywhere?
Not yet, I was just about to start. Do you have any ideas for it yet?
I would think it would be a matter of having a cog with a command to change the channel description specifically for that channel.
I'm not sure what other functionality we would want
is the bot going to tell people what the topic is periodically?
I might want to wait on the functionality and trial it manually for a week or two to see what we'd for sure like
But in terms of a future cog for it, maybe a !weekly topic command to bring up the context for the topic. Some sort of system to load up and change the order of topics? Ability to change the channel description and also pin a message
we'd also want the existing .topic command to have special behavior for that channel, namely that it should always state that week's topic and never pick from the pool.
which bot is the new cog going into? i'd imagine it'd go into @stable mountain, so cross-bot communication probably wouldn't go so well there
I think it should go in Python. It's an "official" thing.
I think the current direction for lancebot is that it's a non-staff-driven open source project that we supply a platform for
Do you think you'd be able to make it to the meeting?
so if we create a new "feature" for the server (the discussion channel), that's part of the server itself, in a way. so it should go in Python
What time is the meeting?
5pm UTC atm
i think it makes more sense to have this in @stable mountain
I'm available at that time if I get a lot done tomorrow
new bounty board issue 
@trim cradle Mentioned the changes for fix/ttt
shit sorry
wrong ping
@gritty wind 😛
lol ok
is there any example of using linapaginator
like is it used somewhere
so i can get an idea of how to use it
On sir-lance or python?
sir-lance
pycharm navigate doesn't give any result except for the pagination file itself
You can use your IDE to find usages
Okay well
I guess we don't use it an lancebot
Maybe try with @stable mountain ?
Python's is still being ported
But hopefully it'll be the same interface
Anyways it is used in sir-lance
One sec
There's also an instance in ttt
so i have a list of dicts like this:
{
"title": "",
"snippet": "",
"pageid": ""
}
Where field title is title with url of pageid and snippet is the description
EDIT: got it
ok
sir-lancebot#560 requires another approve 🙃
!remind 6h review sir-lancebot#560
Your reminder will arrive in 6 hours!
looks pretty well done to me
I will open a pr for it
done 🎉
hmm, i forgot to add logging statements
what should i use for api problems?
which trace level
warning?
I'd say if its coming from wiki themselves, then info is fine, since we can't do anything about it, so no need to notify devops
But a core dev might have a different opinion
Alright, thanks
I'd say warning. Then we get notification about it in dev-core chat.
Yes
done 🎉
I don't think warning is of any use there
using warning there will probs allow people to spam sentry alerts at us
well actually probs not alerts but warning doesn't sound like good one
considering that most likely it will be hitting 404 which is below useful to warn about
those are api errors, people can't spam them to you, until one gets one and starts doing it again and again
well unless we are getting 429 I don't think the error code deserves any better than info
and I don't think we can even get 429 there
ahh right, lets just keep it info for all cases, how do i revert, i tried it few times, but it always messes up
actually interesting logging I've seen is using debug on anything that is not 429 and warning on 429 we could perhaps adapt such idea for interacting with most stuff that is not ours
uhhh i will do that.
am not sure if we do that already though
if we use info elsewhere we can stay with that
https://devconnected.com/how-to-undo-last-git-commit/#:~ perhaps this could help?
git reset HEAD~1 will undo the last commit
then you can do git rm ., make your changes to correct and git add .
ok joe, ty
@vale ibex
Here's your reminder: review sir-lancebot#560.
[Jump back to when you created the reminder](#dev-contrib message)
@short snow why do you want me to do cycle? wouldn't it be more random and better to use random
Is random what we want?
I think it would be better to cycle, as it means the same fact can't be repeated often, which would be possible with random
@gritty wind What were your thoughts about sir-lancebot#597 should I PR it early so we can get them in executors?
Take a look at bot/constants.py
ok
This is where we usually store things like this.
I’m fine with opening it up early if you’re not planning on making large changes to the files you already made
I imagine the group util would probably be indpendent
ok
The only thing that I was planning on doing on top of this was implementing a util to limit concurrency
@vale ibex how would I take the colors from constants.py
so we could make pfp modifying commands queue up
Something like from bot.constants import Colours
ah
then you can do Colours.blue
Alright, feel free to open it, but leave a disclaimer at the top
I could PR this and raise another issue for the concurrency util
Something along the lines of the TODO that you already have
👍
That could work too if the two PRs don’t depend on each other
They don't need to
In that case, feel free to get this one merged while you do another PR for the rest of the features
Alright, I've updated the comment and marked it ready for review
these are all the possible status codes
all except 500 and 200 seem to be of WARNING level
@patent pivot a wild PR has appeared bot#1429
415 412 404 201 are not something that'd need warning
needless to say outside of 200 and 500 wiki won't send us anything else
Hmm, so just info or debug is enough for all then
I think info will be fine for time being
looks like @dusky shore could use some logging rework
reviewed and the branding PR has been merged
sir-lancebot#600 is ready for review 🙃
Oh I thought the logging questions were for Python
Do we even do logging on sir-lance haha
well we should
there are multiple breaking points that we are unaware of due to lack of logging
logging generally is just good practice
But sir-lancebot doesn't have logging for the same reasons it doesn't have unittests
but it does have logging 
I think in general we should stop relying on sir-lancebot for fun features
But that's a discussion for later
then what would sir lance be for?
It's barely used anywhere
just check the logs lol
Beginners to OSS
we did have like 40 logs in past few hours so
¯_(ツ)_/¯
frankly logging is crucial in programming rather often and leaving it out so beginners don't know of it does not sound good
Equally we had 0 over a 2 hour timeframe yesterday during peak activity
Cheers mate
@celest charm when filtering characters, do we want feedback to include the illegal item passed? Or do we want to just say "Illegal character passed."
ctx??
when sanitizing input to a URL?
filtering stuff for the pypi command url
ye
currently I just have ```py
ILLEGAL_CHARACTERS = re.compile(r"[^a-zA-Z0-9-.]+")
...
if (character := re.match(ILLEGAL_CHARACTERS, package)) is not None:
embed.description = f"Illegal character passed into command: {character}."
await ctx.send(embed=embed)
return
Walrus used for now, can be yeeted if we think it's not needed.
I think we should have it, otherwise it can be confusing at times
ye
what is this for?
@gritty wind




