Sha256: 7c9f0adb5a37f1990f829f961f6b9eb6a9a7fcd47b53cbc8d00de0fc74b90dc2
Contents?: true
Size: 1.29 KB
Versions: 6
Compression:
Stored size: 1.29 KB
Contents
module Del class Robot attr_reader :jid, :name def initialize(configuration: Del.configuration) @configuration = configuration @jid = configuration.jid @name = configuration.name end def get_funky!(start_server: true) Del.logger.info("🔥🔥🔥") xmpp_connection.connect(self) socket_server.run(self) if start_server rescue Interrupt xmpp_connection.disconnect end def receive(message, source:) return if source.from?(self) configuration.router.route(Message.new(message, robot: self, source: source)) end def send_message(jid, message) if user?(jid) xmpp_connection.deliver(jid, message) else xmpp_connection.deliver_to_room(jid, message) end end def execute(request) case request['command'] when 'send_message' send_message(request['jid'], request['message']) "Sent!" else "Unknown" end end private attr_reader :configuration def xmpp_connection @xmpp_connection ||= Connection.new(configuration: configuration) end def socket_server @socket_server ||= SocketServer.new(socket_file: configuration.socket_file) end def user?(jid) configuration.users[jid] end end end
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
del-0.1.16 | lib/del/robot.rb |
del-0.1.15 | lib/del/robot.rb |
del-0.1.14 | lib/del/robot.rb |
del-0.1.13 | lib/del/robot.rb |
del-0.1.12 | lib/del/robot.rb |
del-0.1.11 | lib/del/robot.rb |