cinch-twitterstatus 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
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/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cinch-twitterstatus.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Brian Haberer
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # Cinch::TwitterStatus
2
+
3
+ Posts the content of a linked Tweet to the channel.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'cinch-twitterstatus'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install cinch-twitterstatus
18
+
19
+ ## Usage
20
+
21
+ For the gem to work alll you will need to is add the gem to your plugins:
22
+ @bot = Cinch::Bot.new do
23
+ configure do |c|
24
+ c.plugins.plugins = [ Cinch::Plugins::TwitterStatus]
25
+ end
26
+ end
27
+
28
+ And, acquire Twitter credentials. They are simple to acquire, see https://dev.twitter.com/apps/new
29
+
30
+ Once you have said credentials you will need to pass them to the Plugin's config like so:
31
+
32
+ c.plugins.options[Cinch::Plugins::TwitterStatus] = { :consumer_key => 'consumer_key',
33
+ :consumer_secret => 'consumer_secret',
34
+ :oauth_token => 'oauth_token',
35
+ :oauth_secret => 'oauth_secret' }
36
+
37
+ Then post a link to a specific tweet and the bot should post the content of said tweet to the channel.
38
+
39
+ ## Contributing
40
+
41
+ 1. Fork it
42
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
43
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
44
+ 4. Push to the branch (`git push origin my-new-feature`)
45
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cinch/plugins/twitterstatus/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "cinch-twitterstatus"
8
+ gem.version = Cinch::Twitterstatus::VERSION
9
+ gem.authors = ["Brian Haberer"]
10
+ gem.email = ["bhaberer@gmail.com"]
11
+ gem.description = %q{Cinch IRC bot Plugin that access the Twitter API to post the content of linked twitter statuses to the channel.}
12
+ gem.summary = %q{Cinch Plugin to post tweets to channel.}
13
+ gem.homepage = "https://github.com/bhaberer/cinch-twitterstatus"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency 'twitter', '4.6.2'
21
+ end
@@ -0,0 +1,46 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'cinch'
3
+ require 'twitter'
4
+
5
+ module Cinch::Plugins
6
+ class TwitterStatus
7
+ include Cinch::Plugin
8
+
9
+ self.help = 'Just link to a specific twitter status and I will post the content of that tweet.'
10
+
11
+ listen_to :channel
12
+
13
+ def initialize(*args)
14
+ super
15
+ if config
16
+ Twitter.configure do |c|
17
+ c.consumer_key = config[:consumer_key]
18
+ c.consumer_secret = config[:consumer_secret]
19
+ c.oauth_token = config[:oauth_token]
20
+ c.oauth_token_secret = config[:oauth_secret]
21
+ end
22
+ else
23
+ debug "You have not set your Twitter credentials, please do so!"
24
+ end
25
+ end
26
+
27
+ def listen(m)
28
+ urls = URI.extract(m.message, ["http", "https"])
29
+ urls.each do |url|
30
+ if url.match(/^https?:\/\/mobile|w{3}?\.?twitter\.com/)
31
+ twitter = {}
32
+ if tweet = url.match(/https?:\/\/mobile|w{3}?\.?twitter\.com\/?#?!?\/([^\/]+)\/statuse?s?\/(\d+)\/?/)
33
+ unless config[:twitter] == false
34
+ twitter[:status] = Twitter.status(tweet[2]).text
35
+ twitter[:status].gsub!(/[\n]+/, " ");
36
+ twitter[:user] = tweet[1]
37
+ m.reply "@#{twitter[:user]} tweeted \"#{twitter[:status]}\""
38
+ # FIXME Make this cinch-linkstumble aware at some point!
39
+ # post_quote(twitter[:status], "<a href='#{url}'>#{twitter[:user]} on Twitter</a>")
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,5 @@
1
+ module Cinch
2
+ module Twitterstatus
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require 'cinch/plugins/twitterstatus/version'
2
+ require 'cinch/plugins/twitterstatus/twitterstatus'
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cinch-twitterstatus
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Brian Haberer
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-05-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: twitter
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 4.6.2
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: 4.6.2
30
+ description: Cinch IRC bot Plugin that access the Twitter API to post the content
31
+ of linked twitter statuses to the channel.
32
+ email:
33
+ - bhaberer@gmail.com
34
+ executables: []
35
+ extensions: []
36
+ extra_rdoc_files: []
37
+ files:
38
+ - .gitignore
39
+ - Gemfile
40
+ - LICENSE.txt
41
+ - README.md
42
+ - Rakefile
43
+ - cinch-twitterstatus.gemspec
44
+ - lib/cinch-twitterstatus.rb
45
+ - lib/cinch/plugins/twitterstatus/twitterstatus.rb
46
+ - lib/cinch/plugins/twitterstatus/version.rb
47
+ homepage: https://github.com/bhaberer/cinch-twitterstatus
48
+ licenses: []
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ requirements: []
66
+ rubyforge_project:
67
+ rubygems_version: 1.8.24
68
+ signing_key:
69
+ specification_version: 3
70
+ summary: Cinch Plugin to post tweets to channel.
71
+ test_files: []