-
-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
not omitting bot token #61
Comments
This isn't a bug. Let's discuss why. I have a set of rules that I follow while designing and developing Jishaku. One of these unspoken design principles is the reason why this behavior isn't a bug. I'll write it out in plain English for reference later, but for now, I'm going to try and see if you can derive what the rule is from a set of examples regarding the design of the REPL components that back A REPL with a little moreJishaku's design motive is to be a Discord-based frontend for evaluating and executing code. Let's go over some features Jishaku adds, starting from "least obviously magic" to "most obviously magic" (a sort of increasing nonstandardness). I'll also include how it differs from what you'd expect with standard Python, for reference. Returned values are sent back to DiscordWhen you execute a block of code that contains a The value is interpreted and sent in whatever format is deemed most appropriate. For instance, This is the "most standard" behavior, because typically all eval or REPL command implementations have some variant of this kind of behavior. Some even have automatic What Would Python Do (WWPD)?Either:
Bare expressions at the end of the top-level scope are sent back to DiscordWhen you execute a block of code that includes a bare expression at the end that isn't in control flow (such as This follows the same display procedures as returning. It is sometimes referred to as an "implicit return" in old documentation, but this isn't always how it's implemented, as we will soon find out. What Would Python Do (WWPD)?
Yielded values are sent back to DiscordWhen you execute a block of code that includes This is similar to the "implicit return", except it doesn't halt execution. This allows data to be sent back easily during longer evals, or in situations where states may have to be read at different times (such as wanting to check the attribute of an object before and after a given function call). The message is even sent back to the evaluation context from the yield, allowing it to be inspected or edited. What Would Python Do (WWPD)?Depends on the exact context, but typically:
Yielding and returning values can be mixed.When you execute a block of code that includes both 'yield' and 'return', they both work and function as expected. While you may not see this as weird, this is actually nonstandard because it is usually not allowed for To deal with this, Jishaku automatically packs out yield x
return This allows returning of values to not require the cognitive overhead of checking whether it already contains a yield, as Jishaku makes the transformation for you. What Would Python Do (WWPD)?
Import expressionsWhen a name is suffixed with an exclamation mark ( The module name to be imported can even be a submodule: This is the most 'nonstandard' feature because it's effectively an in-Python extension of standard syntax. It allows what is usually a tedious procedure to write longform to be done quickly and effectively in-line, with nothing more than the acknowledgement of what needs to be imported. What Would Python Do (WWPD)?
So what's the rule?If you haven't yet figured out what the rule is, now's your chance to stop and reflect on the features I've highlighted above. I've formatted them very specifically, so try to pick out the pattern. Here's an image to act as a scroll buffer while you think. The answer, as you might expect, lies in the What Would Python Do (WWPD)? section. Do you notice how for each of these changes, the way Python traditionally reacts is either by doing nothing or raising an exception? Or, in terms more fitting to this context, no feature modifies existing behavior as to subvert the developer's expectations? This is the fiber that makes up one of the primary design philosophies that underpins Jishaku as an REPL. In plain English, it goes something like this:
Jishaku is a toolset designed to be used for legitimate, serious development and debugging. There may be legitimate times where a developer does, truly, wish to send their token to chat for whatever reason. The reason the However, outside of such cases, the intention is clear. In accordance with the above philosophy, when you write The solution for this problem is thus clear: if you don't want your token to be sent to chat, don't run code that sends your token to chat. The power of the interpreter is unwieldy. One who wields Jishaku holds the same power as whatever user it is running under (which in some cases, can even mean root access - depending on how the host is set up). Perhaps in the future I should have Jishaku warn you more aggressively about this during usage, but for now, I think referring to the sudo lecture is most appropriate:
|
Summary
invoking
jsk py _bot.http.token
covers the token, but invoking it asjsk py await _ctx.send(_bot.http.token)
does notReproduction steps
doing
jsk py await _ctx.send(_bot.http.token)
Expected results
Covering the token in both ways
Actual results
It didnt the cover in
jsk py await _ctx.send(_bot.http.token)
Checklist
System information
Jishaku v1.18.2, discord.py 1.3.2, Python 3.8.2 (default, Mar 10 2020, 03:00:36) [GCC 7.4.0] on linux
The text was updated successfully, but these errors were encountered: