Make rpsystem contrib's say use at_before_say hook
This commit is contained in:
parent
af74ff49da
commit
4982b934a5
1 changed files with 16 additions and 3 deletions
|
|
@ -896,10 +896,9 @@ class CmdSay(RPCommand): # replaces standard say
|
||||||
caller.msg("Say what?")
|
caller.msg("Say what?")
|
||||||
return
|
return
|
||||||
|
|
||||||
# calling the speech hook on the location
|
# calling the speech modifying hook
|
||||||
speech = caller.location.at_before_say(self.args)
|
speech = caller.at_before_say(self.args)
|
||||||
# preparing the speech with sdesc/speech parsing.
|
# preparing the speech with sdesc/speech parsing.
|
||||||
speech = '/me says, "{speech}"'.format(speech=speech)
|
|
||||||
targets = self.caller.location.contents
|
targets = self.caller.location.contents
|
||||||
send_emote(self.caller, targets, speech, anonymous_add=None)
|
send_emote(self.caller, targets, speech, anonymous_add=None)
|
||||||
|
|
||||||
|
|
@ -1509,6 +1508,20 @@ class ContribRPCharacter(DefaultCharacter, ContribRPObject):
|
||||||
# initializing sdesc
|
# initializing sdesc
|
||||||
self.sdesc.add("A normal person")
|
self.sdesc.add("A normal person")
|
||||||
|
|
||||||
|
def at_before_say(self, message, **kwargs):
|
||||||
|
"""
|
||||||
|
Called before the object says or whispers anything, return modified message.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
message (str): The suggested say/whisper text spoken by self.
|
||||||
|
Kwargs:
|
||||||
|
whisper (bool): If True, this is a whisper rather than a say.
|
||||||
|
|
||||||
|
"""
|
||||||
|
if kwargs.get("whisper"):
|
||||||
|
return f'/me whispers "{message}"'
|
||||||
|
return f'/me says, "{message}"'
|
||||||
|
|
||||||
def process_sdesc(self, sdesc, obj, **kwargs):
|
def process_sdesc(self, sdesc, obj, **kwargs):
|
||||||
"""
|
"""
|
||||||
Allows to customize how your sdesc is displayed (primarily by
|
Allows to customize how your sdesc is displayed (primarily by
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue