lita-twit 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5dd114b06bb9786cce1ee867ba0352236f8e8d4c
4
+ data.tar.gz: d5b14e3bba2b125579604e31a1537921ac28458b
5
+ SHA512:
6
+ metadata.gz: c90deb9efd370db82cb3d00b551eaa222f51cc8c861dd7f75693f548e2cfb8c9ac9e9950aa22054b083441e90545309f97428e05915f8cb69af0359cbe1d51cd
7
+ data.tar.gz: 479738252c0cdfdd06405d1843517f53d4b370e0b0e0893310c78c2af9dfe32365f81be5e591d354ce89fb84cfdf17464d66c2a667ec1860096e7c3e3eae2e1a
@@ -0,0 +1,42 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /.yardoc
5
+ /coverage/
6
+ /doc/
7
+ /InstalledFiles
8
+ /pkg/
9
+ /rdoc/
10
+ /lib/bundler/man
11
+ /spec/reports/
12
+ /test/tmp/
13
+ /test/version_tmp/
14
+ /tmp/
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+
21
+ ## Documentation cache and generated files:
22
+ /.yardoc/
23
+ /_yardoc/
24
+ /doc/
25
+ /rdoc/
26
+
27
+ ## Environment normalisation:
28
+ /.bundle/
29
+ /vendor/bundle
30
+ /lib/bundler/man/
31
+
32
+ # for a library or gem, you might want to ignore these files since the code is
33
+ # intended to run in multiple environments; otherwise, check them in:
34
+ Gemfile.lock
35
+ .ruby-version
36
+ .ruby-gemset
37
+
38
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
39
+ .rvmrc
40
+
41
+
42
+
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Jivko Georgiev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,19 @@
1
+ # lita-twit
2
+
3
+ TODO: Add a description of the plugin.
4
+
5
+ ## Installation
6
+
7
+ Add lita-twit to your Lita instance's Gemfile:
8
+
9
+ ``` ruby
10
+ gem "lita-twit"
11
+ ```
12
+
13
+ ## Configuration
14
+
15
+ TODO: Describe any configuration attributes the plugin exposes.
16
+
17
+ ## Usage
18
+
19
+ TODO: Describe the plugin's features and how to use them.
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,12 @@
1
+ require "lita"
2
+
3
+ Lita.load_locales Dir[File.expand_path(
4
+ File.join("..", "..", "locales", "*.yml"), __FILE__
5
+ )]
6
+
7
+ require "lita/handlers/twit"
8
+
9
+ Lita::Handlers::Twit.template_root File.expand_path(
10
+ File.join("..", "..", "templates"),
11
+ __FILE__
12
+ )
@@ -0,0 +1,55 @@
1
+ require "twitter"
2
+ module Lita
3
+ module Handlers
4
+ class Twit < Handler
5
+ config :consumer_key, type: String, required: true
6
+ config :consumer_secret, type: String, required: true
7
+ config :access_token, type: String, required: true
8
+ config :access_token_secret, type: String , required: true
9
+
10
+ route(/^tw(?:eet|itter)?\s+(\w+)/i, :user_tweet, command: true,
11
+ help: {t("help.twit_key") => t("help.twit_value")})
12
+
13
+ route(/^tw(?:it)?\s+(\w+)/i, :twit, command: true,
14
+ help: {"twit" => "twit status"})
15
+
16
+
17
+ def initialize(robot)
18
+ super
19
+ @client = Twitter::REST::Client.new do |config|
20
+ config.consumer_key = Lita.config.handlers.twit.consumer_key
21
+ config.consumer_secret = Lita.config.handlers.twit.consumer_secret
22
+ config.access_token = Lita.config.handlers.twit.access_token
23
+ config.access_token_secret = Lita.config.handlers.twit.access_token_secret
24
+ end
25
+ end
26
+
27
+ def twit(response)
28
+ text = response.message.body
29
+ response.reply post_twit(text)
30
+ end
31
+
32
+ def user_tweet(response)
33
+ username = response.matches.first.first
34
+ if @client.user?(username)
35
+ user = @client.user(username)
36
+ tweets = @client.user_timeline(user, {count: 1, include_rts: false})
37
+ unless tweets.empty?
38
+ response.reply format(tweets.first)
39
+ end
40
+ end
41
+ end
42
+
43
+ private
44
+ def post_twit(text)
45
+ client = @client.update(text.gsub("twit", ""))
46
+ return client.user.name + " twit: " + client.text
47
+ end
48
+ def format(tweet)
49
+ "\"#{tweet.text}\" --#{tweet.user.name}, #{tweet.created_at.strftime('%F')}"
50
+ end
51
+ end
52
+
53
+ Lita.register_handler(Twit)
54
+ end
55
+ end
@@ -0,0 +1,25 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "lita-twit"
3
+ spec.version = "0.0.2"
4
+ spec.authors = ["Jivko Georgiev"]
5
+ spec.email = ["jivkobg@gmail.com"]
6
+ spec.description = "Twitter handler"
7
+ spec.summary = "Twitter api handler"
8
+ spec.homepage = "https://github.com/jivko/lita-twit"
9
+ spec.license = "MIT License (MIT)"
10
+ spec.metadata = { "lita_plugin_type" => "handler" }
11
+
12
+ spec.files = `git ls-files`.split($/)
13
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
14
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
+ spec.require_paths = ["lib"]
16
+
17
+ spec.add_runtime_dependency "lita", "~> 4.4"
18
+ spec.add_runtime_dependency "twitter", '~> 5.14', '>= 5.14.0'
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.3"
21
+ spec.add_development_dependency "pry-byebug", '~> 0'
22
+ spec.add_development_dependency "rake", '~> 0'
23
+ spec.add_development_dependency "rack-test", '~> 0'
24
+ spec.add_development_dependency "rspec", '~> 3.0', '>= 3.0.0'
25
+ end
@@ -0,0 +1,7 @@
1
+ en:
2
+ lita:
3
+ handlers:
4
+ twit:
5
+ help:
6
+ twit_key: "tweet USERNAME"
7
+ twit_value: "Display the latest tweet by USERNAME."
@@ -0,0 +1,4 @@
1
+ require "spec_helper"
2
+
3
+ describe Lita::Handlers::Twit, lita_handler: true do
4
+ end
@@ -0,0 +1,6 @@
1
+ require "lita-twit"
2
+ require "lita/rspec"
3
+
4
+ # A compatibility mode is provided for older plugins upgrading from Lita 3. Since this plugin
5
+ # was generated with Lita 4, the compatibility mode should be left disabled.
6
+ Lita.version_3_compatibility_mode = false
File without changes
metadata ADDED
@@ -0,0 +1,169 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lita-twit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Jivko Georgiev
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-28 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: '4.4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: twitter
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5.14'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 5.14.0
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '5.14'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 5.14.0
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.3'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.3'
61
+ - !ruby/object:Gem::Dependency
62
+ name: pry-byebug
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rake
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: rack-test
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: rspec
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '3.0'
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 3.0.0
113
+ type: :development
114
+ prerelease: false
115
+ version_requirements: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: '3.0'
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: 3.0.0
123
+ description: Twitter handler
124
+ email:
125
+ - jivkobg@gmail.com
126
+ executables: []
127
+ extensions: []
128
+ extra_rdoc_files: []
129
+ files:
130
+ - ".gitignore"
131
+ - Gemfile
132
+ - LICENSE
133
+ - README.md
134
+ - Rakefile
135
+ - lib/lita-twit.rb
136
+ - lib/lita/handlers/twit.rb
137
+ - lita-twit.gemspec
138
+ - locales/en.yml
139
+ - spec/lita/handlers/twit_spec.rb
140
+ - spec/spec_helper.rb
141
+ - templates/.gitkeep
142
+ homepage: https://github.com/jivko/lita-twit
143
+ licenses:
144
+ - MIT License (MIT)
145
+ metadata:
146
+ lita_plugin_type: handler
147
+ post_install_message:
148
+ rdoc_options: []
149
+ require_paths:
150
+ - lib
151
+ required_ruby_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ required_rubygems_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ requirements: []
162
+ rubyforge_project:
163
+ rubygems_version: 2.4.5
164
+ signing_key:
165
+ specification_version: 4
166
+ summary: Twitter api handler
167
+ test_files:
168
+ - spec/lita/handlers/twit_spec.rb
169
+ - spec/spec_helper.rb