mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
python: Reformat with Black, except quotes.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
5028c081cb
commit
11741543da
@@ -60,12 +60,15 @@ class StateHandler:
|
||||
def contains(self, key: str) -> bool:
|
||||
return is_key_in_bot_storage(self.user_profile, key)
|
||||
|
||||
|
||||
class EmbeddedBotQuitException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class EmbeddedBotEmptyRecipientsList(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class EmbeddedBotHandler:
|
||||
def __init__(self, user_profile: UserProfile) -> None:
|
||||
# Only expose a subset of our UserProfile's functionality
|
||||
@@ -82,8 +85,11 @@ class EmbeddedBotHandler:
|
||||
|
||||
if message['type'] == 'stream':
|
||||
internal_send_stream_message_by_name(
|
||||
self.user_profile.realm, self.user_profile,
|
||||
message['to'], message['topic'], message['content'],
|
||||
self.user_profile.realm,
|
||||
self.user_profile,
|
||||
message['to'],
|
||||
message['topic'],
|
||||
message['content'],
|
||||
)
|
||||
return
|
||||
|
||||
@@ -96,31 +102,37 @@ class EmbeddedBotHandler:
|
||||
raise EmbeddedBotEmptyRecipientsList(_('Message must have recipients!'))
|
||||
elif len(message['to']) == 1:
|
||||
recipient_user = get_active_user(recipients[0], self.user_profile.realm)
|
||||
internal_send_private_message(self.user_profile.realm, self.user_profile,
|
||||
recipient_user, message['content'])
|
||||
internal_send_private_message(
|
||||
self.user_profile.realm, self.user_profile, recipient_user, message['content']
|
||||
)
|
||||
else:
|
||||
internal_send_huddle_message(self.user_profile.realm, self.user_profile,
|
||||
recipients, message['content'])
|
||||
internal_send_huddle_message(
|
||||
self.user_profile.realm, self.user_profile, recipients, message['content']
|
||||
)
|
||||
|
||||
def send_reply(self, message: Dict[str, Any], response: str) -> None:
|
||||
if message['type'] == 'private':
|
||||
self.send_message(dict(
|
||||
type='private',
|
||||
to=[x['email'] for x in message['display_recipient']],
|
||||
content=response,
|
||||
sender_email=message['sender_email'],
|
||||
))
|
||||
self.send_message(
|
||||
dict(
|
||||
type='private',
|
||||
to=[x['email'] for x in message['display_recipient']],
|
||||
content=response,
|
||||
sender_email=message['sender_email'],
|
||||
)
|
||||
)
|
||||
else:
|
||||
self.send_message(dict(
|
||||
type='stream',
|
||||
to=message['display_recipient'],
|
||||
topic=get_topic_from_message_info(message),
|
||||
content=response,
|
||||
sender_email=message['sender_email'],
|
||||
))
|
||||
self.send_message(
|
||||
dict(
|
||||
type='stream',
|
||||
to=message['display_recipient'],
|
||||
topic=get_topic_from_message_info(message),
|
||||
content=response,
|
||||
sender_email=message['sender_email'],
|
||||
)
|
||||
)
|
||||
|
||||
# The bot_name argument exists only to comply with ExternalBotHandler.get_config_info().
|
||||
def get_config_info(self, bot_name: str, optional: bool=False) -> Dict[str, str]:
|
||||
def get_config_info(self, bot_name: str, optional: bool = False) -> Dict[str, str]:
|
||||
try:
|
||||
return get_bot_config(self.user_profile)
|
||||
except ConfigError:
|
||||
@@ -128,5 +140,5 @@ class EmbeddedBotHandler:
|
||||
return {}
|
||||
raise
|
||||
|
||||
def quit(self, message: str= "") -> None:
|
||||
def quit(self, message: str = "") -> None:
|
||||
raise EmbeddedBotQuitException(message)
|
||||
|
||||
Reference in New Issue
Block a user