bots: Support determining bot runtime identity.
This improves the ability of a bot to specify how to mention it, which varies at run-time depending upon the identity used to run it; this is commonly used in many bot help commands.
This commit is contained in:
parent
4c8d86c1d9
commit
56c59d915a
3 changed files with 17 additions and 0 deletions
|
@ -21,6 +21,7 @@ from zulip_bots.test_file_utils import (
|
|||
read_bot_fixture_data,
|
||||
)
|
||||
|
||||
from zulip_bots.lib import BotIdentity
|
||||
|
||||
class StubBotHandler:
|
||||
def __init__(self) -> None:
|
||||
|
@ -33,6 +34,9 @@ class StubBotHandler:
|
|||
def reset_transcript(self) -> None:
|
||||
self.transcript = [] # type: List[Tuple[str, Dict[str, Any]]]
|
||||
|
||||
def identity(self) -> BotIdentity:
|
||||
return BotIdentity(self.full_name, self.email)
|
||||
|
||||
def send_message(self, message: Dict[str, Any]) -> Dict[str, Any]:
|
||||
self.transcript.append(('send_message', message))
|
||||
return self.message_server.send(message)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue