Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/slack.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Util = require 'util'

class SlackBot extends Adapter
@MAX_MESSAGE_LENGTH: 4000
@LAST_MESSAGE_TIMESTAMP_KEY = 'SlackLastMessageTimestamp'

constructor: (robot) ->
@robot = robot
Expand Down Expand Up @@ -91,6 +92,12 @@ class SlackBot extends Adapter
process.exit 0

message: (msg) =>
# Ignore messages we've already seen
lastMessageTimestamp = @robot.brain.get SlackBot.LAST_MESSAGE_TIMESTAMP_KEY
lastMessageTimestamp ?= -Infinity
return if msg.ts <= lastMessageTimestamp
@robot.brain.set SlackBot.LAST_MESSAGE_TIMESTAMP_KEY, msg.ts

# Ignore our own messages
return if msg.user == @self.id

Expand Down