cinch 0.3.5 → 1.0.0

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 (82) hide show
  1. data/LICENSE +20 -0
  2. data/README.md +192 -0
  3. data/Rakefile +53 -43
  4. data/examples/basic/autovoice.rb +32 -0
  5. data/examples/basic/google.rb +35 -0
  6. data/examples/basic/hello.rb +15 -0
  7. data/examples/basic/join_part.rb +38 -0
  8. data/examples/basic/memo.rb +39 -0
  9. data/examples/basic/msg.rb +16 -0
  10. data/examples/basic/seen.rb +36 -0
  11. data/examples/basic/urban_dict.rb +35 -0
  12. data/examples/basic/url_shorten.rb +35 -0
  13. data/examples/plugins/autovoice.rb +40 -0
  14. data/examples/plugins/custom_prefix.rb +23 -0
  15. data/examples/plugins/google.rb +37 -0
  16. data/examples/plugins/hello.rb +22 -0
  17. data/examples/plugins/join_part.rb +42 -0
  18. data/examples/plugins/memo.rb +50 -0
  19. data/examples/plugins/msg.rb +22 -0
  20. data/examples/plugins/multiple_matches.rb +41 -0
  21. data/examples/plugins/seen.rb +45 -0
  22. data/examples/plugins/urban_dict.rb +30 -0
  23. data/examples/plugins/url_shorten.rb +32 -0
  24. data/lib/cinch.rb +7 -20
  25. data/lib/cinch/ban.rb +41 -0
  26. data/lib/cinch/bot.rb +479 -0
  27. data/lib/cinch/callback.rb +11 -0
  28. data/lib/cinch/channel.rb +419 -0
  29. data/lib/cinch/constants.rb +369 -0
  30. data/lib/cinch/exceptions.rb +25 -0
  31. data/lib/cinch/helpers.rb +21 -0
  32. data/lib/cinch/irc.rb +344 -38
  33. data/lib/cinch/isupport.rb +96 -0
  34. data/lib/cinch/logger/formatted_logger.rb +80 -0
  35. data/lib/cinch/logger/logger.rb +44 -0
  36. data/lib/cinch/logger/null_logger.rb +18 -0
  37. data/lib/cinch/mask.rb +46 -0
  38. data/lib/cinch/message.rb +183 -0
  39. data/lib/cinch/message_queue.rb +62 -0
  40. data/lib/cinch/plugin.rb +205 -0
  41. data/lib/cinch/rubyext/infinity.rb +1 -0
  42. data/lib/cinch/rubyext/module.rb +18 -0
  43. data/lib/cinch/rubyext/queue.rb +19 -0
  44. data/lib/cinch/rubyext/string.rb +24 -0
  45. data/lib/cinch/syncable.rb +55 -0
  46. data/lib/cinch/user.rb +325 -0
  47. data/spec/bot_spec.rb +5 -0
  48. data/spec/channel_spec.rb +5 -0
  49. data/spec/cinch_spec.rb +5 -0
  50. data/spec/irc_spec.rb +5 -0
  51. data/spec/message_spec.rb +5 -0
  52. data/spec/plugin_spec.rb +5 -0
  53. data/spec/{helper.rb → spec_helper.rb} +0 -0
  54. data/spec/user_spec.rb +5 -0
  55. metadata +69 -51
  56. data/README.rdoc +0 -195
  57. data/examples/autovoice.rb +0 -32
  58. data/examples/custom_patterns.rb +0 -19
  59. data/examples/custom_prefix.rb +0 -25
  60. data/examples/google.rb +0 -31
  61. data/examples/hello.rb +0 -13
  62. data/examples/join_part.rb +0 -26
  63. data/examples/memo.rb +0 -40
  64. data/examples/msg.rb +0 -14
  65. data/examples/named-param-types.rb +0 -19
  66. data/examples/seen.rb +0 -41
  67. data/examples/urban_dict.rb +0 -31
  68. data/examples/url_shorten.rb +0 -34
  69. data/lib/cinch/base.rb +0 -368
  70. data/lib/cinch/irc/message.rb +0 -135
  71. data/lib/cinch/irc/parser.rb +0 -141
  72. data/lib/cinch/irc/socket.rb +0 -329
  73. data/lib/cinch/names.rb +0 -54
  74. data/lib/cinch/rules.rb +0 -171
  75. data/spec/base_spec.rb +0 -94
  76. data/spec/irc/helper.rb +0 -8
  77. data/spec/irc/message_spec.rb +0 -61
  78. data/spec/irc/parser_spec.rb +0 -103
  79. data/spec/irc/socket_spec.rb +0 -90
  80. data/spec/names_spec.rb +0 -393
  81. data/spec/options_spec.rb +0 -45
  82. data/spec/rules_spec.rb +0 -109
