2020-11-24 12:31:28 +01:00
|
|
|
|
from typing import Dict, List
|
2020-06-11 00:54:34 +02:00
|
|
|
|
|
2017-08-02 05:20:50 +02:00
|
|
|
|
from django.conf import settings
|
2020-11-14 09:10:24 +01:00
|
|
|
|
from django.db import transaction
|
2020-03-28 10:02:45 +01:00
|
|
|
|
from django.db.models import Count
|
2021-04-16 00:57:30 +02:00
|
|
|
|
from django.utils.translation import gettext as _
|
2022-01-24 11:22:11 +01:00
|
|
|
|
from django.utils.translation import override as override_language
|
2017-08-02 05:20:50 +02:00
|
|
|
|
|
2022-04-14 23:58:15 +02:00
|
|
|
|
from zerver.actions.create_realm import setup_realm_internal_bots
|
2022-04-14 23:50:10 +02:00
|
|
|
|
from zerver.actions.message_send import (
|
2020-06-11 00:54:34 +02:00
|
|
|
|
do_send_messages,
|
|
|
|
|
internal_prep_stream_message_by_name,
|
|
|
|
|
internal_send_private_message,
|
|
|
|
|
)
|
2022-04-14 23:54:01 +02:00
|
|
|
|
from zerver.actions.reactions import do_add_reaction
|
2019-08-15 20:31:01 +02:00
|
|
|
|
from zerver.lib.emoji import emoji_name_to_emoji_code
|
2020-11-24 12:31:28 +01:00
|
|
|
|
from zerver.lib.message import SendMessageRequest
|
2019-02-24 22:22:32 +01:00
|
|
|
|
from zerver.models import Message, Realm, UserProfile, get_system_bot
|
2017-08-02 05:20:50 +02:00
|
|
|
|
|
|
|
|
|
|
2020-03-28 10:02:45 +01:00
|
|
|
|
def missing_any_realm_internal_bots() -> bool:
|
2021-02-12 08:19:30 +01:00
|
|
|
|
bot_emails = [
|
2021-02-12 08:20:45 +01:00
|
|
|
|
bot["email_template"] % (settings.INTERNAL_BOT_DOMAIN,)
|
2021-02-12 08:19:30 +01:00
|
|
|
|
for bot in settings.REALM_INTERNAL_BOTS
|
|
|
|
|
]
|
2022-08-05 21:30:47 +02:00
|
|
|
|
bot_counts = {
|
|
|
|
|
email: count
|
|
|
|
|
for email, count in UserProfile.objects.filter(email__in=bot_emails)
|
|
|
|
|
.values_list("email")
|
|
|
|
|
.annotate(Count("id"))
|
|
|
|
|
}
|
2020-03-28 10:02:45 +01:00
|
|
|
|
realm_count = Realm.objects.count()
|
|
|
|
|
return any(bot_counts.get(email, 0) < realm_count for email in bot_emails)
|
|
|
|
|
|
2021-02-12 08:19:30 +01:00
|
|
|
|
|
2018-05-23 05:40:28 +02:00
|
|
|
|
def create_if_missing_realm_internal_bots() -> None:
|
|
|
|
|
"""This checks if there is any realm internal bot missing.
|
|
|
|
|
|
|
|
|
|
If that is the case, it creates the missing realm internal bots.
|
|
|
|
|
"""
|
|
|
|
|
if missing_any_realm_internal_bots():
|
|
|
|
|
for realm in Realm.objects.all():
|
|
|
|
|
setup_realm_internal_bots(realm)
|
|
|
|
|
|
2021-02-12 08:19:30 +01:00
|
|
|
|
|
2017-11-05 11:15:10 +01:00
|
|
|
|
def send_initial_pms(user: UserProfile) -> None:
|
2017-08-18 03:44:29 +02:00
|
|
|
|
organization_setup_text = ""
|
2021-09-09 06:50:40 +02:00
|
|
|
|
|
2022-01-24 11:22:11 +01:00
|
|
|
|
# We need to override the language in this code path, because it's
|
|
|
|
|
# called from account registration, which is a pre-account API
|
|
|
|
|
# request and thus may not have the user's language context yet.
|
|
|
|
|
with override_language(user.default_language):
|
|
|
|
|
if user.is_realm_admin:
|
|
|
|
|
help_url = user.realm.uri + "/help/getting-your-organization-started-with-zulip"
|
|
|
|
|
organization_setup_text = (
|
|
|
|
|
" " + _("We also have a guide for [Setting up your organization]({help_url}).")
|
|
|
|
|
).format(help_url=help_url)
|
|
|
|
|
|
|
|
|
|
welcome_msg = _("Hello, and welcome to Zulip!") + "👋"
|
|
|
|
|
demo_org_warning = ""
|
|
|
|
|
if user.realm.demo_organization_scheduled_deletion_date is not None:
|
|
|
|
|
demo_org_warning = (
|
|
|
|
|
_(
|
|
|
|
|
"Note that this is a [demo organization]({demo_org_help_url}) and will be "
|
|
|
|
|
"**automatically deleted** in 30 days."
|
|
|
|
|
)
|
|
|
|
|
+ "\n\n"
|
2021-10-06 01:37:43 +02:00
|
|
|
|
)
|
2022-01-24 11:22:11 +01:00
|
|
|
|
|
|
|
|
|
content = "".join(
|
|
|
|
|
[
|
|
|
|
|
welcome_msg + " ",
|
|
|
|
|
_("This is a private message from me, Welcome Bot.") + "\n\n",
|
|
|
|
|
_(
|
|
|
|
|
"If you are new to Zulip, check out our [Getting started guide]({getting_started_url})!"
|
|
|
|
|
),
|
|
|
|
|
"{organization_setup_text}" + "\n\n",
|
|
|
|
|
"{demo_org_warning}",
|
|
|
|
|
_(
|
|
|
|
|
"I can also help you get set up! Just click anywhere on this message or press `r` to reply."
|
|
|
|
|
)
|
|
|
|
|
+ "\n\n",
|
|
|
|
|
_("Here are a few messages I understand:") + " ",
|
|
|
|
|
bot_commands(),
|
|
|
|
|
]
|
|
|
|
|
)
|
2021-02-12 08:19:30 +01:00
|
|
|
|
|
|
|
|
|
content = content.format(
|
2021-09-09 06:50:40 +02:00
|
|
|
|
organization_setup_text=organization_setup_text,
|
2021-10-16 10:29:21 +02:00
|
|
|
|
demo_org_warning=demo_org_warning,
|
2021-09-09 06:50:40 +02:00
|
|
|
|
demo_org_help_url="/help/demo-organizations",
|
2021-10-16 10:29:21 +02:00
|
|
|
|
getting_started_url="/help/getting-started-with-zulip",
|
2020-04-10 16:49:18 +02:00
|
|
|
|
)
|
|
|
|
|
|
2021-07-26 17:04:16 +02:00
|
|
|
|
internal_send_private_message(
|
|
|
|
|
get_system_bot(settings.WELCOME_BOT, user.realm_id), user, content
|
|
|
|
|
)
|
2017-08-02 05:20:50 +02:00
|
|
|
|
|
|
|
|
|
|
2021-12-06 19:55:22 +01:00
|
|
|
|
def bot_commands(no_help_command: bool = False) -> str:
|
2021-10-16 10:29:21 +02:00
|
|
|
|
commands = [
|
|
|
|
|
"apps",
|
2021-12-02 08:15:17 +01:00
|
|
|
|
"profile",
|
2021-10-16 10:29:21 +02:00
|
|
|
|
"theme",
|
|
|
|
|
"streams",
|
|
|
|
|
"topics",
|
|
|
|
|
"message formatting",
|
|
|
|
|
"keyboard shortcuts",
|
|
|
|
|
]
|
2021-12-06 19:55:22 +01:00
|
|
|
|
if not no_help_command:
|
2021-10-16 10:29:21 +02:00
|
|
|
|
commands.append("help")
|
|
|
|
|
return ", ".join(["`" + command + "`" for command in commands]) + "."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def select_welcome_bot_response(human_response_lower: str) -> str:
|
|
|
|
|
# Given the raw (pre-markdown-rendering) content for a private
|
|
|
|
|
# message from the user to Welcome Bot, select the appropriate reply.
|
|
|
|
|
if human_response_lower in ["app", "apps"]:
|
|
|
|
|
return _(
|
|
|
|
|
"You can [download](/apps) the [mobile and desktop apps](/apps). "
|
|
|
|
|
"Zulip also works great in a browser."
|
|
|
|
|
)
|
|
|
|
|
elif human_response_lower == "profile":
|
|
|
|
|
return _(
|
|
|
|
|
"Go to [Profile settings](#settings/profile) "
|
|
|
|
|
"to add a [profile picture](/help/change-your-profile-picture) "
|
|
|
|
|
"and edit your [profile information](/help/edit-your-profile)."
|
|
|
|
|
)
|
|
|
|
|
elif human_response_lower == "theme":
|
|
|
|
|
return _(
|
|
|
|
|
"Go to [Display settings](#settings/display-settings) "
|
|
|
|
|
"to [switch between the light and dark themes](/help/dark-theme), "
|
|
|
|
|
"[pick your favorite emoji theme](/help/emoji-and-emoticons#change-your-emoji-set), "
|
|
|
|
|
"[change your language](/help/change-your-language), "
|
|
|
|
|
"and make other tweaks to your Zulip experience."
|
|
|
|
|
)
|
|
|
|
|
elif human_response_lower in ["stream", "streams", "channel", "channels"]:
|
|
|
|
|
return "".join(
|
|
|
|
|
[
|
|
|
|
|
_(
|
|
|
|
|
"In Zulip, streams [determine who gets a message](/help/streams-and-topics). "
|
|
|
|
|
"They are similar to channels in other chat apps."
|
|
|
|
|
)
|
|
|
|
|
+ "\n\n",
|
|
|
|
|
_("[Browse and subscribe to streams](#streams/all)."),
|
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
elif human_response_lower in ["topic", "topics"]:
|
|
|
|
|
return "".join(
|
|
|
|
|
[
|
|
|
|
|
_(
|
|
|
|
|
"In Zulip, topics [tell you what a message is about](/help/streams-and-topics). "
|
|
|
|
|
"They are light-weight subjects, very similar to the subject line of an email."
|
|
|
|
|
)
|
|
|
|
|
+ "\n\n",
|
|
|
|
|
_(
|
2022-10-24 12:18:09 +02:00
|
|
|
|
"Check out [Recent conversations](#recent) to see what's happening! "
|
2021-10-16 10:29:21 +02:00
|
|
|
|
'You can return to this conversation by clicking "Private messages" in the upper left.'
|
|
|
|
|
),
|
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
elif human_response_lower in ["keyboard", "shortcuts", "keyboard shortcuts"]:
|
|
|
|
|
return "".join(
|
|
|
|
|
[
|
|
|
|
|
_(
|
|
|
|
|
"Zulip's [keyboard shortcuts](#keyboard-shortcuts) "
|
|
|
|
|
"let you navigate the app quickly and efficiently."
|
|
|
|
|
)
|
|
|
|
|
+ "\n\n",
|
|
|
|
|
_("Press `?` any time to see a [cheat sheet](#keyboard-shortcuts)."),
|
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
elif human_response_lower in ["formatting", "message formatting"]:
|
|
|
|
|
return "".join(
|
|
|
|
|
[
|
|
|
|
|
_(
|
|
|
|
|
"Zulip uses [Markdown](/help/format-your-message-using-markdown), "
|
|
|
|
|
"an intuitive format for **bold**, *italics*, bulleted lists, and more. "
|
|
|
|
|
"Click [here](#message-formatting) for a cheat sheet."
|
|
|
|
|
)
|
|
|
|
|
+ "\n\n",
|
|
|
|
|
_(
|
|
|
|
|
"Check out our [messaging tips](/help/messaging-tips) "
|
|
|
|
|
"to learn about emoji reactions, code blocks and much more!"
|
|
|
|
|
),
|
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
elif human_response_lower in ["help", "?"]:
|
|
|
|
|
return "".join(
|
|
|
|
|
[
|
|
|
|
|
_("Here are a few messages I understand:") + " ",
|
2021-12-06 19:55:22 +01:00
|
|
|
|
bot_commands(no_help_command=True) + "\n\n",
|
2021-10-16 10:29:21 +02:00
|
|
|
|
_(
|
|
|
|
|
"Check out our [Getting started guide](/help/getting-started-with-zulip), "
|
|
|
|
|
"or browse the [Help center](/help/) to learn more!"
|
|
|
|
|
),
|
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
else:
|
|
|
|
|
return "".join(
|
|
|
|
|
[
|
|
|
|
|
_(
|
|
|
|
|
"I’m sorry, I did not understand your message. Please try one of the following commands:"
|
|
|
|
|
)
|
|
|
|
|
+ " ",
|
|
|
|
|
bot_commands(),
|
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2020-11-24 12:31:28 +01:00
|
|
|
|
def send_welcome_bot_response(send_request: SendMessageRequest) -> None:
|
2021-10-16 10:29:21 +02:00
|
|
|
|
"""Given the send_request object for a private message from the user
|
|
|
|
|
to welcome-bot, trigger the welcome-bot reply."""
|
2021-07-26 17:04:16 +02:00
|
|
|
|
welcome_bot = get_system_bot(settings.WELCOME_BOT, send_request.message.sender.realm_id)
|
2021-10-16 10:29:21 +02:00
|
|
|
|
human_response_lower = send_request.message.content.lower()
|
|
|
|
|
content = select_welcome_bot_response(human_response_lower)
|
|
|
|
|
internal_send_private_message(welcome_bot, send_request.message.sender, content)
|
2021-02-12 08:19:30 +01:00
|
|
|
|
|
2020-09-03 20:28:29 +02:00
|
|
|
|
|
2020-11-14 09:10:24 +01:00
|
|
|
|
@transaction.atomic
|
2017-11-05 11:15:10 +01:00
|
|
|
|
def send_initial_realm_messages(realm: Realm) -> None:
|
2021-07-26 17:04:16 +02:00
|
|
|
|
welcome_bot = get_system_bot(settings.WELCOME_BOT, realm.id)
|
2017-08-02 05:20:50 +02:00
|
|
|
|
# Make sure each stream created in the realm creation process has at least one message below
|
|
|
|
|
# Order corresponds to the ordering of the streams on the left sidebar, to make the initial Home
|
|
|
|
|
# view slightly less overwhelming
|
2020-04-10 18:50:22 +02:00
|
|
|
|
content_of_private_streams_topic = (
|
2021-02-12 08:19:30 +01:00
|
|
|
|
_("This is a private stream, as indicated by the lock icon next to the stream name.")
|
|
|
|
|
+ " "
|
|
|
|
|
+ _("Private streams are only visible to stream members.")
|
|
|
|
|
+ "\n"
|
2020-04-10 18:50:22 +02:00
|
|
|
|
"\n"
|
2021-02-12 08:19:30 +01:00
|
|
|
|
+ _(
|
|
|
|
|
"To manage this stream, go to [Stream settings]({stream_settings_url}) "
|
|
|
|
|
"and click on `{initial_private_stream_name}`."
|
|
|
|
|
)
|
|
|
|
|
).format(
|
|
|
|
|
stream_settings_url="#streams/subscribed",
|
|
|
|
|
initial_private_stream_name=Realm.INITIAL_PRIVATE_STREAM_NAME,
|
|
|
|
|
)
|
2020-04-10 18:50:22 +02:00
|
|
|
|
|
|
|
|
|
content1_of_topic_demonstration_topic = (
|
2021-02-12 08:19:30 +01:00
|
|
|
|
_(
|
|
|
|
|
"This is a message on stream #**{default_notification_stream_name}** with the "
|
|
|
|
|
"topic `topic demonstration`."
|
|
|
|
|
)
|
2020-04-10 18:50:22 +02:00
|
|
|
|
).format(default_notification_stream_name=Realm.DEFAULT_NOTIFICATION_STREAM_NAME)
|
|
|
|
|
|
|
|
|
|
content2_of_topic_demonstration_topic = (
|
2021-02-12 08:19:30 +01:00
|
|
|
|
_("Topics are a lightweight tool to keep conversations organized.")
|
|
|
|
|
+ " "
|
|
|
|
|
+ _("You can learn more about topics at [Streams and topics]({about_topics_help_url}).")
|
2021-09-15 01:42:35 +02:00
|
|
|
|
).format(about_topics_help_url="/help/streams-and-topics")
|
2020-04-10 18:50:22 +02:00
|
|
|
|
|
|
|
|
|
content_of_swimming_turtles_topic = (
|
2021-02-12 08:19:30 +01:00
|
|
|
|
_(
|
|
|
|
|
"This is a message on stream #**{default_notification_stream_name}** with the "
|
|
|
|
|
"topic `swimming turtles`."
|
|
|
|
|
)
|
|
|
|
|
+ "\n"
|
2020-04-10 18:50:22 +02:00
|
|
|
|
"\n"
|
|
|
|
|
"[](/static/images/cute/turtle.png)"
|
|
|
|
|
"\n"
|
2021-02-12 08:19:30 +01:00
|
|
|
|
"\n"
|
|
|
|
|
+ _(
|
|
|
|
|
"[Start a new topic]({start_topic_help_url}) any time you're not replying to a \
|
|
|
|
|
previous message."
|
|
|
|
|
)
|
|
|
|
|
).format(
|
|
|
|
|
default_notification_stream_name=Realm.DEFAULT_NOTIFICATION_STREAM_NAME,
|
|
|
|
|
start_topic_help_url="/help/start-a-new-topic",
|
|
|
|
|
)
|
2020-04-10 18:50:22 +02:00
|
|
|
|
|
python: Convert assignment type annotations to Python 3.6 style.
This commit was split by tabbott; this piece covers the vast majority
of files in Zulip, but excludes scripts/, tools/, and puppet/ to help
ensure we at least show the right error messages for Xenial systems.
We can likely further refine the remaining pieces with some testing.
Generated by com2ann, with whitespace fixes and various manual fixes
for runtime issues:
- invoiced_through: Optional[LicenseLedger] = models.ForeignKey(
+ invoiced_through: Optional["LicenseLedger"] = models.ForeignKey(
-_apns_client: Optional[APNsClient] = None
+_apns_client: Optional["APNsClient"] = None
- notifications_stream: Optional[Stream] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
- signup_notifications_stream: Optional[Stream] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
+ notifications_stream: Optional["Stream"] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
+ signup_notifications_stream: Optional["Stream"] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
- author: Optional[UserProfile] = models.ForeignKey('UserProfile', blank=True, null=True, on_delete=CASCADE)
+ author: Optional["UserProfile"] = models.ForeignKey('UserProfile', blank=True, null=True, on_delete=CASCADE)
- bot_owner: Optional[UserProfile] = models.ForeignKey('self', null=True, on_delete=models.SET_NULL)
+ bot_owner: Optional["UserProfile"] = models.ForeignKey('self', null=True, on_delete=models.SET_NULL)
- default_sending_stream: Optional[Stream] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
- default_events_register_stream: Optional[Stream] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
+ default_sending_stream: Optional["Stream"] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
+ default_events_register_stream: Optional["Stream"] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
-descriptors_by_handler_id: Dict[int, ClientDescriptor] = {}
+descriptors_by_handler_id: Dict[int, "ClientDescriptor"] = {}
-worker_classes: Dict[str, Type[QueueProcessingWorker]] = {}
-queues: Dict[str, Dict[str, Type[QueueProcessingWorker]]] = {}
+worker_classes: Dict[str, Type["QueueProcessingWorker"]] = {}
+queues: Dict[str, Dict[str, Type["QueueProcessingWorker"]]] = {}
-AUTH_LDAP_REVERSE_EMAIL_SEARCH: Optional[LDAPSearch] = None
+AUTH_LDAP_REVERSE_EMAIL_SEARCH: Optional["LDAPSearch"] = None
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-22 01:09:50 +02:00
|
|
|
|
welcome_messages: List[Dict[str, str]] = [
|
2021-02-12 08:19:30 +01:00
|
|
|
|
{
|
2021-02-12 08:20:45 +01:00
|
|
|
|
"stream": Realm.INITIAL_PRIVATE_STREAM_NAME,
|
|
|
|
|
"topic": "private streams",
|
|
|
|
|
"content": content_of_private_streams_topic,
|
2021-02-12 08:19:30 +01:00
|
|
|
|
},
|
|
|
|
|
{
|
2021-02-12 08:20:45 +01:00
|
|
|
|
"stream": Realm.DEFAULT_NOTIFICATION_STREAM_NAME,
|
|
|
|
|
"topic": "topic demonstration",
|
|
|
|
|
"content": content1_of_topic_demonstration_topic,
|
2021-02-12 08:19:30 +01:00
|
|
|
|
},
|
|
|
|
|
{
|
2021-02-12 08:20:45 +01:00
|
|
|
|
"stream": Realm.DEFAULT_NOTIFICATION_STREAM_NAME,
|
|
|
|
|
"topic": "topic demonstration",
|
|
|
|
|
"content": content2_of_topic_demonstration_topic,
|
2021-02-12 08:19:30 +01:00
|
|
|
|
},
|
|
|
|
|
{
|
2021-02-12 08:20:45 +01:00
|
|
|
|
"stream": realm.DEFAULT_NOTIFICATION_STREAM_NAME,
|
|
|
|
|
"topic": "swimming turtles",
|
|
|
|
|
"content": content_of_swimming_turtles_topic,
|
2021-02-12 08:19:30 +01:00
|
|
|
|
},
|
python: Convert assignment type annotations to Python 3.6 style.
This commit was split by tabbott; this piece covers the vast majority
of files in Zulip, but excludes scripts/, tools/, and puppet/ to help
ensure we at least show the right error messages for Xenial systems.
We can likely further refine the remaining pieces with some testing.
Generated by com2ann, with whitespace fixes and various manual fixes
for runtime issues:
- invoiced_through: Optional[LicenseLedger] = models.ForeignKey(
+ invoiced_through: Optional["LicenseLedger"] = models.ForeignKey(
-_apns_client: Optional[APNsClient] = None
+_apns_client: Optional["APNsClient"] = None
- notifications_stream: Optional[Stream] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
- signup_notifications_stream: Optional[Stream] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
+ notifications_stream: Optional["Stream"] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
+ signup_notifications_stream: Optional["Stream"] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
- author: Optional[UserProfile] = models.ForeignKey('UserProfile', blank=True, null=True, on_delete=CASCADE)
+ author: Optional["UserProfile"] = models.ForeignKey('UserProfile', blank=True, null=True, on_delete=CASCADE)
- bot_owner: Optional[UserProfile] = models.ForeignKey('self', null=True, on_delete=models.SET_NULL)
+ bot_owner: Optional["UserProfile"] = models.ForeignKey('self', null=True, on_delete=models.SET_NULL)
- default_sending_stream: Optional[Stream] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
- default_events_register_stream: Optional[Stream] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
+ default_sending_stream: Optional["Stream"] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
+ default_events_register_stream: Optional["Stream"] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
-descriptors_by_handler_id: Dict[int, ClientDescriptor] = {}
+descriptors_by_handler_id: Dict[int, "ClientDescriptor"] = {}
-worker_classes: Dict[str, Type[QueueProcessingWorker]] = {}
-queues: Dict[str, Dict[str, Type[QueueProcessingWorker]]] = {}
+worker_classes: Dict[str, Type["QueueProcessingWorker"]] = {}
+queues: Dict[str, Dict[str, Type["QueueProcessingWorker"]]] = {}
-AUTH_LDAP_REVERSE_EMAIL_SEARCH: Optional[LDAPSearch] = None
+AUTH_LDAP_REVERSE_EMAIL_SEARCH: Optional["LDAPSearch"] = None
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-22 01:09:50 +02:00
|
|
|
|
]
|
2020-04-10 18:50:22 +02:00
|
|
|
|
|
2021-02-12 08:19:30 +01:00
|
|
|
|
messages = [
|
|
|
|
|
internal_prep_stream_message_by_name(
|
|
|
|
|
realm,
|
|
|
|
|
welcome_bot,
|
2021-02-12 08:20:45 +01:00
|
|
|
|
message["stream"],
|
|
|
|
|
message["topic"],
|
|
|
|
|
message["content"],
|
2021-02-12 08:19:30 +01:00
|
|
|
|
)
|
|
|
|
|
for message in welcome_messages
|
|
|
|
|
]
|
2017-08-02 06:02:06 +02:00
|
|
|
|
message_ids = do_send_messages(messages)
|
|
|
|
|
|
|
|
|
|
# We find the one of our just-sent messages with turtle.png in it,
|
|
|
|
|
# and react to it. This is a bit hacky, but works and is kinda a
|
|
|
|
|
# 1-off thing.
|
2020-11-14 09:10:24 +01:00
|
|
|
|
turtle_message = Message.objects.select_for_update().get(
|
|
|
|
|
id__in=message_ids, content__icontains="cute/turtle.png"
|
|
|
|
|
)
|
2021-02-12 08:20:45 +01:00
|
|
|
|
(emoji_code, reaction_type) = emoji_name_to_emoji_code(realm, "turtle")
|
|
|
|
|
do_add_reaction(welcome_bot, turtle_message, "turtle", emoji_code, reaction_type)
|