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
objects.py at_say method update adds flexibility, maintains backward compatiblility. #1419
Conversation
Returns the "type" kwarg to the message output, allowing messages of different types, but having at_say default to "say" type, as before.
Defaults to using msg_self ("You say, ) format, but allows _not_ excluding the speaker from msg_location messages. Keeps the hard-coded defaults, including whisper, but whisper mode is engaged with a kwarg _or_ msg_type for flexibility/compatability.
|
This does break the unit test due to the whisper default format change.
Does anyone prefer one format over the other? |
msg_self is defaulted True only for whispering. If set True for any other type, then default say type is used.
For the default format to msg the caller of say, must now set bool.
Can be None, False, True, or a string with mappings.
at_say calls must include a msg_self, which can be None, False, True, or a string with mappings
|
@chainsol Thanks for the feedback.
Based on my own preferences and the above comment, I change the whisper format default and unit test accordingly. It's worth noting that If the docstring seems confusing, please comment regarding how it can be clarified -- otherwise, this PR should be ready to go into devel. |
|
I find msg_self to being a different value and use than msg_location while having very similar docstrings to be a bit confusing - having never looked at the code before, it seemed like the documentation didn't match what the method now does. I think I'd find it more intuitive to do something like It probably would make a little more sense to me if Something else that might be worth thinking about is if receivers was an iterable in order to support sending one message to selected receivers in a room, and a separate message to anyone else in the room who did not quality. For example, if you wished to support 'whispering' to more than one person at a time, and then just sending 'Blau whispers quietly to Griatch, Chainsol' or whatever to the room. I sort of feel that base hooks should try to capture as many use-cases as possible without having overwhelming complexity, but I don't think a list of receivers versus one would be more difficult to understand for a user implementing the hook. |
|
I think the intent @vlegoff had with msg_self and msg_location was to be able to apply filtering to msg_location independently, but doesn't handle the use case of each listener in the location to receive a different msg_location, nor does CmdWhisper handle multiple coma-delimited targets. I'm confused while trying to interpret what is meant by:
since as far as I know, I didn't remove that, I just made msg_self optional, because I don't use it in my say (in the say way pose doesn't have a pose_self). But, If msg_location and receivers did handle iterables of strings and objects, (an optional dict contained receiver keys with string values for each unique msg_location), then such a use case wouldn't have to call at_say multiple times for a list of receivers receiving custom messages. The same would be true of a custom CmdWhisper. |
|
I would say that the new |
|
@Griatch The reason I restored msg_type was because it was in 0.6, in say, pose, and whisper and is still in 0.7's pose. It broke @CloudKeeper1 's implementation of the puppetbot when @vlegoff removed it, maybe just an oversight, since he could have used the type embedded in whispers as a marker for whispered text versus speech. To have other objects parse it server side is the best we can do, as the whisper kwarg isn't included in the actual message sent whereas in this implementation similar to how it is done in 0.6, it's embedded in the tuple. When an object receives a message from another object without the type embedded in the tuple, the most the receiving object knows is which object sent it. If default say, whisper, pose removes type from the tuple in 0.7, default say, pose, and whisper can no longer be used the way it was in 0.6, unless the commands injected the tuple to the hooks. For example If you decide that |
|
Another feature of this PR is make excluding the caller from being sent msg_location optional, instead of mandatory; a mandatory exclusion of msg_location does not fit everyone's use_case for a say command, which is the first reason I had to rewrite CmdSay for my implementation. In 0.7, I would have to bypass using Put plainly, without this, Evennia's at_say would enforce a specific (but perhaps marginally more popular) use case, and require being bypassed for the alternate use case where everyone (including the caller) sees '{object} says, "{speech}"' in the same way pose does. |
|
@BlauFeuer I'm not sure where 0.6's I added |
|
@Griatch **kwargs support to the at_say hook isn't relevant to the issue this PR addresses, which is two-fold:
|
|
Ok, just so we ware on the same page: 0.6 never passed the type to
|
|
@Griatch Here's all my thoughts I can express regarding the feedback I've received: **kwargs passingAs my understanding goes, relevant to the discussion about msg_type, in that you mentioned including both would be "superfluous". Another point of view is that it's "backward compatible" and "flexible" to allow one or the other or both. The msg_type argThe question remaining is what extend you want tuple messages to be part of the official API. Having messages sent via msg method by a string or by tuple with the first element being a string has legitimate uses, and you seem to support that. What's remaining is the use of {'type': } in messages. That usage need not be an official part of the API, but it is used in 0.6 in CmdSay, CmdWhisper, and CmdPose as what I imagine to be an example usage, one that @CloudKeeper1 leveraged so that the tuple in the message denoted the type of message being conveyed by the string portion of the message. So I'm assuming it's not "official", but it's a demonstrated usage in Evennia's default commands. What I read from you as relevant to the PR is:
How to update the PR to make it more acceptable: I could even address the parts I understand from @TehomCD and include accepting a dict for message and msg_location alternate formats per targeted object so that at_say allows for a single call to send a variety of formats and outputs after being processed through a language check to obscure parts of the message to some of the audience -- but that's somewhat beyond the initial scope of the PR. |
|
I probably didn't explain myself clearly - I was confused by msg_self being changed from an optional argument, which it still states it is in the docstring, to a mandatory one, due to removing its default argument of None. The use case I was addressing wasn't suggesting a dict for message/msg_location formats, but for having an iterable for the receivers where they would all be sent the specified speech, while msg_location was then used for the location which would receive a different message, probably with the receivers passed as the exclude argument. To me, the common use case for pose/say/whisper/etc has three separate messages I've had to handle in my implementations: a message to the sender, a message to the receivers, and a message to the room. It seems like your implementation of at_say almost handles this by default, but doesn't quite do it. My suggestion would be changing the default exclude to receivers for msg_location and making receivers an iterable and sending the message to each. That's just my opinion, though! |
|
@BlauFeuer Sure, this PR can certainly be made something that can be merged! We are almost there in the discussion I think. Still some confusion though I feel. :)
From an API standpoint there is no "backwards compatibility" to consider here since 0.6's (master branch)
Just to be clear on what we refer to here. I refer to the outputfunc. That is, the call
No, the argument would only accept strings or None (since it's optional). It would look for
Hm, this is a little outside the scope of this PR, but I guess it would be useful to expand |
|
Since this is not a blocker for |
|
I ran out of time to work on this. Since there's a push to merge devel branch, I'm considering if breaking this into separate issues is a more workable solution. I probably should have made an issue of it, but thinking devel would be in development longer and the issue would be addressed sooner, instead I only mentioned it in a comment of #1174 as something that breaks existing published game code. |
|
Ah, didn't intend to close this. Since this is essentially a bug fix not changing API, please re-open against the |
|
I have implemented most of this manually in latest master along with rewrites of the entire at_say hook. Should hopefully work the same way as intended here. |
Brief overview of PR changes/additions
Returns use of the the "type" kwarg to the tuple msg output, allowing messages of different types, but having at_say default to "say" type, as before.
Defaults to using msg_self ("You say, ) format, but allows not excluding the speaker from msg_location messages. Keeps the hard-coded defaults, including whisper, but whisper mode is engaged with a kwarg or msg_type for flexibility/ compatibility.
Motivation for adding to Evennia
Game code relying on Evennia 0.6 behavior of sending type kwarg in tuple msg output won't break, but keeps the nice mappings and default says/whisper (albeit in a slightly modified format) that @v-legoff added.
Other info (issues closed, discussion etc)
devel branch
Does this change break anything differently, and will it fit the expected and more uncommon use cases?