You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ignoring message from itself
These things together can loop and flood the server with messages.
I'm lazy to write tests so I'll just leave my monkey-patch for gem v0.3.0. Instead of rewriting dispatch one probably could wrap each "message" callback in one for check but it would be harder with dynamic adding callbacks.
Slack::RealTime::Api::Message.module_eval do
alias :message_old :message
def message *args
message_old *args
sleep 1
end
end
Slack::RealTime::Client.class_eval do
alias :old_initialize :initialize
def initialize *args
old_initialize *args
@callbacks = Hash.new{ |h, k| h[k] = [] }
end
protected
def dispatch event
return false unless event.data
data = JSON.parse event.data
return false unless type = data["type"]
return false unless callbacks = @callbacks[type]
callbacks.each do |c|
c.call data unless type == "message" && self.self["id"] == data["user"]
end.empty? ^ true
end
end
The text was updated successfully, but these errors were encountered:
I don't think this belongs in slack-ruby-client because a message is a message and downstream clients may want to notice that their own message was delivered. However I've implemented this in dblock/slack-ruby-bot@3a54456 for slack-ruby-bot as a feature. Closing this here.
You may be interested in:
These things together can loop and flood the server with messages.
I'm lazy to write tests so I'll just leave my monkey-patch for gem v0.3.0. Instead of rewriting
dispatch
one probably could wrap each "message" callback in one for check but it would be harder with dynamic adding callbacks.The text was updated successfully, but these errors were encountered: