1 | # Description:
|
2 | # declare events usable programmaticaly by other commands
|
3 | #
|
4 | # Dependencies:
|
5 | #
|
6 | # Configuration:
|
7 | # PHABRICATOR_URL
|
8 | # PHABRICATOR_API_KEY
|
9 | #
|
10 | # Commands:
|
11 | #
|
12 | # Author:
|
13 | # mose
|
14 |
|
15 | Phabricator = require '../lib/phabricator'
|
16 |
|
17 | module.exports = (robot) ->
|
18 |
|
19 | robot.phab ?= new Phabricator robot, process.env
|
20 | phab = robot.phab
|
21 |
|
22 | # robot.respond (
|
23 | # /phtest new ([-_a-zA-Z0-9]+)(?::([-_a-zA-Z0-9]+))? ([^=]+)(?: *@([^=]+))?(?: = (.*))?$/
|
24 | # ), (msg) ->
|
25 | # data =
|
26 | # project: msg.match[1]
|
27 | # template: msg.match[2]
|
28 | # title: msg.match[3]
|
29 | # description: msg.match[5]
|
30 | # user: msg.envelope.user
|
31 | # assign: msg.match[4]
|
32 | # announce: msg.envelope.room
|
33 | # phab.getPermission(msg.envelope.user, 'phuser')
|
34 | # .then ->
|
35 | # robot.emit 'phab.createTask', data
|
36 |
|
37 | robot.on 'phab.createTask', (data) ->
|
38 | phab.createTask(data)
|
39 | .then (res) ->
|
40 | robot.logger.info "Task T#{res.id} created = #{res.url}"
|
41 | if data.announce?
|
42 | robot.messageRoom data.announce, "Task T#{res.id} created = #{res.url}"
|
43 | .catch (e) ->
|
44 | robot.logger.error e
|