@@ -0,0 +1,5 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Cinch::Bot do
4
+
5
+ end
@@ -0,0 +1,5 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Cinch::Channel do
4
+
5
+ end
@@ -0,0 +1,5 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Cinch do
4
+
5
+ end
@@ -0,0 +1,5 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Cinch::IRC do
4
+
5
+ end
@@ -0,0 +1,5 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Cinch::Message do
4
+
5
+ end
@@ -0,0 +1,5 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Cinch::Plugin do
4
+
5
+ end
File without changes
@@ -0,0 +1,5 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Cinch::User do
4
+
5
+ end
metadata CHANGED
@@ -1,21 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cinch
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
5
4
  prerelease: false
6
5
  segments:
6
+ - 1
7
7
  - 0
8
- - 3
9
- - 5
10
- version: 0.3.5
8
+ - 0
9
+ version: 1.0.0
11
10
  platform: ruby
12
11
  authors:
13
- - Lee 'injekt' Jarvis
12
+ - Lee Jarvis
13
+ - Dominik Honnef
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-25 00:00:00 +01:00
18
+ date: 2010-08-19 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,7 +26,6 @@ dependencies:
26
26
  requirements:
27
27
  - - "="
28
28
  - !ruby/object:Gem::Version
29
- hash: 27
30
29
  segments:
31
30
  - 1
32
31
  - 3
@@ -34,58 +33,79 @@ dependencies:
34
33
  version: 1.3.0
35
34
  type: :development
36
35
  version_requirements: *id001
37
- description: An IRC Bot Building Framework
38
- email: ljjarvis@gmail.com
36
+ description: A simple, friendly DSL for creating IRC bots
37
+ email:
38
+ - lee@jarvis.co
39
+ - dominikh@fork-bomb.org
39
40
  executables: []
40
41
 
41
42
  extensions: []
42
43
 
43
- extra_rdoc_files:
44
- - README.rdoc
44
+ extra_rdoc_files: []
45
+
45
46
  files:
46
- - README.rdoc
47
+ - LICENSE
47
48
  - Rakefile
48
- - spec/names_spec.rb
49
- - spec/irc/message_spec.rb
50
- - spec/irc/parser_spec.rb
51
- - spec/irc/socket_spec.rb
52
- - spec/irc/helper.rb
53
- - spec/rules_spec.rb
49
+ - README.md
50
+ - spec/message_spec.rb
51
+ - spec/spec_helper.rb
54
52
  - spec/spec.opts
55
- - spec/options_spec.rb
56
- - spec/base_spec.rb
57
- - spec/helper.rb
53
+ - spec/cinch_spec.rb
54
+ - spec/plugin_spec.rb
55
+ - spec/irc_spec.rb
56
+ - spec/bot_spec.rb
57
+ - spec/channel_spec.rb
58
+ - spec/user_spec.rb
58
59
  - lib/cinch.rb
59
- - lib/cinch/names.rb
60
- - lib/cinch/irc/socket.rb
61
- - lib/cinch/irc/message.rb
62
- - lib/cinch/irc/parser.rb
60
+ - lib/cinch/bot.rb
61
+ - lib/cinch/user.rb
62
+ - lib/cinch/mask.rb
63
+ - lib/cinch/exceptions.rb
63
64
  - lib/cinch/irc.rb
