Browse Source

Created pixiv command

master
Daniel Muckerman 9 years ago
parent
commit
f77c098a25
3 changed files with 14 additions and 65 deletions
  1. +1
    -1
      slack-pixiv.rb
  2. +0
    -64
      slack-pixiv/commands/calculate.rb
  3. +13
    -0
      slack-pixiv/commands/pixiv.rb

+ 1
- 1
slack-pixiv.rb View File

@ -1,4 +1,4 @@
require 'slack-ruby-bot'
require 'wolfram'
require 'slack-pixiv/commands/calculate'
require 'slack-pixiv/commands/pixiv'
require 'slack-pixiv/app'

+ 0
- 64
slack-pixiv/commands/calculate.rb View File

@ -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

+ 13
- 0
slack-pixiv/commands/pixiv.rb View File

@ -0,0 +1,13 @@
# coding: utf-8
module SlackMathbot
module Commands
class Pixiv < SlackRubyBot::Commands::Base
match /pixiv\.net(?<url>.*)\?$/ do |client, _data, _match|
#asdf
client.say(channel: data.channel, text: "Testing: #{match[:url]}")
end
end
end
end

Loading…
Cancel
Save