Skip to content

Commit

Permalink
✨ 优雅的消息推送格式
Browse files Browse the repository at this point in the history
  • Loading branch information
imoki committed Jun 20, 2024
1 parent e9cce1c commit ade6217
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions polymerization/caiyun.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// 中国移动云盘签到
// 20240512
// 20240620
// 文中引用代码改编自公众号"Jerry不是猫"

pushData = []
Expand Down Expand Up @@ -37,7 +37,7 @@ var jsonEmail = {
flagConfig = ActivateSheet(sheetNameConfig); // 激活推送表
// 主配置工作表存在
if (flagConfig == 1) {
console.log("开始读取主配置表");
console.log("🍳 开始读取主配置表");
let name; // 名称
let onlyError;
let nickname;
Expand All @@ -53,12 +53,12 @@ if (flagConfig == 1) {
if (name == sheetNameSubConfig) {
if (onlyError == "是") {
messageOnlyError = 1;
console.log("只推送错误消息");
console.log("🍳 只推送错误消息");
}

if (nickname == "是") {
messageNickname = 1;
console.log("单元格用昵称替代");
console.log("🍳 单元格用昵称替代");
}

break; // 提前退出,提高效率
Expand All @@ -69,7 +69,7 @@ if (flagConfig == 1) {
flagPush = ActivateSheet(sheetNamePush); // 激活推送表
// 推送工作表存在
if (flagPush == 1) {
console.log("开始读取推送工作表");
console.log("🍳 开始读取推送工作表");
let pushName; // 推送类型
let pushKey;
let pushFlag; // 是否推送标志
Expand All @@ -92,7 +92,7 @@ emailConfig();

flagSubConfig = ActivateSheet(sheetNameSubConfig); // 激活分配置表
if (flagSubConfig == 1) {
console.log("开始读取分配置表");
console.log("🍳 开始读取分配置表");
for (let i = 2; i <= line; i++) {
var cookie = Application.Range("A" + i).Text;
var exec = Application.Range("B" + i).Text;
Expand Down Expand Up @@ -151,7 +151,7 @@ function push(message) {
}
}
} else {
console.log("消息为空不推送");
console.log("🍳 消息为空不推送");
}
}

Expand Down Expand Up @@ -220,14 +220,14 @@ function email(message) {
subject: pushHeader + " - " + data_time,
text: message,
});
// console.log("已发送邮件至:" + sender);
console.log("已发送邮件");
// console.log("🍳 已发送邮件至:" + sender);
console.log("🍳 已发送邮件");
sleep(5000);
}

// 邮箱配置
function emailConfig() {
console.log("开始读取邮箱配置");
console.log("🍳 开始读取邮箱配置");
let length = jsonPush.length; // 因为此json数据可无序,因此需要遍历
let name;
for (let i = 0; i < length; i++) {
Expand All @@ -240,7 +240,7 @@ function emailConfig() {
// 'email':'', 'port':'', 'sender':'', 'authorizationCode':''
// } // 有效配置
if (flag == 1) {
console.log("开始读取邮箱表");
console.log("🍳 开始读取邮箱表");
for (let i = 2; i <= 2; i++) {
// 从工作表中读取推送数据
jsonEmail.server = Application.Range("A" + i).Text;
Expand Down Expand Up @@ -285,11 +285,11 @@ function ActivateSheet(sheetName) {
// 激活工作表
let sheet = Application.Sheets.Item(sheetName);
sheet.Activate();
console.log("激活工作表:" + sheet.Name);
console.log("🥚 激活工作表:" + sheet.Name);
flag = 1;
} catch {
flag = 0;
console.log("无法激活工作表,工作表可能不存在");
console.log("🍳 无法激活工作表,工作表可能不存在");
}
return flag;
}
Expand Down Expand Up @@ -2206,7 +2206,7 @@ ${text}`
// ../utils/index.ts
function getPushConfig() {
let usedRange2 = Application.Sheets.Item("\u63A8\u9001").UsedRange;
if (!usedRange2) return console.log("\u672A\u5F00\u542F\u63A8\u9001"), {};
if (!usedRange2) return console.log("🍳 \u672A\u5F00\u542F\u63A8\u9001"), {};
let cells = usedRange2.Columns.Cells, columnEnd = Math.min(50, usedRange2.ColumnEnd), rowEnd = Math.min(50, usedRange2.RowEnd), pushConfig = {};
for(let option = usedRange2.Column; option <= columnEnd; option++){
let t = {}, item = cells.Item(option);
Expand Down Expand Up @@ -2363,7 +2363,7 @@ ${text}`
}, {
pushData: pushData
});
// newAuth && (console.log("\u66F4\u65B0 auth \u6210\u529F"), cell.Text.length === 11 ? BColumn.Rows(i).Value = newAuth : AColumn.Rows(i).Value = newAuth);
// newAuth && (console.log("🍳 \u66F4\u65B0 auth \u6210\u529F"), cell.Text.length === 11 ? BColumn.Rows(i).Value = newAuth : AColumn.Rows(i).Value = newAuth);
newAuth
} catch (error) {
console.log(error.message);
Expand All @@ -2389,7 +2389,7 @@ function execHandle(cookie, pos) {
}

posLabel = pos-2 ; // 存放下标,从0开始
messageHeader[posLabel] = messageName
messageHeader[posLabel] = "👨‍🚀" + messageName
// try {

// var sheet = Application.Sheets.Item("\u79FB\u52A8\u4E91\u76D8") || Application.Sheets.Item("caiyun") || ActiveSheet, usedRange = sheet.UsedRange, AColumn = sheet.Columns("A"), len = usedRange.Row + usedRange.Rows.Count - 1, BColumn = sheet.Columns("B"), pushData = [];
Expand Down Expand Up @@ -2423,8 +2423,8 @@ function execHandle(cookie, pos) {
}

}
console.log(msg)
messageSuccess += msg
console.log( "🎉" + msg)
messageSuccess += "🎉" + msg + "\n"

// messageSuccess += msg[0]
// messageFail += msg[1]
Expand Down

0 comments on commit ade6217

Please sign in to comment.