hipbot-plugins 0.0.1 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c30652ba6332517579abf6342c768f2d3116c7a9
4
+ data.tar.gz: 744466fd9846b70c90550b2ad869037df65561d8
5
+ SHA512:
6
+ metadata.gz: 087d7e421dd75cd96d95cf3e6fc721b4c2a3ee780846b25cfc4af7e9415cbd7926dcdb87f0917c88692e03e2e345f28d9e382829356ad4c167a11473242b8dce
7
+ data.tar.gz: cc05e2b8f6fc29a90a816712a24701177f0f26cfcadb3da67c544d529eadf61905b05c4f18855e9923e7227040ef2b17cfa786da1c51ac04f04e01a968ffc750
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.1.0
data/.travis.yml ADDED
@@ -0,0 +1,18 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.1.0
7
+ - jruby-19mode
8
+ - rbx-19mode
9
+ - ruby-head
10
+ matrix:
11
+ allow_failures:
12
+ - rvm: ruby-head
13
+ notifications:
14
+ email:
15
+ recipients:
16
+ - pewniak747@gmail.com
17
+ - bartosz.kopinski@netguru.pl
18
+
data/Gemfile CHANGED
@@ -2,3 +2,4 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in hipbot-plugins.gemspec
4
4
  gemspec
5
+ gem 'hipbot', github: 'pewniak747/hipbot', branch: 'master'
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # hipbot-plugins
2
2
 
