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.

50 lines
1.2 KiB

  1. require 'slack-ruby-bot'
  2. require 'wolfram'
  3. module NumberManBot
  4. class App < SlackRubyBot::App
  5. end
  6. class Weather < SlackRubyBot::Commands::Base
  7. match(/^How is the weather in (?<location>\w*)\?$/i) do |client, data, match|
  8. send_message client, data.channel, "The weather in #{match[:location]} is nice."
  9. end
  10. end
  11. class Calculator < SlackRubyBot::Commands::Base
  12. operator '=' do |client, _data, _match|
  13. # implementation detail
  14. Wolfram.appid = "R3KHQ2-2T2769PP4P"
  15. eq = _match[1..-1]
  16. result = Wolfram.fetch(eq[1])
  17. # to see the result as a hash of pods and assumptions:
  18. hash = Wolfram::HashPresenter.new(result).to_hash
  19. puts hash
  20. pods = hash[:pods]
  21. result = pods["Result"]
  22. #solution = pods["Real solutions"]
  23. puts result
  24. if result != nil
  25. result[0].sub! "~~", ""
  26. send_message client, _data.channel, result[0]
  27. else
  28. solution = pods["Real solution"]
  29. puts solution
  30. if solution != nil
  31. solution[0].sub! "~~", ""
  32. send_message client, _data.channel, solution[0]
  33. else
  34. solution = pods["Real solutions"]
  35. solution[0].sub! "~~", ""
  36. puts solution
  37. send_message client, _data.channel, solution[0]
  38. end
  39. end
  40. end
  41. end
  42. end
  43. NumberManBot::App.instance.run