提交 b4f6a600 编写于 作者: C CodFrm

优化推送机器人

上级 f54ac8b2
{
"name": "cxmooc-tools",
"version": "2.0.7",
"version": "2.0.8",
"description": "> 一个快速学习超星慕课的chrome扩展工具(੧ᐛ੭挂科模式,启动)\r > 初次开发chrome扩展,有兴趣的朋友可以一起来哦",
"main": "mooc.js",
"scripts": {
......
......@@ -14,15 +14,20 @@ const tgBot = new TelegramBot(botToken, { polling: false });
let lastTag = '';
if (branch == tag) {
//获取上一个tag
exec('git describe --tags HEAD^', (err, stdout, stderr) => {
lastTag = stdout.toString().match(/([v\.\d]+)-/)[1];
exec('git describe --tags HEAD^^', (err, stdout, stderr) => {
let match = stdout.toString().match(/([v\.\d]+)-/);
lastTag = match[1];
push();
});
} else {
push();
}
function push() {
exec('git log --pretty=format:"%s" ' + (branch == tag ? tag + '..' + lastTag : commit_range) + (commit_range.search('.') < 0 ? ' -1' : ''), (err, stdout, stderr) => {
let range=commit_range;
if (branch == tag) {
range = tag + '...' + lastTag;
}
exec('git log --pretty=format:"%s" ' + range + (range.search('.') < 0 ? ' -1' : ''), (err, stdout, stderr) => {
let sendText = '';
let end = '';
if (branch == tag) {
......@@ -37,6 +42,7 @@ function push() {
sendText += hotUpdate();
}
sendText += "更新了以下内容:\n```\n" + stdout + "\n```\n" + end;
console.log(sendText);
tgBot.sendMessage(chat_id, sendText, { parse_mode: 'Markdown' });
tgBot.sendDocument(chat_id, fs.createReadStream('build/cxmooc-tools.crx'));
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册