64
- - lib/cinch/base.rb
65
- - lib/cinch/rules.rb
66
- - examples/join_part.rb
67
- - examples/named-param-types.rb
68
- - examples/url_shorten.rb
69
- - examples/custom_prefix.rb
70
- - examples/urban_dict.rb
71
- - examples/msg.rb
72
- - examples/hello.rb
73
- - examples/seen.rb
74
- - examples/memo.rb
75
- - examples/custom_patterns.rb
76
- - examples/google.rb
77
- - examples/autovoice.rb
65
+ - lib/cinch/helpers.rb
66
+ - lib/cinch/isupport.rb
67
+ - lib/cinch/logger/null_logger.rb
68
+ - lib/cinch/logger/logger.rb
69
+ - lib/cinch/logger/formatted_logger.rb
70
+ - lib/cinch/constants.rb
71
+ - lib/cinch/ban.rb
72
+ - lib/cinch/message.rb
73
+ - lib/cinch/syncable.rb
74
+ - lib/cinch/plugin.rb
75
+ - lib/cinch/callback.rb
76
+ - lib/cinch/channel.rb
77
+ - lib/cinch/message_queue.rb
78
+ - lib/cinch/rubyext/infinity.rb
79
+ - lib/cinch/rubyext/queue.rb
80
+ - lib/cinch/rubyext/string.rb
81
+ - lib/cinch/rubyext/module.rb
82
+ - examples/basic/join_part.rb
83
+ - examples/basic/url_shorten.rb
84
+ - examples/basic/urban_dict.rb
85
+ - examples/basic/msg.rb
86
+ - examples/basic/hello.rb
87
+ - examples/basic/seen.rb
88
+ - examples/basic/memo.rb
89
+ - examples/basic/google.rb
90
+ - examples/basic/autovoice.rb
91
+ - examples/plugins/join_part.rb
92
+ - examples/plugins/url_shorten.rb
93
+ - examples/plugins/custom_prefix.rb
94
+ - examples/plugins/urban_dict.rb
95
+ - examples/plugins/msg.rb
96
+ - examples/plugins/hello.rb
97
+ - examples/plugins/multiple_matches.rb
98
+ - examples/plugins/seen.rb
99
+ - examples/plugins/memo.rb
100
+ - examples/plugins/google.rb
101
+ - examples/plugins/autovoice.rb
78
102
  has_rdoc: true
79
- homepage: http://rdoc.injekt.net/cinch
103
+ homepage: http://doc.injekt.net/cinch
80
104
  licenses: []
81
105
 
82
106
  post_install_message:
83
- rdoc_options:
84
- - --quiet
85
- - --title
86
- - "Cinch: The IRC Bot Building Framework"
87
- - --main
88
- - README.rdoc
107
+ rdoc_options: []
108
+
89
109
  require_paths:
90
110
  - lib
91
111
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -93,18 +113,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
93
113
  requirements:
94
114
  - - ">="
95
115
  - !ruby/object:Gem::Version
96
- hash: 57
97
116
  segments:
98
117
  - 1
99
- - 8
100
- - 7
101
- version: 1.8.7
118
+ - 9
119
+ - 1
120
+ version: 1.9.1
102
121
  required_rubygems_version: !ruby/object:Gem::Requirement
103
122
  none: false
104
123
  requirements:
105
124
  - - ">="
106
125
  - !ruby/object:Gem::Version
107
- hash: 3
108
126
  segments:
109
127
  - 0
110
128
  version: "0"
