From f77c098a25cf723e4ceec05d6175c0838bc64a5e Mon Sep 17 00:00:00 2001 From: Daniel Muckerman Date: Sun, 17 Jan 2016 21:44:33 -0500 Subject: [PATCH] Created pixiv command --- slack-pixiv.rb | 2 +- slack-pixiv/commands/calculate.rb | 64 ------------------------------- slack-pixiv/commands/pixiv.rb | 13 +++++++ 3 files changed, 14 insertions(+), 65 deletions(-) delete mode 100644 slack-pixiv/commands/calculate.rb create mode 100644 slack-pixiv/commands/pixiv.rb diff --git a/slack-pixiv.rb b/slack-pixiv.rb index 43d6f12..a1f34da 100644 --- a/slack-pixiv.rb +++ b/slack-pixiv.rb @@ -1,4 +1,4 @@ require 'slack-ruby-bot' require 'wolfram' -require 'slack-pixiv/commands/calculate' +require 'slack-pixiv/commands/pixiv' require 'slack-pixiv/app' diff --git a/slack-pixiv/commands/calculate.rb b/slack-pixiv/commands/calculate.rb deleted file mode 100644 index 4761f0b..0000000 --- a/slack-pixiv/commands/calculate.rb +++ /dev/null @@ -1,64 +0,0 @@ -module SlackMathbot - module Commands - class Calculator < SlackRubyBot::Commands::Base - operator '=' do |client, _data, _match| - # Set API key (donut steal) - Wolfram.appid = "R3KHQ2-2T2769PP4P" - - # Get equation part of argument - eq = _match[1..-1] - - # Get results from Wolfram Alpha - result = Wolfram.fetch(eq[1]) - - # Get hash of results - hash = Wolfram::HashPresenter.new(result).to_hash - - # Debug output hash - puts hash - - # Breakdown hash - pods = hash[:pods] - - # Try for results - result = pods["Result"] - puts result - - # If result exists - if result != nil - # Prettify equivalency - result[0].sub! "~~", "≈" - send_message client, _data.channel, result[0] - else - # If result doesn't exist, look for the real solution - solution = pods["Real solution"] - puts solution - - # If the real solution exists - if solution != nil - # Prettify equivalency - solution[0].sub! "~~", "≈" - send_message client, _data.channel, solution[0] - else - # Check the other possible name for real solutions - solution = pods["Real solutions"] - - if solution != nil - # Prettify equivalency - solution[0].sub! "~~", "≈" - puts solution - send_message client, _data.channel, solution[0] - else - decimal = pods["Decimal approximation"] - - if decimal != nil - puts decimal - send_message client, _data.channel, decimal[0] - end - end - end - end - end - end - end -end diff --git a/slack-pixiv/commands/pixiv.rb b/slack-pixiv/commands/pixiv.rb new file mode 100644 index 0000000..4cb0622 --- /dev/null +++ b/slack-pixiv/commands/pixiv.rb @@ -0,0 +1,13 @@ +# coding: utf-8 +module SlackMathbot + module Commands + class Pixiv < SlackRubyBot::Commands::Base + match /pixiv\.net(?.*)\?$/ do |client, _data, _match| + + #asdf + client.say(channel: data.channel, text: "Testing: #{match[:url]}") + + end + end + end +end