mirror of
https://github.com/qitoqito/psyduck.git
synced 2026-01-16 07:30:43 +08:00
Update message.js
This commit is contained in:
parent
19f8ab03d1
commit
46901224d2
@ -5,34 +5,38 @@ export class Message {
|
|||||||
this.func = process.psyDuck
|
this.func = process.psyDuck
|
||||||
this.msg = this.func.message
|
this.msg = this.func.message
|
||||||
this.title = `🐽 消息提醒: ${this.func.profile.title}`
|
this.title = `🐽 消息提醒: ${this.func.profile.title}`
|
||||||
message.push([`PsyDuck [https://github.com/qitoqito/psyduck]`])
|
this.msgAry = message.map(d => d.join("\n"))
|
||||||
this.message = message.map(d => d.join("\n"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async send(msgAry) {
|
async send(msgAry) {
|
||||||
if (this.msg.hasOwnProperty('TELEGRAM_TOKEN')) {
|
const result = this.splitArrays(this.msgAry);
|
||||||
await this.tgNotify()
|
for (let message of result) {
|
||||||
}
|
message.push([`PsyDuck [https://github.com/qitoqito/psyduck]`])
|
||||||
if (this.msg.hasOwnProperty('BARK_TOKEN')) {
|
this.message = message
|
||||||
await this.barkNotify()
|
if (this.msg.hasOwnProperty('TELEGRAM_TOKEN')) {
|
||||||
}
|
await this.tgNotify()
|
||||||
if (this.msg.hasOwnProperty('PUSHPLUS_TOKEN')) {
|
}
|
||||||
await this.ppNotify()
|
if (this.msg.hasOwnProperty('BARK_TOKEN')) {
|
||||||
}
|
await this.barkNotify()
|
||||||
if (this.msg.hasOwnProperty('FTQQ_TOKEN')) {
|
}
|
||||||
await this.ftqqNotify()
|
if (this.msg.hasOwnProperty('PUSHPLUS_TOKEN')) {
|
||||||
}
|
await this.ppNotify()
|
||||||
if (this.msg.hasOwnProperty('DINGTALK_TOKEN')) {
|
}
|
||||||
await this.ddNotify()
|
if (this.msg.hasOwnProperty('FTQQ_TOKEN')) {
|
||||||
}
|
await this.ftqqNotify()
|
||||||
if (this.msg.hasOwnProperty('IGOT_TOKEN')) {
|
}
|
||||||
await this.igotNotify()
|
if (this.msg.hasOwnProperty('DINGTALK_TOKEN')) {
|
||||||
}
|
await this.ddNotify()
|
||||||
if (this.msg.hasOwnProperty('WEIXIN_TOKEN')) {
|
}
|
||||||
await this.wechatNotify()
|
if (this.msg.hasOwnProperty('IGOT_TOKEN')) {
|
||||||
}
|
await this.igotNotify()
|
||||||
if (this.msg.hasOwnProperty('WXAM_TOKEN')) {
|
}
|
||||||
await this.wxamNotify()
|
if (this.msg.hasOwnProperty('WEIXIN_TOKEN')) {
|
||||||
|
await this.wechatNotify()
|
||||||
|
}
|
||||||
|
if (this.msg.hasOwnProperty('WXAM_TOKEN')) {
|
||||||
|
await this.wxamNotify()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,4 +324,26 @@ export class Message {
|
|||||||
console.log('[Message] Telegram 发送通知消息失败')
|
console.log('[Message] Telegram 发送通知消息失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
splitArrays(arr, maxLength = 200) {
|
||||||
|
const result = [];
|
||||||
|
let currentArray = [];
|
||||||
|
let currentLength = 0;
|
||||||
|
for (const subArray of arr) {
|
||||||
|
const subLength = subArray.split("\n").length;
|
||||||
|
if (currentLength + subLength<=maxLength) {
|
||||||
|
currentArray.push(subArray);
|
||||||
|
currentLength += subLength;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result.push(currentArray);
|
||||||
|
currentArray = [subArray];
|
||||||
|
currentLength = subLength;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (currentArray.length>0) {
|
||||||
|
result.push(currentArray);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user