cinch 1.1.3 → 2.0.0.pre.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.
- data/LICENSE +1 -0
- data/README.md +3 -3
- data/docs/bot_options.md +435 -0
- data/docs/changes.md +440 -0
- data/docs/common_mistakes.md +35 -0
- data/docs/common_tasks.md +47 -0
- data/docs/encodings.md +67 -0
- data/docs/events.md +272 -0
- data/docs/logging.md +5 -0
- data/docs/migrating.md +267 -0
- data/docs/readme.md +18 -0
- data/examples/plugins/custom_prefix.rb +1 -1
- data/examples/plugins/dice_roll.rb +38 -0
- data/examples/plugins/lambdas.rb +1 -1
- data/examples/plugins/memo.rb +16 -10
- data/examples/plugins/url_shorten.rb +1 -0
- data/lib/cinch.rb +5 -60
- data/lib/cinch/ban.rb +13 -7
- data/lib/cinch/bot.rb +228 -403
- data/lib/cinch/{cache_manager.rb → cached_list.rb} +5 -1
- data/lib/cinch/callback.rb +3 -0
- data/lib/cinch/channel.rb +119 -195
- data/lib/cinch/{channel_manager.rb → channel_list.rb} +6 -3
- data/lib/cinch/configuration.rb +73 -0
- data/lib/cinch/configuration/bot.rb +47 -0
- data/lib/cinch/configuration/dcc.rb +16 -0
- data/lib/cinch/configuration/plugins.rb +41 -0
- data/lib/cinch/configuration/sasl.rb +17 -0
- data/lib/cinch/configuration/ssl.rb +19 -0
- data/lib/cinch/configuration/storage.rb +37 -0
- data/lib/cinch/configuration/timeouts.rb +14 -0
- data/lib/cinch/constants.rb +531 -369
- data/lib/cinch/dcc.rb +12 -0
- data/lib/cinch/dcc/dccable_object.rb +37 -0
- data/lib/cinch/dcc/incoming.rb +1 -0
- data/lib/cinch/dcc/incoming/send.rb +131 -0
- data/lib/cinch/dcc/outgoing.rb +1 -0
- data/lib/cinch/dcc/outgoing/send.rb +115 -0
- data/lib/cinch/exceptions.rb +8 -1
- data/lib/cinch/formatting.rb +106 -0
- data/lib/cinch/handler.rb +104 -0
- data/lib/cinch/handler_list.rb +86 -0
- data/lib/cinch/helpers.rb +167 -10
- data/lib/cinch/irc.rb +525 -110
- data/lib/cinch/isupport.rb +11 -9
- data/lib/cinch/logger.rb +168 -0
- data/lib/cinch/logger/formatted_logger.rb +72 -55
- data/lib/cinch/logger/zcbot_logger.rb +9 -24
- data/lib/cinch/logger_list.rb +62 -0
- data/lib/cinch/mask.rb +19 -10
- data/lib/cinch/message.rb +94 -28
- data/lib/cinch/message_queue.rb +70 -28
- data/lib/cinch/mode_parser.rb +6 -1
- data/lib/cinch/network.rb +104 -0
- data/lib/cinch/{rubyext/queue.rb → open_ended_queue.rb} +8 -1
- data/lib/cinch/pattern.rb +24 -4
- data/lib/cinch/plugin.rb +352 -177
- data/lib/cinch/plugin_list.rb +35 -0
- data/lib/cinch/rubyext/float.rb +3 -0
- data/lib/cinch/rubyext/module.rb +7 -0
- data/lib/cinch/rubyext/string.rb +9 -0
- data/lib/cinch/sasl.rb +34 -0
- data/lib/cinch/sasl/dh_blowfish.rb +71 -0
- data/lib/cinch/sasl/diffie_hellman.rb +47 -0
- data/lib/cinch/sasl/mechanism.rb +6 -0
- data/lib/cinch/sasl/plain.rb +26 -0
- data/lib/cinch/storage.rb +62 -0
- data/lib/cinch/storage/null.rb +12 -0
- data/lib/cinch/storage/yaml.rb +96 -0
- data/lib/cinch/syncable.rb +13 -1
- data/lib/cinch/target.rb +144 -0
- data/lib/cinch/timer.rb +145 -0
- data/lib/cinch/user.rb +169 -225
- data/lib/cinch/{user_manager.rb → user_list.rb} +7 -2
- data/lib/cinch/utilities/deprecation.rb +12 -0
- data/lib/cinch/utilities/encoding.rb +54 -0
- data/lib/cinch/utilities/kernel.rb +13 -0
- data/lib/cinch/utilities/string.rb +13 -0
- data/lib/cinch/version.rb +4 -0
- metadata +88 -47
- data/lib/cinch/logger/logger.rb +0 -44
- data/lib/cinch/logger/null_logger.rb +0 -18
- data/lib/cinch/rubyext/infinity.rb +0 -1
@@ -1,7 +1,10 @@
|
|
1
|
-
require "cinch/
|
1
|
+
require "cinch/cached_list"
|
2
2
|
|
3
3
|
module Cinch
|
4
|
-
|
4
|
+
# @since 2.0.0
|
5
|
+
# @version 1.1.0
|
6
|
+
# @note In prior versions, this class was called UserManager
|
7
|
+
class UserList < CachedList
|
5
8
|
# Finds or creates a user.
|
6
9
|
# @overload find_ensured(nick)
|
7
10
|
# Finds or creates a user based on his nick.
|
@@ -45,6 +48,7 @@ module Cinch
|
|
45
48
|
end
|
46
49
|
|
47
50
|
# @api private
|
51
|
+
# @return [void]
|
48
52
|
def update_nick(user)
|
49
53
|
@mutex.synchronize do
|
50
54
|
@cache[user.nick.irc_downcase(@bot.irc.isupport["CASEMAPPING"])] = user
|
@@ -53,6 +57,7 @@ module Cinch
|
|
53
57
|
end
|
54
58
|
|
55
59
|
# @api private
|
60
|
+
# @return [void]
|
56
61
|
def delete(user)
|
57
62
|
@cache.delete_if {|n, u| u == user }
|
58
63
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Cinch
|
2
|
+
# @since 2.0.0
|
3
|
+
# @api private
|
4
|
+
module Utilities
|
5
|
+
module Deprecation
|
6
|
+
def self.print_deprecation(version, method)
|
7
|
+
$stderr.puts "Deprecation warning: Beginning with version #{version}, #{method} should not be used anymore."
|
8
|
+
$stderr.puts caller
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Cinch
|
2
|
+
# @since 2.0.0
|
3
|
+
# @api private
|
4
|
+
module Utilities
|
5
|
+
module Encoding
|
6
|
+
def self.encode_incoming(string, encoding)
|
7
|
+
string = string.dup
|
8
|
+
if encoding == :irc
|
9
|
+
# If incoming text is valid UTF-8, it will be interpreted as
|
10
|
+
# such. If it fails validation, a CP1252 -> UTF-8 conversion
|
11
|
+
# is performed. This allows you to see non-ASCII from mIRC
|
12
|
+
# users (non-UTF-8) and other users sending you UTF-8.
|
13
|
+
#
|
14
|
+
# (from http://xchat.org/encoding/#hybrid)
|
15
|
+
string.force_encoding("UTF-8")
|
16
|
+
if !string.valid_encoding?
|
17
|
+
string.force_encoding("CP1252").encode!("UTF-8", {:invalid => :replace, :undef => :replace})
|
18
|
+
end
|
19
|
+
else
|
20
|
+
string.force_encoding(encoding).encode!({:invalid => :replace, :undef => :replace})
|
21
|
+
string = string.chars.select { |c| c.valid_encoding? }.join
|
22
|
+
end
|
23
|
+
|
24
|
+
return string
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.encode_outgoing(string, encoding)
|
28
|
+
string = string.dup
|
29
|
+
if encoding == :irc
|
30
|
+
# If your text contains only characters that fit inside the CP1252
|
31
|
+
# code page (aka Windows Latin-1), the entire line will be sent
|
32
|
+
# that way. mIRC users should see it correctly. XChat users who
|
33
|
+
# are using UTF-8 will also see it correctly, because it will fail
|
34
|
+
# UTF-8 validation and will be assumed to be CP1252, even by older
|
35
|
+
# XChat versions.
|
36
|
+
#
|
37
|
+
# If the text doesn't fit inside the CP1252 code page, (for example if you
|
38
|
+
# type Eastern European characters, or Russian) it will be sent as UTF-8. Only
|
39
|
+
# UTF-8 capable clients will be able to see these characters correctly
|
40
|
+
#
|
41
|
+
# (from http://xchat.org/encoding/#hybrid)
|
42
|
+
begin
|
43
|
+
string.encode!("CP1252")
|
44
|
+
rescue ::Encoding::UndefinedConversionError
|
45
|
+
end
|
46
|
+
else
|
47
|
+
string.encode!(encoding, {:invalid => :replace, :undef => :replace}).force_encoding("ASCII-8BIT")
|
48
|
+
end
|
49
|
+
|
50
|
+
return string
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Cinch
|
2
|
+
# @since 2.0.0
|
3
|
+
# @api private
|
4
|
+
module Utilities
|
5
|
+
module Kernel
|
6
|
+
# @return [Object]
|
7
|
+
def self.string_to_const(s)
|
8
|
+
return s unless s.is_a?(::String)
|
9
|
+
s.split("::").inject(Kernel) {|base, name| base.const_get(name) }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
metadata
CHANGED
@@ -1,21 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cinch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
prerelease:
|
4
|
+
version: 2.0.0.pre.1
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
|
-
- Lee Jarvis
|
9
8
|
- Dominik Honnef
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
14
|
-
default_executable:
|
12
|
+
date: 2012-03-03 00:00:00.000000000 Z
|
15
13
|
dependencies: []
|
16
14
|
description: A simple, friendly DSL for creating IRC bots
|
17
15
|
email:
|
18
|
-
- lee@jarvis.co
|
19
16
|
- dominikh@fork-bomb.org
|
20
17
|
executables: []
|
21
18
|
extensions: []
|
@@ -23,62 +20,105 @@ extra_rdoc_files: []
|
|
23
20
|
files:
|
24
21
|
- LICENSE
|
25
22
|
- README.md
|
26
|
-
-
|
27
|
-
-
|
28
|
-
-
|
23
|
+
- docs/changes.md
|
24
|
+
- docs/readme.md
|
25
|
+
- docs/bot_options.md
|
26
|
+
- docs/common_mistakes.md
|
27
|
+
- docs/events.md
|
28
|
+
- docs/encodings.md
|
29
|
+
- docs/logging.md
|
30
|
+
- docs/common_tasks.md
|
31
|
+
- docs/migrating.md
|
32
|
+
- lib/cinch/formatting.rb
|
29
33
|
- lib/cinch/channel.rb
|
30
|
-
- lib/cinch/
|
31
|
-
- lib/cinch/
|
34
|
+
- lib/cinch/timer.rb
|
35
|
+
- lib/cinch/sasl/diffie_hellman.rb
|
36
|
+
- lib/cinch/sasl/plain.rb
|
37
|
+
- lib/cinch/sasl/dh_blowfish.rb
|
38
|
+
- lib/cinch/sasl/mechanism.rb
|
39
|
+
- lib/cinch/network.rb
|
40
|
+
- lib/cinch/sasl.rb
|
41
|
+
- lib/cinch/cached_list.rb
|
32
42
|
- lib/cinch/bot.rb
|
33
|
-
- lib/cinch/
|
34
|
-
- lib/cinch/ban.rb
|
35
|
-
- lib/cinch/syncable.rb
|
36
|
-
- lib/cinch/message.rb
|
37
|
-
- lib/cinch/channel_manager.rb
|
38
|
-
- lib/cinch/logger/zcbot_logger.rb
|
39
|
-
- lib/cinch/logger/null_logger.rb
|
40
|
-
- lib/cinch/logger/formatted_logger.rb
|
41
|
-
- lib/cinch/logger/logger.rb
|
43
|
+
- lib/cinch/storage.rb
|
42
44
|
- lib/cinch/isupport.rb
|
43
|
-
- lib/cinch/pattern.rb
|
44
|
-
- lib/cinch/user.rb
|
45
45
|
- lib/cinch/helpers.rb
|
46
|
-
- lib/cinch/
|
46
|
+
- lib/cinch/handler.rb
|
47
|
+
- lib/cinch/handler_list.rb
|
47
48
|
- lib/cinch/rubyext/module.rb
|
48
|
-
- lib/cinch/rubyext/
|
49
|
-
- lib/cinch/rubyext/infinity.rb
|
49
|
+
- lib/cinch/rubyext/float.rb
|
50
50
|
- lib/cinch/rubyext/string.rb
|
51
|
+
- lib/cinch/syncable.rb
|
52
|
+
- lib/cinch/plugin_list.rb
|
53
|
+
- lib/cinch/message.rb
|
54
|
+
- lib/cinch/target.rb
|
51
55
|
- lib/cinch/mask.rb
|
52
|
-
- lib/cinch/
|
53
|
-
- lib/cinch/
|
56
|
+
- lib/cinch/configuration/sasl.rb
|
57
|
+
- lib/cinch/configuration/bot.rb
|
58
|
+
- lib/cinch/configuration/storage.rb
|
59
|
+
- lib/cinch/configuration/plugins.rb
|
60
|
+
- lib/cinch/configuration/ssl.rb
|
61
|
+
- lib/cinch/configuration/dcc.rb
|
62
|
+
- lib/cinch/configuration/timeouts.rb
|
63
|
+
- lib/cinch/pattern.rb
|
64
|
+
- lib/cinch/open_ended_queue.rb
|
65
|
+
- lib/cinch/logger_list.rb
|
66
|
+
- lib/cinch/callback.rb
|
67
|
+
- lib/cinch/dcc.rb
|
68
|
+
- lib/cinch/version.rb
|
69
|
+
- lib/cinch/utilities/deprecation.rb
|
70
|
+
- lib/cinch/utilities/kernel.rb
|
71
|
+
- lib/cinch/utilities/string.rb
|
72
|
+
- lib/cinch/utilities/encoding.rb
|
73
|
+
- lib/cinch/constants.rb
|
54
74
|
- lib/cinch/mode_parser.rb
|
75
|
+
- lib/cinch/user.rb
|
76
|
+
- lib/cinch/storage/yaml.rb
|
77
|
+
- lib/cinch/storage/null.rb
|
78
|
+
- lib/cinch/logger/formatted_logger.rb
|
79
|
+
- lib/cinch/logger/zcbot_logger.rb
|
80
|
+
- lib/cinch/exceptions.rb
|
81
|
+
- lib/cinch/logger.rb
|
82
|
+
- lib/cinch/plugin.rb
|
83
|
+
- lib/cinch/user_list.rb
|
84
|
+
- lib/cinch/dcc/incoming/send.rb
|
85
|
+
- lib/cinch/dcc/dccable_object.rb
|
86
|
+
- lib/cinch/dcc/outgoing.rb
|
87
|
+
- lib/cinch/dcc/incoming.rb
|
88
|
+
- lib/cinch/dcc/outgoing/send.rb
|
89
|
+
- lib/cinch/irc.rb
|
90
|
+
- lib/cinch/channel_list.rb
|
91
|
+
- lib/cinch/ban.rb
|
92
|
+
- lib/cinch/message_queue.rb
|
93
|
+
- lib/cinch/configuration.rb
|
94
|
+
- lib/cinch.rb
|
95
|
+
- examples/plugins/timer.rb
|
55
96
|
- examples/plugins/msg.rb
|
56
|
-
- examples/plugins/
|
57
|
-
- examples/plugins/urban_dict.rb
|
58
|
-
- examples/plugins/last_nick.rb
|
59
|
-
- examples/plugins/join_part.rb
|
97
|
+
- examples/plugins/dice_roll.rb
|
60
98
|
- examples/plugins/lambdas.rb
|
61
|
-
- examples/plugins/
|
62
|
-
- examples/plugins/
|
99
|
+
- examples/plugins/join_part.rb
|
100
|
+
- examples/plugins/google.rb
|
101
|
+
- examples/plugins/autovoice.rb
|
63
102
|
- examples/plugins/multiple_matches.rb
|
64
|
-
- examples/plugins/
|
103
|
+
- examples/plugins/url_shorten.rb
|
104
|
+
- examples/plugins/memo.rb
|
65
105
|
- examples/plugins/own_events.rb
|
66
106
|
- examples/plugins/seen.rb
|
67
|
-
- examples/plugins/
|
68
|
-
- examples/plugins/
|
69
|
-
- examples/plugins/autovoice.rb
|
107
|
+
- examples/plugins/last_nick.rb
|
108
|
+
- examples/plugins/urban_dict.rb
|
70
109
|
- examples/plugins/hooks.rb
|
110
|
+
- examples/plugins/hello.rb
|
111
|
+
- examples/plugins/custom_prefix.rb
|
71
112
|
- examples/basic/msg.rb
|
72
|
-
- examples/basic/memo.rb
|
73
|
-
- examples/basic/urban_dict.rb
|
74
113
|
- examples/basic/join_part.rb
|
75
|
-
- examples/basic/url_shorten.rb
|
76
|
-
- examples/basic/hello.rb
|
77
|
-
- examples/basic/seen.rb
|
78
114
|
- examples/basic/google.rb
|
79
115
|
- examples/basic/autovoice.rb
|
80
|
-
|
81
|
-
|
116
|
+
- examples/basic/url_shorten.rb
|
117
|
+
- examples/basic/memo.rb
|
118
|
+
- examples/basic/seen.rb
|
119
|
+
- examples/basic/urban_dict.rb
|
120
|
+
- examples/basic/hello.rb
|
121
|
+
homepage: http://cinchrb.org
|
82
122
|
licenses: []
|
83
123
|
post_install_message:
|
84
124
|
rdoc_options: []
|
@@ -93,13 +133,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
93
133
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
134
|
none: false
|
95
135
|
requirements:
|
96
|
-
- - ! '
|
136
|
+
- - ! '>'
|
97
137
|
- !ruby/object:Gem::Version
|
98
|
-
version:
|
138
|
+
version: 1.3.1
|
99
139
|
requirements: []
|
100
140
|
rubyforge_project:
|
101
|
-
rubygems_version: 1.
|
141
|
+
rubygems_version: 1.8.15
|
102
142
|
signing_key:
|
103
143
|
specification_version: 3
|
104
144
|
summary: An IRC Bot Building Framework
|
105
145
|
test_files: []
|
146
|
+
has_rdoc: yard
|
data/lib/cinch/logger/logger.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
module Cinch
|
2
|
-
module Logger
|
3
|
-
# This is an abstract class describing the logger interface. All
|
4
|
-
# loggers should inherit from this class and provide all necessary
|
5
|
-
# methods.
|
6
|
-
#
|
7
|
-
# Note: You cannot initialize this class directly.
|
8
|
-
#
|
9
|
-
# @abstract
|
10
|
-
class Logger
|
11
|
-
def initialize(output)
|
12
|
-
raise
|
13
|
-
end
|
14
|
-
|
15
|
-
# This method can be used by plugins to log custom messages.
|
16
|
-
#
|
17
|
-
# @param [String] message The message to log
|
18
|
-
# @return [void]
|
19
|
-
def debug(message)
|
20
|
-
raise
|
21
|
-
end
|
22
|
-
|
23
|
-
# This method is used by {#debug} and {#log_exception} to log
|
24
|
-
# messages, and also by the IRC parser to log incoming and
|
25
|
-
# outgoing messages. You should not have to call this.
|
26
|
-
#
|
27
|
-
# @param [String] message The message to log
|
28
|
-
# @param [Symbol<:debug, :generic, :incoming, :outgoing>] kind
|
29
|
-
# The kind of message to log
|
30
|
-
# @return [void]
|
31
|
-
def log(message, kind = :generic)
|
32
|
-
raise
|
33
|
-
end
|
34
|
-
|
35
|
-
# This method is used for logging messages.
|
36
|
-
#
|
37
|
-
# @param [Exception] e The exception to log
|
38
|
-
# @return [void]
|
39
|
-
def log_exception(e)
|
40
|
-
raise
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require "cinch/logger/logger"
|
2
|
-
module Cinch
|
3
|
-
module Logger
|
4
|
-
class NullLogger < Cinch::Logger::Logger
|
5
|
-
def initialize(output = nil)
|
6
|
-
end
|
7
|
-
|
8
|
-
def debug(message)
|
9
|
-
end
|
10
|
-
|
11
|
-
def log(message, kind = :generic)
|
12
|
-
end
|
13
|
-
|
14
|
-
def log_exception(e)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
Infinity = 1.0/0.0
|