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.

19 lines
577 B

  1. module SlackMathbot
  2. module Commands
  3. class Calculate < SlackRubyBot::Commands::Base
  4. operator '='
  5. def self.call(data, _command, arguments)
  6. result = Dentaku::Calculator.new.evaluate(arguments.join)
  7. result = result.to_s if result
  8. if result && result.length > 0
  9. send_message data.channel, result
  10. else
  11. send_message_with_gif data.channel, 'Got nothing.', 'nothing'
  12. end
  13. rescue StandardError => e
  14. send_message_with_gif data.channel, "Sorry, #{e.message}.", 'idiot'
  15. end
  16. end
  17. end
  18. end