Skip to content

Commit 9159d28

Browse files
committed
Use enter/leave messages on enter/leave events.
1 parent 8d33bdd commit 9159d28

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/irc.coffee

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Robot = require('hubot').Robot
22
Adapter = require('hubot').Adapter
33
TextMessage = require('hubot').TextMessage
4+
EnterMessage = require('hubot').EnterMessage
5+
LeaveMessage = require('hubot').LeaveMessage
46
Response = require('hubot').Response
57

68
Irc = require 'irc'
@@ -36,12 +38,17 @@ class IrcBot extends Adapter
3638
self = @
3739
@bot.join channel, () ->
3840
console.log('joined %s', channel)
39-
self.emit 'joined'
41+
42+
user = self.userForName @bot.name
43+
self.receive new EnterMessage(user)
4044

4145
part: (channel) ->
4246
@bot.part channel, () ->
4347
console.log('left %s', channel)
4448

49+
user = self.userForName @bot.name
50+
self.receive new LeaveMessage(user)
51+
4552
kick: (channel, client, message) ->
4653
@bot.emit 'raw',
4754
command: 'KICK'
@@ -96,7 +103,7 @@ class IrcBot extends Adapter
96103

97104
bot.addListener 'message', (from, to, message) ->
98105
console.log "From #{from} to #{to}: #{message}"
99-
106+
100107
user = self.userForName from
101108
unless user?
102109
id = (new Date().getTime() / 1000).toString().replace('.','')
@@ -121,9 +128,15 @@ class IrcBot extends Adapter
121128
bot.addListener 'join', (channel, who) ->
122129
console.log('%s has joined %s', who, channel)
123130

131+
user = self.userForName who
132+
self.receive new EnterMessage(user)
133+
124134
bot.addListener 'part', (channel, who, reason) ->
125135
console.log('%s has left %s: %s', who, channel, reason)
126136

137+
user = self.userForName who
138+
self.receive new LeaveMessage(user)
139+
127140
bot.addListener 'kick', (channel, who, _by, reason) ->
128141
console.log('%s was kicked from %s by %s: %s', who, channel, _by, reason)
129142

0 commit comments

Comments
 (0)