mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 11:22:04 +00:00
Slack importer: Map Slack channel mentions to Zulip stream mentions.
This commit is contained in:
@@ -4,6 +4,7 @@ from typing import Any, Dict, Tuple, List
|
||||
# stubs
|
||||
ZerverFieldsT = Dict[str, Any]
|
||||
AddedUsersT = Dict[str, int]
|
||||
AddedChannelsT = Dict[str, Tuple[str, int]]
|
||||
|
||||
# Slack link can be in the format <http://www.foo.com|www.foo.com> and <http://foo.com/>
|
||||
LINK_REGEX = r"""
|
||||
@@ -66,6 +67,7 @@ def get_user_full_name(user: ZerverFieldsT) -> str:
|
||||
|
||||
# Markdown mapping
|
||||
def convert_to_zulip_markdown(text: str, users: List[ZerverFieldsT],
|
||||
added_channels: AddedChannelsT,
|
||||
added_users: AddedUsersT) -> Tuple[str, List[int], bool]:
|
||||
mentioned_users_id = []
|
||||
text = convert_markdown_syntax(text, SLACK_BOLD_REGEX, "**")
|
||||
@@ -80,6 +82,11 @@ def convert_to_zulip_markdown(text: str, users: List[ZerverFieldsT],
|
||||
text = text.replace('<!channel>', '@**all**')
|
||||
text = text.replace('<!here>', '@**all**')
|
||||
|
||||
# Map Slack channel mention: '<#C5Z73A7RA|general>' to '#**general**'
|
||||
for cname, ids in added_channels.items():
|
||||
cid = ids[0]
|
||||
text = text.replace('<#%s|%s>' % (cid, cname), '#**' + cname + '**')
|
||||
|
||||
tokens = text.split(' ')
|
||||
for iterator in range(len(tokens)):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user