t-comm
Version:
专业、稳定、纯粹的工具库
25 lines (23 loc) • 664 B
JavaScript
/**
* 获取 rtx 拼接的提及字符串
* @param rawStr 原始字符串,比如 `foo,bar`
* @returns 处理后的字符串,比如 <@foo><@bar>
* @example
* ```ts
* getMentionRtx('foo,bar'); // '<@foo><@bar>'
* getMentionRtx('foo;bar'); // '<@foo><@bar>'
* getMentionRtx('foo'); // '<@foo>'
* getMentionRtx(''); // ''
* ```
*/
function getMentionRtx() {
var rawStr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
if (!rawStr) {
return '';
}
var result = rawStr.split(/,|;/).map(function (item) {
return "<@".concat(item, ">");
}).join('');
return result;
}
export { getMentionRtx };