Skip to content

Commit

Permalink
Display typing indicator to channel while searching an issue in Jira
Browse files Browse the repository at this point in the history
  • Loading branch information
okovpashko committed Aug 14, 2017
1 parent e904014 commit 8edb44d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions jira-bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class JiraBot extends EventEmitter {
this.slack.sendMessage.apply(this.slack, args);
}

sendTyping(...args) {
this.slack.sendTyping.apply(this.slack, args);
}

_onOpen(rtmStartData) {
log.info(`Connected to Slack. You are @${rtmStartData.self.name} of "${rtmStartData.team.name}" team`);
}
Expand Down
8 changes: 5 additions & 3 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@ const JiraTicket = require('./jira-ticket');
const JiraBot = require('./jira-bot');
const log = require('winston');

let jiraTicket = new JiraTicket(config.jira),
jiraBot = new JiraBot(config.slack);
const jiraTicket = new JiraTicket(config.jira);
const jiraBot = new JiraBot(config.slack);

jiraBot.on('ticketKeyFound', (key, channel) => {
jiraBot.sendTyping(channel.id);

jiraTicket.get(key, function(error, ticket) {
if (error) {
return;
}

const message = `>*${ticket.key}*\n>${ticket.summary}\n>Status: ${ticket.status}\n>${ticket.url}`;
jiraBot.sendMessage(message, channel.id, (error) => {
if(error) {
if (error) {
log.error('Error while posting issue info to Slack', error);
return;
}
Expand Down

0 comments on commit 8edb44d

Please sign in to comment.