A Slack Bot that pulls Pixiv information and posts the full image(s) into Slack, with iOS shortcuts.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
690 B

9 years ago
9 years ago
  1. module SlackMathbot
  2. module Commands
  3. class Calculate < SlackRubyBot::Commands::Base
  4. operator '='
  5. command 'calculate'
  6. def self.call(client, data, match)
  7. send_message client, data.channel, match[:expression]
  8. result = Dentaku::Calculator.new.evaluate(match[:expression])
  9. #if match.names.include?('expression')
  10. result = result.to_s if result
  11. if result && result.length > 0
  12. send_message client, data.channel, result
  13. else
  14. send_message client, data.channel, 'Got nothing.'
  15. end
  16. rescue StandardError => e
  17. send_message client, data.channel, "Sorry, #{e.message}."
  18. end
  19. end
  20. end
  21. end