1
1
Robot = require (' hubot' ).Robot
2
2
Adapter = require (' hubot' ).Adapter
3
3
TextMessage = require (' hubot' ).TextMessage
4
+ EnterMessage = require (' hubot' ).EnterMessage
5
+ LeaveMessage = require (' hubot' ).LeaveMessage
4
6
Response = require (' hubot' ).Response
5
7
6
8
Irc = require ' irc'
@@ -36,12 +38,17 @@ class IrcBot extends Adapter
36
38
self = @
37
39
@bot .join channel, () ->
38
40
console .log (' joined %s' , channel)
39
- self .emit ' joined'
41
+
42
+ user = self .userForName @bot .name
43
+ self .receive new EnterMessage (user)
40
44
41
45
part : (channel ) ->
42
46
@bot .part channel, () ->
43
47
console .log (' left %s' , channel)
44
48
49
+ user = self .userForName @bot .name
50
+ self .receive new LeaveMessage (user)
51
+
45
52
kick : (channel , client , message ) ->
46
53
@bot .emit ' raw' ,
47
54
command : ' KICK'
@@ -96,7 +103,7 @@ class IrcBot extends Adapter
96
103
97
104
bot .addListener ' message' , (from , to , message ) ->
98
105
console .log " From #{ from } to #{ to} : #{ message} "
99
-
106
+
100
107
user = self .userForName from
101
108
unless user?
102
109
id = (new Date ().getTime () / 1000 ).toString ().replace (' .' ,' ' )
@@ -121,9 +128,15 @@ class IrcBot extends Adapter
121
128
bot .addListener ' join' , (channel , who ) ->
122
129
console .log (' %s has joined %s' , who, channel)
123
130
131
+ user = self .userForName who
132
+ self .receive new EnterMessage (user)
133
+
124
134
bot .addListener ' part' , (channel , who , reason ) ->
125
135
console .log (' %s has left %s: %s' , who, channel, reason)
126
136
137
+ user = self .userForName who
138
+ self .receive new LeaveMessage (user)
139
+
127
140
bot .addListener ' kick' , (channel , who , _by , reason ) ->
128
141
console .log (' %s was kicked from %s by %s: %s' , who, channel, _by, reason)
129
142
0 commit comments