File tree 2 files changed +11
-4
lines changed
2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -61,9 +61,10 @@ module.exports = (robot) ->
61
61
robot .respond / toggl login (\w {32} ) ([\w\W\d\s ] + )/ , (res ) ->
62
62
token = res .match [1 ]
63
63
secret = res .match [2 ]
64
- unless res .message .room is res .message .user .room
64
+ room = robot .adapter .client .rtm .dataStore .getDMByName res .message .user .name
65
+ unless res .message .room is room .id
65
66
res .reply " only use this command in a private message"
66
- robot .send {room : res . message . user . room }, " Send me toggl command"
67
+ robot .send {room : room . id }, " Send me toggl command"
67
68
return
68
69
if secret .length < 16
69
70
res .reply " the secret minimum length must be 16 characters"
@@ -89,9 +90,10 @@ module.exports = (robot) ->
89
90
price = res .match [2 ]
90
91
secret = res .match [4 ]
91
92
channel = process .env .TOGGL_CHANNEL or " #random"
92
- unless res .message .room is res .message .user .room
93
+ room = robot .adapter .client .rtm .dataStore .getDMByName res .message .user .name
94
+ unless res .message .room is room .id
93
95
res .reply " only use this command in a private message"
94
- robot .send {room : res . message . user . room }, " Send me toggl command"
96
+ robot .send {room : room . id }, " Send me toggl command"
95
97
return
96
98
if secret .length < 16
97
99
res .reply " the secret minimum length must be 16 characters"
Original file line number Diff line number Diff line change @@ -49,6 +49,11 @@ describe "hubot-toggl-payment", ->
49
49
50
50
beforeEach ->
51
51
room = helper .createRoom ({name : " user" })
52
+ room .robot .adapter .client =
53
+ rtm :
54
+ dataStore :
55
+ getDMByName : (name ) ->
56
+ return {id : name, name : name}
52
57
nock .disableNetConnect ()
53
58
54
59
afterEach ->
You can’t perform that action at this time.
0 commit comments