Sha256: eead62d4889f1f1b15f26f6a0cfda2685e1fa966fcb97d61873e42fb31609729

Contents?: true

Size: 730 Bytes

Versions: 3

Compression:

Stored size: 730 Bytes

Contents

module Messenger
  module Bot
    class Receiver
      def self.share(data)
        messaging_events = data["entry"].first["messaging"]
        messaging_events.each_with_index do |event, key|
          if event["message"]
            self.class.send(:message, event)
          elsif event["postback"]
            self.class.send(:postback, event)
          elsif event["delivery"]
            self.class.send(:delivery, event)
          end 
        end 
      end

      def self.define_event(event, &block)
        self.class.instance_eval do
          define_method(event.to_sym) do |event|
            yield(event, Messenger::Bot::Transmitter.new(event["sender"]["id"]))
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
messenger-bot-0.1.6 lib/messenger/bot/receiver.rb
messenger-bot-0.1.5 lib/messenger/bot/receiver.rb
messenger-bot-0.1.4 lib/messenger/bot/receiver.rb