lita-memegen 1.0.0

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: 6f0ae8bb57da2a679da02e4291af8d75ca63f146
4
+ data.tar.gz: f5703a90776620a3bfdea6ed961da85bd1f6a106
5
+ SHA512:
6
+ metadata.gz: 9d4bb05f16d0d39391d0e88aa8ab4d0f829fa11279c3c4421fd4de6018de8026276e0be59a0314b2af9926196eae8e9c45a4f53d00b0584f464736ba3c928dc0
7
+ data.tar.gz: c1f993dac97d474d678c86d7fbd1c375a31bb2faaed870b653af574039d0c7e6924ba81d4f0594f75fff0bf915116074fbd1cdbbe08293e4475470ff9b0b8101
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.0.0
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ script: bundle exec rspec
5
+ before_install:
6
+ - gem update --system
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2013 Mitch Dempsey
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # lita-memegen
2
+
3
+ [![Build Status](https://travis-ci.org/webdestroya/lita-memegen.png)](https://travis-ci.org/webdestroya/lita-memegen)
4
+ [![Code Climate](https://codeclimate.com/github/webdestroya/lita-memegen.png)](https://codeclimate.com/github/webdestroya/lita-memegen)
5
+ [![Coverage Status](https://coveralls.io/repos/webdestroya/lita-memegen/badge.png)](https://coveralls.io/r/webdestroya/lita-memegen)
6
+
7
+ **lita-memegen** is a handler for [Lita](https://github.com/jimmycuadra/lita) that generates meme images using memegenerator.net.
8
+
9
+ ## Installation
10
+
11
+ Add lita-memegen to your Lita instance's Gemfile:
12
+
13
+ ``` ruby
14
+ gem "lita-memegen"
15
+ ```
16
+
17
+ ## Configuration
18
+
19
+ You will need to register an account on memegenerator.net and provide the username/password for the account.
20
+
21
+ ```
22
+ Lita.configure do |config|
23
+ config.handlers.memegen.username = 'username'
24
+ config.handlers.memegen.password = 'password'
25
+ end
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ TODO
31
+
32
+ ## License
33
+
34
+ [MIT](http://opensource.org/licenses/MIT)
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1 @@
1
+ require "lita/handlers/memegen"
@@ -0,0 +1,154 @@
1
+ require "lita"
2
+
3
+ module Lita
4
+ module Handlers
5
+ class Memegen < Handler
6
+
7
+ def self.default_config(config)
8
+ config.username = nil
9
+ config.password = nil
10
+ end
11
+
12
+ route %r{(!meme )?(Y U NO) (.+)}i, :meme_y_u_no, command: false
13
+ route %r{(!meme )?(I DON'?T ALWAYS .*) (BUT WHEN I DO,? .*)}i, :meme_i_dont_always, command: false
14
+ route %r{(!meme )?(.*)(O\s?RLY\??.*)}i, :meme_orly, command: false
15
+ route %r{(!meme )?(.*)(SUCCESS|NAILED IT.*)}i, :meme_success, command: false
16
+ route %r{(!meme )?(.*) (ALL the .*)}i, :meme_all_the, command: false
17
+ route %r{(!meme )?(.*) (\w+\sTOO DAMN .*)}i, :meme_too_damn, command: false
18
+ route %r{(!meme )?(GOOD NEWS EVERYONE[,.!]?) (.*)}i, :meme_good_news, command: false
19
+ route %r{(!meme )?(NOT SURE IF .*) (OR .*)}i, :meme_not_sure_if, command: false
20
+ route %r{(!meme )?(YO DAWG .*) (SO .*)}i, :meme_yo_dawg, command: false
21
+ route %r{(!meme )?(ALL YOUR .*) (ARE BELONG TO US)}i, :meme_are_belong, command: false
22
+ route %r{(!meme )?(.*) (FUCK YOU)}i, :meme_fuck_you, command: false
23
+ route %r{(!meme )?(.*) (You'?re gonna have a bad time)}i, :meme_bad_time, command: false
24
+ route %r{(!meme )?(one does not simply) (.*)}i, :meme_simply, command: false
25
+ route %r{(!meme )?(grumpy cat) (.*),(.*)}i, :meme_grumpy_cat, command: false
26
+ route %r{(!meme )?(it looks like you're|it looks like you) (.*)}i, :meme_looks_like, command: false
27
+ route %r{(!meme )?(AM I THE ONLY ONE AROUND HERE) (.*)}i, :meme_am_i_only, command: false
28
+ route %r{(!meme)?(.*)(NOT IMPRESSED*)}i, :meme_not_impressed, command: false
29
+ route %r{(!meme)?(PREPARE YOURSELF) (.*)}i, :meme_prepare_yourself, command: false
30
+ route %r{(!meme)?(WHAT IF I TOLD YOU) (.*)}i, :meme_what_if_i, command: false
31
+ route %r{(!meme)?(.*) (BETTER DRINK MY OWN PISS)}i, :meme_better_drink, command: false
32
+
33
+
34
+ def meme_y_u_no(response)
35
+ generate_meme(response, 2, 166088)
36
+ end
37
+
38
+ def meme_i_dont_always(response)
39
+ generate_meme(response, 74, 2485)
40
+ end
41
+
42
+ def meme_orly(response)
43
+ generate_meme(response, 920, 117049)
44
+ end
45
+
46
+ def meme_success(response)
47
+ generate_meme(response, 121, 1031)
48
+ end
49
+
50
+ def meme_all_the(response)
51
+ generate_meme(response, 6013, 1121885)
52
+ end
53
+
54
+ def meme_too_damn(response)
55
+ generate_meme(response, 998, 203665)
56
+ end
57
+
58
+ def meme_good_news(response)
59
+ generate_meme(response, 1591, 112464)
60
+ end
61
+
62
+ def meme_not_sure_if(response)
63
+ generate_meme(response, 305, 84688)
64
+ end
65
+
66
+ def meme_yo_dawg(response)
67
+ generate_meme(response, 79, 108785)
68
+ end
69
+
70
+ def meme_are_belong(response)
71
+ generate_meme(response, 349058, 2079825)
72
+ end
73
+
74
+ def meme_fuck_you(response)
75
+ generate_meme(response, 1189472, 5044147)
76
+ end
77
+
78
+ def meme_bad_time(response)
79
+ generate_meme(response, 825296, 3786537)
80
+ end
81
+
82
+ def meme_simply(response)
83
+ generate_meme(response, 274947, 1865027)
84
+ end
85
+
86
+ def meme_grumpy_cat(response)
87
+ generate_meme(response, 1590955, 6541210)
88
+ end
89
+
90
+ def meme_looks_like(response)
91
+ generate_meme(response, 20469, 1159769)
92
+ end
93
+
94
+ def meme_am_i_only(response)
95
+ generate_meme(response, 953639, 4240352)
96
+ end
97
+
98
+ def meme_not_impressed(response)
99
+ generate_meme(response, 1420809, 5883168)
100
+ end
101
+
102
+ def meme_prepare_yourself(response)
103
+ generate_meme(response, 414926, 2295701)
104
+ end
105
+
106
+ def meme_what_if_i(response)
107
+ generate_meme(response, 1118843, 4796874)
108
+ end
109
+
110
+ def meme_better_drink(response)
111
+ generate_meme(response, 92, 89714)
112
+ end
113
+
114
+
115
+ private
116
+
117
+ def generate_meme(response, generator_id, image_id)
118
+ line1 = response.matches[0][1]
119
+ line2 = response.matches[0][2]
120
+ return if Lita.config.handlers.memegen.username.nil? || Lita.config.handlers.memegen.password.nil?
121
+
122
+ http_resp = http.get(
123
+ 'http://version1.api.memegenerator.net/Instance_Create',
124
+ username: Lita.config.handlers.memegen.username,
125
+ password: Lita.config.handlers.memegen.password,
126
+ languageCode: 'en',
127
+ generatorID: generator_id,
128
+ imageID: image_id,
129
+ text0: line1,
130
+ text1: line2
131
+ )
132
+
133
+ if http_resp.status == 200
134
+ data = MultiJson.load(http_resp.body)
135
+
136
+ if data['success']
137
+ response.reply data['result']['instanceImageUrl']
138
+ else
139
+ response.reply "Error: Unable to generate a meme image"
140
+ end
141
+
142
+ else
143
+ response.reply "Error: Unable to generate a meme image"
144
+ end
145
+
146
+ end
147
+
148
+
149
+
150
+ end
151
+
152
+ Lita.register_handler(Memegen)
153
+ end
154
+ end
@@ -0,0 +1,23 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "lita-memegen"
3
+ spec.version = "1.0.0"
4
+ spec.authors = ["Mitch Dempsey"]
5
+ spec.email = ["mitch@mitchdempsey.com"]
6
+ spec.description = %q{A Lita handler for generating meme images.}
7
+ spec.summary = %q{A Lita handler for generating meme images.}
8
+ spec.homepage = "https://github.com/webdestroya/lita-memegen"
9
+ spec.license = "MIT"
10
+
11
+ spec.files = `git ls-files`.split($/)
12
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
13
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
14
+ spec.require_paths = ["lib"]
15
+
16
+ spec.add_runtime_dependency "lita", "~> 2.0"
17
+
18
+ spec.add_development_dependency "bundler", "~> 1.3"
19
+ spec.add_development_dependency "rake"
20
+ spec.add_development_dependency "rspec", "~> 2.14"
21
+ spec.add_development_dependency "simplecov"
22
+ spec.add_development_dependency "coveralls"
23
+ end
@@ -0,0 +1,11 @@
1
+ require "spec_helper"
2
+
3
+ describe Lita::Handlers::Memegen, lita_handler: true do
4
+ it { routes_command("Y U NO BLAH").to(:y_u_no) }
5
+
6
+ it "sets the username and password to nil by default" do
7
+ expect(Lita.config.handlers.memegen.username).to be_nil
8
+ expect(Lita.config.handlers.memegen.password).to be_nil
9
+ end
10
+
11
+ end
@@ -0,0 +1,10 @@
1
+ require "simplecov"
2
+ require "coveralls"
3
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
4
+ SimpleCov::Formatter::HTMLFormatter,
5
+ Coveralls::SimpleCov::Formatter
6
+ ]
7
+ SimpleCov.start { add_filter "/spec/" }
8
+
9
+ require "lita-memegen"
10
+ require "lita/rspec"
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lita-memegen
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Mitch Dempsey
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: lita
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.14'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '2.14'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: coveralls
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: A Lita handler for generating meme images.
98
+ email:
99
+ - mitch@mitchdempsey.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .gitignore
105
+ - .ruby-version
106
+ - .travis.yml
107
+ - Gemfile
108
+ - LICENSE
109
+ - README.md
110
+ - Rakefile
111
+ - lib/lita-memegen.rb
112
+ - lib/lita/handlers/memegen.rb
113
+ - lita-memegen.gemspec
114
+ - spec/lita/handlers/memegen_spec.rb
115
+ - spec/spec_helper.rb
116
+ homepage: https://github.com/webdestroya/lita-memegen
117
+ licenses:
118
+ - MIT
119
+ metadata: {}
120
+ post_install_message:
121
+ rdoc_options: []
122
+ require_paths:
123
+ - lib
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - '>='
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ requirements: []
135
+ rubyforge_project:
136
+ rubygems_version: 2.0.7
137
+ signing_key:
138
+ specification_version: 4
139
+ summary: A Lita handler for generating meme images.
140
+ test_files:
141
+ - spec/lita/handlers/memegen_spec.rb
142
+ - spec/spec_helper.rb