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.

27 lines
642 B

  1. module SlackMathbot
  2. module Commands
  3. class Base
  4. def self.send_message(channel, text)
  5. Slack.chat_postMessage(channel: channel, text: text)
  6. end
  7. def self.send_message_with_gif(channel, text, keywords)
  8. gif = begin
  9. Giphy.random(keywords)
  10. rescue StandardError => e
  11. logger.warn "Giphy.random: #{e.message}"
  12. nil
  13. end
  14. text = text + "\n" + gif.image_url.to_s if gif
  15. send_message channel, text
  16. end
  17. def self.logger
  18. @logger ||= begin
  19. $stdout.sync = true
  20. Logger.new(STDOUT)
  21. end
  22. end
  23. end
  24. end
  25. end