@lcap/cli
Advanced tools
| import axios from 'axios'; | ||
| import { SecretData, MessageData } from './types'; | ||
| export declare function fetchToken(token: SecretData): Promise<string>; | ||
| /** 对单人发消息 */ | ||
| export declare function postRobotP2P(token: string, body: MessageData): Promise<axios.AxiosResponse<any, any>>; | ||
| /** 群发消息 */ | ||
| export declare function postRobotTeam(token: string, body: MessageData): Promise<axios.AxiosResponse<any, any>>; | ||
| /** | ||
| * 通过邮箱反查用户名称 | ||
| * @deprecated 暂不支持 | ||
| */ | ||
| export declare function getPersonName(token: string, email: string): Promise<string>; | ||
| export declare function getPersonName(token: string, email: string): Promise<string | undefined>; |
+18
-15
@@ -23,2 +23,3 @@ "use strict"; | ||
| exports.fetchToken = fetchToken; | ||
| /** 对单人发消息 */ | ||
| async function postRobotP2P(token, body) { | ||
@@ -38,2 +39,3 @@ const data = { | ||
| exports.postRobotP2P = postRobotP2P; | ||
| /** 群发消息 */ | ||
| async function postRobotTeam(token, body) { | ||
@@ -44,2 +46,4 @@ const data = { | ||
| message: (0, utils_1.formatMessage)(body.message), | ||
| atUids: [], | ||
| isAtAll: false, | ||
| }; | ||
@@ -49,13 +53,14 @@ if (data.message.includes('@所有人')) { | ||
| } | ||
| // if (body.atEmails.length > 0) { | ||
| // const emails = body.atEmails.filter((email) => email && body.message.includes(email)); | ||
| // const names = await Promise.all(emails.map((email) => getPersonName(token, email))); | ||
| // for (let i = 0; i < emails.length; i++) { | ||
| // const email = emails[i]; | ||
| // const name = names[i]; | ||
| // if (email && name && typeof name === 'string') { | ||
| // data.message = data.message.replace(`@${email}`, `@${name}`); | ||
| // } | ||
| // } | ||
| // } | ||
| if (body.atEmails.length > 0) { | ||
| const emails = body.atEmails.filter((email) => email && body.message.includes(email)); | ||
| const names = await Promise.all(emails.map((email) => getPersonName(token, email))); | ||
| for (let i = 0; i < emails.length; i++) { | ||
| const email = emails[i]; | ||
| const name = names[i]; | ||
| if (email && name && typeof name === 'string') { | ||
| data.message = data.message.replace(`@${email}`, `@${name}`); | ||
| data.atUids.push(email); | ||
| } | ||
| } | ||
| } | ||
| return axios_1.default.post(constant_1.PopoApi.ToTeam, data, { | ||
@@ -71,3 +76,2 @@ headers: { | ||
| * 通过邮箱反查用户名称 | ||
| * @deprecated 暂不支持 | ||
| */ | ||
@@ -85,6 +89,5 @@ async function getPersonName(token, email) { | ||
| }) | ||
| .then((res) => { | ||
| return res.data.name; | ||
| }); | ||
| .then(({ data }) => data.data.name) | ||
| .catch(() => void 0); | ||
| } | ||
| exports.getPersonName = getPersonName; |
@@ -61,8 +61,4 @@ import type { TokenData } from '../utils'; | ||
| export interface TokenResponseData { | ||
| data: { | ||
| openAccessToken: string; | ||
| accessExpiredAt: number; | ||
| }; | ||
| errcode: number; | ||
| errmsg: string; | ||
| openAccessToken: string; | ||
| accessExpiredAt: number; | ||
| } | ||
@@ -126,1 +122,6 @@ export interface MessageData { | ||
| } | ||
| export interface PopoResponse<T> { | ||
| data: T; | ||
| errcode: number; | ||
| errmsg: string; | ||
| } |
| /** 分支名称格式化 */ | ||
| export declare function formatBranch(name: string): string; | ||
| /** 文本格式化 */ | ||
| export declare function formatMessage(message: string): string; |
@@ -9,2 +9,3 @@ "use strict"; | ||
| exports.formatBranch = formatBranch; | ||
| /** 文本格式化 */ | ||
| function formatMessage(message) { | ||
@@ -11,0 +12,0 @@ return message.replace(/\\+n/g, '\n'); |
+1
-1
| { | ||
| "name": "@lcap/cli", | ||
| "version": "2.0.1", | ||
| "version": "2.1.0", | ||
| "description": "utils for lcap", | ||
@@ -5,0 +5,0 @@ "author": "sufangzhou", |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
28645
0.74%828
0.85%