Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding a Y U NO bot

  • Loading branch information...
commit 157c74a57e2804fc419e59d2ad0fa388daf81db5 1 parent acca418
Mike Połtyn authored
Showing with 20 additions and 2 deletions.
  1. +18 −0 app/controllers/yuno.rb
  2. +2 −2 config/boot.rb
View
18 app/controllers/yuno.rb
@@ -0,0 +1,18 @@
+Base.controllers :yuno do
+ before do
+ @message = AwesomeBotMessage.new(request.body)
+ end
+
+ # regex: /^(.*)Y U NO(.+)$/i
+ post :create do
+
+ y_u_no_parts = @message.body.scan(/^(.*)Y U NO (.+)$/i).first
+
+ image = "http://memecaptain.com/i?u=http%3A%2F%2Fmemecaptain.com%2Fy_u_no.jpg"
+ image << "&tt=#{URI.encode_www_form_component(y_u_no_parts[0])}" unless y_u_no_parts[0].empty?
+ image << "&tb=#{URI.encode_www_form_component("Y U NO #{y_u_no_parts[1]}")}"
+
+ {:type => "TextMessage", :body => image}.to_json
+ end
+
+end
View
4 config/boot.rb
@@ -4,7 +4,7 @@
# Load our dependencies
require 'rubygems' unless defined?(Gem)
-require 'uri' # needed by app/controllers/wikilinks.rb
+require 'uri' # needed by app/controllers/wikilinks.rb and app/controllers/yuno.rb
require 'bundler/setup'
Bundler.require(:default, PADRINO_ENV)
@@ -29,4 +29,4 @@
Padrino.after_load do
end
-Padrino.load!
+Padrino.load!
Please sign in to comment.
Something went wrong with that request. Please try again.