cinch-hangouts 0.0.1
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.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +37 -0
- data/Rakefile +1 -0
- data/cinch-hangouts.gemspec +24 -0
- data/lib/cinch-hangouts.rb +5 -0
- data/lib/cinch/plugins/hangouts/hangouts.rb +101 -0
- data/lib/cinch/plugins/hangouts/version.rb +7 -0
- metadata +118 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
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,37 @@
|
|
1
|
+
# Cinch::Plugins::Hangouts
|
2
|
+
|
3
|
+
Cinch Plugin for tracking Hangout URLs linked in the channel.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'cinch-hangouts'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install cinch-hangouts
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Just add the plugin to your list:
|
22
|
+
|
23
|
+
@bot = Cinch::Bot.new do
|
24
|
+
configure do |c|
|
25
|
+
c.plugins.plugins = [Cinch::Plugins::Hangouts]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
Then in channel use .hangouts to get notifications of the hangouts that have been linked recently.
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
1. Fork it
|
34
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
35
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
36
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
37
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,24 @@
|
|
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/hangouts/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "cinch-hangouts"
|
8
|
+
gem.version = Cinch::Plugins::Hangouts::VERSION
|
9
|
+
gem.authors = ["Brian Haberer"]
|
10
|
+
gem.email = ["bhaberer@gmail.com"]
|
11
|
+
gem.description = %q{Cinch Plugin to track any Google Hangouts that are linked into the channel}
|
12
|
+
gem.summary = %q{Cinch Plugin for racking Google Hangouts}
|
13
|
+
gem.homepage = "https://github.com/bhaberer/cinch-hangouts"
|
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 'cinch', '>= 2.0.0'
|
21
|
+
gem.add_dependency 'cinch-storage'
|
22
|
+
gem.add_dependency 'cinch-toolbox'
|
23
|
+
gem.add_dependency 'time-lord', '1.0.1'
|
24
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module Cinch::Plugins
|
3
|
+
class Hangouts
|
4
|
+
include Cinch::Plugin
|
5
|
+
|
6
|
+
self.help = "Use .hangouts to see the info for any recent hangouts. You can also use .hangouts subscribe to sign up for notifications."
|
7
|
+
|
8
|
+
match /hangouts\z/, method: :list_hangouts
|
9
|
+
match /hangouts subscribe/, method: :subscribe
|
10
|
+
match /hangouts unsubscribe/, method: :unsubscribe
|
11
|
+
|
12
|
+
listen_to :channel
|
13
|
+
|
14
|
+
def initialize(*args)
|
15
|
+
super
|
16
|
+
@storage = CinchStorage.new(config[:filename] || 'yaml/hangouts.yml')
|
17
|
+
@storage.data[:hangouts] ||= {}
|
18
|
+
@storage.data[:subscriptions] ||= []
|
19
|
+
@expire_period = config[:expire_period] || 120
|
20
|
+
end
|
21
|
+
|
22
|
+
def listen(m)
|
23
|
+
# This is the regex that captures hangout links in the following format:
|
24
|
+
#
|
25
|
+
# https://plus.google.com/hangouts/_/fbae432b70a47bdf7786e53a16f364895c09d9f8
|
26
|
+
#
|
27
|
+
# The regex will need to be updated if the url scheme changes in the future.
|
28
|
+
if m.message.match(/plus.google.com\/hangouts\//)
|
29
|
+
hangout_id = m.message[/[^\/?]{40}/, 0]
|
30
|
+
unless hangout_id.nil?
|
31
|
+
if @storage.data[:hangouts].key?(hangout_id)
|
32
|
+
@storage.data[:hangouts][hangout_id][:time] = Time.now
|
33
|
+
else
|
34
|
+
@storage.data[:hangouts][hangout_id] = {:user => m.user.nick, :time => Time.now}
|
35
|
+
end
|
36
|
+
|
37
|
+
synchronize(:hangout_save) do
|
38
|
+
@storage.save
|
39
|
+
end
|
40
|
+
|
41
|
+
@storage.data[:subscriptions].each do |user|
|
42
|
+
unless m.user.nick == user
|
43
|
+
Cinch::User.new(user, @bot).notice "#{m.user.nick} just linked a new hangout at #{hangout_url(hangout_id)}!"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def list_hangouts(m)
|
53
|
+
hangouts = sort_and_expire
|
54
|
+
if hangouts.empty?
|
55
|
+
m.user.notice "No hangouts have been linked recently!"
|
56
|
+
else
|
57
|
+
m.user.notice "These hangouts have been linked in the last #{@expire_period} minutes. They may or may not still be going."
|
58
|
+
hangouts.each do |hangout|
|
59
|
+
m.user.notice "#{hangout[:user]} started a hangout #{hangout[:time].ago.to_words} ago at #{hangout_url(hangout[:id])}"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def subscribe(m)
|
65
|
+
nick = m.user.nick
|
66
|
+
if @storage.data[:subscriptions].include?(nick)
|
67
|
+
m.user.notice "You are already subscribed, to unsubscribe use `.hangouts unsubscribe`"
|
68
|
+
else
|
69
|
+
@storage.data[:subscriptions] << nick
|
70
|
+
synchronize(:hangout_save) do
|
71
|
+
@storage.save
|
72
|
+
end
|
73
|
+
m.user.notice "You are now subscribed, and will receive a message when a *new* hangout is linked. To unsubscribe use `.hangouts unsubscribe`."
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def unsubscribe(m)
|
78
|
+
nick = m.user.nick
|
79
|
+
if @storage.data[:subscriptions].include?(nick)
|
80
|
+
@storage.data[:subscriptions].delete(nick)
|
81
|
+
synchronize(:hangout_save) do
|
82
|
+
@storage.save
|
83
|
+
end
|
84
|
+
m.user.notice "You are now unsubscribed, and will no longer receive a messages. To resubscribe use `.hangouts subscribe`."
|
85
|
+
else
|
86
|
+
m.user.notice "You are not subscribed, to subscribe use `.hangouts subscribe`"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def sort_and_expire
|
91
|
+
hangouts = @storage.data[:hangouts].each_pair.map { |x,y| y[:id] = x;y }
|
92
|
+
hangouts.delete_if { |h| Time.now - h[:time] > @expire_period * 60 }
|
93
|
+
hangouts.sort! { |x,y| y[:time] <=> x[:time] }
|
94
|
+
return hangouts
|
95
|
+
end
|
96
|
+
|
97
|
+
def hangout_url(id)
|
98
|
+
return Cinch::Toolbox.shorten("https://plus.google.com/hangouts/_/#{id}")
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cinch-hangouts
|
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-04 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: cinch
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.0.0
|
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: 2.0.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: cinch-storage
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: cinch-toolbox
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: time-lord
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - '='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.0.1
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - '='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 1.0.1
|
78
|
+
description: Cinch Plugin to track any Google Hangouts that are linked into the channel
|
79
|
+
email:
|
80
|
+
- bhaberer@gmail.com
|
81
|
+
executables: []
|
82
|
+
extensions: []
|
83
|
+
extra_rdoc_files: []
|
84
|
+
files:
|
85
|
+
- .gitignore
|
86
|
+
- Gemfile
|
87
|
+
- LICENSE.txt
|
88
|
+
- README.md
|
89
|
+
- Rakefile
|
90
|
+
- cinch-hangouts.gemspec
|
91
|
+
- lib/cinch-hangouts.rb
|
92
|
+
- lib/cinch/plugins/hangouts/hangouts.rb
|
93
|
+
- lib/cinch/plugins/hangouts/version.rb
|
94
|
+
homepage: https://github.com/bhaberer/cinch-hangouts
|
95
|
+
licenses: []
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
102
|
+
requirements:
|
103
|
+
- - ! '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
108
|
+
requirements:
|
109
|
+
- - ! '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 1.8.24
|
115
|
+
signing_key:
|
116
|
+
specification_version: 3
|
117
|
+
summary: Cinch Plugin for racking Google Hangouts
|
118
|
+
test_files: []
|