cinch 0.3.5 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.md +192 -0
- data/Rakefile +53 -43
- data/examples/basic/autovoice.rb +32 -0
- data/examples/basic/google.rb +35 -0
- data/examples/basic/hello.rb +15 -0
- data/examples/basic/join_part.rb +38 -0
- data/examples/basic/memo.rb +39 -0
- data/examples/basic/msg.rb +16 -0
- data/examples/basic/seen.rb +36 -0
- data/examples/basic/urban_dict.rb +35 -0
- data/examples/basic/url_shorten.rb +35 -0
- data/examples/plugins/autovoice.rb +40 -0
- data/examples/plugins/custom_prefix.rb +23 -0
- data/examples/plugins/google.rb +37 -0
- data/examples/plugins/hello.rb +22 -0
- data/examples/plugins/join_part.rb +42 -0
- data/examples/plugins/memo.rb +50 -0
- data/examples/plugins/msg.rb +22 -0
- data/examples/plugins/multiple_matches.rb +41 -0
- data/examples/plugins/seen.rb +45 -0
- data/examples/plugins/urban_dict.rb +30 -0
- data/examples/plugins/url_shorten.rb +32 -0
- data/lib/cinch.rb +7 -20
- data/lib/cinch/ban.rb +41 -0
- data/lib/cinch/bot.rb +479 -0
- data/lib/cinch/callback.rb +11 -0
- data/lib/cinch/channel.rb +419 -0
- data/lib/cinch/constants.rb +369 -0
- data/lib/cinch/exceptions.rb +25 -0
- data/lib/cinch/helpers.rb +21 -0
- data/lib/cinch/irc.rb +344 -38
- data/lib/cinch/isupport.rb +96 -0
- data/lib/cinch/logger/formatted_logger.rb +80 -0
- data/lib/cinch/logger/logger.rb +44 -0
- data/lib/cinch/logger/null_logger.rb +18 -0
- data/lib/cinch/mask.rb +46 -0
- data/lib/cinch/message.rb +183 -0
- data/lib/cinch/message_queue.rb +62 -0
- data/lib/cinch/plugin.rb +205 -0
- data/lib/cinch/rubyext/infinity.rb +1 -0
- data/lib/cinch/rubyext/module.rb +18 -0
- data/lib/cinch/rubyext/queue.rb +19 -0
- data/lib/cinch/rubyext/string.rb +24 -0
- data/lib/cinch/syncable.rb +55 -0
- data/lib/cinch/user.rb +325 -0
- data/spec/bot_spec.rb +5 -0
- data/spec/channel_spec.rb +5 -0
- data/spec/cinch_spec.rb +5 -0
- data/spec/irc_spec.rb +5 -0
- data/spec/message_spec.rb +5 -0
- data/spec/plugin_spec.rb +5 -0
- data/spec/{helper.rb → spec_helper.rb} +0 -0
- data/spec/user_spec.rb +5 -0
- metadata +69 -51
- data/README.rdoc +0 -195
- data/examples/autovoice.rb +0 -32
- data/examples/custom_patterns.rb +0 -19
- data/examples/custom_prefix.rb +0 -25
- data/examples/google.rb +0 -31
- data/examples/hello.rb +0 -13
- data/examples/join_part.rb +0 -26
- data/examples/memo.rb +0 -40
- data/examples/msg.rb +0 -14
- data/examples/named-param-types.rb +0 -19
- data/examples/seen.rb +0 -41
- data/examples/urban_dict.rb +0 -31
- data/examples/url_shorten.rb +0 -34
- data/lib/cinch/base.rb +0 -368
- data/lib/cinch/irc/message.rb +0 -135
- data/lib/cinch/irc/parser.rb +0 -141
- data/lib/cinch/irc/socket.rb +0 -329
- data/lib/cinch/names.rb +0 -54
- data/lib/cinch/rules.rb +0 -171
- data/spec/base_spec.rb +0 -94
- data/spec/irc/helper.rb +0 -8
- data/spec/irc/message_spec.rb +0 -61
- data/spec/irc/parser_spec.rb +0 -103
- data/spec/irc/socket_spec.rb +0 -90
- data/spec/names_spec.rb +0 -393
- data/spec/options_spec.rb +0 -45
- data/spec/rules_spec.rb +0 -109
data/spec/options_spec.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/helper'
|
2
|
-
|
3
|
-
describe "Cinch::Base options" do
|
4
|
-
before do
|
5
|
-
@base = Cinch::Base
|
6
|
-
end
|
7
|
-
|
8
|
-
it "should set options via a hash" do
|
9
|
-
base = @base.new(:server => 'irc.foobar.org')
|
10
|
-
base.options.server.should == "irc.foobar.org"
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should set options via a block" do
|
14
|
-
base = @base.new do
|
15
|
-
server "irc.foobar.org"
|
16
|
-
end
|
17
|
-
base.options.server.should == "irc.foobar.org"
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should set options via setters" do
|
21
|
-
base = @base.new
|
22
|
-
base.options.server = "irc.foobar.org"
|
23
|
-
base.options.server.should == "irc.foobar.org"
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should set specific default values" do
|
27
|
-
defaults = {
|
28
|
-
:port => 6667,
|
29
|
-
:nick => 'Cinch',
|
30
|
-
:nick_suffix => '_',
|
31
|
-
:username => 'cinch',
|
32
|
-
:realname => 'Cinch IRC Bot Building Framework',
|
33
|
-
:usermode => 0,
|
34
|
-
:prefix => '!',
|
35
|
-
:password => nil,
|
36
|
-
}
|
37
|
-
|
38
|
-
base = @base.new
|
39
|
-
defaults.each do |k, v|
|
40
|
-
base.options.send(k).should == v
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
|
data/spec/rules_spec.rb
DELETED
@@ -1,109 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/helper'
|
2
|
-
|
3
|
-
describe "Cinch::Rules" do
|
4
|
-
before do
|
5
|
-
@rules = Cinch::Rules.new
|
6
|
-
@rules.add_rule('foo', [], {}, Proc.new{})
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "::new" do
|
10
|
-
it "should define an empty set of rules" do
|
11
|
-
Cinch::Rules.new.empty?.should == true
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "#add_rule" do
|
16
|
-
it "should add a new rule" do
|
17
|
-
@rules.add_rule('bar', [], {}, Proc.new{})
|
18
|
-
@rules.all.should include 'foo'
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should replace an existing rule" do
|
22
|
-
@rules.add_rule('foo', [], {}, Proc.new{})
|
23
|
-
@rules.count.should == 1
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "#get_rule" do
|
28
|
-
it "should return a Cinch::Rule" do
|
29
|
-
@rules.get_rule('foo').should be_kind_of Cinch::Rule
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe "#remove_rule" do
|
34
|
-
it "should remove a rule" do
|
35
|
-
@rules.remove_rule('foo')
|
36
|
-
@rules.include?('foo').should == false
|
37
|
-
@rules.count.should == 0
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe "#add_callback" do
|
42
|
-
it "should add a callback for a rule" do
|
43
|
-
@rules.add_callback('foo', Proc.new{})
|
44
|
-
rule = @rules.get_rule('foo')
|
45
|
-
rule.callbacks.size.should == 2
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe "#add_option" do
|
50
|
-
it "should add an option for a rule" do
|
51
|
-
@rules.add_option('foo', :nick, 'injekt')
|
52
|
-
rule = @rules.get('foo')
|
53
|
-
rule.options.should include :nick
|
54
|
-
rule.options[:nick].should == 'injekt'
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe "#merge_options" do
|
59
|
-
it "should merge rule options" do
|
60
|
-
@rules.merge_options('foo', {:bar => 'baz'})
|
61
|
-
rule = @rules['foo']
|
62
|
-
rule.options.should == {:bar => 'baz'}
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe "#include?" do
|
67
|
-
it "should check if a rule exists" do
|
68
|
-
@rules.include?('foo').should == true
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
describe "#clear" do
|
73
|
-
it "should clear all rules" do
|
74
|
-
@rules.clear
|
75
|
-
@rules.empty?.should == true
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe "#empty?" do
|
80
|
-
it "should check if any rules exist" do
|
81
|
-
@rules.empty?.should == false
|
82
|
-
@rules.clear
|
83
|
-
@rules.empty?.should == true
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
describe "#count" do
|
88
|
-
it "should show how many rules exist" do
|
89
|
-
@rules.count.should == 1
|
90
|
-
@rules.add_rule('bar', [], {}, Proc.new{})
|
91
|
-
@rules.count.should == 2
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
describe "#all" do
|
96
|
-
it "should return a Hash of all rules" do
|
97
|
-
@rules.all.should be_kind_of Hash
|
98
|
-
@rules.all.should include 'foo'
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
describe "#to_a" do
|
103
|
-
it "should return an Array of rules" do
|
104
|
-
@rules.to_a.should be_kind_of Array
|
105
|
-
@rules.to_a.include?('foo').should == true
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|