0.2.2: 消息推送插件化重构 + 14通道 + 多用户推送 + 全局推送 + 事件模板自定义 + 每日报告 + 变量说明
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { Notifier, NotifyParams, NotifyResult, NotifierParam } from './notifier.types';
|
||||
|
||||
const params: NotifierParam[] = [
|
||||
{ key: 'sendkey', label: 'SendKey', type: 'password', required: true, placeholder: 'Server酱 Turbo SendKey' },
|
||||
{ key: 'title', label: '标题', type: 'text', default: 'CloudSearch', required: false },
|
||||
{ key: 'content', label: '内容', type: 'text', required: true },
|
||||
];
|
||||
|
||||
export const serverchanturboNotifier: Notifier = {
|
||||
name: 'serverchanturbo',
|
||||
label: 'Server酱 Turbo',
|
||||
params,
|
||||
async notify(params: NotifyParams): Promise<NotifyResult> {
|
||||
try {
|
||||
const resp = await fetch(`https://sctapi.ftqq.com/${params.sendkey}.send`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
body: new URLSearchParams({ title: params.title || 'CloudSearch', desp: params.content || '' }).toString(),
|
||||
});
|
||||
const data: any = await resp.json();
|
||||
if (data.code === 0) return { success: true, message: 'Server酱 Turbo 推送成功' };
|
||||
return { success: false, message: data.message || `HTTP ${resp.status}` };
|
||||
} catch (err: any) {
|
||||
return { success: false, message: err.message };
|
||||
}
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user