|
|
@ -4,16 +4,16 @@ module SlackMathbot |
|
|
|
operator '=' |
|
|
|
command 'calculate' |
|
|
|
|
|
|
|
def self.call(data, match) |
|
|
|
def self.call(client, data, match) |
|
|
|
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 data.channel, result |
|
|
|
send_message client, data.channel, result |
|
|
|
else |
|
|
|
send_message_with_gif data.channel, 'Got nothing.', 'nothing' |
|
|
|
send_message_with_gif client, data.channel, 'Got nothing.', 'nothing' |
|
|
|
end |
|
|
|
rescue StandardError => e |
|
|
|
send_message_with_gif data.channel, "Sorry, #{e.message}.", 'idiot' |
|
|
|
send_message_with_gif client, data.channel, "Sorry, #{e.message}.", 'idiot' |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|