-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
853 additions
and
590 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,36 @@ | ||
const routines = require('hubot-routines') | ||
|
||
module.exports = async msg => { | ||
const user = msg.message.user | ||
const { AbstractView } = require('hubot-engine') | ||
|
||
// if already ill | ||
if (user.sick) { | ||
msg.send('Я уже слышал, что ты болеешь. :thinking:') | ||
|
||
return | ||
class View extends AbstractView { | ||
init (options) { | ||
options.app = 'ill' | ||
} | ||
|
||
const message = routines.buildMessageWithButtons( | ||
'Очень жаль. Ты в состоянии работать из дома в эти дни?', | ||
[ | ||
['Да', 'Болею и работаю'], | ||
['Нет', 'Болею и не работаю'] | ||
] | ||
) | ||
callback (msg) { | ||
const user = msg.message.user | ||
|
||
// if already ill | ||
if (user.sick) { | ||
msg.send('Я уже слышал, что ты болеешь. :thinking:') | ||
|
||
return | ||
} | ||
|
||
const message = routines.buildMessageWithButtons( | ||
'Очень жаль. Ты в состоянии работать из дома в эти дни?', | ||
[ | ||
['Да', 'Болею и работаю'], | ||
['Нет', 'Болею и не работаю'] | ||
] | ||
) | ||
|
||
user.sickConfirming = true | ||
user.sickConfirming = true | ||
|
||
msg.send(message) | ||
this.app.set() | ||
|
||
msg.send(message) | ||
} | ||
} | ||
|
||
module.exports = View |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,30 @@ | ||
const routines = require('hubot-routines') | ||
|
||
module.exports = msg => { | ||
const user = msg.message.user | ||
const { AbstractView } = require('hubot-engine') | ||
|
||
if (user.sick) return | ||
if (!(typeof user.sickConfirming === 'boolean')) return | ||
class View extends AbstractView { | ||
init (options) { | ||
options.app = 'ill' | ||
} | ||
|
||
user.sickConfirming = msg.match[1].toLowerCase() | ||
callback (msg) { | ||
const user = msg.message.user | ||
|
||
const message = routines.buildMessageWithButtons( | ||
'Я понял. Согласовано ли отсутствие с руководителем/тимлидом?', | ||
[ | ||
['Да', 'Да, они предупреждены, что я болею'], | ||
['Нет', 'Нет, они не предупреждены, что я болею'] | ||
] | ||
) | ||
if (user.sick) return | ||
if (!(typeof user.sickConfirming === 'boolean')) return | ||
|
||
msg.send(message) | ||
user.sickConfirming = msg.match[1].toLowerCase() | ||
|
||
const message = routines.buildMessageWithButtons( | ||
'Я понял. Согласовано ли отсутствие с руководителем/тимлидом?', | ||
[ | ||
['Да', 'Да, они предупреждены, что я болею'], | ||
['Нет', 'Нет, они не предупреждены, что я болею'] | ||
] | ||
) | ||
|
||
msg.send(message) | ||
} | ||
} | ||
|
||
module.exports = View |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
const vars = require('../../vars') | ||
const utils = require('../../utils') | ||
const { AbstractView } = require('hubot-engine') | ||
|
||
module.exports = async msg => { | ||
const username = msg.message.user.name | ||
const state = await utils.getStateFromBrain(msg.robot, username) | ||
const answer = msg.match[1].toLowerCase().trim() | ||
class View extends AbstractView { | ||
async callback (msg) { | ||
const username = msg.message.user.name | ||
const state = await utils.getStateFromBrain(msg.robot, username) | ||
const answer = msg.match[1].toLowerCase().trim() | ||
|
||
if (!state.reportToCustomer) { | ||
if (answer === 'да, предупрежден') { | ||
state.reportToCustomer = true | ||
msg.robot.messageRoom(vars.LEAVE_COORDINATION_CHANNEL, `Пользователь @${username} только что сообщил, что предупредил заказчика о своем отпуске.`) | ||
msg.send(':thumbsup:') | ||
} else { | ||
msg.send('Обязательно предупреди! :fearful:') | ||
if (!state.reportToCustomer) { | ||
if (answer === 'да, предупрежден') { | ||
state.reportToCustomer = true | ||
msg.robot.messageRoom(vars.LEAVE_COORDINATION_CHANNEL, `Пользователь @${username} только что сообщил, что предупредил заказчика о своем отпуске.`) | ||
msg.send(':thumbsup:') | ||
} else { | ||
msg.send('Обязательно предупреди! :fearful:') | ||
} | ||
} | ||
} | ||
} | ||
|
||
module.exports = View |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.