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.

21 lines
676 B

  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
  8. result = Dentaku::Calculator.new.evaluate(match[:expression]) if match.names.include?('expression')
  9. result = result.to_s if result
  10. if result && result.length > 0
  11. send_message client, data.channel, result
  12. else
  13. send_message client, data.channel, 'Got nothing.'
  14. end
  15. rescue StandardError => e
  16. send_message client, data.channel, "Sorry, #{e.message}."
  17. end
  18. end
  19. end
  20. end