Compare commits

...

11 Commits

Author SHA1 Message Date
whyour 1e749f3731 更新版本 v2.17.5 2024-06-02 17:53:40 +08:00
whyour a68f4b0cde 后端服务指定 ipv4 端口启动 2024-06-02 17:53:37 +08:00
whyour 07541569c5 修复定时任务 real_time 参数,升级 protobufjs 2024-06-02 11:08:35 +08:00
whyour 70f2bef5d2 修改 ql 和 task 命令生成逻辑 2024-05-29 22:09:01 +08:00
whyour 805a716033 修复任务详情查看脚本错误 2024-05-25 18:22:01 +08:00
陈大人 e77d4c4337 增加微加机器人消息通道 (#2373)
Co-authored-by: chensiyuan <chensiyuan@pushplus.plus>
2024-05-25 00:33:31 +08:00
whyour b309ac7613 修复有可能手动运行任务无日志 2024-05-25 00:28:55 +08:00
雨思 8dd379b6b9 PushMe 通知支持自建服务 (#2358) 2024-05-15 22:38:25 +08:00
whyour 0b52e05af8 bark 推送增加 archive 参数 2024-05-05 20:10:57 +08:00
whyour e9852a0002 修改示例脚本 2024-05-05 19:47:54 +08:00
whyour 20be84b352 重构 JavaScript 脚本通知文件 2024-05-05 18:58:15 +08:00
32 changed files with 666 additions and 617 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ async function startServer() {
await require('./loaders/app').default({ expressApp: app });
const server = app
.listen(config.port, () => {
.listen(config.port, '0.0.0.0', () => {
Logger.debug(`✌️ 后端服务启动成功!`);
console.debug(`✌️ 后端服务启动成功!`);
process.send?.('ready');
+11 -1
View File
@@ -14,6 +14,7 @@ export enum NotificationMode {
'aibotk' = 'aibotk',
'iGot' = 'iGot',
'pushPlus' = 'pushPlus',
'wePlusBot' = 'wePlusBot',
'email' = 'email',
'pushMe' = 'pushMe',
'feishu' = 'feishu',
@@ -58,6 +59,7 @@ export class BarkNotification extends NotificationBaseInfo {
public barkGroup = 'qinglong';
public barkLevel = 'active';
public barkUrl = '';
public barkArchive=""
}
export class TelegramBotNotification extends NotificationBaseInfo {
@@ -99,6 +101,12 @@ export class PushPlusNotification extends NotificationBaseInfo {
public pushPlusUser = '';
}
export class WePlusBotNotification extends NotificationBaseInfo {
public wePlusBotToken = '';
public wePlusBotReceiver = '';
public wePlusBotVersion = '';
}
export class EmailNotification extends NotificationBaseInfo {
public emailService: string = '';
public emailUser: string = '';
@@ -107,6 +115,7 @@ export class EmailNotification extends NotificationBaseInfo {
export class PushMeNotification extends NotificationBaseInfo {
public pushMeKey: string = '';
public pushMeUrl: string = '';
}
export class ChronocatNotification extends NotificationBaseInfo {
@@ -144,9 +153,10 @@ export interface NotificationInfo
AibotkNotification,
IGotNotification,
PushPlusNotification,
WePlusBotNotification,
EmailNotification,
PushMeNotification,
WebhookNotification,
ChronocatNotification,
LarkNotification {}
+5 -2
View File
@@ -23,18 +23,21 @@ async function linkCommand() {
{
src: 'update.sh',
dest: 'ql',
tmp: 'ql_tmp',
},
{
src: 'task.sh',
dest: 'task',
tmp: 'task_tmp',
},
];
for (const link of linkShell) {
const source = path.join(config.rootPath, 'shell', link.src);
const target = path.join(commandDir, link.dest);
await rmPath(target);
await fs.symlink(source, target);
const tmpTarget = path.join(commandDir, link.tmp);
await fs.symlink(source, tmpTarget);
await fs.rename(tmpTarget, target);
}
}
+1 -1
View File
@@ -21,7 +21,7 @@ app.get('/api/health', (req, res) => {
});
app
.listen(config.publicPort, async () => {
.listen(config.publicPort, '0.0.0.0', async () => {
await require('./loaders/sentry').default({ expressApp: app });
await require('./loaders/db').default();
+14 -7
View File
@@ -407,7 +407,7 @@ export default class CronService {
}
private async runSingle(cronId: number): Promise<number | void> {
return taskLimit.runWithCronLimit(() => {
return taskLimit.manualRunWithCronLimit(() => {
return new Promise(async (resolve: any) => {
const cron = await this.getDb({ id: cronId });
const params = {
@@ -434,9 +434,11 @@ export default class CronService {
}
const logPath = `${uniqPath}/${logTime}.log`;
const absolutePath = path.resolve(config.logPath, `${logPath}`);
const cp = spawn(
`real_log_path=${logPath} no_delay=true ${this.makeCommand(cron)}`,
`real_log_path=${logPath} no_delay=true ${this.makeCommand(
cron,
true
)}`,
{ shell: '/bin/bash' },
);
@@ -444,11 +446,14 @@ export default class CronService {
{ status: CrontabStatus.running, pid: cp.pid, log_path: logPath },
{ where: { id } },
);
cp.stdout.on('data', async (data) => {
await fs.appendFile(absolutePath, data.toString());
});
cp.stderr.on('data', async (data) => {
await fs.appendFile(`${absolutePath}`, `${data.toString()}`);
await fs.appendFile(absolutePath, data.toString());
});
cp.on('error', async (err) => {
await fs.appendFile(`${absolutePath}`, `${JSON.stringify(err)}`);
await fs.appendFile(absolutePath, JSON.stringify(err));
});
cp.on('exit', async (code) => {
@@ -524,12 +529,14 @@ export default class CronService {
}
}
private makeCommand(tab: Crontab) {
private makeCommand(tab: Crontab, realTime?: boolean) {
let command = tab.command.trim();
if (!command.startsWith(TASK_PREFIX) && !command.startsWith(QL_PREFIX)) {
command = `${TASK_PREFIX}${tab.command}`;
}
let commandVariable = `no_tee=true ID=${tab.id} `;
let commandVariable = `real_time=${Boolean(realTime)} no_tee=true ID=${
tab.id
} `;
if (tab.task_before) {
commandVariable += `task_before='${tab.task_before
.replace(/'/g, "'\\''")
+50 -6
View File
@@ -27,6 +27,7 @@ export default class NotificationService {
['aibotk', this.aibotk],
['iGot', this.iGot],
['pushPlus', this.pushPlus],
['wePlusBot',this.wePlusBot],
['email', this.email],
['pushMe', this.pushMe],
['webhook', this.webhook],
@@ -196,8 +197,15 @@ export default class NotificationService {
}
private async bark() {
let { barkPush, barkIcon, barkSound, barkGroup, barkLevel, barkUrl } =
this.params;
let {
barkPush,
barkIcon = '',
barkSound = '',
barkGroup = '',
barkLevel = '',
barkUrl = '',
barkArchive = '',
} = this.params;
if (!barkPush.startsWith('http')) {
barkPush = `https://api.day.app/${barkPush}`;
}
@@ -205,8 +213,7 @@ export default class NotificationService {
this.title,
)}/${encodeURIComponent(
this.content,
)}?icon=${barkIcon}&sound=${barkSound}&group=${barkGroup}&level=${barkLevel}&url=${barkUrl}`;
)}?icon=${barkIcon}&sound=${barkSound}&group=${barkGroup}&level=${barkLevel}&url=${barkUrl}&isArchive=${barkArchive}`;
try {
const res: any = await got
.get(url, {
@@ -507,6 +514,42 @@ export default class NotificationService {
}
}
private async wePlusBot() {
const { wePlusBotToken, wePlusBotReceiver, wePlusBotVersion } = this.params;
let content = this.content;
let template = 'txt';
if(this.content.length>800){
template = 'html';
content = content.replace(/[\n\r]/g, '<br>');
}
const url = `https://www.weplusbot.com/send`;
try {
const res: any = await got
.post(url, {
...this.gotOption,
json: {
token: `${wePlusBotToken}`,
title: `${this.title}`,
template: `${template}`,
content: `${content}`,
receiver: `${wePlusBotReceiver || ''}`,
version: `${wePlusBotVersion || 'pro'}`,
},
})
.json();
if (res.code === 200) {
return true;
} else {
throw new Error(JSON.stringify(res));
}
} catch (error: any) {
throw new Error(error.response ? error.response.body : error);
}
}
private async lark() {
let { larkKey } = this.params;
@@ -567,13 +610,14 @@ export default class NotificationService {
}
private async pushMe() {
const { pushMeKey } = this.params;
const { pushMeKey, pushMeUrl } = this.params;
try {
const res: any = await got.post(
`https://push.i-i.me/?push_key=${pushMeKey}`,
pushMeUrl || 'https://push.i-i.me/',
{
...this.gotOption,
json: {
push_key: pushMeKey,
title: this.title,
content: this.content,
},
+1 -1
View File
@@ -13,7 +13,7 @@ import taskLimit from '../shared/pLimit';
import { spawn } from 'cross-spawn';
export interface ScheduleTaskType {
id: number;
id?: number;
command: string;
name?: string;
schedule?: string;
+5 -2
View File
@@ -41,7 +41,7 @@ export default class ScriptService {
const relativePath = path.relative(config.scriptPath, filePath);
const command = `${TASK_COMMAND} ${relativePath} now`;
const pid = await this.scheduleService.runTask(
command,
`real_time=true ${command}`,
this.taskCallbacks(filePath),
{ command },
'start',
@@ -63,7 +63,10 @@ export default class ScriptService {
}
public async getFile(filePath: string, fileName: string) {
const _filePath = join(config.scriptPath, filePath, fileName);
let _filePath = join(config.scriptPath, filePath, fileName);
if (filePath.startsWith(config.dataPath)) {
_filePath = join(filePath, fileName);
}
const content = await getFileContentByName(_filePath);
return content;
}
+8 -5
View File
@@ -91,9 +91,9 @@ export default class SubscriptionService {
this.taskCallbacks(doc),
runImmediately,
));
} else {
} else if (doc.interval_schedule) {
this.scheduleService.cancelIntervalTask(doc as any);
const { type, value } = doc.interval_schedule as any;
const { type, value } = doc.interval_schedule;
needCreate &&
(await this.scheduleService.createIntervalTask(
doc as any,
@@ -256,7 +256,7 @@ export default class SubscriptionService {
);
}
public async remove(ids: number[], query: any) {
public async remove(ids: number[], query: { force?: boolean }) {
const docs = await SubscriptionModel.findAll({ where: { id: ids } });
for (const doc of docs) {
await this.handleTask(doc, false);
@@ -279,8 +279,11 @@ export default class SubscriptionService {
public async getDb(
query: FindOptions<Subscription>['where'],
): Promise<Subscription> {
const doc: any = await SubscriptionModel.findOne({ where: { ...query } });
return doc && (doc.get({ plain: true }) as Subscription);
const doc = await SubscriptionModel.findOne({ where: { ...query } });
if (!doc) {
throw new Error(`${JSON.stringify(query)} not found`);
}
return doc.get({ plain: true });
}
public async run(ids: number[]) {
+7 -12
View File
@@ -348,20 +348,13 @@ export default class SystemService {
}
}
public async run(
{ command, logPath }: { command: string; logPath: string },
callback: TaskCallbacks,
) {
public async run({ command }: { command: string }, callback: TaskCallbacks) {
if (!command.startsWith(TASK_COMMAND)) {
command = `${TASK_COMMAND} ${command}`;
}
this.scheduleService.runTask(
`real_log_path=${logPath} real_time=true ${command}`,
callback,
{
command,
},
);
this.scheduleService.runTask(`real_time=true ${command}`, callback, {
command,
});
}
public async stop({ command, pid }: { command: string; pid: number }) {
@@ -388,7 +381,9 @@ export default class SystemService {
public async exportData(res: Response) {
try {
await promiseExec(`cd ${config.rootPath} && tar -zcvf ${config.dataTgzFile} data/`);
await promiseExec(
`cd ${config.rootPath} && tar -zcvf ${config.dataTgzFile} data/`,
);
res.download(config.dataTgzFile);
} catch (error: any) {
return res.send({ code: 400, message: error.message });
+12
View File
@@ -15,6 +15,9 @@ class TaskLimit {
private cronLimit = new PQueue({
concurrency: Math.max(os.cpus().length, 4),
});
private manualCronoLimit = new PQueue({
concurrency: Math.max(os.cpus().length, 4),
});
get cronLimitActiveCount() {
return this.cronLimit.pending;
@@ -71,6 +74,7 @@ class TaskLimit {
public async setCustomLimit(limit?: number) {
if (limit) {
this.cronLimit.concurrency = limit;
this.manualCronoLimit.concurrency = limit;
return;
}
await SystemModel.sync();
@@ -79,6 +83,7 @@ class TaskLimit {
});
if (doc?.info?.cronConcurrency) {
this.cronLimit.concurrency = doc.info.cronConcurrency;
this.manualCronoLimit.concurrency = doc.info.cronConcurrency;
}
}
@@ -89,6 +94,13 @@ class TaskLimit {
return this.cronLimit.add(fn, options);
}
public async manualRunWithCronLimit<T>(
fn: () => Promise<T>,
options?: Partial<QueueAddOptions>,
): Promise<T | void> {
return this.manualCronoLimit.add(fn, options);
}
public runDependeny<T>(
dependency: Dependence,
fn: IDependencyFn<T>,
+1 -1
View File
@@ -12,7 +12,7 @@ async function startServer() {
await require('./loaders/update').default({ app });
app
.listen(config.updatePort, () => {
.listen(config.updatePort, '0.0.0.0', () => {
Logger.debug(`✌️ 更新服务启动成功!`);
console.debug(`✌️ 更新服务启动成功!`);
process.send?.('ready');
-1
View File
@@ -3,7 +3,6 @@
dir_shell=/ql/shell
. $dir_shell/env.sh
. $dir_shell/share.sh
link_shell
echo -e "======================1. 检测配置文件========================\n"
make_dir /etc/nginx/conf.d
+1 -1
View File
@@ -85,7 +85,7 @@
"node-schedule": "^2.1.0",
"nodemailer": "^6.7.2",
"p-queue-cjs": "7.3.4",
"protobufjs": "^7.2.3",
"protobufjs": "^7.3.0",
"pstree.remy": "^1.1.8",
"reflect-metadata": "^0.1.13",
"sequelize": "^6.25.5",
+10 -18
View File
@@ -1,5 +1,9 @@
lockfileVersion: '6.0'
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
dependencies:
'@grpc/grpc-js':
specifier: ^1.8.13
@@ -89,8 +93,8 @@ dependencies:
specifier: 7.3.4
version: 7.3.4
protobufjs:
specifier: ^7.2.3
version: 7.2.3
specifier: ^7.3.0
version: 7.3.0
pstree.remy:
specifier: ^1.1.8
version: 1.1.8
@@ -3930,7 +3934,7 @@ packages:
'@types/long': 4.0.2
lodash.camelcase: 4.3.0
long: 4.0.0
protobufjs: 7.2.3
protobufjs: 7.3.0
yargs: 17.7.2
dev: false
@@ -7386,7 +7390,7 @@ packages:
normalize-path: 3.0.0
readdirp: 3.6.0
optionalDependencies:
fsevents: 2.3.2
fsevents: 2.3.3
/chownr@2.0.0:
resolution: {integrity: sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==}
@@ -9360,19 +9364,11 @@ packages:
resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==}
requiresBuild: true
/fsevents@2.3.2:
resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==}
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
os: [darwin]
requiresBuild: true
optional: true
/fsevents@2.3.3:
resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==}
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
os: [darwin]
requiresBuild: true
dev: true
optional: true
/ftp@0.3.10:
@@ -12834,8 +12830,8 @@ packages:
long: 4.0.0
dev: true
/protobufjs@7.2.3:
resolution: {integrity: sha512-TtpvOqwB5Gdz/PQmOjgsrGH1nHjAQVCN7JG4A6r1sXRWESL5rNMAiRcBQlCAdKxZcAbstExQePYG8xof/JVRgg==}
/protobufjs@7.3.0:
resolution: {integrity: sha512-YWD03n3shzV9ImZRX3ccbjqLxj7NokGN0V/ESiBV5xWqrommYHYiihuIyavq03pWSGqlyvYUFmfoMKd+1rPA/g==}
engines: {node: '>=12.0.0'}
requiresBuild: true
dependencies:
@@ -16673,7 +16669,3 @@ packages:
- encoding
- supports-color
dev: false
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
+40 -9
View File
@@ -56,6 +56,12 @@ export BARK_ICON="https://qn.whyour.cn/logo.png"
export BARK_SOUND=""
## 下方填写推送消息分组,默认为"QingLong"
export BARK_GROUP="QingLong"
## bark 推送时效性
export BARK_LEVEL="active"
## bark 推送是否存档
export BARK_ARCHIVE=""
## bark 推送跳转 URL
export BARK_URL=""
## 3. Telegram
## 下方填写自己申请@BotFather的Token,如10xxx4:AAFcqxxxxgER5uw
@@ -112,7 +118,18 @@ export PUSH_PLUS_TOKEN=""
## 1. 需订阅者扫描二维码 2、如果您是创建群组所属人,也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送
export PUSH_PLUS_USER=""
## 9. go-cqhttp
## 9. 微加机器人
## 官方网站:http://www.weplusbot.com
## 下方填写您的Token;微信扫描登录后在"我的"->"设置"->"令牌"中获取
export WE_PLUS_BOT_TOKEN=""
## 消息接收人;
## 个人版填写接收消息的群编码,不填发送给自己的微信号
## 专业版不填默认发给机器人自己,发送给好友填写wxid,发送给微信群填写群编码
export WE_PLUS_BOT_RECEIVER=""
## 调用版本;分为专业版和个人版,专业版填写pro,个人版填写personal
export WE_PLUS_BOT_VERSION="pro"
## 10. go-cqhttp
## gobot_url 推送到个人QQ: http://127.0.0.1/send_private_msg 群:http://127.0.0.1/send_group_msg
## gobot_token 填写在go-cqhttp文件设置的访问密钥
## gobot_qq 如果GOBOT_URL设置 /send_private_msg 则需要填入 user_id=个人QQ 相反如果是 /send_group_msg 则需要填入 group_id=QQ群
@@ -121,7 +138,7 @@ export GOBOT_URL=""
export GOBOT_TOKEN=""
export GOBOT_QQ=""
## 10. gotify
## 11. gotify
## gotify_url 填写gotify地址,如https://push.example.de:8080
## gotify_token 填写gotify的消息应用token
## gotify_priority 填写推送消息优先级,默认为0
@@ -129,17 +146,17 @@ export GOTIFY_URL=""
export GOTIFY_TOKEN=""
export GOTIFY_PRIORITY=0
## 11. PushDeer
## 12. PushDeer
## deer_key 填写PushDeer的key
export DEER_KEY=""
## 12. Chat
## 13. Chat
## chat_url 填写synology chat地址,http://IP:PORT/webapi/***token=
## chat_token 填写后面的token
export CHAT_URL=""
export CHAT_TOKEN=""
## 13. aibotk
## 14. aibotk
## 官方说明文档:http://wechat.aibotk.com/oapi/oapi?from=ql
## aibotk_key (必填)填写智能微秘书个人中心的apikey
export AIBOTK_KEY=""
@@ -148,7 +165,7 @@ export AIBOTK_TYPE=""
## aibotk_name (必填)填写群名或用户昵称,和上面的type类型要对应
export AIBOTK_NAME=""
## 13. CHRONOCAT
## 15. CHRONOCAT
## CHRONOCAT_URL 推送 http://127.0.0.1:16530
## CHRONOCAT_TOKEN 填写在CHRONOCAT文件生成的访问密钥
## CHRONOCAT_QQ 个人:user_id=个人QQ 群则填入group_id=QQ群 多个用英文;隔开同时支持个人和群 如:user_id=xxx;group_id=xxxx;group_id=xxxxx
@@ -157,7 +174,7 @@ export CHRONOCAT_URL=""
export CHRONOCAT_QQ=""
export CHRONOCAT_TOKEN=""
## 14. SMTP
## 16. SMTP
## 邮箱服务名称,比如126、163、Gmail、QQ等,支持列表 https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json
export SMTP_SERVICE=""
## smtp_email 填写 SMTP 收发件邮箱,通知将会由自己发给自己
@@ -167,12 +184,26 @@ export SMTP_PASSWORD=""
## smtp_name 填写 SMTP 收发件人姓名,可随意填写
export SMTP_NAME=""
## 15. PushMe
## 17. PushMe
## 官方说明文档:https://push.i-i.me/
## PUSHME_KEY (必填)填写PushMe APP上获取的push_key
## PUSHME_URL (选填)填写自建的PushMeServer消息服务接口地址,例如:http://127.0.0.1:3010,不填则使用官方接口服务
export PUSHME_KEY=""
export PUSHME_URL=""
## 15. 自定义通知
## 18. 飞书机器人
## 官方文档:https://www.feishu.cn/hc/zh-CN/articles/360024984973
## FSKEY 飞书机器人的 FSKEY
export FSKEY=""
## 19. Qmsg酱
## 官方文档:https://qmsg.zendee.cn/docs/api/
## qmsg 酱的 QMSG_KEY
## qmsg 酱的 QMSG_TYPE send 为私聊,group 为群聊
export QMSG_KEY=""
export QMSG_TYPE=""
## 20. 自定义通知
## 自定义通知 接收回调的URL
export WEBHOOK_URL=""
## WEBHOOK_BODY 和 WEBHOOK_HEADERS 多个参数时,直接换行或者使用 $'\n' 连接多行字符串,比如 export dd="line 1"$'\n'"line 2"
+364 -485
View File
File diff suppressed because one or more lines are too long
+45 -4
View File
@@ -33,7 +33,7 @@ def print(text, *args, **kw):
# 通知服务
# fmt: off
push_config = {
'HITOKOTO': False, # 启用一言(随机句子)
'HITOKOTO': True, # 启用一言(随机句子)
'BARK_PUSH': '', # bark IP 或设备码,例:https://api.day.app/DxHcxxxxxRxxxxxxcm/
'BARK_ARCHIVE': '', # bark 推送是否存档
@@ -43,7 +43,7 @@ push_config = {
'BARK_LEVEL': '', # bark 推送时效性
'BARK_URL': '', # bark 推送跳转URL
'CONSOLE': True, # 控制台输出
'CONSOLE': False, # 控制台输出
'DD_BOT_SECRET': '', # 钉钉机器人的 DD_BOT_SECRET
'DD_BOT_TOKEN': '', # 钉钉机器人的 DD_BOT_TOKEN
@@ -75,6 +75,10 @@ push_config = {
'PUSH_PLUS_TOKEN': '', # push+ 微信推送的用户令牌
'PUSH_PLUS_USER': '', # push+ 微信推送的群组编码
'WE_PLUS_BOT_TOKEN': '', # 微加机器人的用户令牌
'WE_PLUS_BOT_RECEIVER': '', # 微加机器人的消息接收者
'WE_PLUS_BOT_VERSION': 'pro', # 微加机器人的调用版本
'QMSG_KEY': '', # qmsg 酱的 QMSG_KEY
'QMSG_TYPE': '', # qmsg 酱的 QMSG_TYPE
@@ -101,7 +105,8 @@ push_config = {
'SMTP_PASSWORD': '', # SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定
'SMTP_NAME': '', # SMTP 收发件人姓名,可随意填写
'PUSHME_KEY': '', # PushMe 的 PUSHME_KEY
'PUSHME_KEY': '', # PushMe 的 PUSHME_KEY
'PUSHME_URL': '', # PushMe 的 PUSHME_URL
'CHRONOCAT_QQ': '', # qq号
'CHRONOCAT_TOKEN': '', # CHRONOCAT 的token
@@ -380,6 +385,37 @@ def pushplus_bot(title: str, content: str) -> None:
else:
print("PUSHPLUS 推送失败!")
def weplus_bot(title: str, content: str) -> None:
"""
通过 微加机器人 推送消息。
"""
if not push_config.get("WE_PLUS_BOT_TOKEN"):
print("微加机器人 服务的 WE_PLUS_BOT_TOKEN 未设置!!\n取消推送")
return
print("微加机器人 服务启动")
template = "txt"
if len(content) > 800:
template = "html"
url = "https://www.weplusbot.com/send"
data = {
"token": push_config.get("WE_PLUS_BOT_TOKEN"),
"title": title,
"content": content,
"template": template,
"receiver": push_config.get("WE_PLUS_BOT_RECEIVER"),
"version": push_config.get("WE_PLUS_BOT_VERSION"),
}
body = json.dumps(data).encode(encoding="utf-8")
headers = {"Content-Type": "application/json"}
response = requests.post(url=url, data=body, headers=headers).json()
if response["code"] == 200:
print("微加机器人 推送成功!")
else:
print("微加机器人 推送失败!")
def qmsg_bot(title: str, content: str) -> None:
"""
@@ -668,10 +704,13 @@ def pushme(title: str, content: str) -> None:
return
print("PushMe 服务启动")
url = f'https://push.i-i.me/?push_key={push_config.get("PUSHME_KEY")}'
url = push_config.get("PUSHME_URL") if push_config.get("PUSHME_URL") else "https://push.i-i.me/"
data = {
"push_key": push_config.get("PUSHME_KEY"),
"title": title,
"content": content,
"date": push_config.get("date") if push_config.get("date") else "",
"type": push_config.get("type") if push_config.get("type") else "",
}
response = requests.post(url, data=data)
@@ -854,6 +893,8 @@ def add_notify_function():
notify_function.append(chat)
if push_config.get("PUSH_PLUS_TOKEN"):
notify_function.append(pushplus_bot)
if push_config.get("WE_PLUS_BOT_TOKEN"):
notify_function.append(weplus_bot)
if push_config.get("QMSG_KEY") and push_config.get("QMSG_TYPE"):
notify_function.append(qmsg_bot)
if push_config.get("QYWX_AM"):
+11
View File
@@ -0,0 +1,11 @@
/**
* 任务名称
* name: script name
* 定时规则
* cron: 1 9 * * *
*/
const { sendNotify } = require('./sendNotify.js'); // commonjs
// import { sendNotify } from './sendNotify'; // es6
console.log('test scripts');
sendNotify('test scripts', 'test desc');
+2
View File
@@ -4,5 +4,7 @@ name: script name
定时规则
cron: 1 9 * * *
"""
import notify
print("test script")
notify.send('test script', 'test desc')
-8
View File
@@ -1,8 +0,0 @@
/**
* 任务名称
* name: script name
* 定时规则
* cron: 1 9 * * *
*/
console.log('test scripts');
+4 -29
View File
@@ -33,12 +33,12 @@ file_task_sample=$dir_sample/task.sample.sh
file_extra_sample=$dir_sample/extra.sample.sh
file_notify_js_sample=$dir_sample/notify.js
file_notify_py_sample=$dir_sample/notify.py
file_test_js_sample=$dir_sample/test.js
file_test_py_sample=$dir_sample/test.py
file_test_js_sample=$dir_sample/ql_sample.js
file_test_py_sample=$dir_sample/ql_sample.py
file_notify_py=$dir_scripts/notify.py
file_notify_js=$dir_scripts/sendNotify.js
file_test_js=$dir_scripts/test.js
file_test_py=$dir_scripts/test.py
file_test_js=$dir_scripts/ql_sample.js
file_test_py=$dir_scripts/ql_sample.py
nginx_app_conf=$dir_root/docker/front.conf
nginx_conf=$dir_root/docker/nginx.conf
dep_notify_py=$dir_dep/notify.py
@@ -129,31 +129,6 @@ gen_random_num() {
echo $((${RANDOM} % $divi))
}
link_shell_sub() {
local link_path="$1"
local original_path="$2"
if [[ ! -L $link_path ]] || [[ $(readlink -f $link_path) != $original_path ]]; then
rm -f $link_path 2>/dev/null
ln -sf $original_path $link_path
fi
}
link_shell() {
if [[ $is_termux -eq 1 ]]; then
local path="/data/data/com.termux/files/usr/bin/"
elif [[ $PATH == */usr/local/bin* ]] && [[ -d /usr/local/bin ]]; then
local path="/usr/local/bin/"
else
local path=""
echo -e "脚本功能受限,请自行添加命令的软连接...\n"
fi
if [[ $path ]]; then
for ((i = 0; i < ${#link_name[*]}; i++)); do
link_shell_sub "$path${link_name[i]}" "$dir_shell/${original_name[i]}"
done
fi
}
define_cmd() {
local cmd_prefix cmd_suffix
if type task &>/dev/null; then
+6
View File
@@ -336,6 +336,7 @@
"企业微信应用": "WeChat Work App",
"智能微秘书": "Smart WeChat Assistant",
"群晖chat": "Synology Chat",
"微加机器人": "WePlusBot",
"邮箱": "Email",
"飞书机器人": "Feishu Bot",
"自定义通知": "Custom Notification",
@@ -357,6 +358,7 @@
"BARK推送消息的分组,默认为qinglong": "BARK push message grouping, default is qinglong",
"BARK推送消息的时效性,默认为active": "BARK push message redirecting URL",
"BARK推送消息的跳转URL": "BARK push message grouping, default is qinglong",
"BARK是否保存推送消息": "Does BARK save push messages",
"telegram机器人的token,例如:1077xxx4424:AAFjv0FcqxxxxxxgEMGfi22B4yh15R5uw": "Telegram Bot token, e.g., 1077xxx4424:AAFjv0FcqxxxxxxgEMGfi22B4yh15R5uw",
"telegram用户的id,例如:129xxx206": "Telegram user ID, e.g., 129xxx206",
"代理IP": "Proxy IP",
@@ -377,11 +379,15 @@
"iGot的信息推送key,例如:https://push.hellyw.com/XXXXXXXX": "iGot information push key, e.g., https://push.hellyw.com/XXXXXXXX",
"微信扫码登录后一对一推送或一对多推送下面的token(您的Token),不提供PUSH_PLUS_USER则默认为一对一推送,参考 https://www.pushplus.plus/": "After WeChat scan login, one-to-one or one-to-many push using the provided token (your Token). If PUSH_PLUS_USER is not provided, it defaults to one-to-one push. See reference at https://www.pushplus.plus/",
"一对多推送的“群组编码”(一对多推送下面->您的群组(如无则创建)->群组编码,如果您是创建群组人。也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送)": "The 'group code' for one-to-many push (one-to-many push -> your group (if none, create one) -> group code). If you are the creator of the group, you need to click 'View QR code' to scan and bind, otherwise, you won't receive group messages.",
"用户令牌,扫描登录后 我的—>设置->令牌 中获取,参考 https://www.weplusbot.com/": "Token, which can be obtained after scanning and logging in, is available under 'My Account' -> 'Settings' -> 'Tokens'. Please refer to the instructions for detailed steps: https://www.weplusbot.com/",
"消息接收人": "message recipient",
"调用版本;专业版填写pro,个人版填写personal,为空默认使用专业版": "Version, you can specify 'pro' for the Professional version and 'personal' for the Personal version. If left blank, it will default to the Professional version.",
"飞书群组机器人:https://www.feishu.cn/hc/zh-CN/articles/360024984973": "Feishu group bot: https://www.feishu.cn/hc/zh-CN/articles/360024984973",
"邮箱服务名称,比如126、163、Gmail、QQ等,支持列表https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json": "Email service name, e.g., 126, 163, Gmail, QQ, etc. Supported list: https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json",
"邮箱地址": "Email Address",
"SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定": "The SMTP login password may also be a special passphrase, depending on the specific email service provider's instructions",
"PushMe的Keyhttps://push.i-i.me/": "PushMe key, https://push.i-i.me/",
"自建的PushMeServer消息接口地址,例如:http://127.0.0.1:3010,不填则使用官方消息接口": "The self built PushMeServer message interface address, for example: http://127.0.0.1:3010 If left blank, use the official message interface",
"请求方法": "Request Method",
"请求头Content-Type": "Request Header Content-Type",
"请求链接以http或者https开头。url或者body中必须包含$title$content可选,对应api内容的位置": "Request URL should start with http or https. URL or body must contain $title, $content is optional and corresponds to the API content position.",
+6
View File
@@ -336,6 +336,7 @@
"企业微信应用": "企业微信应用",
"智能微秘书": "智能微秘书",
"群晖chat": "群晖chat",
"微加机器人": "微加机器人",
"邮箱": "邮箱",
"飞书机器人": "飞书机器人",
"自定义通知": "自定义通知",
@@ -357,6 +358,7 @@
"BARK推送消息的分组,默认为qinglong": "BARK推送消息的分组,默认为qinglong",
"BARK推送消息的时效性,默认为active": "BARK推送消息的时效性,默认为active",
"BARK推送消息的跳转URL": "BARK推送消息的跳转URL",
"BARK是否保存推送消息": "BARK是否保存推送消息",
"telegram机器人的token,例如:1077xxx4424:AAFjv0FcqxxxxxxgEMGfi22B4yh15R5uw": "telegram机器人的token,例如:1077xxx4424:AAFjv0FcqxxxxxxgEMGfi22B4yh15R5uw",
"telegram用户的id,例如:129xxx206": "telegram用户的id,例如:129xxx206",
"代理IP": "代理IP",
@@ -377,11 +379,15 @@
"iGot的信息推送key,例如:https://push.hellyw.com/XXXXXXXX": "iGot的信息推送key,例如:https://push.hellyw.com/XXXXXXXX",
"微信扫码登录后一对一推送或一对多推送下面的token(您的Token),不提供PUSH_PLUS_USER则默认为一对一推送,参考 https://www.pushplus.plus/": "微信扫码登录后一对一推送或一对多推送下面的token(您的Token),不提供PUSH_PLUS_USER则默认为一对一推送,参考 https://www.pushplus.plus/",
"一对多推送的“群组编码”(一对多推送下面->您的群组(如无则创建)->群组编码,如果您是创建群组人。也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送)": "一对多推送的“群组编码”(一对多推送下面->您的群组(如无则创建)->群组编码,如果您是创建群组人。也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送)",
"用户令牌,扫描登录后 我的—>设置->令牌 中获取,参考 https://www.weplusbot.com/": "用户令牌,扫描登录后 我的—>设置->令牌 中获取,参考 https://www.weplusbot.com/",
"消息接收人": "消息接收人",
"调用版本;专业版填写pro,个人版填写personal,为空默认使用专业版": "调用版本;专业版填写pro,个人版填写personal,为空默认使用专业版",
"飞书群组机器人:https://www.feishu.cn/hc/zh-CN/articles/360024984973": "飞书群组机器人:https://www.feishu.cn/hc/zh-CN/articles/360024984973",
"邮箱服务名称,比如126、163、Gmail、QQ等,支持列表https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json": "邮箱服务名称,比如126、163、Gmail、QQ等,支持列表https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json",
"邮箱地址": "邮箱地址",
"SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定": "SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定",
"PushMe的Keyhttps://push.i-i.me/": "PushMe的Keyhttps://push.i-i.me/",
"自建的PushMeServer消息接口地址,例如:http://127.0.0.1:3010,不填则使用官方消息接口": "自建的PushMeServer消息接口地址,例如:http://127.0.0.1:3010,不填则使用官方消息接口",
"请求方法": "请求方法",
"请求头Content-Type": "请求头Content-Type",
"请求链接以http或者https开头。url或者body中必须包含$title$content可选,对应api内容的位置": "请求链接以http或者https开头。url或者body中必须包含$title$content可选,对应api内容的位置",
+1
View File
@@ -136,6 +136,7 @@ const Config = () => {
lineNumbersMinChars: 3,
folding: false,
glyphMargin: false,
accessibilitySupport: 'off'
}}
onMount={(editor) => {
editorRef.current = editor;
+11 -4
View File
@@ -110,6 +110,7 @@ const CronDetailModal = ({
minimap: { enabled: false },
lineNumbersMinChars: 3,
glyphMargin: false,
accessibilitySupport: 'off',
}}
onMount={(editor, monaco) => {
editorRef.current = editor;
@@ -161,8 +162,9 @@ const CronDetailModal = ({
setValue(data);
}
});
} else if (result) {
} else {
setValidTabs([validTabs[0]]);
setActiveTabKey('log');
}
};
@@ -358,10 +360,15 @@ const CronDetailModal = ({
<Modal
title={
<div className="crontab-title-wrapper">
<div style={{ minWidth: 0 }}>
<div style={{ minWidth: 0, display: 'flex', alignItems: 'center' }}>
<Typography.Text
style={{ width: '100%' }}
ellipsis={{ tooltip: currentCron.name }}
style={{ width: 200, boxSizing: 'content-box' }}
ellipsis={{
onEllipsis(ellipsis) {
return ellipsis;
},
tooltip: currentCron.name,
}}
>
{currentCron.name}
</Typography.Text>
+1
View File
@@ -81,6 +81,7 @@
display: flex;
align-items: center;
justify-content: space-between;
gap: 24px;
.operations {
display: flex;
+7 -9
View File
@@ -75,18 +75,16 @@ const Crontab = () => {
style={{
wordBreak: 'break-all',
marginBottom: 0,
color: '#1890ff'
color: '#1890ff',
cursor: 'pointer'
}}
ellipsis={{ tooltip: text, rows: 2 }}
onClick={() => {
setDetailCron(record);
setIsDetailModalVisible(true);
}}
>
<Link
onClick={() => {
setDetailCron(record);
setIsDetailModalVisible(true);
}}
>
{record.name || '-'}
</Link>
<Link>{record.name || '-'}</Link>
</Paragraph>
),
sorter: {
+1
View File
@@ -242,6 +242,7 @@ const EditModal = ({
minimap: { enabled: false },
lineNumbersMinChars: 3,
glyphMargin: false,
accessibilitySupport: 'off'
}}
onMount={(editor) => {
editorRef.current = editor;
+1
View File
@@ -643,6 +643,7 @@ const Script = () => {
fontSize: 12,
lineNumbersMinChars: 3,
glyphMargin: false,
accessibilitySupport: 'off'
}}
onMount={(editor) => {
editorRef.current = editor;
+31
View File
@@ -95,6 +95,7 @@ export default {
{ value: 'aibotk', label: intl.get('智能微秘书') },
{ value: 'iGot', label: 'IGot' },
{ value: 'pushPlus', label: 'PushPlus' },
{ value: 'wePlusBot', label: intl.get('微加机器人') },
{ value: 'chat', label: intl.get('群晖chat') },
{ value: 'email', label: intl.get('邮箱') },
{ value: 'lark', label: intl.get('飞书机器人') },
@@ -190,6 +191,10 @@ export default {
label: 'barkUrl',
tip: intl.get('BARK推送消息的跳转URL'),
},
{
label: 'barkArchive',
tip: intl.get('BARK是否保存推送消息'),
},
],
telegramBot: [
{
@@ -308,6 +313,27 @@ export default {
),
},
],
wePlusBot: [
{
label: 'wePlusBotToken',
tip: intl.get(
'用户令牌,扫描登录后 我的—>设置->令牌 中获取,参考 https://www.weplusbot.com/',
),
required: true,
},
{
label: 'wePlusBotReceiver',
tip: intl.get(
'消息接收人',
),
},
{
label: 'wePlusBotVersion',
tip: intl.get(
'调用版本;专业版填写pro,个人版填写personal,为空默认使用专业版',
),
},
],
lark: [
{
label: 'larkKey',
@@ -334,6 +360,11 @@ export default {
tip: intl.get('PushMe的Keyhttps://push.i-i.me/'),
required: true,
},
{
label: 'pushMeUrl',
tip: intl.get('自建的PushMeServer消息接口地址,例如:http://127.0.0.1:3010,不填则使用官方消息接口'),
required: false,
},
],
chronocat: [
{
+8 -10
View File
@@ -1,11 +1,9 @@
version: 2.17.4
changeLogLink: https://t.me/jiao_long/405
publishTime: 2024-04-26 22:00
version: 2.17.5
changeLogLink: https://t.me/jiao_long/406
publishTime: 2024-05-25 19:00
changeLog: |
1. 增加示例脚本
2. 修复上传脚本文件名乱码
3. 修复飞书通知结果校验
4. 修复删除日志提示
5. 修复自定义通知 text/plain 类型
6. 修复脚本和日志列表软连接循环报错
7. 修复 python 通知文件自定义 send
1. 修复有可能手动运行任务无日志
2. 重构 JavaScript 脚本通知文件
3. PushMe 通知支持自建服务
4. 增加微加机器人消息通道
5. 修复任务详情查看脚本错误