t-comm
Version:
专业、稳定、纯粹的工具库
29 lines (25 loc) • 756 B
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
/**
* 获取 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;
}
exports.getMentionRtx = getMentionRtx;