From 341243b3d0ec57735b07531ed65219d08029f968 Mon Sep 17 00:00:00 2001 From: Daniel Muckerman Date: Wed, 25 Nov 2015 17:23:27 -0500 Subject: [PATCH] Hopefully fixed the bot --- numberman.rb | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/numberman.rb b/numberman.rb index 5c4ddc4..d32597f 100644 --- a/numberman.rb +++ b/numberman.rb @@ -3,21 +3,6 @@ require 'wolfram' module NumberManBot class App < SlackRubyBot::App - operator '=' - command 'calculate' - def self.call(client, data, match) - puts match[:expression] - result = Dentaku::Calculator.new.evaluate(match[:expression]) - #if match.names.include?('expression') - result = result.to_s if result - if result && result.length > 0 - send_message client, data.channel, result - else - send_message client, data.channel, 'Got nothing.' - end - rescue StandardError => e - send_message client, data.channel, "Sorry, #{e.message}." - end end class Ping < SlackRubyBot::Commands::Base @@ -25,6 +10,19 @@ module NumberManBot client.message text: 'pong', channel: data.channel end end + + class Weather < SlackRubyBot::Commands::Base + match(/^How is the weather in (?\w*)\?$/i) do |client, data, match| + send_message client, data.channel, "The weather in #{match[:location]} is nice." + end + end + + class Calculator < SlackRubyBot::Commands::Base + operator '=' do |_data, _match| + # implementation detail + send_message client, data.channel, "The weather in the net is nice." + end + end end NumberManBot::App.instance.run