Class: Del::Robot
- Inherits:
-
Object
- Object
- Del::Robot
- Defined in:
- lib/del/robot.rb
Overview
A funky robo-sapien.
Instance Attribute Summary collapse
-
#jid ⇒ Object
readonly
Returns the value of attribute jid.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #get_funky!(start_server: true) ⇒ Object
-
#initialize(configuration: Del.configuration) ⇒ Robot
constructor
A new instance of Robot.
- #receive(message, source:) ⇒ Object
- #send_message(jid, message) ⇒ Object
Constructor Details
#initialize(configuration: Del.configuration) ⇒ Robot
Returns a new instance of Robot.
8 9 10 11 12 |
# File 'lib/del/robot.rb', line 8 def initialize(configuration: Del.configuration) @configuration = configuration @jid = configuration.jid @name = configuration.name end |
Instance Attribute Details
#jid ⇒ Object (readonly)
Returns the value of attribute jid.
6 7 8 |
# File 'lib/del/robot.rb', line 6 def jid @jid end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/del/robot.rb', line 6 def name @name end |
Instance Method Details
#get_funky!(start_server: true) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/del/robot.rb', line 14 def get_funky!(start_server: true) Del.logger.info('🔥🔥🔥') xmpp_connection.connect(self) if start_server deltron = Del::Tron.new(self, configuration) socket_server.run(deltron) end rescue Interrupt xmpp_connection.disconnect end |
#receive(message, source:) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/del/robot.rb', line 25 def receive(, source:) return if source.from?(self) configuration.router.route( Message.new(, robot: self, source: source) ) end |
#send_message(jid, message) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/del/robot.rb', line 33 def (jid, ) if user?(jid) xmpp_connection.deliver(jid, ) else xmpp_connection.deliver_to_room(jid, ) end end |