Skip to content

Commit df2a032

Browse files
committed
append notice method to Adapter and Robot.Response
1 parent a1ee96d commit df2a032

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/irc.coffee

+20
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ class IrcBot extends Adapter
1515
console.log "#{user.name} #{str}"
1616
@bot.say(user.name, str)
1717

18+
notice: (user, strings...) ->
19+
for str in strings
20+
if not str?
21+
continue
22+
if user.room
23+
console.log "notice #{user.room} #{str}"
24+
@bot.notice(user.room, str)
25+
else
26+
console.log "notice #{user.name} #{str}"
27+
@bot.notice(user.name, str)
28+
1829
reply: (user, strings...) ->
1930
for str in strings
2031
@send user, "#{user.name}: #{str}"
@@ -108,6 +119,15 @@ class IrcBot extends Adapter
108119

109120
@bot = bot
110121

122+
class IrcResponse extends Robot.Response
123+
notice: (strings...) ->
124+
@robot.adapter.notice @message.user, strings...
125+
111126
exports.use = (robot) ->
127+
robot.notice = (user, strings...) ->
128+
@adapter.notice user, strings...
129+
130+
robot.Response = IrcResponse
131+
112132
new IrcBot robot
113133

0 commit comments

Comments
 (0)