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.

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