marvin 0.8.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 (54) hide show
  1. data/bin/marvin +33 -0
  2. data/handlers/debug_handler.rb +5 -0
  3. data/handlers/hello_world.rb +9 -0
  4. data/handlers/keiki_thwopper.rb +21 -0
  5. data/handlers/simple_logger.rb +24 -0
  6. data/handlers/tweet_tweet.rb +19 -0
  7. data/lib/marvin.rb +56 -0
  8. data/lib/marvin/abstract_client.rb +146 -0
  9. data/lib/marvin/abstract_parser.rb +29 -0
  10. data/lib/marvin/base.rb +195 -0
  11. data/lib/marvin/client/actions.rb +104 -0
  12. data/lib/marvin/client/default_handlers.rb +97 -0
  13. data/lib/marvin/command_handler.rb +91 -0
  14. data/lib/marvin/console.rb +50 -0
  15. data/lib/marvin/core_commands.rb +49 -0
  16. data/lib/marvin/distributed.rb +8 -0
  17. data/lib/marvin/distributed/client.rb +225 -0
  18. data/lib/marvin/distributed/handler.rb +85 -0
  19. data/lib/marvin/distributed/protocol.rb +88 -0
  20. data/lib/marvin/distributed/server.rb +154 -0
  21. data/lib/marvin/dsl.rb +103 -0
  22. data/lib/marvin/exception_tracker.rb +19 -0
  23. data/lib/marvin/exceptions.rb +11 -0
  24. data/lib/marvin/irc.rb +7 -0
  25. data/lib/marvin/irc/client.rb +168 -0
  26. data/lib/marvin/irc/event.rb +39 -0
  27. data/lib/marvin/irc/replies.rb +154 -0
  28. data/lib/marvin/logging_handler.rb +76 -0
  29. data/lib/marvin/middle_man.rb +103 -0
  30. data/lib/marvin/parsers.rb +9 -0
  31. data/lib/marvin/parsers/command.rb +107 -0
  32. data/lib/marvin/parsers/prefixes.rb +8 -0
  33. data/lib/marvin/parsers/prefixes/host_mask.rb +35 -0
  34. data/lib/marvin/parsers/prefixes/server.rb +24 -0
  35. data/lib/marvin/parsers/ragel_parser.rb +720 -0
  36. data/lib/marvin/parsers/ragel_parser.rl +143 -0
  37. data/lib/marvin/parsers/simple_parser.rb +35 -0
  38. data/lib/marvin/settings.rb +31 -0
  39. data/lib/marvin/test_client.rb +58 -0
  40. data/lib/marvin/util.rb +54 -0
  41. data/templates/boot.erb +3 -0
  42. data/templates/connections.yml.erb +10 -0
  43. data/templates/debug_handler.erb +5 -0
  44. data/templates/hello_world.erb +10 -0
  45. data/templates/rakefile.erb +15 -0
  46. data/templates/settings.yml.erb +8 -0
  47. data/templates/setup.erb +31 -0
  48. data/templates/test_helper.erb +17 -0
  49. data/test/abstract_client_test.rb +63 -0
  50. data/test/parser_comparison.rb +62 -0
  51. data/test/parser_test.rb +266 -0
  52. data/test/test_helper.rb +62 -0
  53. data/test/util_test.rb +57 -0
  54. metadata +136 -0
