Class: Xify::Input::RocketChat
- Inherits:
-
Base::RocketChat
- Object
- Base::RocketChat
- Xify::Input::RocketChat
- Defined in:
- lib/xify/input/rocket_chat.rb
Instance Method Summary collapse
Methods inherited from Base::RocketChat
Constructor Details
This class inherits a constructor from Xify::Base::RocketChat
Instance Method Details
#updates ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/xify/input/rocket_chat.rb', line 13 def updates login EM.run do config = @config uri = URI.parse config['uri'] meteor = Metybur.connect "wss://#{uri.host}:#{uri.port}/websocket" meteor.login resume: @auth_data['authToken'] do meteor.subscribe 'stream-notify-user', "#{result[:id]}/rooms-changed", false = meteor.collection 'stream-notify-user' .on(:changed) do |id, attributes| event = attributes[:args].last room = event[:name] = event[:lastMessage] next if [:editedAt] || room != config['channel'][1..-1] = [:u][:name] text = [:msg] time = [:ts][:'$date'] type = event[:t] == 'p' ? 'group' : 'channel' yield Xify::Event.new , text, parent: "##{room}", parent_link: "#{config['uri']}/#{type}/#{room}", time: Time.at(time / 1000) end end end end |