Skip to content

Commit

Permalink
add: 完善QMsg酱功能 (#25)
Browse files Browse the repository at this point in the history
* [add] 完善QMsg酱功能
- 支持私有化部署自定义url
- 支持指定接收者
- 支持接收者为群聊

Signed-off-by: 钟意 <thatcoder@163.com>

* [add] 完善QMsg酱功能
- 支持私有化部署自定义url
- 支持指定接收者
- 支持接收者为群聊

Signed-off-by: 钟意 <thatcoder@163.com>

---------

Signed-off-by: 钟意 <thatcoder@163.com>
  • Loading branch information
ThatCoders authored Jul 19, 2024
1 parent b20fd8a commit 093b627
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ export interface NoticeOptions {
url?: string;
verifyPay?: boolean;
};
/**
* QMsg酱通知方式的参数配置
*/
qmsg?: {
qq?: string;
url?: string;
group?: boolean;
bot?: string;
};
dingtalk?: {
/**
* 消息类型,目前支持 text、markdown。不设置,默认为 text。
Expand Down Expand Up @@ -103,15 +112,20 @@ function removeUrlAndIp(content: string) {
*/
async function noticeQmsg(options: CommonOptions) {
checkParameters(options, ['token', 'content']);
const url = 'https://qmsg.zendee.cn';
const url = options?.options?.qmsg?.url ||'https://qmsg.zendee.cn';

Check failure on line 115 in src/index.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Multiple spaces found before 'options'

Check failure on line 115 in src/index.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Operator '||' must be spaced
let msg = getTxt(options.content);
if (options.title) {
msg = `${options.title}\n${msg}`;
}
// 移除网址和 IP 以避免 Qmsg 酱被 Tencent 封号
msg = removeUrlAndIp(msg);
const param = new URLSearchParams({ msg });
const response = await axios.post(`${url}/send/${options.token}`, param.toString(), {
const qq = options?.options?.qmsg?.qq || false;
qq?param.append('qq', qq):null;

Check failure on line 124 in src/index.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Expected an assignment or function call and instead saw an expression

Check failure on line 124 in src/index.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Operator '?' must be spaced

Check failure on line 124 in src/index.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Operator ':' must be spaced
const bot = options?.options?.qmsg?.bot || false;
bot?param.append('bot', bot):null;

Check failure on line 126 in src/index.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Expected an assignment or function call and instead saw an expression

Check failure on line 126 in src/index.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Operator '?' must be spaced

Check failure on line 126 in src/index.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Operator ':' must be spaced
const group = options?.options?.qmsg?.group || false;
const response = await axios.post(`${url}/${group?'group':'send'}/${options.token}`, param.toString(), {

Check failure on line 128 in src/index.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Operator '?' must be spaced

Check failure on line 128 in src/index.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Operator ':' must be spaced
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
});
return response.data;
Expand Down

0 comments on commit 093b627

Please sign in to comment.