simonreed-lyrebird 0.1.0.1 → 0.1.0.2
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/bin/lyre_bird +46 -0
- data/lib/lyre_bird.rb +11 -7
- metadata +5 -4
data/bin/lyre_bird
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'lyre_bird'
|
3
|
+
|
4
|
+
routes = [ { 'str' => "Do you have a :item for me" } ]
|
5
|
+
|
6
|
+
@lb = LyreBird.new(
|
7
|
+
:username => 'username',
|
8
|
+
:password => 'password',
|
9
|
+
:routes => routes,
|
10
|
+
:since_filename => File.dirname(__FILE__) + '/listenSince.txt')
|
11
|
+
|
12
|
+
$no_responses = []
|
13
|
+
|
14
|
+
def ask message
|
15
|
+
print message + ' : '
|
16
|
+
STDIN.gets.chomp
|
17
|
+
end
|
18
|
+
|
19
|
+
puts
|
20
|
+
puts "LyreBird Interface"
|
21
|
+
puts
|
22
|
+
debug = ask('DEBUG? (y/n)')
|
23
|
+
DEBUG = ( debug.match(/^(Y|y|yes|Yes|YES)/)) ? true : false
|
24
|
+
CONSOLE = true
|
25
|
+
|
26
|
+
puts if DEBUG
|
27
|
+
puts "Running in DEBUG mode" if DEBUG
|
28
|
+
|
29
|
+
while true
|
30
|
+
msg = ask('What do you want to ask?')
|
31
|
+
while msg.nil?
|
32
|
+
msg = ask('No really, what do you want to ask?')
|
33
|
+
end
|
34
|
+
|
35
|
+
if msg =~ /^(quit|q)$/
|
36
|
+
puts
|
37
|
+
puts "Bye!"
|
38
|
+
puts
|
39
|
+
exit
|
40
|
+
end
|
41
|
+
|
42
|
+
req = LyreBird::Request.new(:tweet => {'text' => msg, 'user'=>{'screen_name'=>'joebloggs'}})
|
43
|
+
|
44
|
+
req.response.post(false)
|
45
|
+
puts
|
46
|
+
end
|
data/lib/lyre_bird.rb
CHANGED
@@ -2,11 +2,13 @@ class LyreBird
|
|
2
2
|
|
3
3
|
attr_accessor :username
|
4
4
|
attr_accessor :password
|
5
|
+
attr_accessor :since_filename
|
5
6
|
|
6
7
|
def initialize(options={})
|
7
8
|
$responses = {}
|
8
9
|
self.username = options[:username] || 'username'
|
9
10
|
self.password = options[:password] || 'password'
|
11
|
+
self.since_filename = options[:since_filename] || "lyre_bird_listen_since.txt"
|
10
12
|
$lyrebird_routes = options[:routes] || []
|
11
13
|
end
|
12
14
|
|
@@ -22,17 +24,19 @@ class LyreBird
|
|
22
24
|
|
23
25
|
def get_since
|
24
26
|
since = 0;
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
if File.exists?(self.since_filename)
|
28
|
+
File.open(self.since_filename).each { |line|
|
29
|
+
since = line
|
30
|
+
}
|
31
|
+
return since
|
32
|
+
else
|
33
|
+
return nil
|
34
|
+
end
|
30
35
|
end
|
31
36
|
|
32
37
|
def set_since(since_id)
|
33
|
-
filename = "#{RAILS_ROOT}/config/listenSince.txt"
|
34
38
|
puts "Modified SINCE_ID to - #{since_id}"
|
35
|
-
since = File.open(
|
39
|
+
since = File.open(self.since_filename, 'w') {|f| f.write(since_id) }
|
36
40
|
since
|
37
41
|
end
|
38
42
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simonreed-lyrebird
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Reed
|
@@ -24,20 +24,21 @@ dependencies:
|
|
24
24
|
version:
|
25
25
|
description: Twitter Gateway, respond to natural language questions from Twitter.
|
26
26
|
email: simonpreed@gmail.com
|
27
|
-
executables:
|
28
|
-
|
27
|
+
executables:
|
28
|
+
- lyre_bird
|
29
29
|
extensions: []
|
30
30
|
|
31
31
|
extra_rdoc_files: []
|
32
32
|
|
33
33
|
files:
|
34
|
+
- bin/lyre_bird
|
34
35
|
- lib/lyre_bird/request.rb
|
35
36
|
- lib/lyre_bird/response.rb
|
36
37
|
- lib/lyre_bird/route.rb
|
37
38
|
- lib/lyre_bird/twitter.rb
|
38
39
|
- lib/lyre_bird.rb
|
39
40
|
- README.rdoc
|
40
|
-
has_rdoc:
|
41
|
+
has_rdoc: false
|
41
42
|
homepage: http://github.com/simonreed/LyreBird/tree/master
|
42
43
|
post_install_message: Thanks for installing LyreBird!
|
43
44
|
rdoc_options:
|