Commit 78633a0
Changed files (5)
lib/del/configuration.rb
@@ -61,6 +61,7 @@ module Del
def load(file)
return if file.nil?
return Kernel.load(file) if File.exist?(file)
+
download(file)
end
lib/del/default_router.rb
@@ -15,6 +15,7 @@ module Del
def route(message)
@routes.each do |route|
next unless (matches = route[:pattern].match(message.text))
+
begin
route[:command].call(message, matches)
rescue StandardError => error
lib/del/robot.rb
@@ -24,6 +24,7 @@ module Del
def receive(message, source:)
return if source.from?(self)
+
configuration.router.route(
Message.new(message, robot: self, source: source)
)
lib/del/user.rb
@@ -20,6 +20,7 @@ module Del
def self.map_from(attributes)
return nil if attributes.nil?
+
new(attributes['jid'], attributes)
end
end
lib/del/xmpp_connection.rb
@@ -91,6 +91,7 @@ module Del
def listen_for_direct_messages(robot)
client.add_message_callback do |message|
next if message.type == :error || message.body.nil?
+
user = configuration.users.find(message.from.strip)
robot.receive(message.body, source: Source.new(user: user))
end