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.

30 lines
846 B

9 years ago
  1. require 'slack-ruby-bot'
  2. require 'wolfram'
  3. module NumberManBot
  4. class App < SlackRubyBot::App
  5. operator '='
  6. command 'calculate'
  7. def self.call(client, data, match)
  8. puts match[:expression]
  9. result = Dentaku::Calculator.new.evaluate(match[:expression])
  10. #if match.names.include?('expression')
  11. result = result.to_s if result
  12. if result && result.length > 0
  13. send_message client, data.channel, result
  14. else
  15. send_message client, data.channel, 'Got nothing.'
  16. end
  17. rescue StandardError => e
  18. send_message client, data.channel, "Sorry, #{e.message}."
  19. end
  20. end
  21. class Ping < SlackRubyBot::Commands::Base
  22. def self.call(client, data, _match)
  23. client.message text: 'pong', channel: data.channel
  24. end
  25. end
  26. end
  27. NumberManBot::App.instance.run