rubot 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/rubot +24 -0
- data/lib/core/command.rb +3 -0
- data/lib/core/dispatcher.rb +2 -1
- data/lib/rubot.rb +0 -3
- data/lib/template/commands/auth.rb +6 -0
- data/lib/template/commands/help.rb +8 -0
- data/lib/template/commands/join.rb +7 -0
- data/lib/template/commands/msg.rb +6 -0
- data/lib/template/commands/part.rb +11 -0
- data/lib/template/commands/quit.rb +8 -0
- data/lib/template/commands/reload.rb +8 -0
- data/lib/template/commands/up_time.rb +29 -0
- data/lib/template/main.rb +8 -0
- data/lib/template/resources/config.yml +14 -0
- metadata +16 -6
- data/lib/init/bundler.rb +0 -9
data/bin/rubot
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "fileutils"
|
3
|
+
|
4
|
+
unless ARGV[0]
|
5
|
+
puts "usage is: rubot <project_name>"
|
6
|
+
exit!
|
7
|
+
end
|
8
|
+
|
9
|
+
if Dir.exist? ARGV[0]
|
10
|
+
puts "directory '#{ARGV[0]}' already exists"
|
11
|
+
exit
|
12
|
+
end
|
13
|
+
|
14
|
+
# there has to be a better way to do this
|
15
|
+
# why does gem documentation suck so back? (don't pay attention to rubot docs, shh)
|
16
|
+
spec = Gem.searcher.find("rubot")
|
17
|
+
template_dir = File.join(spec.installation_path, "gems", spec.full_name, "lib", "template")
|
18
|
+
|
19
|
+
FileUtils.cp_r(template_dir, ARGV[0])
|
20
|
+
# for some reason gem doesn't include empty folders during the install
|
21
|
+
# this is to make sure these directories exist
|
22
|
+
%w{resources commands listeners runners}.each do |dir|
|
23
|
+
FileUtils.mkdir File.join(ARGV[0], dir) unless File.exist? File.join(ARGV[0], dir)
|
24
|
+
end
|
data/lib/core/command.rb
CHANGED
data/lib/core/dispatcher.rb
CHANGED
@@ -10,7 +10,8 @@ module Rubot
|
|
10
10
|
@config = config
|
11
11
|
@function_character = @config["function_character"]
|
12
12
|
|
13
|
-
@auth_list = config["auth_list"].split(',')
|
13
|
+
@auth_list = config["auth_list"].split(',') if config["auth_list"]
|
14
|
+
@auth_list ||= []
|
14
15
|
|
15
16
|
@resource_lock = Mutex.new
|
16
17
|
reload
|
data/lib/rubot.rb
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
class UpTime < Rubot::Core::Command
|
2
|
+
aliases :uptime, :up
|
3
|
+
|
4
|
+
def execute(server, message, options)
|
5
|
+
server.msg(message.destination, seconds_to_words(Time.now - server.connected_at))
|
6
|
+
end
|
7
|
+
|
8
|
+
def seconds_to_words(seconds)
|
9
|
+
time = "#{(seconds % 60).to_i} seconds"
|
10
|
+
|
11
|
+
minutes = seconds / 60
|
12
|
+
|
13
|
+
if minutes >= 1
|
14
|
+
hours = minutes / 60
|
15
|
+
time.insert(0, "#{(minutes % 60).to_i} minutes ")
|
16
|
+
|
17
|
+
if hours >= 1
|
18
|
+
days = hours / 24
|
19
|
+
time.insert(0, "#{(hours % 24).to_i} hours ")
|
20
|
+
|
21
|
+
if days >= 1
|
22
|
+
time.insert(0, "#{days.to_i} days ")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
time
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
---
|
2
|
+
server:
|
3
|
+
host: irc.freenode.net
|
4
|
+
port: 6667
|
5
|
+
nick: #mybot
|
6
|
+
alt_nick: #mybot_
|
7
|
+
real_name: #
|
8
|
+
channels: #"#ruby,#ruby-lang"
|
9
|
+
vhost: #leave blank if none
|
10
|
+
quit_message: powered by rubot
|
11
|
+
message_delay: 2 #in seconds
|
12
|
+
|
13
|
+
function_character: "!"
|
14
|
+
auth_list: #myrealnick
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 3
|
9
|
+
version: 0.0.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Chris Thorn
|
@@ -14,19 +14,20 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-03-
|
17
|
+
date: 2010-03-20 00:00:00 -08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
21
21
|
description: A Ruby Bot framwork for IRC featuring reloadable commands and listeners.
|
22
22
|
email: thorncp@gmail.com
|
23
|
-
executables:
|
24
|
-
|
23
|
+
executables:
|
24
|
+
- rubot
|
25
25
|
extensions: []
|
26
26
|
|
27
27
|
extra_rdoc_files:
|
28
28
|
- README
|
29
29
|
files:
|
30
|
+
- bin/rubot
|
30
31
|
- lib/core/command.rb
|
31
32
|
- lib/core/dispatcher.rb
|
32
33
|
- lib/core/listener.rb
|
@@ -36,13 +37,22 @@ files:
|
|
36
37
|
- lib/extensions/object.rb
|
37
38
|
- lib/extensions/string.rb
|
38
39
|
- lib/extensions.rb
|
39
|
-
- lib/init/bundler.rb
|
40
40
|
- lib/irc/constants.rb
|
41
41
|
- lib/irc/message.rb
|
42
42
|
- lib/irc/message_queue.rb
|
43
43
|
- lib/irc/server.rb
|
44
44
|
- lib/irc.rb
|
45
45
|
- lib/rubot.rb
|
46
|
+
- lib/template/commands/auth.rb
|
47
|
+
- lib/template/commands/help.rb
|
48
|
+
- lib/template/commands/join.rb
|
49
|
+
- lib/template/commands/msg.rb
|
50
|
+
- lib/template/commands/part.rb
|
51
|
+
- lib/template/commands/quit.rb
|
52
|
+
- lib/template/commands/reload.rb
|
53
|
+
- lib/template/commands/up_time.rb
|
54
|
+
- lib/template/main.rb
|
55
|
+
- lib/template/resources/config.yml
|
46
56
|
- README
|
47
57
|
- Rakefile
|
48
58
|
has_rdoc: true
|
data/lib/init/bundler.rb
DELETED