UNPKG

@microsoft/teams.api

Version:

<p> <a href="https://www.npmjs.com/package/@microsoft/teams.api" target="_blank"> <img src="https://img.shields.io/npm/v/@microsoft/teams.api/latest" /> </a> <a href="https://www.npmjs.com/package/@microsoft/teams.api?activeTab=code" t

23 lines (22 loc) • 810 B
function stripMentionsText(activity, { accountId, tagOnly } = {}) { if (!activity.text) return; let text = activity.text; for (const mention of activity.entities?.filter((e) => e.type === "mention") || []) { if (accountId && mention.mentioned.id !== accountId) { continue; } if (mention.text) { const textWithoutTags = mention.text.replace("<at>", "").replace("</at>", ""); text = text.replace(mention.text, !tagOnly ? "" : textWithoutTags); } else if (mention.mentioned.name) { text = text.replace( `<at>${mention.mentioned.name}</at>`, !tagOnly ? "" : mention.mentioned.name ); } } return text.trim(); } export { stripMentionsText }; //# sourceMappingURL=strip-mentions-text.mjs.map //# sourceMappingURL=strip-mentions-text.mjs.map