@@ -0,0 +1,103 @@
1
+ module Marvin
2
+ # The middle man is a class you can use to register
3
+ # other handlers on. e.g. it acts as a way to 'filter'
4
+ # incoming and outgoing messages. Akin to Rack / WSGI
5
+ # middleware.
6
+ class MiddleMan
7
+
8
+ # Set the logger cattr to the default marvin logger.
9
+ cattr_accessor :logger
10
+ self.logger ||= Marvin::Logger
11
+
12
+ # By default, we are *not* setup.
13
+ @@setup = false
14
+
15
+ # Our list of subhandlers. We make sure
16
+ # the list is unique to our subclass / class.
17
+ class_inheritable_accessor :subhandlers
18
+ self.subhandlers = []
19
+
20
+ # Finally, the client.
21
+ attr_reader :client
22
+
23
+ # When we're told to set the client,
24
+ # not only do we set out own instance
25
+ # but we also echo the command down
26
+ # to all of our sub-clients.
27
+ def client=(new_client)
28
+ @client = new_client
29
+ setup_subhandler_clients
30
+ end
31
+
32
+ def process_event(message, options)
33
+ return message, options
34
+ end
35
+
36
+ # Filter incoming events.
37
+ def handle(message, options)
38
+ # Process the current event.
39
+ message, options = process_event(message, options)
40
+ full_handler_name = "handle_#{message}"
41
+ self.send(full_handler_name, opts) if respond_to?(full_handler_name)
42
+ self.subhandlers.each do |sh|
43
+ forward_message_to_handler(sh, message, options, full_handler_name)
44
+ end
45
+ rescue HaltHandlerProcessing
46
+ logger.info "Asked to halt the filter processing chain inside a middleman."
47
+ rescue Exception => e
48
+ logger.fatal "Exception processing handle #{message}"
49
+ Marvin::ExceptionTracker.log(e)
50
+ end
51
+
52
+ class << self
53
+
54
+ def setup?
55
+ @@setup
56
+ end
57
+
58
+ # Forcefully do the setup routine.
59
+ def setup!
60
+ # Register ourselves as a new handler.
61
+ Marvin::Settings.client.register_handler self.new
62
+ @@setup = true
63
+ end
64
+
65
+ # Setup iff setup hasn't been done.
66
+ def setup
67
+ return if self.setup?
68
+ self.setup!
69
+ end
70
+
71
+ # Register a single subhandler.
72
+ def register_handler(handler, run_setup = true)
73
+ self.setup if run_setup
74
+ self.subhandlers << handler unless handler.blank?
75
+ end
76
+
77
+ # Registers a group of subhandlers.
78
+ def register_handlers(*args)
79
+ self.setup
80
+ args.each { |h| self.register_handler(h, false) }
81
+ end
82
+
83
+ end
84
+
85
+ private
86
+
87
+ def setup_subhandler_clients
88
+ self.subhandlers.each { |sh| sh.client = self.client if sh.respond_to?(:client=) }
89
+ end
90
+
91
+ # This should probably be extracted into some sort of Util's library as
92
+ # it's shared across a couple of classes but I really can't be bothered
93
+ # at the moment - I just want to test the concept.
94
+ def forward_message_to_handler(handler, message, options, full_handler_name)
95
+ if handler.respond_to?(full_handler_name)
96
+ handler.send(full_handler_name, options)
97
+ elsif handler.respond_to?(:handle)
98
+ handler.handle message, options
99
+ end
100
+ end
101
+
102
+ end
103
+ end
@@ -0,0 +1,9 @@
1
+ module Marvin
2
+ module Parsers
3
+ # Default Parsers
4
+ autoload :Prefixes, 'marvin/parsers/prefixes'
5
+ autoload :Command, 'marvin/parsers/command'
6
+ autoload :SimpleParser, 'marvin/parsers/simple_parser'
7
+ autoload :RagelParser, 'marvin/parsers/ragel_parser'
8
+ end
9
+ end
@@ -0,0 +1,107 @@
1
+ module Marvin
2
+ module Parsers
3
+ # A single incoming / outgoing irc command,
4
+ # with handy utilities to convert it to a
5
+ # Marvin::IRC::Event instance.
6
+ class Command
7
+
8
+ @@commands = {}
9
+
10
+ attr_accessor :raw, :prefix, :code, :params
11
+
12
+ # Create a new command from the given raw
13
+ # message.
14
+ def initialize(raw)
15
+ self.raw = raw
16
+ self.params = []
17
+ end
18
+
19
+ # From the given command and arguments / params,
20
+ # attempt to recognize the command and convert
21
+ # it to an event which can be used for other stuff.
22
+ def to_event
23
+ # If we have a numeric...
24
+ if @code =~ /^\d+$/
25
+ ev = @@commands[:numeric].dup
26
+ data = @params[0..-2]
27
+ data << "#{@params.last.include?(" ") ? ":" : ""}#{@params.last}"
28
+ ev.raw_arguments = [self.code.to_s, data.join(" ")]
29
+ elsif code == "PRIVMSG" && params.last =~ /^\001(.*)\001$/
30
+ results = $1.to_s
31
+ if results =~ /^ACTION /
32
+ name, value = :action, results.gsub(/^ACTION /, '')
33
+ else
34
+ name, value = :ctcp, results
35
+ end
36
+ self.params[-1] = value
37
+ ev = @@commands[name].dup
38
+ ev.raw_arguments = self.params
39
+ else
40
+ ev = @@commands[self.code.to_sym]
41
+ return nil if ev.nil?
42
+ ev = ev.dup
43
+ ev.raw_arguments = self.params
44
+ end
45
+ ev.prefix = self.prefix
46
+ return ev
47
+ end
48
+
49
+ private
50
+
51
+ # Adds an event that can be processed
52
+ def self.register_event(name, command, *args)
53
+ @@commands[command.to_sym] = Marvin::IRC::Event.new(name, *args)
54
+ end
55
+
56
+ register_event :pass, :PASS, :password
57
+ register_event :user, :USER, :user, :mode, :unused, :real_name
58
+ register_event :oper, :OPER, :name, :password
59
+ register_event :service, :SERVICE, :nick, :reserved, :distribution, :type, :reserved, :info
60
+ register_event :squit, :SQUIT, :server, :comment
61
+ register_event :nick, :NICK, :new_nick
62
+ register_event :quit, :QUIT, :message
63
+ register_event :ping, :PING, :data, :server
64
+ register_event :pong, :PONG, :data, :server
65
+ register_event :join, :JOIN, :target, :key
66
+ register_event :invite, :INVITE, :target, :channel
67
+ register_event :message, :PRIVMSG, :target, :message
68
+ register_event :part, :PART, :target, :message
69
+ register_event :mode, :MODE, :target, :mode, :mode_params
70
+ register_event :kick, :KICK, :target, :channel, :reason
71
+ register_event :notice, :NOTICE, :target, :message
72
+ register_event :topic, :TOPIC, :target, :topic
73
+ register_event :names, :NAMES, :channel, :target
74
+ register_event :list, :LIST, :channel, :target
75
+ register_event :motd, :MOTD, :target
76
+ register_event :lusers, :LUSERS, :mask, :target
77
+ register_event :version, :VERSION, :target
78
+ register_event :links, :LINKS, :remote, :mask
79
+ register_event :connect, :CONNECT, :target, :port, :remote
80
+ register_event :trace, :TRACE, :target
81
+ register_event :admin, :ADMIN, :target
82
+ register_event :info, :INFO, :target
83
+ register_event :servlist, :SERVLIST, :mask, :type
84
+ register_event :squery, :SQUERY, :service_name, :text
85
+ register_event :who, :WHO, :mask, :o
86
+ register_event :whois, :WHOIS, :target, :mask
87
+ register_event :whowas, :WHOWAS, :nick, :count, :target
88
+ register_event :kill, :KILL, :nick, :reason
89
+ register_event :error, :ERROR, :message
90
+ register_event :away, :AWAY, :reason
91
+ register_event :rehash, :REHASH
92
+ register_event :die, :DIE
93
+ register_event :restart, :RESTART
94
+ register_event :summon, :SUMMON, :user, :target, :channel
95
+ register_event :users, :USERS, :target
96
+ register_event :wallops, :WALLOPS, :message
97
+ register_event :userhost, :USERHOST, :nick
98
+ register_event :ison, :ISON, :nick
99
+ # Add the default numeric event
100
+ register_event :numeric, :numeric, :code, :data
101
+ # And a few others reserved for special purposes
102
+ register_event :action, :action, :target, :message
103
+ register_event :ctcp, :ctcp, :target, :message
104
+
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,8 @@
1
+ module Marvin
2
+ module Parsers
3
+ module Prefixes
4
+ autoload :Server, 'marvin/parsers/prefixes/server'
5
+ autoload :HostMask, 'marvin/parsers/prefixes/host_mask'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,35 @@
1
+ module Marvin
2
+ module Parsers
3
+ module Prefixes
4
+ # A Generic host mask prefix for a message.
5
+ class HostMask
6
+ attr_accessor :nick, :user, :host
7
+
8
+ def initialize(nick = nil, user = nil, host = nil)
9
+ @nick = nick || ""
10
+ @user = user || ""
11
+ @host = host || ""
12
+ end
13
+
14
+ # Convert it to a usable hash.
15
+ def to_hash
16
+ {
17
+ :nick => @nick.dup.freeze,
18
+ :ident => @user.dup.freeze,
19
+ :host => @host.dup.freeze
20
+ }
21
+ end
22
+
23
+ # Converts it back to a nicer form / a string.
24
+ def to_s
25
+ str = ""
26
+ str << @nick.to_s
27
+ str << "!#{@user}" unless @user.blank?
28
+ str << "@#{@host}" unless @host.blank?
29
+ str
30
+ end
31
+
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,24 @@
1
+ module Marvin
2
+ module Parsers
3
+ module Prefixes
4
+ # Generic server name prefix
5
+ class Server
6
+
7
+ attr_accessor :name
8
+
9
+ def initialize(name = nil)
10
+ @name = name.to_s
11
+ end
12
+
13
+ def to_hash
14
+ {:server => @name.freeze}
15
+ end
16
+
17
+ def to_s
18
+ @name.to_s
19
+ end
20
+
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,720 @@
1
+
2
+ # line 1 "ragel_parser.rl"
3
+ # Ragel Parser comes from the Arrbot Guys - Kudos to Halogrium and Epitron.
4
+
5
+
6
+ # line 109 "ragel_parser.rl"
7
+
8
+
9
+ module Marvin
10
+ module Parsers
11
+ class RagelParser < Marvin::AbstractParser
12
+
13
+
14
+ # line 15 "ragel_parser.rb"
15
+ class << self
16
+ attr_accessor :_irc_actions
17
+ private :_irc_actions, :_irc_actions=
18
+ end
19
+ self._irc_actions = [
20
+ 0, 1, 1, 1, 2, 1, 4, 1,
21
+ 5, 1, 6, 1, 7, 1, 9, 1,
22
+ 12, 1, 17, 1, 18, 2, 0, 1,
23
+ 2, 1, 4, 2, 2, 7, 2, 3,
24
+ 4, 2, 8, 9, 2, 13, 17, 2,
25
+ 14, 18, 2, 15, 12, 2, 16, 12,
26
+ 2, 17, 18, 3, 10, 11, 12, 3,
27
+ 10, 11, 17, 3, 13, 15, 12, 3,
28
+ 14, 16, 12, 3, 15, 16, 12, 4,
29
+ 0, 1, 3, 4, 4, 13, 17, 14,
30
+ 18, 5, 13, 15, 14, 16, 12
31
+ ]
32
+
33
+ class << self
34
+ attr_accessor :_irc_key_offsets
35
+ private :_irc_key_offsets, :_irc_key_offsets=
36
+ end
37
+ self._irc_key_offsets = [
38
+ 0, 0, 7, 9, 11, 13, 14, 19,
39
+ 23, 28, 32, 37, 41, 46, 50, 55,
40
+ 59, 64, 68, 73, 77, 82, 86, 91,
41
+ 95, 100, 104, 109, 113, 118, 122, 127,
42
+ 131, 136, 140, 144, 147, 150, 153, 156,
43
+ 159, 171, 174, 180, 186, 194, 197, 204,
44
+ 214, 223, 228, 233, 245, 248, 256, 259,
45
+ 266, 276, 291, 301, 316, 322, 329, 335,
46
+ 342, 348, 355, 361, 368, 374, 381, 387,
47
+ 394, 400, 407, 414, 421, 428, 435, 442,
48
+ 449, 456, 463, 472, 479, 485, 493, 495,
49
+ 498, 500, 503, 505, 508, 511, 512, 515,
50
+ 516, 519, 520, 528, 536, 545, 554, 563,
51
+ 572, 581, 590, 599, 608, 617, 626, 635,
52
+ 644, 653, 662, 671, 680, 689, 692, 702,
53
+ 719, 736, 753, 770, 787, 804, 821, 838,
54
+ 855, 872, 889, 906, 923, 940, 957, 969
55
+ ]
56
+
57
+ class << self
58
+ attr_accessor :_irc_trans_keys
59
+ private :_irc_trans_keys, :_irc_trans_keys=
60
+ end
61
+ self._irc_trans_keys = [
62
+ 58, 48, 57, 65, 90, 97, 122, 48,
63
+ 57, 48, 57, 13, 32, 10, 0, 10,
64
+ 13, 32, 58, 0, 10, 13, 32, 0,
65
+ 10, 13, 32, 58, 0, 10, 13, 32,
66
+ 0, 10, 13, 32, 58, 0, 10, 13,
67
+ 32, 0, 10, 13, 32, 58, 0, 10,
68
+ 13, 32, 0, 10, 13, 32, 58, 0,
69
+ 10, 13, 32, 0, 10, 13, 32, 58,
70
+ 0, 10, 13, 32, 0, 10, 13, 32,
71
+ 58, 0, 10, 13, 32, 0, 10, 13,
72
+ 32, 58, 0, 10, 13, 32, 0, 10,
73
+ 13, 32, 58, 0, 10, 13, 32, 0,
74
+ 10, 13, 32, 58, 0, 10, 13, 32,
75
+ 0, 10, 13, 32, 58, 0, 10, 13,
76
+ 32, 0, 10, 13, 32, 58, 0, 10,
77
+ 13, 32, 0, 10, 13, 32, 58, 0,
78
+ 10, 13, 32, 0, 10, 13, 32, 58,
79
+ 0, 10, 13, 32, 0, 10, 13, 58,
80
+ 0, 10, 13, 0, 10, 13, 0, 10,
81
+ 13, 0, 10, 13, 0, 10, 13, 42,
82
+ 43, 48, 57, 65, 90, 91, 96, 97,
83
+ 122, 123, 125, 32, 46, 47, 48, 57,
84
+ 65, 90, 97, 122, 13, 32, 65, 90,
85
+ 97, 122, 32, 42, 48, 57, 65, 90,
86
+ 97, 122, 32, 46, 47, 42, 48, 57,
87
+ 65, 90, 97, 122, 32, 45, 46, 47,
88
+ 48, 57, 65, 90, 97, 122, 32, 33,
89
+ 43, 45, 64, 48, 57, 65, 125, 0,
90
+ 10, 13, 32, 64, 0, 10, 13, 32,
91
+ 64, 42, 48, 49, 57, 65, 70, 71,
92
+ 90, 97, 102, 103, 122, 32, 46, 47,
93
+ 32, 42, 48, 57, 65, 90, 97, 122,
94
+ 32, 46, 47, 42, 48, 57, 65, 90,
95
+ 97, 122, 32, 45, 46, 47, 48, 57,
96
+ 65, 90, 97, 122, 32, 45, 58, 46,
97
+ 47, 48, 57, 65, 70, 71, 90, 97,
98
+ 102, 103, 122, 32, 45, 46, 47, 48,
99
+ 57, 65, 90, 97, 122, 32, 45, 58,
100
+ 46, 47, 48, 57, 65, 70, 71, 90,
101
+ 97, 102, 103, 122, 48, 57, 65, 70,
102
+ 97, 102, 58, 48, 57, 65, 70, 97,
103
+ 102, 48, 57, 65, 70, 97, 102, 58,
104
+ 48, 57, 65, 70, 97, 102, 48, 57,
105
+ 65, 70, 97, 102, 58, 48, 57, 65,
106
+ 70, 97, 102, 48, 57, 65, 70, 97,
107
+ 102, 58, 48, 57, 65, 70, 97, 102,
108
+ 48, 57, 65, 70, 97, 102, 58, 48,
109
+ 57, 65, 70, 97, 102, 48, 57, 65,
110
+ 70, 97, 102, 58, 48, 57, 65, 70,
111
+ 97, 102, 48, 57, 65, 70, 97, 102,
112
+ 32, 48, 57, 65, 70, 97, 102, 48,
113
+ 49, 57, 65, 70, 97, 102, 58, 48,
114
+ 57, 65, 70, 97, 102, 48, 49, 57,
115
+ 65, 70, 97, 102, 58, 48, 57, 65,
116
+ 70, 97, 102, 48, 49, 57, 65, 70,
117
+ 97, 102, 58, 48, 57, 65, 70, 97,
118
+ 102, 48, 49, 57, 65, 70, 97, 102,
119
+ 58, 48, 57, 65, 70, 97, 102, 48,
120
+ 70, 102, 49, 57, 65, 69, 97, 101,
121
+ 58, 48, 57, 65, 70, 97, 102, 48,
122
+ 57, 65, 70, 97, 102, 46, 58, 48,
123
+ 57, 65, 70, 97, 102, 48, 57, 46,
124
+ 48, 57, 48, 57, 46, 48, 57, 48,
125
+ 57, 32, 48, 57, 32, 48, 57, 32,
126
+ 46, 48, 57, 46, 46, 48, 57, 46,
127
+ 46, 58, 48, 57, 65, 70, 97, 102,
128
+ 46, 58, 48, 57, 65, 70, 97, 102,
129
+ 58, 70, 102, 48, 57, 65, 69, 97,
130
+ 101, 58, 70, 102, 48, 57, 65, 69,
131
+ 97, 101, 58, 70, 102, 48, 57, 65,
132
+ 69, 97, 101, 32, 33, 43, 45, 64,
133
+ 48, 57, 65, 125, 32, 33, 43, 45,
134
+ 64, 48, 57, 65, 125, 32, 33, 43,
135
+ 45, 64, 48, 57, 65, 125, 32, 33,
136
+ 43, 45, 64, 48, 57, 65, 125, 32,
137
+ 33, 43, 45, 64, 48, 57, 65, 125,
138
+ 32, 33, 43, 45, 64, 48, 57, 65,
139
+ 125, 32, 33, 43, 45, 64, 48, 57,
140
+ 65, 125, 32, 33, 43, 45, 64, 48,
141
+ 57, 65, 125, 32, 33, 43, 45, 64,
142
+ 48, 57, 65, 125, 32, 33, 43, 45,
143
+ 64, 48, 57, 65, 125, 32, 33, 43,
144
+ 45, 64, 48, 57, 65, 125, 32, 33,
145
+ 43, 45, 64, 48, 57, 65, 125, 32,
146
+ 33, 43, 45, 64, 48, 57, 65, 125,
147
+ 32, 33, 43, 45, 64, 48, 57, 65,
148
+ 125, 32, 33, 64, 32, 45, 46, 47,
149
+ 48, 57, 65, 90, 97, 122, 32, 33,
150
+ 43, 45, 64, 46, 47, 48, 57, 65,
151
+ 90, 91, 96, 97, 122, 123, 125, 32,
152
+ 33, 43, 45, 64, 46, 47, 48, 57,
153
+ 65, 90, 91, 96, 97, 122, 123, 125,
154
+ 32, 33, 43, 45, 64, 46, 47, 48,
155
+ 57, 65, 90, 91, 96, 97, 122, 123,
156
+ 125, 32, 33, 43, 45, 64, 46, 47,
157
+ 48, 57, 65, 90, 91, 96, 97, 122,
158
+ 123, 125, 32, 33, 43, 45, 64, 46,
159
+ 47, 48, 57, 65, 90, 91, 96, 97,
160
+ 122, 123, 125, 32, 33, 43, 45, 64,
161
+ 46, 47, 48, 57, 65, 90, 91, 96,
162
+ 97, 122, 123, 125, 32, 33, 43, 45,
163
+ 64, 46, 47, 48, 57, 65, 90, 91,
164
+ 96, 97, 122, 123, 125, 32, 33, 43,
165
+ 45, 64, 46, 47, 48, 57, 65, 90,
166
+ 91, 96, 97, 122, 123, 125, 32, 33,
167
+ 43, 45, 64, 46, 47, 48, 57, 65,
168
+ 90, 91, 96, 97, 122, 123, 125, 32,
169
+ 33, 43, 45, 64, 46, 47, 48, 57,
170
+ 65, 90, 91, 96, 97, 122, 123, 125,
171
+ 32, 33, 43, 45, 64, 46, 47, 48,
172
+ 57, 65, 90, 91, 96, 97, 122, 123,
173
+ 125, 32, 33, 43, 45, 64, 46, 47,
174
+ 48, 57, 65, 90, 91, 96, 97, 122,
175
+ 123, 125, 32, 33, 43, 45, 64, 46,
176
+ 47, 48, 57, 65, 90, 91, 96, 97,
177
+ 122, 123, 125, 32, 33, 43, 45, 64,
178
+ 46, 47, 48, 57, 65, 90, 91, 96,
179
+ 97, 122, 123, 125, 32, 33, 43, 45,
180
+ 64, 46, 47, 48, 57, 65, 90, 91,
181
+ 96, 97, 122, 123, 125, 32, 33, 45,
182
+ 64, 46, 47, 48, 57, 65, 90, 97,
183
+ 122, 0
184
+ ]
185
+
186
+ class << self
187
+ attr_accessor :_irc_single_lengths
188
+ private :_irc_single_lengths, :_irc_single_lengths=
189
+ end
190
+ self._irc_single_lengths = [
191
+ 0, 1, 0, 0, 2, 1, 5, 4,
192
+ 5, 4, 5, 4, 5, 4, 5, 4,
193
+ 5, 4, 5, 4, 5, 4, 5, 4,
194
+ 5, 4, 5, 4, 5, 4, 5, 4,
195
+ 5, 4, 4, 3, 3, 3, 3, 3,
196
+ 2, 1, 0, 2, 2, 1, 1, 2,
197
+ 5, 5, 5, 2, 1, 2, 1, 1,
198
+ 2, 3, 2, 3, 0, 1, 0, 1,
199
+ 0, 1, 0, 1, 0, 1, 0, 1,
200
+ 0, 1, 1, 1, 1, 1, 1, 1,
201
+ 1, 1, 3, 1, 0, 2, 0, 1,
202
+ 0, 1, 0, 1, 1, 1, 1, 1,
203
+ 1, 1, 2, 2, 3, 3, 3, 5,
204
+ 5, 5, 5, 5, 5, 5, 5, 5,
205
+ 5, 5, 5, 5, 5, 3, 2, 5,
206
+ 5, 5, 5, 5, 5, 5, 5, 5,
207
+ 5, 5, 5, 5, 5, 5, 4, 0
208
+ ]
209
+
210
+ class << self
211
+ attr_accessor :_irc_range_lengths
212
+ private :_irc_range_lengths, :_irc_range_lengths=
213
+ end
214
+ self._irc_range_lengths = [
215
+ 0, 3, 1, 1, 0, 0, 0, 0,
216
+ 0, 0, 0, 0, 0, 0, 0, 0,
217
+ 0, 0, 0, 0, 0, 0, 0, 0,
218
+ 0, 0, 0, 0, 0, 0, 0, 0,
219
+ 0, 0, 0, 0, 0, 0, 0, 0,
220
+ 5, 1, 3, 2, 3, 1, 3, 4,
221
+ 2, 0, 0, 5, 1, 3, 1, 3,
222
+ 4, 6, 4, 6, 3, 3, 3, 3,
223
+ 3, 3, 3, 3, 3, 3, 3, 3,
224
+ 3, 3, 3, 3, 3, 3, 3, 3,
225
+ 3, 3, 3, 3, 3, 3, 1, 1,
226
+ 1, 1, 1, 1, 1, 0, 1, 0,
227
+ 1, 0, 3, 3, 3, 3, 3, 2,
228
+ 2, 2, 2, 2, 2, 2, 2, 2,
229
+ 2, 2, 2, 2, 2, 0, 4, 6,
230
+ 6, 6, 6, 6, 6, 6, 6, 6,
231
+ 6, 6, 6, 6, 6, 6, 4, 0
232
+ ]
233
+
234
+ class << self
235
+ attr_accessor :_irc_index_offsets
236
+ private :_irc_index_offsets, :_irc_index_offsets=
237
+ end
238
+ self._irc_index_offsets = [
239
+ 0, 0, 5, 7, 9, 12, 14, 20,
240
+ 25, 31, 36, 42, 47, 53, 58, 64,
241
+ 69, 75, 80, 86, 91, 97, 102, 108,
242
+ 113, 119, 124, 130, 135, 141, 146, 152,
243
+ 157, 163, 168, 173, 177, 181, 185, 189,
244
+ 193, 201, 204, 208, 213, 219, 222, 227,
245
+ 234, 242, 248, 254, 262, 265, 271, 274,
246
+ 279, 286, 296, 303, 313, 317, 322, 326,
247
+ 331, 335, 340, 344, 349, 353, 358, 362,
248
+ 367, 371, 376, 381, 386, 391, 396, 401,
249
+ 406, 411, 416, 423, 428, 432, 438, 440,
250
+ 443, 445, 448, 450, 453, 456, 458, 461,
251
+ 463, 466, 468, 474, 480, 487, 494, 501,
252
+ 509, 517, 525, 533, 541, 549, 557, 565,
253
+ 573, 581, 589, 597, 605, 613, 617, 624,
254
+ 636, 648, 660, 672, 684, 696, 708, 720,
255
+ 732, 744, 756, 768, 780, 792, 804, 813
256
+ ]
257
+
258
+ class << self
259
+ attr_accessor :_irc_indicies
260
+ private :_irc_indicies, :_irc_indicies=
261
+ end
262
+ self._irc_indicies = [
263
+ 2, 0, 3, 3, 1, 4, 1, 5,
264
+ 1, 6, 7, 1, 8, 1, 1, 1,
265
+ 1, 1, 10, 9, 1, 1, 12, 13,
266
+ 11, 1, 1, 1, 1, 10, 14, 1,
267
+ 1, 12, 16, 15, 1, 1, 1, 1,
268
+ 10, 17, 1, 1, 12, 19, 18, 1,
269
+ 1, 1, 1, 10, 20, 1, 1, 12,
270
+ 22, 21, 1, 1, 1, 1, 10, 23,
271
+ 1, 1, 12, 25, 24, 1, 1, 1,
272
+ 1, 10, 26, 1, 1, 12, 28, 27,
273
+ 1, 1, 1, 1, 10, 29, 1, 1,
274
+ 12, 31, 30, 1, 1, 1, 1, 10,
275
+ 32, 1, 1, 12, 34, 33, 1, 1,
276
+ 1, 1, 10, 35, 1, 1, 12, 37,
277
+ 36, 1, 1, 1, 1, 10, 38, 1,
278
+ 1, 12, 40, 39, 1, 1, 1, 1,
279
+ 10, 41, 1, 1, 12, 43, 42, 1,
280
+ 1, 1, 1, 10, 44, 1, 1, 12,
281
+ 46, 45, 1, 1, 1, 1, 10, 47,
282
+ 1, 1, 12, 49, 48, 1, 1, 1,
283
+ 1, 10, 50, 1, 1, 52, 53, 51,
284
+ 1, 1, 55, 56, 54, 1, 1, 58,
285
+ 57, 1, 1, 60, 59, 1, 1, 52,
286
+ 61, 1, 1, 63, 62, 1, 1, 12,
287
+ 64, 65, 66, 67, 68, 66, 68, 66,
288
+ 1, 69, 70, 1, 0, 3, 3, 1,
289
+ 6, 7, 71, 71, 1, 69, 72, 73,
290
+ 73, 73, 1, 69, 74, 1, 72, 73,
291
+ 73, 73, 1, 69, 73, 74, 73, 73,
292
+ 73, 1, 75, 76, 77, 77, 78, 77,
293
+ 77, 1, 1, 1, 1, 1, 1, 79,
294
+ 1, 1, 1, 1, 78, 79, 80, 81,
295
+ 82, 82, 83, 82, 83, 1, 75, 84,
296
+ 1, 75, 85, 86, 86, 86, 1, 75,
297
+ 87, 1, 85, 86, 86, 86, 1, 75,
298
+ 86, 87, 86, 86, 86, 1, 75, 83,
299
+ 88, 84, 82, 82, 83, 82, 83, 1,
300
+ 75, 83, 84, 83, 83, 83, 1, 75,
301
+ 83, 89, 84, 82, 82, 83, 82, 83,
302
+ 1, 90, 90, 90, 1, 91, 90, 90,
303
+ 90, 1, 92, 92, 92, 1, 93, 92,
304
+ 92, 92, 1, 94, 94, 94, 1, 95,
305
+ 94, 94, 94, 1, 96, 96, 96, 1,
306
+ 97, 96, 96, 96, 1, 98, 98, 98,
307
+ 1, 99, 98, 98, 98, 1, 100, 100,
308
+ 100, 1, 101, 100, 100, 100, 1, 102,
309
+ 102, 102, 1, 75, 102, 102, 102, 1,
310
+ 103, 90, 90, 90, 1, 104, 90, 90,
311
+ 90, 1, 105, 92, 92, 92, 1, 106,
312
+ 92, 92, 92, 1, 107, 94, 94, 94,
313
+ 1, 108, 94, 94, 94, 1, 109, 96,
314
+ 96, 96, 1, 110, 96, 96, 96, 1,
315
+ 111, 112, 112, 98, 98, 98, 1, 113,
316
+ 98, 98, 98, 1, 114, 100, 100, 1,
317
+ 115, 101, 116, 100, 100, 1, 117, 1,
318
+ 118, 119, 1, 120, 1, 121, 122, 1,
319
+ 123, 1, 75, 124, 1, 75, 125, 1,
320
+ 75, 1, 121, 126, 1, 121, 1, 118,
321
+ 127, 1, 118, 1, 115, 101, 128, 100,
322
+ 100, 1, 115, 101, 100, 100, 100, 1,
323
+ 99, 129, 129, 98, 98, 98, 1, 99,
324
+ 130, 130, 98, 98, 98, 1, 99, 111,
325
+ 111, 98, 98, 98, 1, 75, 76, 131,
326
+ 131, 78, 131, 131, 1, 75, 76, 132,
327
+ 132, 78, 132, 132, 1, 75, 76, 133,
328
+ 133, 78, 133, 133, 1, 75, 76, 134,
329
+ 134, 78, 134, 134, 1, 75, 76, 135,
330
+ 135, 78, 135, 135, 1, 75, 76, 136,
331
+ 136, 78, 136, 136, 1, 75, 76, 137,
332
+ 137, 78, 137, 137, 1, 75, 76, 138,
333
+ 138, 78, 138, 138, 1, 75, 76, 139,
334
+ 139, 78, 139, 139, 1, 75, 76, 140,
335
+ 140, 78, 140, 140, 1, 75, 76, 141,
336
+ 141, 78, 141, 141, 1, 75, 76, 142,
337
+ 142, 78, 142, 142, 1, 75, 76, 143,
338
+ 143, 78, 143, 143, 1, 75, 76, 144,
339
+ 144, 78, 144, 144, 1, 75, 76, 78,
340
+ 1, 69, 145, 70, 145, 145, 145, 1,
341
+ 146, 76, 77, 147, 78, 70, 147, 147,
342
+ 77, 147, 77, 1, 146, 76, 131, 148,
343
+ 78, 70, 148, 148, 131, 148, 131, 1,
344
+ 146, 76, 132, 149, 78, 70, 149, 149,
345
+ 132, 149, 132, 1, 146, 76, 133, 150,
346
+ 78, 70, 150, 150, 133, 150, 133, 1,
347
+ 146, 76, 134, 151, 78, 70, 151, 151,
348
+ 134, 151, 134, 1, 146, 76, 135, 152,
349
+ 78, 70, 152, 152, 135, 152, 135, 1,
350
+ 146, 76, 136, 153, 78, 70, 153, 153,
351
+ 136, 153, 136, 1, 146, 76, 137, 154,
352
+ 78, 70, 154, 154, 137, 154, 137, 1,
353
+ 146, 76, 138, 155, 78, 70, 155, 155,
354
+ 138, 155, 138, 1, 146, 76, 139, 156,
355
+ 78, 70, 156, 156, 139, 156, 139, 1,
356
+ 146, 76, 140, 157, 78, 70, 157, 157,
357
+ 140, 157, 140, 1, 146, 76, 141, 158,
358
+ 78, 70, 158, 158, 141, 158, 141, 1,
359
+ 146, 76, 142, 159, 78, 70, 159, 159,
360
+ 142, 159, 142, 1, 146, 76, 143, 160,
361
+ 78, 70, 160, 160, 143, 160, 143, 1,
362
+ 146, 76, 144, 161, 78, 70, 161, 161,
363
+ 144, 161, 144, 1, 146, 76, 145, 78,
364
+ 70, 145, 145, 145, 1, 1, 0
365
+ ]
366
+
367
+ class << self
368
+ attr_accessor :_irc_trans_targs
369
+ private :_irc_trans_targs, :_irc_trans_targs=
370
+ end
371
+ self._irc_trans_targs = [
372
+ 2, 0, 40, 43, 3, 4, 5, 6,
373
+ 135, 7, 38, 7, 5, 8, 9, 9,
374
+ 10, 11, 11, 12, 13, 13, 14, 15,
375
+ 15, 16, 17, 17, 18, 19, 19, 20,
376
+ 21, 21, 22, 23, 23, 24, 25, 25,
377
+ 26, 27, 27, 28, 29, 29, 30, 31,
378
+ 31, 32, 33, 33, 5, 34, 35, 5,
379
+ 36, 35, 5, 37, 5, 37, 39, 5,
380
+ 39, 41, 48, 118, 119, 42, 44, 43,
381
+ 45, 47, 46, 42, 49, 103, 51, 50,
382
+ 52, 57, 59, 58, 53, 54, 56, 55,
383
+ 74, 60, 61, 62, 63, 64, 65, 66,
384
+ 67, 68, 69, 70, 71, 72, 73, 75,
385
+ 76, 77, 78, 79, 80, 81, 82, 83,
386
+ 100, 84, 85, 86, 98, 87, 88, 96,
387
+ 89, 90, 94, 91, 92, 93, 95, 97,
388
+ 99, 101, 102, 104, 105, 106, 107, 108,
389
+ 109, 110, 111, 112, 113, 114, 115, 116,
390
+ 117, 118, 42, 120, 121, 122, 123, 124,
391
+ 125, 126, 127, 128, 129, 130, 131, 132,
392
+ 133, 134
393
+ ]
394
+
395
+ class << self
396
+ attr_accessor :_irc_trans_actions
397
+ private :_irc_trans_actions, :_irc_trans_actions=
398
+ end
399
+ self._irc_trans_actions = [
400
+ 33, 0, 0, 33, 13, 13, 55, 51,
401
+ 0, 81, 15, 67, 17, 15, 81, 67,
402
+ 15, 81, 67, 15, 81, 67, 15, 81,
403
+ 67, 15, 81, 67, 15, 81, 67, 15,
404
+ 81, 67, 15, 81, 67, 15, 81, 67,
405
+ 15, 81, 67, 15, 81, 67, 15, 81,
406
+ 67, 15, 81, 67, 48, 15, 63, 39,
407
+ 63, 45, 19, 81, 76, 67, 59, 36,
408
+ 42, 21, 30, 21, 71, 3, 1, 13,
409
+ 1, 1, 1, 11, 0, 5, 0, 7,
410
+ 9, 9, 9, 9, 9, 9, 9, 9,
411
+ 9, 9, 9, 9, 9, 9, 9, 9,
412
+ 9, 9, 9, 9, 9, 9, 9, 9,
413
+ 9, 9, 9, 9, 9, 9, 9, 9,
414
+ 9, 9, 9, 9, 9, 9, 9, 9,
415
+ 9, 9, 9, 9, 9, 9, 9, 9,
416
+ 9, 9, 9, 5, 5, 5, 5, 5,
417
+ 5, 5, 5, 5, 5, 5, 5, 5,
418
+ 5, 1, 27, 24, 24, 24, 24, 24,
419
+ 24, 24, 24, 24, 24, 24, 24, 24,
420
+ 24, 24
421
+ ]
422
+
423
+ class << self
424
+ attr_accessor :irc_start
425
+ end
426
+ self.irc_start = 1;
427
+ class << self
428
+ attr_accessor :irc_first_final
429
+ end
430
+ self.irc_first_final = 135;
431
+ class << self
432
+ attr_accessor :irc_error
433
+ end
434
+ self.irc_error = 0;
435
+
436
+ class << self
437
+ attr_accessor :irc_en_main
438
+ end
439
+ self.irc_en_main = 1;
440
+
441
+
442
+ # line 116 "ragel_parser.rl"
443
+
444
+ private
445
+
446
+ def self.parse!(line)
447
+ data = "#{line.strip}\r\n"
448
+
449
+ p = 0;
450
+ pe = data.length
451
+ cs = 0
452
+
453
+ hostmask = nil
454
+ server = nil
455
+ code = nil
456
+ command = Command.new(data)
457
+
458
+
459
+ # line 460 "ragel_parser.rb"
460
+ begin
461
+ p ||= 0
462
+ pe ||= data.length
463
+ cs = irc_start
464
+ end
465
+
466
+ # line 132 "ragel_parser.rl"
467
+
468
+ # line 469 "ragel_parser.rb"
469
+ begin
470
+ _klen, _trans, _keys, _acts, _nacts = nil
471
+ _goto_level = 0
472
+ _resume = 10
473
+ _eof_trans = 15
474
+ _again = 20
475
+ _test_eof = 30
476
+ _out = 40
477
+ while true
478
+ _trigger_goto = false
479
+ if _goto_level <= 0
480
+ if p == pe
481
+ _goto_level = _test_eof
482
+ next
483
+ end
484
+ if cs == 0
485
+ _goto_level = _out
486
+ next
487
+ end
488
+ end
489
+ if _goto_level <= _resume
490
+ _keys = _irc_key_offsets[cs]
491
+ _trans = _irc_index_offsets[cs]
492
+ _klen = _irc_single_lengths[cs]
493
+ _break_match = false
494
+
495
+ begin
496
+ if _klen > 0
497
+ _lower = _keys
498
+ _upper = _keys + _klen - 1
499
+
500
+ loop do
501
+ break if _upper < _lower
502
+ _mid = _lower + ( (_upper - _lower) >> 1 )
503
+
504
+ if data[p] < _irc_trans_keys[_mid]
505
+ _upper = _mid - 1
506
+ elsif data[p] > _irc_trans_keys[_mid]
507
+ _lower = _mid + 1
508
+ else
509
+ _trans += (_mid - _keys)
510
+ _break_match = true
511
+ break
512
+ end
513
+ end # loop
514
+ break if _break_match
515
+ _keys += _klen
516
+ _trans += _klen
517
+ end
518
+ _klen = _irc_range_lengths[cs]
519
+ if _klen > 0
520
+ _lower = _keys
521
+ _upper = _keys + (_klen << 1) - 2
522
+ loop do
523
+ break if _upper < _lower
524
+ _mid = _lower + (((_upper-_lower) >> 1) & ~1)
525
+ if data[p] < _irc_trans_keys[_mid]
526
+ _upper = _mid - 2
527
+ elsif data[p] > _irc_trans_keys[_mid+1]
528
+ _lower = _mid + 2
529
+ else
530
+ _trans += ((_mid - _keys) >> 1)
531
+ _break_match = true
532
+ break
533
+ end
534
+ end # loop
535
+ break if _break_match
536
+ _trans += _klen
537
+ end
538
+ end while false
539
+ _trans = _irc_indicies[_trans]
540
+ cs = _irc_trans_targs[_trans]
541
+ if _irc_trans_actions[_trans] != 0
542
+ _acts = _irc_trans_actions[_trans]
543
+ _nacts = _irc_actions[_acts]
544
+ _acts += 1
545
+ while _nacts > 0
546
+ _nacts -= 1
547
+ _acts += 1
548
+ case _irc_actions[_acts - 1]
549
+ when 0 then
550
+ # line 6 "ragel_parser.rl"
551
+ begin
552
+
553
+ server = Prefixes::Server.new
554
+ end
555
+ # line 6 "ragel_parser.rl"
556
+ when 1 then
557
+ # line 10 "ragel_parser.rl"
558
+ begin
559
+
560
+ server.name << data[p]
561
+ end
562
+ # line 10 "ragel_parser.rl"
563
+ when 2 then
564
+ # line 14 "ragel_parser.rl"
565
+ begin
566
+
567
+ command.prefix = server
568
+ end
569
+ # line 14 "ragel_parser.rl"
570
+ when 3 then
571
+ # line 18 "ragel_parser.rl"
572
+ begin
573
+
574
+ hostmask = Prefixes::HostMask.new
575
+ end
576
+ # line 18 "ragel_parser.rl"
577
+ when 4 then
578
+ # line 22 "ragel_parser.rl"
579
+ begin
580
+
581
+ hostmask.nick << data[p]
582
+ end
583
+ # line 22 "ragel_parser.rl"
584
+ when 5 then
585
+ # line 26 "ragel_parser.rl"
586
+ begin
587
+
588
+ hostmask.user << data[p]
589
+ end
590
+ # line 26 "ragel_parser.rl"
591
+ when 6 then
592
+ # line 30 "ragel_parser.rl"
593
+ begin
594
+
595
+ hostmask.host << data[p]
596
+ end
597
+ # line 30 "ragel_parser.rl"
598
+ when 7 then
599
+ # line 34 "ragel_parser.rl"
600
+ begin
601
+
602
+ command.prefix = hostmask
603
+ end
604
+ # line 34 "ragel_parser.rl"
605
+ when 8 then
606
+ # line 38 "ragel_parser.rl"
607
+ begin
608
+
609
+ code = ""
610
+ end
611
+ # line 38 "ragel_parser.rl"
612
+ when 9 then
613
+ # line 42 "ragel_parser.rl"
614
+ begin
615
+
616
+ code << data[p]
617
+ end
618
+ # line 42 "ragel_parser.rl"
619
+ when 10 then
620
+ # line 46 "ragel_parser.rl"
621
+ begin
622
+
623
+ command.code = code
624
+ end
625
+ # line 46 "ragel_parser.rl"
626
+ when 11 then
627
+ # line 50 "ragel_parser.rl"
628
+ begin
629
+
630
+ params_1 = []
631
+ params_2 = []
632
+ end
633
+ # line 50 "ragel_parser.rl"
634
+ when 12 then
635
+ # line 55 "ragel_parser.rl"
636
+ begin
637
+
638
+ end
639
+ # line 55 "ragel_parser.rl"
640
+ when 13 then
641
+ # line 58 "ragel_parser.rl"
642
+ begin
643
+
644
+ params_1 << ""
645
+ end
646
+ # line 58 "ragel_parser.rl"
647
+ when 14 then
648
+ # line 62 "ragel_parser.rl"
649
+ begin
650
+
651
+ params_2 << ""
652
+ end
653
+ # line 62 "ragel_parser.rl"
654
+ when 15 then
655
+ # line 66 "ragel_parser.rl"
656
+ begin
657
+
658
+ params_1.last << data[p]
659
+ end
660
+ # line 66 "ragel_parser.rl"
661
+ when 16 then
662
+ # line 70 "ragel_parser.rl"
663
+ begin
664
+
665
+ params_2.last << data[p]
666
+ end
667
+ # line 70 "ragel_parser.rl"
668
+ when 17 then
669
+ # line 74 "ragel_parser.rl"
670
+ begin
671
+
672
+ command.params = params_1
673
+ end
674
+ # line 74 "ragel_parser.rl"
675
+ when 18 then
676
+ # line 78 "ragel_parser.rl"
677
+ begin
678
+
679
+ command.params = params_2
680
+ end
681
+ # line 78 "ragel_parser.rl"
682
+ # line 683 "ragel_parser.rb"
683
+ end # action switch
684
+ end
685
+ end
686
+ if _trigger_goto
687
+ next
688
+ end
689
+ end
690
+ if _goto_level <= _again
691
+ if cs == 0
692
+ _goto_level = _out
693
+ next
694
+ end
695
+ p += 1
696
+ if p != pe
697
+ _goto_level = _resume
698
+ next
699
+ end
700
+ end
701
+ if _goto_level <= _test_eof
702
+ end
703
+ if _goto_level <= _out
704
+ break
705
+ end
706
+ end
707
+ end
708
+
709
+ # line 133 "ragel_parser.rl"
710
+
711
+ if cs >= irc_first_final
712
+ command
713
+ else
714
+ raise UnparseableMessage, "Failed to parse the message: #{line.strip}"
715
+ end
716
+ end
717
+
718
+ end
719
+ end
720
+ end