ruboty-tweetstream 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0daa0e09b9b02bb202c5758b7e7da75bf62b0754
4
- data.tar.gz: 910e27925876cef8b523fdadd86304c451647d22
3
+ metadata.gz: 519c862311055965634469a893ad735086af36f9
4
+ data.tar.gz: 6453c1bf7f6d47bb77036e1356fd98f531394d1c
5
5
  SHA512:
6
- metadata.gz: 4cf3b110e2d90087382c91a18d03ab9d869b2020564123028676123e1859793d44785a24534d6ab5291499bfe3b5dd608232224a1eaa305892fe16ca9aee0a20
7
- data.tar.gz: 89feb0ccf67d56db00fa0a87fe14884ca5feeb9c09ad2aaf0a698e3138b7fd9940ac7c5ca4a1585e1398acfd5400f9d697a80a63bfad881b2c4fa770af5155b2
6
+ metadata.gz: 9659780620d3ef540382b5b035d7b2ebe5b0fd72e4441ff73f6ec1246ae20c3b6904b516c988be2a78eb29c1a02dcd498a82cbf31b7754cdc78abe56279c6943
7
+ data.tar.gz: 5215d7ad056c000baa6482c5e9d5f84123d548b56b6f20903bfc4720ee39638f486e617e56f5e5d63d1476283d8744944c503f6c56df58c2e68389e8bf2e560d
data/README.md CHANGED
@@ -26,7 +26,7 @@ gem 'ruboty-tweetstream'
26
26
  @kaihar4> テスト1
27
27
  @kaihar4> テスト2
28
28
  > @ruboty list ts
29
- @kaihar4 -> id:2703995576, started_at:2014-11-18 17:00:00 +0900
29
+ @kaihar4 -> id:2703995576
30
30
  > @ruboty delete ts @kaihar4
31
31
  '@kaihar4' stream is stopped.
32
32
  ```
@@ -4,7 +4,7 @@ module Ruboty
4
4
  module Handlers
5
5
  class Tweetstream < Base
6
6
  on /add ts @(?<username>.+)/, name: 'add', description: 'Add a tweetstream'
7
- on /list ts/, name: 'list', description: 'Show all tweetstreams'
7
+ on /list ts\z/, name: 'list', description: 'Show all tweetstreams'
8
8
  on /delete ts @(?<username>.+)/, name: 'delete', description: 'Delete a tweetstream'
9
9
 
10
10
  def initialize(*args)
@@ -14,17 +14,22 @@ module Ruboty
14
14
 
15
15
  def add(message)
16
16
  username = message[:username]
17
- stream = Ruboty::Tweetstream::Stream.new(
18
- message.original.except(:robot).merge(
19
- username: username,
20
- id: twitter_id(username)
17
+ if streams.has_key?(username)
18
+ message.reply("'@#{username}' stream is already started.")
19
+ else
20
+ stream = Ruboty::Tweetstream::Stream.new(
21
+ message.original.except(:robot).merge(
22
+ username: username,
23
+ id: twitter_id(username)
24
+ )
21
25
  )
22
- )
23
- stream.start(robot)
24
- running_streams[username] = stream
25
26
 
26
- streams[username] = stream.hash
27
- message.reply("'@#{username}' stream is started.")
27
+ stream.start(robot)
28
+ running_streams[username] = stream
29
+
30
+ streams[username] = stream.hash
31
+ message.reply("'@#{username}' stream is started.")
32
+ end
28
33
  end
29
34
 
30
35
  def delete(message)
@@ -41,16 +46,14 @@ module Ruboty
41
46
  end
42
47
 
43
48
  def list(message)
44
- body =
45
- if streams.empty?
46
- "The stream doesn't exist."
47
- else
48
- streams.map do |username, hash|
49
- "@#{username} -> id:#{hash[:id]}"
50
- end.join("\n")
51
- end
52
-
53
- message.reply(body)
49
+ if streams.empty?
50
+ message.reply("The stream doesn't exist.")
51
+ else
52
+ stream_list = streams.map do |username, _hash|
53
+ "@#{username}"
54
+ end.join("\t")
55
+ message.reply(stream_list, code: true)
56
+ end
54
57
  end
55
58
 
56
59
  def restart
@@ -17,10 +17,10 @@ module Ruboty
17
17
  def start(robot)
18
18
  @thread = Thread.start do
19
19
  @client.filter(follow: hash[:id].to_s) do |object|
20
- if object.is_a?(Twitter::Tweet)
20
+ if object.is_a?(Twitter::Tweet) && object.in_reply_to_screen_name.nil?
21
21
  Message.new(
22
22
  hash.except(:username, :id).merge(robot: robot)
23
- ).reply("@#{hash[:username]}> #{ object.text}")
23
+ ).reply("@#{hash[:username]}> #{object.text}")
24
24
  end
25
25
  end
26
26
  end
@@ -1,5 +1,5 @@
1
1
  module Ruboty
2
2
  module Tweetstream
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruboty-tweetstream
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - kaihar4
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-18 00:00:00.000000000 Z
11
+ date: 2014-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruboty