examples/inventory/inventorybot.rb in slack-ruby-bot-0.12.0 vs examples/inventory/inventorybot.rb in slack-ruby-bot-0.13.0
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
require 'slack-ruby-bot'
require 'sqlite3'
# Demonstrate the usage of the Model, View, and Controller
# classes to build an inventory bot.
@@ -54,10 +56,11 @@
private
def notify_admin
row = _row.first
return if row[:quantity].to_i.zero?
+
view.email_admin("Inventory item #{row[:name]} needs to be refilled.")
view.say(channel: data.channel, text: "Administrator notified via email to refill #{row[:name]}.")
end
def around_reaction
@@ -91,10 +94,11 @@
s = @db.prepare 'SELECT * FROM Inventory'
results = s.execute
count = 0
count += 1 while results.next
return if count < 4
+
add_item "'Audi',3,52642"
add_item "'Mercedes',1,57127"
add_item "'Skoda',5,9000"
add_item "'Volvo',1,29000"
end
@@ -239,10 +243,10 @@
#
model = InventoryModel.new
view = InventoryView.new
@controller = InventoryController.new(model, view)
@controller.class.command_class.routes.each do |route|
- STDERR.puts route.inspect
+ warn route.inspect
end
end
InventoryBot.run