cinch-twitterstatus 1.0.0 → 1.1.3
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.
- checksums.yaml +7 -0
- data/.travis.yml +31 -14
- data/README.md +10 -7
- data/cinch-twitterstatus.gemspec +13 -11
- data/lib/cinch-twitterstatus.rb +2 -1
- data/lib/cinch/plugins/twitterstatus.rb +66 -0
- data/lib/cinch/plugins/twitterstatus/version.rb +6 -2
- data/spec/cinch-twitterstatus_spec.rb +39 -26
- metadata +75 -48
- data/lib/cinch/plugins/twitterstatus/twitterstatus.rb +0 -45
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 5f2a2dbea0eb64b6be134d7650be065f23132950eeedec17cba6dfe21fa543dd
|
|
4
|
+
data.tar.gz: 34ff00fb7bee7625b26619e80a0326ed6e3eebeac19ce6d4cee078bbb5c0bd83
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: d589f98bffa2c599f7630efe12ac828a02b5e83beb20ce6f44e875828cb746cf9ec70b26394ed6c5dd13dbb1eea8fefc32637c5738fce71a73edea4ff2a9f58b
|
|
7
|
+
data.tar.gz: e852f71819fae6834bccb1d3bb22e70e8c176bc5c4bb0677a7f1792e446de050d935456a9ba03221ba991770951e84ed47dd44f0ec92dcb33ad0e037827ee002
|
data/.travis.yml
CHANGED
|
@@ -1,27 +1,44 @@
|
|
|
1
1
|
---
|
|
2
2
|
language: ruby
|
|
3
3
|
rvm:
|
|
4
|
-
- 1.
|
|
5
|
-
-
|
|
4
|
+
- 2.1.0
|
|
5
|
+
- 2.0.0
|
|
6
|
+
- 1.9.3
|
|
7
|
+
- 1.9.2
|
|
8
|
+
- 1.8.7
|
|
9
|
+
- jruby-18mode
|
|
10
|
+
- jruby-19mode
|
|
11
|
+
- ruby-head
|
|
12
|
+
- jruby-head
|
|
13
|
+
- ree
|
|
14
|
+
matrix:
|
|
15
|
+
allow_failures:
|
|
16
|
+
- rvm: 1.8.7
|
|
17
|
+
- rvm: ree
|
|
18
|
+
- rvm: jruby-18mode
|
|
19
|
+
- rvm: jruby-19mode
|
|
20
|
+
- rvm: jruby-head
|
|
21
|
+
fast_finish: true
|
|
6
22
|
env:
|
|
7
23
|
global:
|
|
8
|
-
|
|
24
|
+
- JRUBY_OPTS=-Xcext.enabled=true
|
|
25
|
+
- secure: ! 'Yz/VAtfbXwk6JD/2/z6c2SGygNGELrF0dlZ/M5nOrDiKNm8lxpC6w19esGbB
|
|
9
26
|
|
|
10
|
-
|
|
27
|
+
CYt8UtqylceJ2UxYngHLVH48oPb+A5fv21/jDJMqHeO/N4WjwQUOzBZXfZG6
|
|
11
28
|
|
|
12
|
-
|
|
13
|
-
|
|
29
|
+
lpugXIsT9Q10q0AsXry65YuzZtpY7VkVQUNSBYte7jTcWbLmIWQ='
|
|
30
|
+
- secure: ! 'CbdMyExVnyHfPQ+scSky8JIlqK0dU7idBrtvipQIA2dGfIIj0lzuUDEqvtAv
|
|
14
31
|
|
|
15
|
-
|
|
32
|
+
+9A7Mw01ddxQ/tXdixHDBNOhp9Ddz+4/0OSMyIb/5uFy+l7b2B2K4A4R5crI
|
|
16
33
|
|
|
17
|
-
|
|
18
|
-
|
|
34
|
+
RBc5W5rgzRLnDD7HL4BZMRDpx3sJRLcIH9S4bclXyjkzQ7yzVDc='
|
|
35
|
+
- secure: ! 'Pl14JkhwMe+HHi1Ht0znd0+TnSzdSGvtG4pX8+oSWuIyfTd3xfoj7Pf1S4P/
|
|
19
36
|
|
|
20
|
-
|
|
37
|
+
7SVnixq2gQh13OaL4Tj2sR6+AHz6n+onareFoKkZPSJuDRh6yXFfvKIdx4MV
|
|
21
38
|
|
|
22
|
-
|
|
23
|
-
|
|
39
|
+
l5lIJbSI4icPWOMk6ObMCzIb/m3m4Z/BG3O5E/6AcJDQa7rspL0='
|
|
40
|
+
- secure: ! 'Xrh52mNuRCf1kJHpZctrz3gfBZQ/rlC+qz/MlvZ9L7sm1CFSIoJdizrOYawt
|
|
24
41
|
|
|
25
|
-
|
|
42
|
+
cKOyLfsLrcnJqGbq0s++cSQ2QDggEGxtVkMXxIw7dBFn2icZsKsTN5rh28UR
|
|
26
43
|
|
|
27
|
-
|
|
44
|
+
W2TakLhFB8f+LQ+/P9PvV1wlSOJQRFItLjjOtcEoQVLi51Pwuzw='
|
data/README.md
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
[](https://coveralls.io/r/bhaberer/cinch-twitterstatus?branch=master)
|
|
7
7
|
[](https://codeclimate.com/github/bhaberer/cinch-twitterstatus)
|
|
8
8
|
|
|
9
|
-
Posts the content of a linked Tweet to the channel
|
|
9
|
+
Posts the content of a linked Tweet to the channel, can also follow users and
|
|
10
|
+
post their tweets.
|
|
10
11
|
|
|
11
12
|
## Installation
|
|
12
13
|
|
|
@@ -32,14 +33,16 @@ For the gem to work alll you will need to is add the gem to your plugins:
|
|
|
32
33
|
end
|
|
33
34
|
end
|
|
34
35
|
|
|
35
|
-
And, acquire Twitter credentials. They are simple to acquire,
|
|
36
|
+
And, acquire Twitter credentials. They are simple to acquire,
|
|
37
|
+
see https://dev.twitter.com/apps/new
|
|
36
38
|
|
|
37
|
-
Once you have said credentials you will need to pass them to the Plugin's
|
|
39
|
+
Once you have said credentials you will need to pass them to the Plugin's
|
|
40
|
+
config like so:
|
|
38
41
|
|
|
39
|
-
c.plugins.options[Cinch::Plugins::TwitterStatus] = { :
|
|
40
|
-
:
|
|
41
|
-
:
|
|
42
|
-
:
|
|
42
|
+
c.plugins.options[Cinch::Plugins::TwitterStatus] = { consumer_key: 'consumer_key',
|
|
43
|
+
consumer_secret: 'consumer_secret',
|
|
44
|
+
access_token: 'access_token',
|
|
45
|
+
access_secret: 'access_secret' }
|
|
43
46
|
|
|
44
47
|
Then post a link to a specific tweet and the bot should post the content of said tweet to the channel.
|
|
45
48
|
|
data/cinch-twitterstatus.gemspec
CHANGED
|
@@ -4,23 +4,25 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
|
4
4
|
require 'cinch/plugins/twitterstatus/version'
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |gem|
|
|
7
|
-
gem.name =
|
|
8
|
-
gem.version = Cinch::
|
|
9
|
-
gem.authors = [
|
|
10
|
-
gem.email = [
|
|
7
|
+
gem.name = 'cinch-twitterstatus'
|
|
8
|
+
gem.version = Cinch::Plugins::TwitterStatus::VERSION
|
|
9
|
+
gem.authors = ['Brian Haberer']
|
|
10
|
+
gem.email = ['bhaberer@gmail.com']
|
|
11
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
12
|
gem.summary = %q{Cinch Plugin to post tweets to channel.}
|
|
13
|
-
gem.homepage =
|
|
13
|
+
gem.homepage = 'https://github.com/bhaberer/cinch-twitterstatus'
|
|
14
|
+
gem.license = 'MIT'
|
|
14
15
|
|
|
15
16
|
gem.files = `git ls-files`.split($/)
|
|
16
17
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
17
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
18
19
|
gem.require_paths = ["lib"]
|
|
20
|
+
gem.add_development_dependency 'rake', '~> 12.3.3'
|
|
21
|
+
gem.add_development_dependency 'rspec', '~> 3'
|
|
22
|
+
gem.add_development_dependency 'coveralls', '~> 0.7'
|
|
23
|
+
gem.add_development_dependency 'cinch-test', '~> 0.1', '>= 0.1.4'
|
|
19
24
|
|
|
20
|
-
gem.
|
|
21
|
-
gem.
|
|
22
|
-
gem.
|
|
23
|
-
gem.add_development_dependency 'cinch-test'
|
|
24
|
-
|
|
25
|
-
gem.add_dependency 'twitter', '~> 4.8.1'
|
|
25
|
+
gem.add_dependency 'cinch', '~> 2'
|
|
26
|
+
gem.add_dependency 'cinch-toolbox', '~> 1.1.7'
|
|
27
|
+
gem.add_dependency 'twitter', '~> 5.16', '>= 5.16.0'
|
|
26
28
|
end
|
data/lib/cinch-twitterstatus.rb
CHANGED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'cinch'
|
|
3
|
+
require 'cinch/toolbox'
|
|
4
|
+
require 'twitter'
|
|
5
|
+
|
|
6
|
+
module Cinch
|
|
7
|
+
module Plugins
|
|
8
|
+
# Cinch Plugin to post twitter statuses
|
|
9
|
+
class TwitterStatus
|
|
10
|
+
include Cinch::Plugin
|
|
11
|
+
|
|
12
|
+
self.help = 'Just link to a specific twitter status and I will ' \
|
|
13
|
+
'post the content of that tweet.'
|
|
14
|
+
|
|
15
|
+
listen_to :channel
|
|
16
|
+
|
|
17
|
+
def initialize(*args)
|
|
18
|
+
super
|
|
19
|
+
@client = twitter_client
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def listen(m)
|
|
23
|
+
Cinch::Toolbox.extract_urls(m.message).each do |url|
|
|
24
|
+
next unless url.match(%r(^https?://mobile|w{3}?\.?twitter\.com/))
|
|
25
|
+
msg = format_tweet(url)
|
|
26
|
+
m.reply msg unless msg.nil?
|
|
27
|
+
end
|
|
28
|
+
rescue Twitter::Error::NotFound, Twitter::Error::Forbidden
|
|
29
|
+
debug 'User posted an invalid twitter status'
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def format_tweet(url)
|
|
33
|
+
# Parse the url and get the relevant data
|
|
34
|
+
user, status = parse_twitter_url(url)
|
|
35
|
+
|
|
36
|
+
# Return blank if we didn't get a good user and status
|
|
37
|
+
return if user.nil? || status.nil?
|
|
38
|
+
|
|
39
|
+
tweet_text(user, status)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def tweet_text(user, status)
|
|
43
|
+
# Scrub the tweet for returns so we don't have multilined responses.
|
|
44
|
+
status = status.gsub(/[\n]+/, ' ') if status.match(/\n/)
|
|
45
|
+
"@#{user} tweeted \"#{status}\""
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
private
|
|
49
|
+
|
|
50
|
+
def parse_twitter_url(url)
|
|
51
|
+
tweet_id = url[%r{statuse?s?/(\d+)/?}, 1]
|
|
52
|
+
user = url[%r{/?#?!?/([^\/]+)/statuse?s?}, 1]
|
|
53
|
+
[user, @client.status(tweet_id).text]
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def twitter_client
|
|
57
|
+
Twitter::REST::Client.new do |c|
|
|
58
|
+
c.consumer_key = config[:consumer_key]
|
|
59
|
+
c.consumer_secret = config[:consumer_secret]
|
|
60
|
+
c.access_token = config[:access_token]
|
|
61
|
+
c.access_token_secret = config[:access_secret]
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -5,37 +5,50 @@ describe Cinch::Plugins::TwitterStatus do
|
|
|
5
5
|
include Cinch::Test
|
|
6
6
|
|
|
7
7
|
before(:all) do
|
|
8
|
-
@bot = make_bot(Cinch::Plugins::TwitterStatus,
|
|
9
|
-
{ filename:
|
|
10
|
-
|
|
11
|
-
consumer_key:
|
|
8
|
+
@bot = make_bot(Cinch::Plugins::TwitterStatus,
|
|
9
|
+
{ filename: '/dev/null',
|
|
10
|
+
watchers: { '#foo' => ['weirdo513'] },
|
|
11
|
+
consumer_key: ENV['CONSUMER_KEY'],
|
|
12
12
|
consumer_secret: ENV['CONSUMER_SECRET'],
|
|
13
|
-
oauth_token:
|
|
14
|
-
oauth_secret:
|
|
13
|
+
oauth_token: ENV['OAUTH_TOKEN'],
|
|
14
|
+
oauth_secret: ENV['OAUTH_SECRET'] })
|
|
15
|
+
@status =
|
|
16
|
+
{ normal: 'https://twitter.com/weirdo513/status/344186643609174016',
|
|
17
|
+
protected: 'https://twitter.com/brewtopian/status/68071618055901184',
|
|
18
|
+
invalid: 'https://twitter.com/weirdo513/status/3INVALI643609174016',
|
|
19
|
+
multiline: 'https://twitter.com/Peeardee/status/502209346038951937'}
|
|
15
20
|
end
|
|
16
21
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
describe "Twitter Link Parsing" do
|
|
23
|
+
it 'should return the text of the tweet when linked in the channel' do
|
|
24
|
+
msg = get_replies(make_message(@bot, @status[:normal],
|
|
25
|
+
{ channel: '#foo', nick: 'bar' })).first
|
|
26
|
+
expect(msg.text).to eq('@weirdo513 tweeted "HOW IS THAT MIC STILL ON JESUS"')
|
|
27
|
+
end
|
|
22
28
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
it 'should return the text of the tweet when linked in the channel' do
|
|
30
|
+
msg = get_replies(make_message(@bot, @status[:multiline],
|
|
31
|
+
{ channel: '#foo', nick: 'bar' })).first
|
|
32
|
+
expect(msg.text).to eq('@Peeardee tweeted "Dear My RP Group, I *will* be working on the Enforcer schedule during our Call of Cthulhu session tonight. Will make frequent sanity rolls."')
|
|
33
|
+
end
|
|
28
34
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
it 'should not return any text if the status is invalid' do
|
|
36
|
+
msg = get_replies(make_message(@bot, @status[:invalid],
|
|
37
|
+
{ channel: '#foo', nick: 'bar' }))
|
|
38
|
+
expect(msg).to be_empty
|
|
39
|
+
end
|
|
34
40
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
it 'should not return any text if the status is protected' do
|
|
42
|
+
msg = get_replies(make_message(@bot, @status[:protected],
|
|
43
|
+
{ channel: '#foo', nick: 'bar' }))
|
|
44
|
+
expect(msg).to be_empty
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'should not run without credentials set' do
|
|
48
|
+
bot = make_bot(Cinch::Plugins::TwitterStatus)
|
|
49
|
+
msg = get_replies(make_message(bot, @status[:normal],
|
|
50
|
+
{ channel: '#foo', nick: 'bar' }))
|
|
51
|
+
expect(msg).to be_empty
|
|
52
|
+
end
|
|
39
53
|
end
|
|
40
54
|
end
|
|
41
|
-
|
metadata
CHANGED
|
@@ -1,96 +1,125 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cinch-twitterstatus
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
5
|
-
prerelease:
|
|
4
|
+
version: 1.1.3
|
|
6
5
|
platform: ruby
|
|
7
6
|
authors:
|
|
8
7
|
- Brian Haberer
|
|
9
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 2021-01-27 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
14
|
name: rake
|
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
|
17
|
-
none: false
|
|
18
16
|
requirements:
|
|
19
|
-
- -
|
|
17
|
+
- - "~>"
|
|
20
18
|
- !ruby/object:Gem::Version
|
|
21
|
-
version:
|
|
19
|
+
version: 12.3.3
|
|
22
20
|
type: :development
|
|
23
21
|
prerelease: false
|
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
-
none: false
|
|
26
23
|
requirements:
|
|
27
|
-
- -
|
|
24
|
+
- - "~>"
|
|
28
25
|
- !ruby/object:Gem::Version
|
|
29
|
-
version:
|
|
26
|
+
version: 12.3.3
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
|
31
28
|
name: rspec
|
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
|
33
|
-
none: false
|
|
34
30
|
requirements:
|
|
35
|
-
- -
|
|
31
|
+
- - "~>"
|
|
36
32
|
- !ruby/object:Gem::Version
|
|
37
|
-
version: '
|
|
33
|
+
version: '3'
|
|
38
34
|
type: :development
|
|
39
35
|
prerelease: false
|
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
-
none: false
|
|
42
37
|
requirements:
|
|
43
|
-
- -
|
|
38
|
+
- - "~>"
|
|
44
39
|
- !ruby/object:Gem::Version
|
|
45
|
-
version: '
|
|
40
|
+
version: '3'
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
|
47
42
|
name: coveralls
|
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
|
49
|
-
none: false
|
|
50
44
|
requirements:
|
|
51
|
-
- -
|
|
45
|
+
- - "~>"
|
|
52
46
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: '0'
|
|
47
|
+
version: '0.7'
|
|
54
48
|
type: :development
|
|
55
49
|
prerelease: false
|
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
-
none: false
|
|
58
51
|
requirements:
|
|
59
|
-
- -
|
|
52
|
+
- - "~>"
|
|
60
53
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '0'
|
|
54
|
+
version: '0.7'
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
|
63
56
|
name: cinch-test
|
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
|
65
|
-
none: false
|
|
66
58
|
requirements:
|
|
67
|
-
- -
|
|
59
|
+
- - "~>"
|
|
68
60
|
- !ruby/object:Gem::Version
|
|
69
|
-
version: '0'
|
|
61
|
+
version: '0.1'
|
|
62
|
+
- - ">="
|
|
63
|
+
- !ruby/object:Gem::Version
|
|
64
|
+
version: 0.1.4
|
|
70
65
|
type: :development
|
|
71
66
|
prerelease: false
|
|
72
67
|
version_requirements: !ruby/object:Gem::Requirement
|
|
73
|
-
none: false
|
|
74
68
|
requirements:
|
|
75
|
-
- -
|
|
69
|
+
- - "~>"
|
|
70
|
+
- !ruby/object:Gem::Version
|
|
71
|
+
version: '0.1'
|
|
72
|
+
- - ">="
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: 0.1.4
|
|
75
|
+
- !ruby/object:Gem::Dependency
|
|
76
|
+
name: cinch
|
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - "~>"
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: '2'
|
|
82
|
+
type: :runtime
|
|
83
|
+
prerelease: false
|
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - "~>"
|
|
76
87
|
- !ruby/object:Gem::Version
|
|
77
|
-
version: '
|
|
88
|
+
version: '2'
|
|
89
|
+
- !ruby/object:Gem::Dependency
|
|
90
|
+
name: cinch-toolbox
|
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
|
92
|
+
requirements:
|
|
93
|
+
- - "~>"
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: 1.1.7
|
|
96
|
+
type: :runtime
|
|
97
|
+
prerelease: false
|
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
99
|
+
requirements:
|
|
100
|
+
- - "~>"
|
|
101
|
+
- !ruby/object:Gem::Version
|
|
102
|
+
version: 1.1.7
|
|
78
103
|
- !ruby/object:Gem::Dependency
|
|
79
104
|
name: twitter
|
|
80
105
|
requirement: !ruby/object:Gem::Requirement
|
|
81
|
-
none: false
|
|
82
106
|
requirements:
|
|
83
|
-
- - ~>
|
|
107
|
+
- - "~>"
|
|
84
108
|
- !ruby/object:Gem::Version
|
|
85
|
-
version:
|
|
109
|
+
version: '5.16'
|
|
110
|
+
- - ">="
|
|
111
|
+
- !ruby/object:Gem::Version
|
|
112
|
+
version: 5.16.0
|
|
86
113
|
type: :runtime
|
|
87
114
|
prerelease: false
|
|
88
115
|
version_requirements: !ruby/object:Gem::Requirement
|
|
89
|
-
none: false
|
|
90
116
|
requirements:
|
|
91
|
-
- - ~>
|
|
117
|
+
- - "~>"
|
|
118
|
+
- !ruby/object:Gem::Version
|
|
119
|
+
version: '5.16'
|
|
120
|
+
- - ">="
|
|
92
121
|
- !ruby/object:Gem::Version
|
|
93
|
-
version:
|
|
122
|
+
version: 5.16.0
|
|
94
123
|
description: Cinch IRC bot Plugin that access the Twitter API to post the content
|
|
95
124
|
of linked twitter statuses to the channel.
|
|
96
125
|
email:
|
|
@@ -99,43 +128,41 @@ executables: []
|
|
|
99
128
|
extensions: []
|
|
100
129
|
extra_rdoc_files: []
|
|
101
130
|
files:
|
|
102
|
-
- .gitignore
|
|
103
|
-
- .travis.yml
|
|
131
|
+
- ".gitignore"
|
|
132
|
+
- ".travis.yml"
|
|
104
133
|
- Gemfile
|
|
105
134
|
- LICENSE.txt
|
|
106
135
|
- README.md
|
|
107
136
|
- Rakefile
|
|
108
137
|
- cinch-twitterstatus.gemspec
|
|
109
138
|
- lib/cinch-twitterstatus.rb
|
|
110
|
-
- lib/cinch/plugins/twitterstatus
|
|
139
|
+
- lib/cinch/plugins/twitterstatus.rb
|
|
111
140
|
- lib/cinch/plugins/twitterstatus/version.rb
|
|
112
141
|
- spec/cinch-twitterstatus_spec.rb
|
|
113
142
|
- spec/spec_helper.rb
|
|
114
143
|
homepage: https://github.com/bhaberer/cinch-twitterstatus
|
|
115
|
-
licenses:
|
|
116
|
-
|
|
144
|
+
licenses:
|
|
145
|
+
- MIT
|
|
146
|
+
metadata: {}
|
|
147
|
+
post_install_message:
|
|
117
148
|
rdoc_options: []
|
|
118
149
|
require_paths:
|
|
119
150
|
- lib
|
|
120
151
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
121
|
-
none: false
|
|
122
152
|
requirements:
|
|
123
|
-
- -
|
|
153
|
+
- - ">="
|
|
124
154
|
- !ruby/object:Gem::Version
|
|
125
155
|
version: '0'
|
|
126
156
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
|
-
none: false
|
|
128
157
|
requirements:
|
|
129
|
-
- -
|
|
158
|
+
- - ">="
|
|
130
159
|
- !ruby/object:Gem::Version
|
|
131
160
|
version: '0'
|
|
132
161
|
requirements: []
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
specification_version: 3
|
|
162
|
+
rubygems_version: 3.2.6
|
|
163
|
+
signing_key:
|
|
164
|
+
specification_version: 4
|
|
137
165
|
summary: Cinch Plugin to post tweets to channel.
|
|
138
166
|
test_files:
|
|
139
167
|
- spec/cinch-twitterstatus_spec.rb
|
|
140
168
|
- spec/spec_helper.rb
|
|
141
|
-
has_rdoc:
|
|
@@ -1,45 +0,0 @@
|
|
|
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
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def listen(m)
|
|
26
|
-
urls = URI.extract(m.message, ["http", "https"])
|
|
27
|
-
urls.each do |url|
|
|
28
|
-
if url.match(/^https?:\/\/mobile|w{3}?\.?twitter\.com/)
|
|
29
|
-
if tweet = url.match(/https?:\/\/mobile|w{3}?\.?twitter\.com\/?#?!?\/([^\/]+)\/statuse?s?\/(\d+)\/?/)
|
|
30
|
-
status = Twitter.status(tweet[2]).text
|
|
31
|
-
status.gsub!(/[\n]+/, " ") if status.match(/\n/)
|
|
32
|
-
user = tweet[1]
|
|
33
|
-
unless user.nil? || status.nil?
|
|
34
|
-
m.reply "@#{user} tweeted \"#{status}\""
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
rescue Twitter::Error::NotFound
|
|
40
|
-
debug "User posted an invalid twitter status"
|
|
41
|
-
rescue Twitter::Error::Forbidden
|
|
42
|
-
debug "User attempted to post a Protected Tweet or you have not set valid Twitter credentials."
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|