3
+ [![Build Status](https://travis-ci.org/netguru/hipbot-plugins.png?branch=master)](https://travis-ci.org/netguru/hipbot-plugins)
4
+ [![Code Climate](https://codeclimate.com/github/netguru/hipbot-plugins.png)](https://codeclimate.com/github/netguru/hipbot-plugins)
5
+ [![Gem Version](https://badge.fury.io/rb/hipbot-plugins.png)](http://badge.fury.io/rb/hipbot-plugins)
6
+
3
7
  This is a collection of open-source plugins for https://github.com/pewniak747/hipbot, initially developped at http://netguru.co
4
8
 
5
9
  ## Installation
@@ -14,18 +18,17 @@ And then execute:
14
18
 
15
19
  ## Usage
16
20
 
17
- To include a plugin, use hipbot's configuration (https://github.com/pewniak747/hipbot#customize)
21
+ To include a plugin, require it in your bot.rb file:
18
22
 
19
23
  ``` ruby
20
24
  require 'hipbot'
21
25
  require 'hipbot-plugins'
26
+ require 'hipbot-plugins/human'
22
27
 
23
28
  class MyCompanyBot < Hipbot::Bot
24
29
  configure do |c|
25
- c.name = 'robot'
26
30
  c.jid = 'changeme@chat.hipchat.com'
27
31
  c.password = 'secret'
28
- c.plugins = [ Hipbot::Plugins::Human, Hipbot::Plugins::Google ]
29
32
  end
30
33
  end
31
34
  ```
@@ -42,7 +45,6 @@ Hipbot responds to:
42
45
  * open the pod bay door
43
46
  * make me a sandwich
44
47
  * slap @someone
45
- * insult @someone
46
48
  * choose
47
49
  * comfort me
48
50
  * (AI simulation with Cleverbot)
@@ -59,7 +61,7 @@ Hipbot responds to:
59
61
  * something vs somethingelse vs someoranother vs ...
60
62
  * translate en:pl something I want to translate
61
63
 
62
- ### Github
64
+ ### Hipbot::Plugins::Github
63
65
 
64
66
  Can generate links to github
65
67
 
@@ -70,6 +72,42 @@ Hipbot responds to:
70
72
 
71
73
  ( For this to work you need to define `project` and `organization` methods as a response helpers: https://github.com/pewniak747/hipbot#response-helpers )
72
74
 
75
+ ### Hipbot::Plugins::MemeGenerator
76
+
77
+ Create instant memes using memecaptain.com!
78
+
79
+ Hipbot responds to:
80
+
81
+ * memes
82
+ * meme allthethings "create all" "the memes!"
83
+
84
+ ### Hipbot::Plugins::UrbanDictionary
85
+
86
+ Explains reality using UrbanDictionary.com
87
+
88
+ Hipbot responds to:
89
+
90
+ * explain the meaning of life, the universe and everything
91
+
92
+ ### Hipbot::Plugins::WolframAlpha
93
+
94
+ Adds the ability to use wolframalpha.com computational search engine. You need to register for api key.
95
+
96
+ ``` ruby
97
+ class MyCompanyBot < Hipbot::Bot
98
+ configure do |c|
99
+ # ...
100
+ Hipbot::Plugins::WolframAlpha.configure do |c|
101
+ c.appid = 'my-api-key'
102
+ end
103
+ end
104
+ end
105
+ ```
106
+
107
+ Hipbot responds to:
108
+
109
+ * wolfram plot x^2 + 3x - 1
110
+
73
111
  ## Contributing
74
112
 
75
113
  1. Fork it
data/Rakefile CHANGED
@@ -1 +1,5 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+ RSpec::Core::RakeTask.new(:spec)
4
+
5
+ task default: :spec
@@ -7,16 +7,20 @@ Gem::Specification.new do |gem|
7
7
  gem.name = "hipbot-plugins"
8
8
  gem.version = Hipbot::Plugins::VERSION
9
9
  gem.authors = ["Bartosz Kopiński", "Tomasz Pewiński"]
10
- gem.email = ["bartosz.kopinski@netguru.pl", "pewniak747@gmail.com"]
11
- gem.description = %q{A collection of plugins to use in your hipbot installation}
12
- gem.summary = %q{A collection of plugins to use in your hipbot installation}
10
+ gem.email = ["bartosz.kopinski@gmail.com", "pewniak747@gmail.com"]
11
+ gem.description = %q{Hipbot sample plugins}
12
+ gem.summary = %q{A collection of plugins to use in your Hipbot installation}
13
13
  gem.homepage = "https://github.com/netguru/hipbot-plugins"
14
14
 
15
15
  gem.files = `git ls-files`.split($/)
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
- gem.add_runtime_dependency "hipbot"
20
- gem.add_runtime_dependency 'cleverbot'
21
- gem.add_runtime_dependency 'htmlentities'
19
+ gem.add_dependency "hipbot", '~> 1.0', '>= 1.0.0'
20
+ gem.add_dependency 'cleverbot', '~> 0.2.0'
21
+ gem.add_dependency 'htmlentities'
22
+ gem.add_dependency 'wolfram', '~> 0.2.1'
23
+
24
+ gem.add_development_dependency 'rake'
25
+ gem.add_development_dependency 'rspec'
22
26
  end
@@ -1,7 +1,13 @@
1
+ require "hipbot"
1
2
  require "hipbot-plugins/version"
3
+ require "hipbot-plugins/ascii"
4
+ require "hipbot-plugins/excuses"
5
+ require "hipbot-plugins/help"
2
6
  require "hipbot-plugins/human"
3
7
  require "hipbot-plugins/github"
4
8
  require "hipbot-plugins/google"
9
+ require "hipbot-plugins/wolfram_alpha"
10
+ require "hipbot-plugins/meme_generator"
5
11
 
6
12
  module Hipbot
7
13
  module Plugins
@@ -0,0 +1,47 @@
1
+ # encoding: utf-8
2
+ class ASCII
3
+ include Hipbot::Plugin
4
+
5
+ TABLE_FLIPS = [
6
+ '(╯°□°)╯︵ ┻━┻',
7
+ '(╯°□°)╯︵ ┻━┻',
8
+ '(ノ ゜Д゜)ノ ︵ ┻━┻',
9
+ '‎(ノಥ益ಥ)ノ ┻━┻',
10
+ "(╯'□')╯︵ ┻━┻",
11
+ '(ノಥДಥ)ノ︵┻━┻',
12
+ 'ʕノ•ᴥ•ʔノ ︵ ┻━┻',
13
+ '(/¯◡ ‿ ◡)/¯ ~ ┻━┻',
14
+ '┗[© □ ©]┛ ︵ ┻━┻',
15
+ '┻━┻ ︵ ლ(⌒-⌒ლ)',
16
+ ]
17
+
18
+ CLEAN_UPS = [
19
+ '┬──┬ ¯\\_(ツ)',
20
+ '┬─┬ノ( º _ ºノ)',
21
+ '(╯°Д°)╯︵ /(.□ . \\)',
22
+ '(/ .□.)\\ ︵╰(゜Д゜)╯︵ /(.□. \\)',
23
+ 'ノ┬─┬ノ ︵ ( \\o°o)\\',
24
+ ]
25
+
26
+ scope global: true do
27
+ on Regexp.union(TABLE_FLIPS) do
28
+ reply(CLEAN_UPS.sample)
29
+ end
30
+
31
+ on Regexp.union(CLEAN_UPS) do
32
+ reply(TABLE_FLIPS.sample)
33
+ end
34
+
35
+ on /\A\\o\/\z/ do
36
+ reply('\o/')
37
+ end
38
+
39
+ on /\A\/o\/\z/ do
40
+ reply('\\o\\')
41
+ end
42
+
43
+ on /\A\\o\\\z/ do
44
+ reply('/o/')
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,34 @@
1
+ require 'open-uri'
2
+
3
+ module Hipbot
4
+ module Plugins
5
+ class Excuses
6
+ include Hipbot::Plugin
7
+
8
+ desc 'provides you with an excuse'
9
+ on /^excuse/ do
10
+ excuse = Grabber.new.call
11
+ reply(excuse)
12
+ end
13
+
14
+ class Grabber
15
+ ADDRESS = 'http://developerexcuses.com/'
16
+
17
+ def call
18
+ data = page.match link_regexp
19
+ data[1]
20
+ end
21
+
22
+ private
23
+
24
+ def page
25
+ @page ||= open(ADDRESS).read
26
+ end
27
+
28
+ def link_regexp
29
+ /\<a href.+\>(.+)<\/a>/
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,13 +1,27 @@
1
1
  module Hipbot
2
2
  module Plugins
3
- class Github < Hipbot::Plugin
3
+ class Github
4
+ include Hipbot::Plugin
5
+
6
+ desc 'links to two github branches comparision eg. `compare master to stable`'
4
7
  on /^compare (\w+)(?: to)? (\w+)$/, room: true do |stage1, stage2|
5
8
  reply "https://github.com/#{organization}/#{project.name}/compare/#{stage1}...#{stage2}" if project
6
9
  end
7
10
 
11
+ desc 'links to production <-> staging comparision'
12
+ on /^compare$/, room: true do
13
+ reply "https://github.com/#{organization}/#{project.name}/compare/production...staging" if project
14
+ end
15
+
16
+ desc 'links to github code search in organization'
8
17
  on /^github (.+)/ do |query|
9
- query = URI::encode query
10
- reply "https://github.com/search?q=#{query}+%40#{organization}&ref=searchresults&type=Code&s=indexed"
18
+ query_hash = {
19
+ q: "#{query} @#{organization}",
20
+ ref: 'searchresults',
21
+ type: 'Code',
22
+ s: 'indexed'
23
+ }
24
+ reply "https://github.com/search?#{query_hash.to_query}"
11
25
  end
12
26
  end
13
27
  end
@@ -1,47 +1,72 @@
1
1
  module Hipbot
2
2
  module Plugins
3
- class Google < Hipbot::Plugin
3
+ class Google
4
+ include Hipbot::Plugin
5
+
6
+ desc 'returns first few results for Google search'
4
7
  on /^google (.+)/ do |search|
5
- get('http://ajax.googleapis.com/ajax/services/search/web', { q: URI::encode(search), safe: 'off', v: '1.0' }) do |http|
6
- http.json['responseData']['results'].each do |page|
8
+ get('http://ajax.googleapis.com/ajax/services/search/web', { q: search, safe: 'off', v: '1.0' }) do |http|
9
+ results = http.json.fetch('responseData', {}).fetch('results', [])
10
+ results.each do |page|
7
11
  reply("#{page['url']} - #{page['titleNoFormatting']}")
8
12
  end
9
13
  end
10
14
  end
11
15
 
16
+ desc 'does an Google result count comparision eg. `firefox vs chrome vs ie`'
12
17
  on /^(.+ vs?\.? .+)/i do |battle|
13
18
  winner = { score: 0 }
14
19
  objects = battle.split(/ vs?\.? /i)
15
20
  left = objects.count
16
21
  objects.each do |obj|
17
- get('http://ajax.googleapis.com/ajax/services/search/web', { q: URI::encode(obj), safe: 'off', v: '1.0' }) do |http|
18
- score = http.json['responseData']['cursor']['resultCount'].delete(' ').to_i
22
+ get('http://ajax.googleapis.com/ajax/services/search/web', { q: obj, safe: 'off', v: '1.0' }) do |http|
23
+ resultCount = http.json.fetch('responseData', {}).fetch('cursor', {}).fetch('resultCount', 0)
24
+ score = resultCount.to_s.delete(' ').to_i
19
25
  winner = { name: obj, score: score } if score > winner[:score]
20
26
  left -= 1
21
27
  end
22
28
  end
23
29
  sleep(1) until left == 0
24
- notify("...and the winner is #{winner[:name]}!", 'Google')
30
+ reply("...and the winner is #{winner[:name]}!")
25
31
  end
26
32
 
33
+ desc 'returns sample result of Google image search eg. `image trollface`'
27
34
  on /^image (.+)/ do |search|
28
- get('http://ajax.googleapis.com/ajax/services/search/images', { q: URI::encode(search), safe: 'moderate', v: '1.0', hl: 'pl', imgsz: 'large', rsz: 1 }) do |http|
29
- reply http.json['responseData']['results'].sample['url']
35
+ get('http://ajax.googleapis.com/ajax/services/search/images', { q: search, safe: 'moderate', v: '1.0', hl: 'pl', imgsz: 'large', rsz: 1 }) do |http|
36
+ results = http.json.fetch('responseData', {}).fetch('results', [])
37
+ if results.any?
38
+ reply results.sample['url']
39
+ else
40
+ reply "I found nothing, #{sender}"
41
+ end
30
42
  end
31
43
  end
32
44
 
45
+ desc 'returns sample result of YouTube search eg. `yt rick roll`'
33
46
  on /^youtube (.+)/, /^yt (.+)/ do |query|
34
- get('http://gdata.youtube.com/feeds/api/videos', { q: URI::encode(query), alt: 'json', :'max-results' => 3, orderBy: 'relevance'}) do |http|
35
- reply http.json['feed']['entry'].sample['link'][0]['href']
47
+ get('http://gdata.youtube.com/feeds/api/videos', { q: query, alt: 'json', :'max-results' => 3, orderBy: 'relevance' }) do |http|
48
+ entry = http.json.fetch('feed', {}).fetch('entry', [])
49
+ if entry.any?
50
+ reply entry.sample['link'][0]['href']
51
+ else
52
+ reply "I found nothing, #{sender}"
53
+ end
36
54
  end
37
55
  end
38
56
 
57
+ desc 'translates text using Google Translate eg. `translate en:pl Hello world`'
39
58
  on /^translate (.+)/ do |query|
40
59
  params, text = query.split(' ', 2)
41
- from, to = params.split(':')
42
- if to.nil?
43
- to = from
44
- from = 'pl'
60
+ if text.nil?
61
+ text = params
62
+ from = 'auto'
63
+ to = 'en'
64
+ else
65
+ from, to = params.split(':')
66
+ if to.nil?
67
+ to = from
68
+ from = 'auto'
69
+ end
45
70
  end
46
71
 
47
72
  params = {
@@ -0,0 +1,64 @@
1
+ module Hipbot
2
+ module Plugins
3
+ class Help
4
+ include Hipbot::Plugin
5
+
6
+ desc 'lists all standard emoticons'
7
+ on /^emoticons/ do
8
+ reply ":-) :o :$ :( :-* :# :'( ;-) (embarrassed) :Z :p 8) O:) :-D (oops) :| (thumbsup) (thumbsdown) (allthethings) (android) (areyoukiddingme)" +
9
+ " (arrington) (ashton) (awyeah) (badpokerface) (basket) (beer) (bumble) (bunny) (cadbury) (cake) (candycorn) (caruso) (cereal)" +
10
+ " (challengeaccepted) (chewie) (chocobunny) (chompy) (chris) (coffee) (content) (cornelius) (dealwithit) (derp)" +
11
+ " (disapproval) (dosequis) (ducreux) (dumb) (facepalm) (fap) (foreveralone) (freddie) (fry) (fu) (fuckyeah) (garret) (gates) (ghost) (goodnews)"
12
+ # splitted for better formatting under Adobe AIR clients
13
+ reply "(greenbeer) (gtfo) (haveaseat) (heart) (hipchat) (hipster) (huh) (ilied) (itsatrap) (jackie) (jobs) (kennypowers) (krang) (kwanzaa) (lincoln)" +
14
+ " (lol) (lolwut) (megusta) (menorah) (notbad) (nothingtodohere) (ohcrap) (okay) (omg) (orly) (pbr) (pete) (philosoraptor) (pirate) (pokerface)" +
15
+ " (poo) (present) (pumpkin) (rageguy) (rebeccablack) (reddit) (rudolph) (sadpanda) (sadtroll) (samuel) (santa) (scumbag) (seomoz) (shamrock)" +
16
+ " (skyrim) (stare) (sweetjesus) (taft) (tree) (troll) (truestory) (turkey) (washington) (wat) (wtf) (yey) (yodawg) (yuno) (zoidberg) (zzz)"
17
+ end
18
+
19
+ desc 'generates help for all reactions'
20
+ on /^help$/ do
21
+ reactions_with_description = Hipbot.reactions.reject{ |reaction| reaction.desc.nil? }
22
+ help = reactions_with_description.map do |reaction|
23
+ "#{reaction.plugin_name}: #{reaction.readable_command} - #{reaction.desc}"
24
+ end
25
+ reply help.join("\n")
26
+ end
27
+
28
+ desc 'returns more info on given command'
29
+ on /^help (.+)/ do |subject|
30
+ reactions = Hipbot.reactions.select do |reaction|
31
+ [reaction.plugin_name, reaction.readable_command, reaction.desc].any?{ |v| v =~ /#{subject}/i }
32
+ end
33
+ help = []
34
+ reactions.each do |reaction|
35
+ help << "#{reaction.plugin_name}: #{reaction.readable_command}"
36
+ if !reaction.desc.nil?
37
+ help << " - #{reaction.desc}"
38
+ end
39
+
40
+ if reaction.to_private_message?
41
+ help << " - Private only"
42
+ elsif reaction.in_any_room?
43
+ help << " - Room only"
44
+ elsif reaction.rooms.any?
45
+ help << " - Only in: #{reaction.rooms.to_sentence}"
46
+ else
47
+ help << " - All rooms and private messages"
48
+ end
49
+
50
+ if !reaction.options[:from].nil?
51
+ help << " - Only for: #{reaction.users.to_sentence}"
52
+ else
53
+ help << " - From anybody"
54
+ end
55
+
56
+ if reaction.global?
57
+ help << " - Without mention"
58
+ end
59
+ end
60
+ reply help.join("\n")
61
+ end
62
+ end
63
+ end
64
+ end
@@ -3,7 +3,10 @@ require 'htmlentities'
3
3
 
4
4
  module Hipbot
5
5
  module Plugins
6
- class Human < Hipbot::Plugin
6
+ class Human
7
+ include Hipbot::Plugin
8
+
9
+ desc 'kindly greets the sender'
7
10
  on /^hello/ do
8
11
  reply("hello #{sender.first_name}!")
9
12
  end
@@ -16,35 +19,34 @@ module Hipbot
16
19
  reply("/me hands #{sender} a #{thing}")
17
20
  end
18
21
 
19
- on /slap (.+)/ do
20
- message.mentions.each do |mention|
21
- reply("/me slaps #{mention} around a bit with a large trout.")
22
- end
23
- end
24
-
25
- on /insult (.+)/ do
26
- message.mentions.each do |mention|
27
- get('http://programmerinsults.com/') do |http|
28
- insult = http.body.scan(/color: #333;">(.+?)<\/a>/mi).flatten
29
- reply("#{mention}, #{insult.first}")
30
- end
31
- end
22
+ desc 'slaps given user eg. `slap @admin`'
23
+ on /slap (.+)/ do |name|
24
+ reply("/me slaps #{name} around a bit with a large trout.")
32
25
  end
33
26
 
27
+ desc 'randomly chooses by default 1 person from online users eg. `choose 3`'
34
28
  on /^choose( ([0-9]+))?/, room: true do |_, number|
35
29
  number ||= 1
36
- reply("/me chooses #{room.users.sample(number.to_i).map(&:name).to_sentence}") if room.present?
30
+ reply("/me chooses #{room.users.sample(number.to_i).map(&:name).to_sentence}")
37
31
  end
38
32
 
33
+ desc 'comforts with a pat on the back'
39
34
  on /^(comfort|i haz a sad|i have a sad)/ do
40
35
  reply("/me pats #{message.sender.first_name} on the head")
41
36
  reply("#{message.sender.first_name}, everything is going to be alright!")
42
37
  end
43
38
 
39
+ coder = HTMLEntities.new
40
+ cleverbot = Cleverbot::Client.new
44
41
  default do |message|
45
- cleverbot = Cleverbot::Client.new
46
- coder = HTMLEntities.new
47
- reply(coder.decode(cleverbot.write(message)) || 'I don\'t undersand you')
42
+ response = cleverbot.write(message).to_s
43
+ if !response.empty?
44
+ # fixing broken encoding from cleverbot
45
+ response = coder.decode(response).gsub(/\|([0-9]{4})/){ |s| s.hex.chr }
46
+ reply(response)
47
+ else
48
+ reply('I don\'t understand you')
49
+ end
48
50
  end
49
51
  end
50
52
  end
@@ -0,0 +1,70 @@
1
+ module Hipbot
2
+ module Plugins
3
+ class MemeGenerator
4
+ include Hipbot::Plugin
5
+
6
+ attr_accessor :username, :password
7
+
8
+ desc 'list available memes to generate'
9
+ on /^memes/ do
10
+ reply(Generator.memes.keys.sort.join(', '))
11
+ end
12
+
13
+ desc 'generates new meme eg. `meme allthethings Generate all the memes!`'
14
+ on /^meme (\w+)\s+(.*)/ do |meme, text|
15
+ generator = Generator.new(meme, text)
16
+ query = {
17
+ u: generator.image_url,
18
+ tt: generator.upper_text,
19
+ tb: generator.lower_text
20
+ }
21
+ encoded_query = query.respond_to?(:to_query) ? query.to_query : URI.encode_www_form(query)
22
+ image_url = "http://v1.memecaptain.com/i?#{encoded_query}"
23
+ reply(image_url)
24
+ end
25
+
26
+ class Generator
27
+ attr_reader :upper_text, :lower_text, :meme
28
+ def initialize meme, text
29
+ @meme = meme
30
+ assign_texts(text)
31
+ end
32
+
33
+ def image_url
34
+ meme_name = self.class.memes.fetch(meme.to_s)
35
+ "http://v1.memecaptain.com/#{meme_name}.png"
36
+ end
37
+
38
+ private
39
+
40
+ def assign_texts text
41
+ quotes_regexp = /"(.*)"\s+"(.*)"/
42
+ matches = text.match(quotes_regexp)
43
+ if matches
44
+ assign_upper_and_lower_texts(matches[1], matches[2])
45
+ else
46
+ middle = text.length / 2
47
+ middle += 1 while !(text[middle].nil? || text[middle] =~ /\s/)
48
+ assign_upper_and_lower_texts(text[0..middle], text[middle+1..-1])
49
+ end
50
+ end
51
+
52
+ def assign_upper_and_lower_texts upper_text, lower_text
53
+ @upper_text = upper_text.to_s.strip
54
+ @lower_text = lower_text.to_s.strip
55
+ end
56
+
57
+ def self.memes
58
+ {
59
+ "yuno" => "y_u_no",
60
+ "idontalways" => "most_interesting",
61
+ "allthethings" => "all_the_things",
62
+ "yodawg" => "xzibit",
63
+ "toodamnhigh" => "too_damn_high",
64
+ "fry" => "fry"
65
+ }
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,19 @@
1
+ require 'urban_dictionary'
2
+
3
+ module Hipbot
4
+ module Plugins
5
+ class UrbanDictionary
6
+ include Hipbot::Plugin
7
+
8
+ desc 'explains a phrase using UrbanDictionary'
9
+ on /^explain (.+)/ do |phrase|
10
+ entry = ::UrbanDictionary.define(phrase)
11
+ if entry.entries.nil? || entry.entries.empty?
12
+ reply("Congrats #{sender.first_name}, you just invented a completely new #{phrase.count(' ').zero? ? 'word' : 'phrase'}.")
13
+ else
14
+ reply(entry.entries.first.definition)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,5 +1,5 @@
1
1
  module Hipbot
2
2
  module Plugins
3
- VERSION = "0.0.1"
3
+ VERSION = "1.0.1"
4
4
  end
5
5
  end
@@ -0,0 +1,26 @@
1
+ require 'wolfram'
2
+
3
+ module Hipbot
4
+ module Plugins
5
+ class WolframAlpha
6
+ include Hipbot::Plugin
7
+
8
+ delegate :appid=, to: :Wolfram
9
+
10
+ desc 'returns first three WolframAlpha search results'
11
+ on /^wolfram (.+)/ do |query|
12
+ result = Wolfram.fetch(query)
13
+ result.pods[1..3].each do |pod|
14
+ if !pod.plaintext.nil?
15
+ text = pod.plaintext
16
+ elsif !pod.img.attributes['src'].value.nil?
17
+ text = pod.img.attributes['src'].value + "#.jpg"
18
+ else
19
+ next
20
+ end
21
+ reply("#{pod.title}: #{text}")
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe Hipbot::Plugins::MemeGenerator::Generator do
4
+ let(:meme) { stub.as_null_object }
5
+
6
+ describe "splitting text" do
7
+ it "should split text according to quotation marks" do
8
+ generator = described_class.new(meme, '"I don\'t always do a deploy" "but when I do, I do it on friday"')
9
+ generator.upper_text.should == "I don\'t always do a deploy"
10
+ generator.lower_text.should == "but when I do, I do it on friday"
11
+ end
12
+
13
+ it "should split text evenly" do
14
+ generator = described_class.new(meme, 'I don\'t always do a deploy but when I do, I do it on friday')
15
+ generator.upper_text.should == "I don't always do a deploy but"
16
+ generator.lower_text.should == "when I do, I do it on friday"
17
+ end
18
+
19
+ it "should not split monolithic text" do
20
+ generator = described_class.new(meme, 'ermagherdtestdrivendevelopment')
21
+ generator.upper_text.should == "ermagherdtestdrivendevelopment"
22
+ generator.lower_text.should == ""
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,4 @@
1
+ require_relative '../lib/hipbot-plugins'
2
+
3
+ RSpec.configure do |config|
4
+ end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hipbot-plugins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 1.0.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Bartosz Kopiński
@@ -10,98 +9,150 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-04-21 00:00:00.000000000 Z
12
+ date: 2014-03-03 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: hipbot
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ! '>='
18
+ - - "~>"
21
19
  - !ruby/object:Gem::Version
22
- version: '0'
20
+ version: '1.0'
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.0.0
23
24
  type: :runtime
24
25
  prerelease: false
25
26
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
27
  requirements:
28
- - - ! '>='
28
+ - - "~>"
29
29
  - !ruby/object:Gem::Version
30
- version: '0'
30
+ version: '1.0'
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.0
31
34
  - !ruby/object:Gem::Dependency
32
35
  name: cleverbot
33
36
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
37
  requirements:
36
- - - ! '>='
38
+ - - "~>"
37
39
  - !ruby/object:Gem::Version
38
- version: '0'
40
+ version: 0.2.0
39
41
  type: :runtime
40
42
  prerelease: false
41
43
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
44
  requirements:
44
- - - ! '>='
45
+ - - "~>"
45
46
  - !ruby/object:Gem::Version
46
- version: '0'
47
+ version: 0.2.0
47
48
  - !ruby/object:Gem::Dependency
48
49
  name: htmlentities
49
50
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
51
  requirements:
52
- - - ! '>='
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: wolfram
64
+ requirement: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.2.1
55
69
  type: :runtime
56
70
  prerelease: false
57
71
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
72
  requirements:
60
- - - ! '>='
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.2.1
76
+ - !ruby/object:Gem::Dependency
77
+ name: rake
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ type: :development
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ - !ruby/object:Gem::Dependency
91
+ name: rspec
92
+ requirement: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ type: :development
98
+ prerelease: false
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
61
102
  - !ruby/object:Gem::Version
62
103
  version: '0'
63
- description: A collection of plugins to use in your hipbot installation
104
+ description: Hipbot sample plugins
64
105
  email:
65
- - bartosz.kopinski@netguru.pl
106
+ - bartosz.kopinski@gmail.com
66
107
  - pewniak747@gmail.com
67
108
  executables: []
68
109
  extensions: []
69
110
  extra_rdoc_files: []
70
111
  files:
71
- - .gitignore
112
+ - ".gitignore"
113
+ - ".ruby-version"
114
+ - ".travis.yml"
72
115
  - Gemfile
73
116
  - LICENSE.txt
74
117
  - README.md
75
118
  - Rakefile
76
119
  - hipbot-plugins.gemspec
77
120
  - lib/hipbot-plugins.rb
121
+ - lib/hipbot-plugins/ascii.rb
122
+ - lib/hipbot-plugins/excuses.rb
78
123
  - lib/hipbot-plugins/github.rb
79
124
  - lib/hipbot-plugins/google.rb
125
+ - lib/hipbot-plugins/help.rb
80
126
  - lib/hipbot-plugins/human.rb
127
+ - lib/hipbot-plugins/meme_generator.rb
128
+ - lib/hipbot-plugins/urban_dictionary.rb
81
129
  - lib/hipbot-plugins/version.rb
130
+ - lib/hipbot-plugins/wolfram_alpha.rb
131
+ - spec/meme_generator_spec.rb
132
+ - spec/spec_helper.rb
82
133
  homepage: https://github.com/netguru/hipbot-plugins
83
134
  licenses: []
135
+ metadata: {}
84
136
  post_install_message:
85
137
  rdoc_options: []
86
138
  require_paths:
87
139
  - lib
88
140
  required_ruby_version: !ruby/object:Gem::Requirement
89
- none: false
90
141
  requirements:
91
- - - ! '>='
142
+ - - ">="
92
143
  - !ruby/object:Gem::Version
93
144
  version: '0'
94
145
  required_rubygems_version: !ruby/object:Gem::Requirement
95
- none: false
96
146
  requirements:
97
- - - ! '>='
147
+ - - ">="
98
148
  - !ruby/object:Gem::Version
99
149
  version: '0'
100
150
  requirements: []
101
151
  rubyforge_project:
102
- rubygems_version: 1.8.23
152
+ rubygems_version: 2.2.0.rc.1
103
153
  signing_key:
104
- specification_version: 3
105
- summary: A collection of plugins to use in your hipbot installation
106
- test_files: []
107
- has_rdoc:
154
+ specification_version: 4
155
+ summary: A collection of plugins to use in your Hipbot installation
156
+ test_files:
157
+ - spec/meme_generator_spec.rb
158
+ - spec/spec_helper.rb