@@ -1,195 +0,0 @@
1
- = Cinch: The IRC Bot Building Framework
2
-
3
- == Description
4
- Cinch is an IRC Bot Building Framework for quickly creating IRC bots
5
- in Ruby with minimal effort.
6
- It provides a minimal interface based on plugins and rules. It's as simple as creating a
7
- plugin, defining a rule, and watching your profits flourish.
8
-
9
- Cinch will do all of the hard work for you, so you can spend time creating cool plugins
10
- and extensions to wow your internet peers.
11
-
12
- If you'd like to test your own Cinch experiments you can do so in the cinch IRC channel
13
- on {irc.freenode.org}[irc://irc.freenode.org/cinch]. Support is also welcome here.
14
-
15
- == Installation
16
-
17
- === RubyGems
18
- You can install the latest version of Cinch using RubyGems
19
- gem install cinch
20
-
21
- === GitHub
22
- Alternatively you can check out the latest code directly from Github
23
- git clone http://github.com/injekt/cinch.git
24
-
25
- == Example
26
- Your typical <em>Hello, World</em> application would go something like this:
27
-
28
- require 'cinch'
29
-
30
- bot = Cinch.setup do
31
- server "irc.freenode.org"
32
- nick "Cinch"
33
- end
34
-
35
- bot.plugin "hello" do |m|
36
- m.reply "Hello, #{m.nick}!"
37
- end
38
-
39
- bot.run
40
-
41
- It doesn't take much to work out what's happening here, but I'll explain it anyway.
42
-
43
- First we run the <em>Cinch::setup</em> block which is required in every application. Cinch is boxed
44
- with a load of default values, so the <b>only</b> option required in this block is the server.
45
-
46
- We then define a plugin using the <em>plugin</em> method and pass it a rule (a String in this
47
- case). Every plugin must be mapped to a rule. When the rule matches an IRC message its block is
48
- invoked, the contents of which contains your plugin interface. The variable passed to the block is
49
- an instance of Cinch::IRC::Message.
50
-
51
- Cinch::IRC::Message also supplies us with some helper methods which aid in replying to users and
52
- channels.
53
-
54
- === See Also
55
- * Cinch::IRC::Message#reply
56
- * Cinch::IRC::Message#answer
57
-
58
- This example would provide the following response on IRC:
59
-
60
- * Cinch has joined #cinch
61
- injekt> !hello
62
- Cinch> Hello, injekt!
63
-
64
- Since Cinch doesn't provide a binary executable, running your application is as simple as you would any
65
- other Ruby script.
66
-
67
- ruby hello.rb
68
-
69
- Cinch also parses the command line for options, to save you having to configure
70
- options within your script.
71
-
72
- ruby hello.rb -s irc.freenode.org -n Coolbot
73
- ruby hello.rb -C foo,bar
74
-
75
- Doing a <b>ruby hello.rb -h</b> provides all possible command line options.
76
-
77
- When using the <em>-C</em> or <em>--channels</em> option, the channel prefix is
78
- optional, and if none is given the channel will be prefixed with a hash (#) character.
79
-
80
- == Plugins
81
- Plugins are invoked using the command prefix character (which by default is set to <b>!</b>). You can
82
- also tell Cinch to ignore any command prefix and instead use the bots username. This would provide
83
- a result similar to this:
84
-
85
- injekt> Cinch: hello
86
- Cinch> Hello, injekt!
87
-
88
- Cinch also provides named parameters. This method of expression was inspired by the {Sinatra
89
- Web Framework}[http://www.sinatrarb.com/] and although it doesn't quite follow the same pattern,
90
- it's useful for naming parameters passed to plugins. These paramaters are available through the
91
- Cinch::IRC::Message#args method which is passed to each plugin.
92
-
93
- bot.plugin("say :text") do |m|
94
- m.reply m.args[:text]
95
- end
96
-
97
- This plugin would provide the following output:
98
-
99
- injekt> !say foo bar baz
100
- Cinch> foo bar baz
101
-
102
- Each plugin takes an optional hash of message specific options. These options provide an extension to
103
- the rules given, for example if we want to reply only if the nick sending the message is injekt, we
104
- could pass the 'nick' option to the hash.
105
-
106
- bot.plugin("join :channel", :nick => 'injekt') do |m|
107
- bot.join #{m.args[:channel]}
108
- end
109
-
110
- This method also works for arrays, to only reply to a message sent in the foo and bar channels
111
-
112
- bot.plugin :hello, :channel => ['#foo', '#bar'] do |m|
113
- m.reply "Hello"
114
- end
115
-
116
- You can also set a custom prefix for each individual plugin, this is a great method if you have
117
- two commands which do slightly different things. You can seperate the commands depending on which
118
- prefix the rule contains.
119
-
120
- bot.plugin "foo", :prefix => '@' do |m|
121
- m.reply "Doing foo.."
122
- end
123
-
124
- You can also prefix the rule with the bots nickname. Either pass the <b>:bot</b>, <b>:botnick</b> or
125
- <b>bot.nick</b> values to the prefix option.
126
-
127
- bot.plugin "foo", :prefix => :bot do |m|
128
- m.reply "Doing foo.."
129
- end
130
-
131
- Assuming the username is cinch, this will respond to the following:
132
- * cinch: foo
133
- * cinch, foo
134
-
135
- More examples of this can be found in the /examples directory
136
-
137
- == Named Parameter Patterns
138
- Since version 0.2, Cinch supports named parameter patterns. It means stuff like the this works:
139
-
140
- bot.plugin("say :n-digit :text") do |m|
141
- m.args[:n].to_i.times do
142
- m.reply m.args[:text]
143
- end
144
- end
145
-
146
- This would provide the following output on IRC
147
-
148
- injekt> !say foo bar
149
- injekt> !say 2 foo bar
150
- Cinch> foo bar
151
- Cinch> foo bar
152
-
153
- * See Cinch::Base#compile for more information and the available patterns
154
-
155
- Cinch also supports custom named parameter patterns. That's right, you can define you own
156
- pattern. Just like this:
157
-
158
- bot.add_custom_pattern(:friends, /injekt|lee|john|bob/)
159
-
160
- bot.plugin("I like :friend-friends", :prefix => false) do |m|
161
- m.reply "I like #{m.args[:friend]} too!"
162
- end
163
-
164
- Which would provide the following output on IRC:
165
-
166
- * Cinch has joined #cinch
167
- injekt> I like spongebob
168
- injekt> I like bob
169
- Cinch> I like bob too!
170
-
171
- Note though that although Cinch adds the capturing parenthesis for you, you must escape it yourself
172
-
173
- == Examples
174
- Check out the /examples directory for basic, yet fully functional out-of-the-box bots.
175
- If you have any examples you'd like to add, please either fork the repo and push your example
176
- before sending me a pull request. Alternatively paste the example and inform me in the IRC
177
- channel or by email
178
-
179
- == Authors
180
- * {Lee Jarvis}[http://injekt.net]
181
-
182
- == Notes
183
- * RDoc API documentation is available {here}[http://rdoc.injekt.net/cinch]
184
- * Issue and feature tracking is available {here}[https://github.com/injekt/cinch/issues]
185
- * Contribution in the form of bugfixes or feature requests is welcome and encouraged
186
-
187
- == Contribute
188
- If you'd like to contribute, fork the GitHub repository, make any changes, and send
189
- {injekt}[http://github.com/injekt] a pull request. Collaborator access is available on
190
- request once one patch has been submitted. Any contribution is welcome and appreciated
191
-
192
- == TODO
193
- * More specs
194
- * More documentation
195
-
@@ -1,32 +0,0 @@
1
- require 'cinch'
2
-
3
- # Give this bot ops in a channel and it'll auto voice
4
- # visitors
5
- #
6
- # Enable with !autovoice on
7
- # Disable with !autovoice off
8
-
9
- bot = Cinch.setup do
10
- server "irc.freenode.org"
11
- channels %w( #cinch )
12
- end
13
-
14
- autovoice = true
15
-
16
- bot.on :join do |m|
17
- unless m.nick == bot.options.nick # We shouldn't attempt to voice ourselves
18
- bot.mode(m.channel, '+v', m.nick) if autovoice
19
- end
20
- end
21
-
22
- bot.add_custom_pattern(:onoff, '(on|off)')
23
-
24
- bot.plugin "autovoice :option-onoff" do |m|
25
- case m.args[:option]
26
- when 'on'; autovoice = true
27
- when 'off'; autovoice = false
28
- end
29
- m.answer "Autovoice is now #{autovoice ? 'enabled' : 'disabled'}"
30
- end
31
-
32
- bot.run