litaio / lita

ChatOps for Ruby.
https://www.lita.io
MIT License
1.68k stars 179 forks source link

Accept adapter specific messages #138

Closed jaisonerick closed 9 years ago

jaisonerick commented 9 years ago

I put this approach in discussion at https://github.com/kenjij/lita-slack/issues/30.

The idea here is that the handler can create a class, implementing any to_adapter methods it can support, and lita would call the adapter correspondent method. If the adapter isn't supported, a fallback to_s method must exist. Here is a sample class that the handler could create:

class Message
  def initialize(message)
    @message = message
  end

  def to_slack
    @message
  end

  def to_s
    @message[:text]
  end
end
assimovt commented 9 years ago

This one would be so great to have! :+1:

jimmycuadra commented 9 years ago

Thanks for the PR! I'm going to be approaching adapter-specific functionality in a different way, but it will be coming very soon! Stay tuned.