Skip to content

Commit

Permalink
ver 0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Черный Евгений committed Feb 19, 2019
1 parent d29e84d commit 1b576fc
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 10 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
node_modules
*.vsix
launch.json
package-lock.json
*.vsix
.taskkey
2 changes: 1 addition & 1 deletion .taskkey
Original file line number Diff line number Diff line change
@@ -1 +1 @@
728eb7e2-0e28-4775-a30f-fe219e86744f
003e05ea-7788-415d-9d1b-69bbd914ca2a
2 changes: 1 addition & 1 deletion SendTelegramNotification/.taskkey
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f124873c-4800-437d-9de2-f662f5c7d186
b8c970cc-5182-43fa-a088-312f29c34f69
30 changes: 30 additions & 0 deletions SendTelegramNotification/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions SendTelegramNotification/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"author": "Evgeny Chernyi",
"license": "MIT",
"dependencies": {
"https-proxy-agent": "^2.2.1",
"telegraf": "^3.20.0",
"vso-task-lib": "^0.5.5",
"vsts-task-lib": "^2.4.0"
Expand Down
9 changes: 6 additions & 3 deletions SendTelegramNotification/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ const Telegram = require('telegraf/telegram');
const Telegraf = require('telegraf');
const tgtools = require('./tgtools');


if (tl.getBoolInput('getChatId',false)) {
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
console.log("You now can get chat IDs from your chats \n Use /chat command to get the ID \n Then /stop to finish the task");
const bot = new Telegraf(tl.getInput('botToken', true));
console.log("You now can get chat IDs from your chats: \n - Use /chat command to get the ID \n - Then /stop to finish the task \n\n *If something goes wrong - clear chat history*");
const bot = new Telegraf(tl.getInput('botToken', true),{
telegram: tgtools.getProxyCfg()
});
bot.command('/chat', (ctx) => ctx.reply(ctx.chat));
bot.command('/stop', function () { bot.stop(); });
bot.startPolling();
Expand Down Expand Up @@ -77,7 +80,7 @@ function run() {
}


const telegram = new Telegram(token);
const telegram = new Telegram(token, tgtools.getProxyCfg());
chats.forEach(chat => {
telegram.sendMessage(chat,body, {parse_mode: 'HTML'});
});
Expand Down
46 changes: 46 additions & 0 deletions SendTelegramNotification/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,52 @@
"helpMarkDown": "Target chat id's to notify (use comma as a delimiter). [More information about chat id] ()",
"visibleRule":"getChatId = false"
},
{
"name": "useProxy",
"type": "boolean",
"label": "Use proxy",
"defaultValue": "false",
"required": false,
"groupName": "botConfig"
},
{
"name": "proxyHost",
"type": "string",
"label": "Host",
"defaultValue": "",
"required": false,
"groupName": "botConfig",
"visibleRule":"useProxy = true"
},
{
"name": "proxyPort",
"type": "string",
"label": "Port",
"defaultValue": "",
"required": false,
"groupName": "botConfig",
"visibleRule":"useProxy = true"
},
{
"name": "proxyUsername",
"type": "string",
"label": "Username",
"defaultValue": "",
"required": false,
"groupName": "botConfig",
"visibleRule":"useProxy = true",
"helpMarkDown": "(*optional*)"
},
{
"name": "proxyPassword",
"type": "string",
"label": "Password",
"defaultValue": "",
"required": false,
"groupName": "botConfig",
"visibleRule":"useProxy = true",
"helpMarkDown": "(*optional*)"
},
{
"name": "taskStatus",
"type": "boolean",
Expand Down
26 changes: 24 additions & 2 deletions SendTelegramNotification/tgtools.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
// <a href="http://www.example.com/">inline URL</a>
const SocksAgent = require('socks5-https-client/lib/Agent');
const tl = require("vsts-task-lib/task");

exports.tglinkbuilder = function (href,linkText) {
return "<a href=\""+ encodeURI(href) +"\">"+linkText+"</a>";
};
return "<a href=\""+ encodeURI(href) +"\">"+linkText+"</a>"
};

exports.getProxyCfg = function (){
var config = {};
if(tl.getBoolInput("useProxy",false))
{
config = configbuilder(tl.getInput('proxyHost',false),tl.getInput('proxyPort',false),tl.getInput('proxyUsername',false),tl.getInput('proxyPassword',false));
}
return config;
};

// {agent: proxyAgent}
configbuilder = function (host, port, username = null, password = null) {
var socksAgent = new SocksAgent({
socksHost: host,
socksPort: port,
socksUsername: username,
socksPassword: password,
});
return {agent: socksAgent}
};
4 changes: 2 additions & 2 deletions vss-extension.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"manifestVersion": 1,
"id": "telegram-notification-extension",
"version": "0.0.33",
"name": "Telegram Notification",
"version": "0.1.1",
"publisher": "EvgenyChernyi",
"description": "Send custom notifications about your build/release process to Telegram",
"targets": [
Expand All @@ -29,7 +29,7 @@
"vso.work"
],
"categories": [
"Build and release"
"Azure Pipelines"
],
"branding": {
"color": "rgb(4, 4, 5)",
Expand Down

0 comments on commit 1b576fc

Please sign in to comment.