cinch-seen 1.0.3 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +23 -1
- data/cinch-seen.gemspec +12 -16
- data/lib/cinch/plugins/seen.rb +40 -48
- data/lib/cinch/plugins/seen/version.rb +1 -1
- data/spec/cinch-seen_spec.rb +17 -18
- metadata +38 -61
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: 0dfb70190d00e68a3163bf19fa941f62b2d7dcf9
|
4
|
+
data.tar.gz: 6b18a160621100b8a2d71e28ed944d4acc02ae56
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d40c2bc0ef84aa67c95d7c8396fd0afe44768e90f6ed0c18ddaf2e3c6970ec6d1be160566706c88d09b9469616a88c5c765d6e1bc54f46f233d5911f90166d2c
|
7
|
+
data.tar.gz: f3a0bd1b46a7c389884d5a725152632d3d41af006d6c8d1bd47a23dd6c87e88b43585562800460bd54f6811de7772ba833838db31033a926b3c23b5fcba541b4
|
data/.travis.yml
CHANGED
@@ -1,4 +1,26 @@
|
|
1
1
|
language: ruby
|
2
|
+
env:
|
3
|
+
global:
|
4
|
+
- "JRUBY_OPTS=-Xcext.enabled=true"
|
2
5
|
rvm:
|
3
|
-
- 1.
|
6
|
+
- 2.1.0
|
7
|
+
- 2.0.0
|
4
8
|
- 1.9.3
|
9
|
+
- 1.9.2
|
10
|
+
- 1.8.7
|
11
|
+
- jruby-18mode
|
12
|
+
- jruby-19mode
|
13
|
+
- ruby-head
|
14
|
+
- jruby-head
|
15
|
+
- ree
|
16
|
+
matrix:
|
17
|
+
allow_failures:
|
18
|
+
- rvm: 1.8.7
|
19
|
+
- rvm: ree
|
20
|
+
- rvm: jruby-18mode
|
21
|
+
- rvm: jruby-19mode
|
22
|
+
- rvm: jruby-head
|
23
|
+
fast_finish: true
|
24
|
+
env:
|
25
|
+
global:
|
26
|
+
- "JRUBY_OPTS=-Xcext.enabled=true"
|
data/cinch-seen.gemspec
CHANGED
@@ -8,24 +8,20 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.version = Cinch::Plugins::Seen::VERSION
|
9
9
|
gem.authors = ['Brian Haberer']
|
10
10
|
gem.email = ['bhaberer@gmail.com']
|
11
|
-
gem.description = %q
|
12
|
-
gem.summary = %q
|
11
|
+
gem.description = %q(Cinch Plugin to allow users to find out how long it's been since a user was active)
|
12
|
+
gem.summary = %q(Cinch Plugin for Seen)
|
13
13
|
gem.homepage = 'https://github.com/bhaberer/cinch-seen'
|
14
14
|
gem.license = 'MIT'
|
15
|
-
|
16
15
|
gem.files = `git ls-files`.split($/)
|
17
|
-
gem.executables = gem.files.grep(
|
18
|
-
gem.test_files = gem.files.grep(
|
16
|
+
gem.executables = gem.files.grep(/^bin\//).map { |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(/^(test|spec|features)\//)
|
19
18
|
gem.require_paths = ['lib']
|
20
|
-
|
21
|
-
gem.add_development_dependency
|
22
|
-
gem.add_development_dependency
|
23
|
-
gem.add_development_dependency
|
24
|
-
gem.
|
25
|
-
|
26
|
-
gem.add_dependency
|
27
|
-
gem.add_dependency
|
28
|
-
gem.add_dependency 'cinch-cooldown', '~> 1.1.1'
|
29
|
-
gem.add_dependency 'cinch-storage', '~> 1.1.0'
|
30
|
-
gem.add_dependency 'time-lord', '~> 1.0.1'
|
19
|
+
gem.add_development_dependency 'rake', '~> 10'
|
20
|
+
gem.add_development_dependency 'rspec', '~> 3'
|
21
|
+
gem.add_development_dependency 'coveralls', '~> 0.7'
|
22
|
+
gem.add_development_dependency 'cinch-test', '~> 0.1', '>= 0.1.0'
|
23
|
+
gem.add_dependency 'cinch', '~> 2'
|
24
|
+
gem.add_dependency 'cinch-cooldown', '~> 1.1', '>= 1.1.1'
|
25
|
+
gem.add_dependency 'cinch-storage', '~> 1.1'
|
26
|
+
gem.add_dependency 'cinch-toolbox', '~> 1.1'
|
31
27
|
end
|
data/lib/cinch/plugins/seen.rb
CHANGED
@@ -5,62 +5,54 @@ require 'cinch/storage'
|
|
5
5
|
require 'cinch/cooldown'
|
6
6
|
require 'time-lord'
|
7
7
|
|
8
|
-
module Cinch
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
@storage.data ||= {}
|
28
|
-
end
|
8
|
+
module Cinch
|
9
|
+
module Plugins
|
10
|
+
# plugin to allow users to see when other users were last active
|
11
|
+
class Seen
|
12
|
+
include Cinch::Plugin
|
13
|
+
|
14
|
+
# Simple object used to track users.
|
15
|
+
Activity = Struct.new(:nick, :time, :message)
|
16
|
+
|
17
|
+
enforce_cooldown
|
18
|
+
self.help = 'Use .seen <name> to see the last time that nick was active.'
|
19
|
+
listen_to :channel
|
20
|
+
match(/seen ([^\s]+)\z/)
|
21
|
+
|
22
|
+
def initialize(*args)
|
23
|
+
super
|
24
|
+
@storage = Cinch::Storage.new(config[:filename] || 'yaml/seen.yml')
|
25
|
+
@storage.data ||= {}
|
26
|
+
end
|
29
27
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
28
|
+
def listen(m)
|
29
|
+
channel = m.channel.name
|
30
|
+
nick = m.user.nick
|
31
|
+
@storage.data[channel] ||= {}
|
32
|
+
@storage.data[channel][nick.downcase] =
|
33
|
+
Activity.new(nick, Time.now, m.message)
|
34
|
+
@storage.synced_save(@bot)
|
35
|
+
end
|
38
36
|
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
def execute(m, nick)
|
38
|
+
return if Cinch::Toolbox.sent_via_private_message?(m) ||
|
39
|
+
m.user.nick.downcase == nick.downcase
|
42
40
|
m.reply last_seen(m.channel.name, nick), true
|
43
41
|
end
|
44
|
-
end
|
45
42
|
|
46
|
-
|
43
|
+
private
|
47
44
|
|
48
|
-
|
49
|
-
|
50
|
-
|
45
|
+
def last_seen(channel, nick)
|
46
|
+
@storage.data[channel] ||= {}
|
47
|
+
activity = @storage.data[channel][nick.downcase]
|
51
48
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
49
|
+
if activity.nil?
|
50
|
+
"I've never seen #{nick} before, sorry!"
|
51
|
+
else
|
52
|
+
"I last saw #{activity.nick} #{activity.time.ago.to_words} " \
|
53
|
+
"saying '#{activity.message}'"
|
54
|
+
end
|
57
55
|
end
|
58
56
|
end
|
59
|
-
|
60
|
-
def sent_via_pm?(m)
|
61
|
-
return false unless m.channel.nil?
|
62
|
-
m.reply 'You must use that command in the main channel.'
|
63
|
-
true
|
64
|
-
end
|
65
57
|
end
|
66
58
|
end
|
data/spec/cinch-seen_spec.rb
CHANGED
@@ -9,37 +9,36 @@ describe Cinch::Plugins::Seen do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'should allow users to see when users were last active' do
|
12
|
-
get_replies(make_message(@bot, 'hello, world!', { :
|
12
|
+
get_replies(make_message(@bot, 'hello, world!', { nick: 'foo', channel: '#bar' }))
|
13
13
|
sleep 1 # time-lord hack
|
14
|
-
msg = make_message(@bot, '!seen foo', { :
|
15
|
-
get_replies(msg).last.text
|
16
|
-
|
14
|
+
msg = make_message(@bot, '!seen foo', { nick: 'baz', channel: '#bar' })
|
15
|
+
expect(get_replies(msg).last.text)
|
16
|
+
.to match(/baz: I last saw foo \d seconds? ago/)
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'should allow show the last said thing' do
|
20
|
-
get_replies(make_message(@bot, 'hello, world!', { :
|
20
|
+
get_replies(make_message(@bot, 'hello, world!', { nick: 'foo', channel: '#bar' }))
|
21
21
|
sleep 1 # time-lord hack
|
22
|
-
msg = make_message(@bot, '!seen foo', { :
|
23
|
-
get_replies(msg).last.text
|
24
|
-
|
22
|
+
msg = make_message(@bot, '!seen foo', { nick: 'baz', channel: '#bar' })
|
23
|
+
expect(get_replies(msg).last.text)
|
24
|
+
.to match(/saying 'hello, world!'/)
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'should not respond to a users seen request for themselves' do
|
28
|
-
msg = make_message(@bot, '!seen foo', { :
|
29
|
-
get_replies(msg).
|
30
|
-
should be_empty
|
28
|
+
msg = make_message(@bot, '!seen foo', { nick: 'foo', channel: '#bar' })
|
29
|
+
expect(get_replies(msg)).to be_empty
|
31
30
|
end
|
32
31
|
|
33
32
|
it 'should inform users when a person has not been seen before' do
|
34
|
-
msg = make_message(@bot, '!seen foo', { :
|
35
|
-
get_replies(msg).
|
36
|
-
|
33
|
+
msg = make_message(@bot, '!seen foo', { channel: '#bar' })
|
34
|
+
expect(get_replies(msg).last.text)
|
35
|
+
.to eq('test: I\'ve never seen foo before, sorry!')
|
37
36
|
end
|
38
37
|
|
39
38
|
it 'should not let people make dumb jokes (or look for multiple people in one seen)' do
|
40
|
-
get_replies(make_message(@bot, '!seen your mom today', { :
|
41
|
-
|
42
|
-
get_replies(make_message(@bot, '!seen archer pam lana', { :
|
43
|
-
|
39
|
+
msg = get_replies(make_message(@bot, '!seen your mom today', { channel: '#bar' }))
|
40
|
+
expect(msg).to be_empty
|
41
|
+
msg = get_replies(make_message(@bot, '!seen archer pam lana', { channel: '#bar' }))
|
42
|
+
expect(msg).to be_empty
|
44
43
|
end
|
45
44
|
end
|
metadata
CHANGED
@@ -1,160 +1,139 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cinch-seen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.5
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Brian Haberer
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-
|
11
|
+
date: 2014-08-01 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: '10'
|
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: '10'
|
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:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.1'
|
67
62
|
- - ! '>='
|
68
63
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
64
|
+
version: 0.1.0
|
70
65
|
type: :development
|
71
66
|
prerelease: false
|
72
67
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ! '>='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '0'
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: cinch
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
68
|
requirements:
|
83
69
|
- - ~>
|
84
70
|
- !ruby/object:Gem::Version
|
85
|
-
version:
|
86
|
-
|
87
|
-
prerelease: false
|
88
|
-
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
|
-
requirements:
|
91
|
-
- - ~>
|
71
|
+
version: '0.1'
|
72
|
+
- - ! '>='
|
92
73
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
74
|
+
version: 0.1.0
|
94
75
|
- !ruby/object:Gem::Dependency
|
95
|
-
name: cinch
|
76
|
+
name: cinch
|
96
77
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
78
|
requirements:
|
99
79
|
- - ~>
|
100
80
|
- !ruby/object:Gem::Version
|
101
|
-
version:
|
81
|
+
version: '2'
|
102
82
|
type: :runtime
|
103
83
|
prerelease: false
|
104
84
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
85
|
requirements:
|
107
86
|
- - ~>
|
108
87
|
- !ruby/object:Gem::Version
|
109
|
-
version:
|
88
|
+
version: '2'
|
110
89
|
- !ruby/object:Gem::Dependency
|
111
90
|
name: cinch-cooldown
|
112
91
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
92
|
requirements:
|
115
93
|
- - ~>
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '1.1'
|
96
|
+
- - ! '>='
|
116
97
|
- !ruby/object:Gem::Version
|
117
98
|
version: 1.1.1
|
118
99
|
type: :runtime
|
119
100
|
prerelease: false
|
120
101
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
102
|
requirements:
|
123
103
|
- - ~>
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '1.1'
|
106
|
+
- - ! '>='
|
124
107
|
- !ruby/object:Gem::Version
|
125
108
|
version: 1.1.1
|
126
109
|
- !ruby/object:Gem::Dependency
|
127
110
|
name: cinch-storage
|
128
111
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
112
|
requirements:
|
131
113
|
- - ~>
|
132
114
|
- !ruby/object:Gem::Version
|
133
|
-
version: 1.1
|
115
|
+
version: '1.1'
|
134
116
|
type: :runtime
|
135
117
|
prerelease: false
|
136
118
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
119
|
requirements:
|
139
120
|
- - ~>
|
140
121
|
- !ruby/object:Gem::Version
|
141
|
-
version: 1.1
|
122
|
+
version: '1.1'
|
142
123
|
- !ruby/object:Gem::Dependency
|
143
|
-
name:
|
124
|
+
name: cinch-toolbox
|
144
125
|
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
126
|
requirements:
|
147
127
|
- - ~>
|
148
128
|
- !ruby/object:Gem::Version
|
149
|
-
version: 1.
|
129
|
+
version: '1.1'
|
150
130
|
type: :runtime
|
151
131
|
prerelease: false
|
152
132
|
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
133
|
requirements:
|
155
134
|
- - ~>
|
156
135
|
- !ruby/object:Gem::Version
|
157
|
-
version: 1.
|
136
|
+
version: '1.1'
|
158
137
|
description: Cinch Plugin to allow users to find out how long it's been since a user
|
159
138
|
was active
|
160
139
|
email:
|
@@ -178,29 +157,27 @@ files:
|
|
178
157
|
homepage: https://github.com/bhaberer/cinch-seen
|
179
158
|
licenses:
|
180
159
|
- MIT
|
160
|
+
metadata: {}
|
181
161
|
post_install_message:
|
182
162
|
rdoc_options: []
|
183
163
|
require_paths:
|
184
164
|
- lib
|
185
165
|
required_ruby_version: !ruby/object:Gem::Requirement
|
186
|
-
none: false
|
187
166
|
requirements:
|
188
167
|
- - ! '>='
|
189
168
|
- !ruby/object:Gem::Version
|
190
169
|
version: '0'
|
191
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
192
|
-
none: false
|
193
171
|
requirements:
|
194
172
|
- - ! '>='
|
195
173
|
- !ruby/object:Gem::Version
|
196
174
|
version: '0'
|
197
175
|
requirements: []
|
198
176
|
rubyforge_project:
|
199
|
-
rubygems_version:
|
177
|
+
rubygems_version: 2.2.2
|
200
178
|
signing_key:
|
201
|
-
specification_version:
|
179
|
+
specification_version: 4
|
202
180
|
summary: Cinch Plugin for Seen
|
203
181
|
test_files:
|
204
182
|
- spec/cinch-seen_spec.rb
|
205
183
|
- spec/spec_helper.rb
|
206
|
-
has_rdoc:
|