ruben 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -13,19 +13,7 @@ Ruben is an IRC chat bot written in Ruby. He is inspired, in part, by [Hubot](ht
13
13
 
14
14
  ###Installation
15
15
 
16
- Ruben isn't quite finished, so he hasn't been pushed to RubyGems. If you want to get your own copy of Ruben, you can clone the repo:
17
-
18
- $ git clone https://github.com/ericqweinstein/ruben.git
19
-
20
- In the `ruben/` directory, run his (admittedly sparse) tests:
21
-
22
- $ rake
23
-
24
- Build the gem:
25
-
26
- $ gem build ruben.gemspec
27
-
28
- And install it:
16
+ Ruben's a little janky, but he works. Version 1.0.1 is available from RubyGems; you can get your version of Ruben by typing
29
17
 
30
18
  $ gem install ruben
31
19
 
@@ -47,13 +35,15 @@ You should see:
47
35
 
48
36
  ...
49
37
 
50
- And so on.
51
-
52
38
  ###Adding Scripts
53
39
 
54
- You can extend Ruben's functionality by adding scripts to `/scripts`, like so:
40
+ You can extend Ruben's functionality by adding scripts to `/scripts`. Each script should be a `.rb` file that instantiates a new `Listener` object, like so:
41
+
42
+ thing_to_do lambda do
43
+ # Arcane magicks go here
44
+ end
55
45
 
56
- Listener.new(/Regexp/, "response string")
46
+ Listener.new(/Regexp/, thing_to_do)
57
47
 
58
- Ruben's listeners hear every incoming IRC message. If a listener's Regexp matches the inbound message, Ruben will respond with the associated text string.
48
+ Ruben's listeners hear every incoming IRC message. If a listener's Regexp matches the inbound message, Ruben will call the associated lambda.
59
49
 
data/bin/ruben CHANGED
@@ -3,7 +3,7 @@
3
3
  require_relative "../lib/robot"
4
4
 
5
5
  begin
6
- ruben = Robot.new(ARGV[0], ARGV[1], ARGV[2], ARGV[3])
6
+ $ruben = Robot.new(ARGV[0], ARGV[1], ARGV[2], ARGV[3])
7
7
  rescue SocketError
8
8
  puts "-- Usage: ruben <server> <port> <channel> <nick>"
9
9
  puts "-- Error: Either \"#{ARGV[0]}\" is not a valid IRC network or \"#{ARGV[1]}\" is not a valid port number."
@@ -11,7 +11,7 @@ rescue SocketError
11
11
  end
12
12
 
13
13
  # Ensure Ruben leaves politely when ^C-ed
14
- trap("INT") { ruben.quit }
14
+ trap("INT") { $ruben.quit }
15
15
 
16
- ruben.run
16
+ $ruben.run
17
17
 
data/lib/robot/channel.rb CHANGED
@@ -5,7 +5,7 @@ Dir[File.dirname(__FILE__) + "/scripts/*.rb"].each { |script| require script }
5
5
 
6
6
  module Channel
7
7
 
8
- PARTING_MESSAGES = ["Goodbye!", "Peace!", "Later.", "I'm out!"]
8
+ PARTING_MESSAGES = ["bye", "peace!", "later", "I'm out"]
9
9
 
10
10
  def send(msg)
11
11
  @socket.puts msg
@@ -29,7 +29,7 @@ module Channel
29
29
  # Respond to messages in the channel
30
30
  @listeners.each do |listener|
31
31
  if @inbound.match(listener.pattern)
32
- say listener.response
32
+ listener.response.call
33
33
  end
34
34
  end
35
35
  end
@@ -0,0 +1,8 @@
1
+ # MAXIMUM WARP
2
+
3
+ warp_factor = lambda do
4
+ $ruben.say "WARP FACTOR #{rand(9) + 1}"
5
+ end
6
+
7
+ Listener.new(/\bengage\b/i, warp_factor)
8
+
@@ -1,4 +1,9 @@
1
1
  # Friendly robots are good robots
2
2
 
3
- Listener.new(/:(?:hi|hello|hey)\s*,?\s*(?:ruben)/i, "Hello!")
3
+ say_hello = lambda do
4
+ greetings = ["sup", "hey", "what up", "sup g"]
5
+ $ruben.say "#{greetings.sample}"
6
+ end
7
+
8
+ Listener.new(/:(?:hi|hello|hey)\s*,?\s*(?:ruben)/i, say_hello)
4
9
 
@@ -1,4 +1,9 @@
1
1
  # Polite robots are good robots
2
2
 
3
- Listener.new(/:(?:thanks|ty|thank\s*you),?\s*(?:ruben)/i, "You're welcome!")
3
+ youre_welcome = lambda do
4
+ responses = ["no prob", "sure thing", "np boss"]
5
+ $ruben.say "#{responses.sample}"
6
+ end
7
+
8
+ Listener.new(/:(?:thanks|ty|thank\s*you),?\s*(?:ruben)/i, youre_welcome)
4
9
 
@@ -1,4 +1,11 @@
1
1
  # Teaching Ruben to tell time
2
2
 
3
- Listener.new(/(?:what\s*time)/i, "Right now it's #{Time.now.localtime.strftime("%H:%M:%S %p")}.")
3
+ what_time = lambda do
4
+ current_hour = Time.now.localtime.strftime("%H").to_i
5
+ current_hour = current_hour > 12 ? current_hour - 12 : current_hour
6
+
7
+ $ruben.say "I dunno, around #{Time.now.localtime.strftime("#{current_hour}:%M %p")}"
8
+ end
9
+
10
+ Listener.new(/(?:what\s*time)/i, what_time)
4
11
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruben
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -23,6 +23,7 @@ files:
23
23
  - bin/ruben
24
24
  - lib/robot/channel.rb
25
25
  - lib/robot/listener.rb
26
+ - lib/robot/scripts/engage.rb
26
27
  - lib/robot/scripts/hello.rb
27
28
  - lib/robot/scripts/politeness.rb
28
29
  - lib/robot/scripts/tell_time.rb