mirror of
https://github.com/evennia/evennia.git
synced 2026-03-30 20:47:17 +02:00
Make rpsystem contrib's say use at_before_say hook
This commit is contained in:
parent
c9c6d935d0
commit
327d996b76
1 changed files with 16 additions and 3 deletions
|
|
@ -896,10 +896,9 @@ class CmdSay(RPCommand): # replaces standard say
|
|||
caller.msg("Say what?")
|
||||
return
|
||||
|
||||
# calling the speech hook on the location
|
||||
speech = caller.location.at_before_say(self.args)
|
||||
# calling the speech modifying hook
|
||||
speech = caller.at_before_say(self.args)
|
||||
# preparing the speech with sdesc/speech parsing.
|
||||
speech = '/me says, "{speech}"'.format(speech=speech)
|
||||
targets = self.caller.location.contents
|
||||
send_emote(self.caller, targets, speech, anonymous_add=None)
|
||||
|
||||
|
|
@ -1509,6 +1508,20 @@ class ContribRPCharacter(DefaultCharacter, ContribRPObject):
|
|||
# initializing sdesc
|
||||
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):
|
||||
"""
|
||||
Allows to customize how your sdesc is displayed (primarily by
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue