ronimopi 0.1.0 → 0.1.1

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.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/bin/ronimopi.rb +1 -51
  3. data/lib/ronimopi.rb +67 -0
  4. metadata +2 -1
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
data/bin/ronimopi.rb CHANGED
@@ -15,54 +15,4 @@
15
15
  # You should have received a copy of the GNU General Public License
16
16
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
 
18
- require 'isaac/bot'
19
- CFGDIR=File::join(ENV['HOME'], '.config', 'ronimopi')
20
-
21
- bot = Isaac::Bot.new do
22
- @channels = []
23
-
24
- configure do |cfg|
25
- File::open(File::join(CFGDIR, 'config.yml')) do |yf|
26
- YAML.each_document(yf) do |ydoc|
27
- cfg.nick = ydoc["nick"] if ydoc.key? "nick"
28
- cfg.server = ydoc["server"] if ydoc.key? "server"
29
- cfg.port = ydoc["port"] if ydoc.key? "port"
30
- @channels += ydoc["channels"] if ydoc.key? "channels"
31
- end
32
- end
33
- end
34
-
35
- helpers do
36
- helperstr = ""
37
- Dir::glob(File::join(CFGDIR, 'commands.d', '*.rb')).each do |helper|
38
- File.new(helper).each_line do |line|
39
- helperstr << line
40
- end
41
- end
42
- eval helperstr
43
- end
44
-
45
- on :connect do
46
- @channels.each do |ch|
47
- puts "Joining #{ch}"
48
- join ch
49
- end
50
- end
51
-
52
- on :channel, /^[!](.+)/ do |cmdstr|
53
- parts = cmdstr.split(/\s+/, 2)
54
- cmd = "handle_#{parts[0]}".to_sym
55
- args = parts[1]
56
- if respond_to? cmd
57
- send(cmd, channel, nick, args)
58
- else
59
- msg channel, "I don't know that command"
60
- end
61
- end
62
-
63
- on :channel do
64
- # catchall, do nothing
65
- end
66
- end
67
-
68
- bot.start
18
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'ronimopi')
data/lib/ronimopi.rb ADDED
@@ -0,0 +1,67 @@
1
+ # Ronimopi, a simple extensible IRC bot
2
+ # Copyright (C) 2010 Ilkka Laukkanen <ilkka.s.laukkanen@gmail.com>
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or (at
7
+ # your option) any later version.
8
+
9
+ # This program is distributed in the hope that it will be useful, but
10
+ # WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ # General Public License for more details.
13
+
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ require 'isaac/bot'
18
+ CFGDIR=File::join(ENV['HOME'], '.config', 'ronimopi')
19
+
20
+ bot = Isaac::Bot.new do
21
+ @channels = []
22
+
23
+ configure do |cfg|
24
+ File::open(File::join(CFGDIR, 'config.yml')) do |yf|
25
+ YAML.each_document(yf) do |ydoc|
26
+ cfg.nick = ydoc["nick"] if ydoc.key? "nick"
27
+ cfg.server = ydoc["server"] if ydoc.key? "server"
28
+ cfg.port = ydoc["port"] if ydoc.key? "port"
29
+ @channels += ydoc["channels"] if ydoc.key? "channels"
30
+ end
31
+ end
32
+ end
33
+
34
+ helpers do
35
+ helperstr = ""
36
+ Dir::glob(File::join(CFGDIR, 'commands.d', '*.rb')).each do |helper|
37
+ File.new(helper).each_line do |line|
38
+ helperstr << line
39
+ end
40
+ end
41
+ eval helperstr
42
+ end
43
+
44
+ on :connect do
45
+ @channels.each do |ch|
46
+ puts "Joining #{ch}"
47
+ join ch
48
+ end
49
+ end
50
+
51
+ on :channel, /^[!](.+)/ do |cmdstr|
52
+ parts = cmdstr.split(/\s+/, 2)
53
+ cmd = "handle_#{parts[0]}".to_sym
54
+ args = parts[1]
55
+ if respond_to? cmd
56
+ send(cmd, channel, nick, args)
57
+ else
58
+ msg channel, "I don't know that command"
59
+ end
60
+ end
61
+
62
+ on :channel do
63
+ # catchall, do nothing
64
+ end
65
+ end
66
+
67
+ bot.start
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ronimopi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilkka Laukkanen
@@ -55,6 +55,7 @@ files:
55
55
  - examples/commands.d/lounas.rb
56
56
  - examples/commands.d/wtf.rb
57
57
  - examples/config.yml
58
+ - lib/ronimopi.rb
58
59
  - test/helper.rb
59
60
  - test/test_test.rb
60
61
  has_rdoc: true