Skip to content
This repository was archived by the owner on Apr 25, 2022. It is now read-only.

Commit b4f6a60

Browse files
committed
优化推送机器人
1 parent f54ac8b commit b4f6a60

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cxmooc-tools",
3-
"version": "2.0.7",
3+
"version": "2.0.8",
44
"description": "> 一个快速学习超星慕课的chrome扩展工具(੧ᐛ੭挂科模式,启动)\r > 初次开发chrome扩展,有兴趣的朋友可以一起来哦",
55
"main": "mooc.js",
66
"scripts": {

src/tg-bot.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,20 @@ const tgBot = new TelegramBot(botToken, { polling: false });
1414
let lastTag = '';
1515
if (branch == tag) {
1616
//获取上一个tag
17-
exec('git describe --tags HEAD^', (err, stdout, stderr) => {
18-
lastTag = stdout.toString().match(/([v\.\d]+)-/)[1];
17+
exec('git describe --tags HEAD^^', (err, stdout, stderr) => {
18+
let match = stdout.toString().match(/([v\.\d]+)-/);
19+
lastTag = match[1];
1920
push();
2021
});
2122
} else {
2223
push();
2324
}
2425
function push() {
25-
exec('git log --pretty=format:"%s" ' + (branch == tag ? tag + '..' + lastTag : commit_range) + (commit_range.search('.') < 0 ? ' -1' : ''), (err, stdout, stderr) => {
26+
let range=commit_range;
27+
if (branch == tag) {
28+
range = tag + '...' + lastTag;
29+
}
30+
exec('git log --pretty=format:"%s" ' + range + (range.search('.') < 0 ? ' -1' : ''), (err, stdout, stderr) => {
2631
let sendText = '';
2732
let end = '';
2833
if (branch == tag) {
@@ -37,6 +42,7 @@ function push() {
3742
sendText += hotUpdate();
3843
}
3944
sendText += "更新了以下内容:\n```\n" + stdout + "\n```\n" + end;
45+
console.log(sendText);
4046
tgBot.sendMessage(chat_id, sendText, { parse_mode: 'Markdown' });
4147
tgBot.sendDocument(chat_id, fs.createReadStream('build/cxmooc-tools.crx'));
4248
});

0 commit comments

Comments
 (0)