spox-mod_spox 0.3.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/CHANGELOG +174 -0
- data/INSTALL +15 -0
- data/LICENSE +674 -0
- data/README.rdoc +73 -0
- data/bin/mod_spox +112 -0
- data/data/mod_spox/extras/AOLSpeak.rb +257 -0
- data/data/mod_spox/extras/AutoKick.rb +152 -0
- data/data/mod_spox/extras/AutoMode.rb +122 -0
- data/data/mod_spox/extras/AutoRejoin.rb +37 -0
- data/data/mod_spox/extras/Bash.rb +55 -0
- data/data/mod_spox/extras/Bouncer.rb +220 -0
- data/data/mod_spox/extras/Bullshit.rb +19 -0
- data/data/mod_spox/extras/Bytes.rb +11 -0
- data/data/mod_spox/extras/Confess.rb +244 -0
- data/data/mod_spox/extras/DCC.rb +182 -0
- data/data/mod_spox/extras/DevWatch.rb +153 -0
- data/data/mod_spox/extras/DownForEveryoneOrJustMe.rb +47 -0
- data/data/mod_spox/extras/EightBall.rb +33 -0
- data/data/mod_spox/extras/FML.rb +35 -0
- data/data/mod_spox/extras/FloodKicker.rb +129 -0
- data/data/mod_spox/extras/Fortune.rb +76 -0
- data/data/mod_spox/extras/GoogleIt.rb +13 -0
- data/data/mod_spox/extras/Headers.rb +59 -0
- data/data/mod_spox/extras/Karma.rb +302 -0
- data/data/mod_spox/extras/Locator.rb +44 -0
- data/data/mod_spox/extras/Logger.rb +182 -0
- data/data/mod_spox/extras/LolSpeak.rb +21 -0
- data/data/mod_spox/extras/NickServ.rb +84 -0
- data/data/mod_spox/extras/PhpCli.rb +308 -0
- data/data/mod_spox/extras/PhpFuncLookup.rb +297 -0
- data/data/mod_spox/extras/Pinger.rb +11 -0
- data/data/mod_spox/extras/Quotes.rb +79 -0
- data/data/mod_spox/extras/RegexTracker.rb +158 -0
- data/data/mod_spox/extras/Roulette.rb +267 -0
- data/data/mod_spox/extras/RubyCli.rb +93 -0
- data/data/mod_spox/extras/Search.rb +49 -0
- data/data/mod_spox/extras/Seen.rb +150 -0
- data/data/mod_spox/extras/Slashdot.rb +35 -0
- data/data/mod_spox/extras/SlashdotHeadlineGenerator.rb +500 -0
- data/data/mod_spox/extras/Talk.rb +32 -0
- data/data/mod_spox/extras/Topten.rb +103 -0
- data/data/mod_spox/extras/TracTicket.rb +66 -0
- data/data/mod_spox/extras/Translate.rb +132 -0
- data/data/mod_spox/extras/Twitter.rb +458 -0
- data/data/mod_spox/extras/UrbanDictionary.rb +55 -0
- data/data/mod_spox/extras/Weather.rb +55 -0
- data/data/mod_spox/plugins/Authenticator.rb +289 -0
- data/data/mod_spox/plugins/Banner.rb +585 -0
- data/data/mod_spox/plugins/BotNick.rb +18 -0
- data/data/mod_spox/plugins/Helper.rb +49 -0
- data/data/mod_spox/plugins/Initializer.rb +35 -0
- data/data/mod_spox/plugins/Joiner.rb +23 -0
- data/data/mod_spox/plugins/Nicker.rb +14 -0
- data/data/mod_spox/plugins/Parter.rb +23 -0
- data/data/mod_spox/plugins/Permissions.rb +60 -0
- data/data/mod_spox/plugins/PluginLoader.rb +180 -0
- data/data/mod_spox/plugins/Ponger.rb +70 -0
- data/data/mod_spox/plugins/PoolConfig.rb +52 -0
- data/data/mod_spox/plugins/Quitter.rb +15 -0
- data/data/mod_spox/plugins/Servers.rb +57 -0
- data/data/mod_spox/plugins/Status.rb +31 -0
- data/data/mod_spox/plugins/Triggers.rb +85 -0
- data/lib/mod_spox/BaseConfig.rb +51 -0
- data/lib/mod_spox/Bot.rb +604 -0
- data/lib/mod_spox/BotConfig.rb +65 -0
- data/lib/mod_spox/ConfigurationWizard.rb +180 -0
- data/lib/mod_spox/Database.rb +51 -0
- data/lib/mod_spox/Exceptions.rb +84 -0
- data/lib/mod_spox/Helpers.rb +122 -0
- data/lib/mod_spox/Loader.rb +60 -0
- data/lib/mod_spox/Logger.rb +37 -0
- data/lib/mod_spox/MessageFactory.rb +112 -0
- data/lib/mod_spox/Pipeline.rb +207 -0
- data/lib/mod_spox/Plugin.rb +97 -0
- data/lib/mod_spox/PluginHolder.rb +22 -0
- data/lib/mod_spox/PluginManager.rb +257 -0
- data/lib/mod_spox/PriorityQueue.rb +69 -0
- data/lib/mod_spox/Socket.rb +201 -0
- data/lib/mod_spox/Sockets.rb +226 -0
- data/lib/mod_spox/Timer.rb +60 -0
- data/lib/mod_spox/Version.rb +14 -0
- data/lib/mod_spox/handlers/BadNick.rb +19 -0
- data/lib/mod_spox/handlers/Bounce.rb +24 -0
- data/lib/mod_spox/handlers/Created.rb +27 -0
- data/lib/mod_spox/handlers/Handler.rb +39 -0
- data/lib/mod_spox/handlers/Invite.rb +28 -0
- data/lib/mod_spox/handlers/Join.rb +38 -0
- data/lib/mod_spox/handlers/Kick.rb +36 -0
- data/lib/mod_spox/handlers/LuserChannels.rb +19 -0
- data/lib/mod_spox/handlers/LuserClient.rb +18 -0
- data/lib/mod_spox/handlers/LuserMe.rb +16 -0
- data/lib/mod_spox/handlers/LuserOp.rb +19 -0
- data/lib/mod_spox/handlers/LuserUnknown.rb +19 -0
- data/lib/mod_spox/handlers/Mode.rb +62 -0
- data/lib/mod_spox/handlers/Motd.rb +38 -0
- data/lib/mod_spox/handlers/MyInfo.rb +24 -0
- data/lib/mod_spox/handlers/Names.rb +86 -0
- data/lib/mod_spox/handlers/Nick.rb +50 -0
- data/lib/mod_spox/handlers/NickInUse.rb +19 -0
- data/lib/mod_spox/handlers/Notice.rb +35 -0
- data/lib/mod_spox/handlers/Part.rb +39 -0
- data/lib/mod_spox/handlers/Ping.rb +25 -0
- data/lib/mod_spox/handlers/Pong.rb +23 -0
- data/lib/mod_spox/handlers/Privmsg.rb +39 -0
- data/lib/mod_spox/handlers/Quit.rb +29 -0
- data/lib/mod_spox/handlers/Topic.rb +38 -0
- data/lib/mod_spox/handlers/Welcome.rb +30 -0
- data/lib/mod_spox/handlers/Who.rb +83 -0
- data/lib/mod_spox/handlers/Whois.rb +117 -0
- data/lib/mod_spox/handlers/YourHost.rb +20 -0
- data/lib/mod_spox/messages/Messages.rb +6 -0
- data/lib/mod_spox/messages/incoming/BadNick.rb +16 -0
- data/lib/mod_spox/messages/incoming/Bounce.rb +18 -0
- data/lib/mod_spox/messages/incoming/Created.rb +15 -0
- data/lib/mod_spox/messages/incoming/Invite.rb +21 -0
- data/lib/mod_spox/messages/incoming/Join.rb +19 -0
- data/lib/mod_spox/messages/incoming/Kick.rb +26 -0
- data/lib/mod_spox/messages/incoming/LuserChannels.rb +15 -0
- data/lib/mod_spox/messages/incoming/LuserClient.rb +24 -0
- data/lib/mod_spox/messages/incoming/LuserMe.rb +18 -0
- data/lib/mod_spox/messages/incoming/LuserOp.rb +15 -0
- data/lib/mod_spox/messages/incoming/LuserUnknown.rb +15 -0
- data/lib/mod_spox/messages/incoming/Message.rb +22 -0
- data/lib/mod_spox/messages/incoming/Mode.rb +42 -0
- data/lib/mod_spox/messages/incoming/Motd.rb +18 -0
- data/lib/mod_spox/messages/incoming/MyInfo.rb +24 -0
- data/lib/mod_spox/messages/incoming/Names.rb +24 -0
- data/lib/mod_spox/messages/incoming/Nick.rb +26 -0
- data/lib/mod_spox/messages/incoming/NickInUse.rb +15 -0
- data/lib/mod_spox/messages/incoming/Notice.rb +9 -0
- data/lib/mod_spox/messages/incoming/Part.rb +21 -0
- data/lib/mod_spox/messages/incoming/Ping.rb +18 -0
- data/lib/mod_spox/messages/incoming/Pong.rb +9 -0
- data/lib/mod_spox/messages/incoming/Privmsg.rb +90 -0
- data/lib/mod_spox/messages/incoming/Quit.rb +18 -0
- data/lib/mod_spox/messages/incoming/Topic.rb +21 -0
- data/lib/mod_spox/messages/incoming/TopicInfo.rb +21 -0
- data/lib/mod_spox/messages/incoming/Welcome.rb +27 -0
- data/lib/mod_spox/messages/incoming/Who.rb +18 -0
- data/lib/mod_spox/messages/incoming/Whois.rb +49 -0
- data/lib/mod_spox/messages/incoming/YourHost.rb +18 -0
- data/lib/mod_spox/messages/internal/BotInitialized.rb +11 -0
- data/lib/mod_spox/messages/internal/ChangeNick.rb +15 -0
- data/lib/mod_spox/messages/internal/Connected.rb +20 -0
- data/lib/mod_spox/messages/internal/ConnectionFailed.rb +23 -0
- data/lib/mod_spox/messages/internal/DCCListener.rb +12 -0
- data/lib/mod_spox/messages/internal/DCCRequest.rb +12 -0
- data/lib/mod_spox/messages/internal/DCCSocket.rb +19 -0
- data/lib/mod_spox/messages/internal/Disconnected.rb +8 -0
- data/lib/mod_spox/messages/internal/Disconnecting.rb +8 -0
- data/lib/mod_spox/messages/internal/EstablishConnection.rb +22 -0
- data/lib/mod_spox/messages/internal/HaltBot.rb +8 -0
- data/lib/mod_spox/messages/internal/NickRequest.rb +9 -0
- data/lib/mod_spox/messages/internal/NickResponse.rb +15 -0
- data/lib/mod_spox/messages/internal/PluginLoadRequest.rb +21 -0
- data/lib/mod_spox/messages/internal/PluginLoadResponse.rb +17 -0
- data/lib/mod_spox/messages/internal/PluginModuleRequest.rb +14 -0
- data/lib/mod_spox/messages/internal/PluginModuleResponse.rb +18 -0
- data/lib/mod_spox/messages/internal/PluginReload.rb +18 -0
- data/lib/mod_spox/messages/internal/PluginRequest.rb +18 -0
- data/lib/mod_spox/messages/internal/PluginResponse.rb +21 -0
- data/lib/mod_spox/messages/internal/PluginUnloadRequest.rb +9 -0
- data/lib/mod_spox/messages/internal/PluginUnloadResponse.rb +9 -0
- data/lib/mod_spox/messages/internal/PluginsReady.rb +10 -0
- data/lib/mod_spox/messages/internal/QueueSocket.rb +8 -0
- data/lib/mod_spox/messages/internal/Reconnect.rb +8 -0
- data/lib/mod_spox/messages/internal/Request.rb +15 -0
- data/lib/mod_spox/messages/internal/Response.rb +15 -0
- data/lib/mod_spox/messages/internal/Shutdown.rb +8 -0
- data/lib/mod_spox/messages/internal/SignaturesUpdate.rb +8 -0
- data/lib/mod_spox/messages/internal/StatusRequest.rb +10 -0
- data/lib/mod_spox/messages/internal/StatusResponse.rb +18 -0
- data/lib/mod_spox/messages/internal/TimerAdd.rb +36 -0
- data/lib/mod_spox/messages/internal/TimerClear.rb +16 -0
- data/lib/mod_spox/messages/internal/TimerRemove.rb +23 -0
- data/lib/mod_spox/messages/internal/TimerResponse.rb +34 -0
- data/lib/mod_spox/messages/internal/TriggersUpdate.rb +8 -0
- data/lib/mod_spox/messages/internal/UnqueueSocket.rb +8 -0
- data/lib/mod_spox/messages/outgoing/Admin.rb +15 -0
- data/lib/mod_spox/messages/outgoing/Away.rb +11 -0
- data/lib/mod_spox/messages/outgoing/ChannelMode.rb +25 -0
- data/lib/mod_spox/messages/outgoing/Connect.rb +24 -0
- data/lib/mod_spox/messages/outgoing/Die.rb +9 -0
- data/lib/mod_spox/messages/outgoing/Info.rb +15 -0
- data/lib/mod_spox/messages/outgoing/Invite.rb +19 -0
- data/lib/mod_spox/messages/outgoing/Ison.rb +15 -0
- data/lib/mod_spox/messages/outgoing/Join.rb +19 -0
- data/lib/mod_spox/messages/outgoing/Kick.rb +23 -0
- data/lib/mod_spox/messages/outgoing/Kill.rb +19 -0
- data/lib/mod_spox/messages/outgoing/Links.rb +19 -0
- data/lib/mod_spox/messages/outgoing/List.rb +19 -0
- data/lib/mod_spox/messages/outgoing/Lusers.rb +19 -0
- data/lib/mod_spox/messages/outgoing/Motd.rb +16 -0
- data/lib/mod_spox/messages/outgoing/Names.rb +20 -0
- data/lib/mod_spox/messages/outgoing/Nick.rb +16 -0
- data/lib/mod_spox/messages/outgoing/Notice.rb +12 -0
- data/lib/mod_spox/messages/outgoing/Oper.rb +19 -0
- data/lib/mod_spox/messages/outgoing/Part.rb +19 -0
- data/lib/mod_spox/messages/outgoing/Pass.rb +16 -0
- data/lib/mod_spox/messages/outgoing/Ping.rb +11 -0
- data/lib/mod_spox/messages/outgoing/Pong.rb +17 -0
- data/lib/mod_spox/messages/outgoing/Privmsg.rb +43 -0
- data/lib/mod_spox/messages/outgoing/Quit.rb +11 -0
- data/lib/mod_spox/messages/outgoing/Raw.rb +16 -0
- data/lib/mod_spox/messages/outgoing/Rehash.rb +9 -0
- data/lib/mod_spox/messages/outgoing/Restart.rb +9 -0
- data/lib/mod_spox/messages/outgoing/ServList.rb +19 -0
- data/lib/mod_spox/messages/outgoing/Simple.rb +12 -0
- data/lib/mod_spox/messages/outgoing/Squery.rb +19 -0
- data/lib/mod_spox/messages/outgoing/Squit.rb +19 -0
- data/lib/mod_spox/messages/outgoing/Stats.rb +18 -0
- data/lib/mod_spox/messages/outgoing/Summon.rb +23 -0
- data/lib/mod_spox/messages/outgoing/Time.rb +15 -0
- data/lib/mod_spox/messages/outgoing/Topic.rb +19 -0
- data/lib/mod_spox/messages/outgoing/Trace.rb +15 -0
- data/lib/mod_spox/messages/outgoing/Unaway.rb +9 -0
- data/lib/mod_spox/messages/outgoing/User.rb +23 -0
- data/lib/mod_spox/messages/outgoing/UserHost.rb +15 -0
- data/lib/mod_spox/messages/outgoing/UserMode.rb +19 -0
- data/lib/mod_spox/messages/outgoing/Users.rb +15 -0
- data/lib/mod_spox/messages/outgoing/Version.rb +16 -0
- data/lib/mod_spox/messages/outgoing/Who.rb +23 -0
- data/lib/mod_spox/messages/outgoing/WhoWas.rb +23 -0
- data/lib/mod_spox/messages/outgoing/Whois.rb +19 -0
- data/lib/mod_spox/migrations/001_initialize_models.rb +115 -0
- data/lib/mod_spox/migrations/002_persistent_sigs.rb +14 -0
- data/lib/mod_spox/migrations/003_auth_restructure.rb +31 -0
- data/lib/mod_spox/migrations/004_mode_index_fix.rb +18 -0
- data/lib/mod_spox/migrations/005_nick_mode_nopark.rb +18 -0
- data/lib/mod_spox/models/Auth.rb +65 -0
- data/lib/mod_spox/models/AuthMask.rb +13 -0
- data/lib/mod_spox/models/Channel.rb +89 -0
- data/lib/mod_spox/models/Config.rb +30 -0
- data/lib/mod_spox/models/Group.rb +30 -0
- data/lib/mod_spox/models/Models.rb +4 -0
- data/lib/mod_spox/models/Nick.rb +195 -0
- data/lib/mod_spox/models/NickMode.rb +32 -0
- data/lib/mod_spox/models/Server.rb +27 -0
- data/lib/mod_spox/models/Setting.rb +52 -0
- data/lib/mod_spox/models/Signature.rb +52 -0
- data/lib/mod_spox/models/Trigger.rb +9 -0
- data/lib/mod_spox/rfc2812.rb +49 -0
- data/populate_gemspec.rb +15 -0
- data/tests/BotHolder.rb +24 -0
- data/tests/handlers/tc_BadNick.rb +21 -0
- data/tests/handlers/tc_Created.rb +24 -0
- data/tests/handlers/tc_Invite.rb +50 -0
- data/tests/handlers/tc_Join.rb +33 -0
- data/tests/handlers/tc_Kick.rb +32 -0
- data/tests/handlers/tc_Mode.rb +85 -0
- data/tests/handlers/tc_Names.rb +35 -0
- data/tests/handlers/tc_Nick.rb +55 -0
- data/tests/handlers/tc_Part.rb +44 -0
- data/tests/handlers/tc_Ping.rb +40 -0
- data/tests/handlers/tc_Pong.rb +28 -0
- data/tests/handlers/tc_Privmsg.rb +85 -0
- data/tests/handlers/tc_Quit.rb +40 -0
- data/tests/handlers/tc_Who.rb +50 -0
- data/tests/handlers/tc_Whois.rb +61 -0
- data/tests/models/tc_Auth.rb +39 -0
- data/tests/models/tc_Channel.rb +52 -0
- data/tests/models/tc_Config.rb +19 -0
- data/tests/models/tc_Nick.rb +144 -0
- data/tests/models/tc_NickMode.rb +40 -0
- data/tests/models/tc_Setting.rb +21 -0
- data/tests/models/tc_Signature.rb +14 -0
- data/tests/run_tests.rb +6 -0
- metadata +362 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'mod_spox/handlers/Handler'
|
2
|
+
require 'mod_spox/messages/incoming/Welcome'
|
3
|
+
module ModSpox
|
4
|
+
module Handlers
|
5
|
+
class Welcome < Handler
|
6
|
+
def initialize(handlers)
|
7
|
+
handlers[RFC[:RPL_WELCOME][:value]] = self
|
8
|
+
end
|
9
|
+
# >> :holmes.freenode.net 001 spax :Welcome to the freenode IRC Network spax
|
10
|
+
def process(string)
|
11
|
+
parse = string.dup
|
12
|
+
begin
|
13
|
+
parse.slice!(0)
|
14
|
+
server = parse.slice!(0..parse.index(' ')-1)
|
15
|
+
2.times{parse.slice!(0..parse.index(' '))}
|
16
|
+
nick = parse.slice!(0..parse.index(' ')-1)
|
17
|
+
parse.slice!(0..parse.index(':'))
|
18
|
+
nick = Models::Nick.find_or_create(:nick => nick)
|
19
|
+
nick.botnick = true
|
20
|
+
nick.visible = true
|
21
|
+
nick.save
|
22
|
+
return Messages::Incoming::Welcome.new(string, server, parse, nick, nil, nil)
|
23
|
+
rescue Object => boom
|
24
|
+
Logger.warn("Failed to parse welcome message: #{string}")
|
25
|
+
raise Exceptions::GeneralException.new(boom)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'mod_spox/handlers/Handler'
|
2
|
+
require 'mod_spox/messages/incoming/Who'
|
3
|
+
module ModSpox
|
4
|
+
module Handlers
|
5
|
+
class Who < Handler
|
6
|
+
def initialize(handlers)
|
7
|
+
handlers[RFC[:RPL_WHOREPLY][:value]] = self
|
8
|
+
handlers[RFC[:RPL_ENDOFWHO][:value]] = self
|
9
|
+
@cache = Hash.new
|
10
|
+
@raw_cache = Hash.new
|
11
|
+
end
|
12
|
+
# :host 352 spox #mod_spox ~pizza_ 12.229.112.195 punch.va.us.dal.net pizza_ H@ :5 pizza_
|
13
|
+
def process(string)
|
14
|
+
string = string.dup
|
15
|
+
orig = string.dup
|
16
|
+
begin
|
17
|
+
until(string.slice(0..RFC[:RPL_WHOREPLY][:value].size-1) == RFC[:RPL_WHOREPLY][:value] || string.slice(0..RFC[:RPL_ENDOFWHO][:value].size-1) == RFC[:RPL_ENDOFWHO][:value])
|
18
|
+
string.slice!(0..string.index(' '))
|
19
|
+
end
|
20
|
+
if(string.slice(0..RFC[:RPL_WHOREPLY][:value].size-1) == RFC[:RPL_WHOREPLY][:value])
|
21
|
+
2.times{string.slice!(0..string.index(' '))}
|
22
|
+
location = string.slice!(0..string.index(' ')-1)
|
23
|
+
string.slice!(0)
|
24
|
+
username = string.slice!(0..string.index(' ')-1)
|
25
|
+
string.slice!(0)
|
26
|
+
host = string.slice!(0..string.index(' ')-1)
|
27
|
+
string.slice!(0)
|
28
|
+
server = string.slice!(0..string.index(' ')-1)
|
29
|
+
string.slice!(0)
|
30
|
+
nick = find_model(string.slice!(0..string.index(' ')-1))
|
31
|
+
string.slice!(0)
|
32
|
+
info = string.slice!(0..string.index(' ')-1)
|
33
|
+
string.slice!(0..string.index(':'))
|
34
|
+
hops = string.slice!(0..string.index(' ')-1)
|
35
|
+
string.slice!(0)
|
36
|
+
realname = string
|
37
|
+
location = nil if location == '*'
|
38
|
+
nick.username = username
|
39
|
+
nick.address = location
|
40
|
+
nick.real_name = realname
|
41
|
+
nick.connected_to = server
|
42
|
+
nick.away = !info.index('G').nil?
|
43
|
+
nick.add_channel(find_model(location)) unless location.nil?
|
44
|
+
nick.save_changes
|
45
|
+
key = location.nil? ? nick.nick : location
|
46
|
+
@cache[key] = Array.new unless @cache[key]
|
47
|
+
@cache[key] << nick
|
48
|
+
@raw_cache[key] = Array.new unless @raw_cache[key]
|
49
|
+
@raw_cache[key] << orig
|
50
|
+
unless(location.nil?)
|
51
|
+
channel = find_model(location)
|
52
|
+
channel.add_nick(nick)
|
53
|
+
if(info.include?('+'))
|
54
|
+
m = Models::NickMode.find_or_create(:channel_id => channel.pk, :nick_id => nick.pk)
|
55
|
+
m.set_mode('v')
|
56
|
+
elsif(info.include?('@'))
|
57
|
+
m = Models::NickMode.find_or_create(:channel_id => channel.pk, :nick_id => nick.pk)
|
58
|
+
m.set_mode('o')
|
59
|
+
else
|
60
|
+
m = Models::NickMode.find_or_create(:channel_id => channel.pk, :nick_id => nick.pk)
|
61
|
+
m.clear_modes
|
62
|
+
end
|
63
|
+
end
|
64
|
+
return nil
|
65
|
+
else
|
66
|
+
2.times{string.slice!(0..string.index(' '))}
|
67
|
+
location = string.slice!(0..string.index(' ')-1)
|
68
|
+
loc = find_model(location)
|
69
|
+
@raw_cache[location] << orig
|
70
|
+
message = Messages::Incoming::Who.new(@raw_cache[location].join("\n"), loc, @cache[location])
|
71
|
+
@raw_cache.delete(location)
|
72
|
+
@cache.delete(location)
|
73
|
+
return message
|
74
|
+
end
|
75
|
+
rescue Object => boom
|
76
|
+
Logger.error("Failed to match WHO type message: #{orig}")
|
77
|
+
raise Exceptions::GeneralException.new(boom)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
require 'mod_spox/handlers/Handler'
|
2
|
+
require 'mod_spox/messages/incoming/Whois'
|
3
|
+
module ModSpox
|
4
|
+
module Handlers
|
5
|
+
class Whois < Handler
|
6
|
+
def initialize(handlers)
|
7
|
+
handlers[RFC[:RPL_WHOISUSER][:value]] = self
|
8
|
+
handlers[RFC[:RPL_WHOISSERVER][:value]] = self
|
9
|
+
handlers[RFC[:RPL_WHOISOPERATOR][:value]] = self
|
10
|
+
handlers[RFC[:RPL_WHOISIDLE][:value]] = self
|
11
|
+
handlers[RFC[:RPL_WHOISCHANNELS][:value]] = self
|
12
|
+
handlers[RFC[:RPL_WHOISIDENTIFIED][:value]] = self
|
13
|
+
handlers[RFC[:RPL_ENDOFWHOIS][:value]] = self
|
14
|
+
@cache = Hash.new
|
15
|
+
@raw = Hash.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def process(string)
|
19
|
+
orig = string.dup
|
20
|
+
string = string.dup
|
21
|
+
begin
|
22
|
+
until(string.slice(0..string.index(' ')-1) ==RFC[:RPL_WHOISUSER][:value] ||
|
23
|
+
string.slice(0..string.index(' ')-1) ==RFC[:RPL_WHOISSERVER][:value] ||
|
24
|
+
string.slice(0..string.index(' ')-1) ==RFC[:RPL_WHOISOPERATOR][:value] ||
|
25
|
+
string.slice(0..string.index(' ')-1) ==RFC[:RPL_WHOISIDLE][:value] ||
|
26
|
+
string.slice(0..string.index(' ')-1) ==RFC[:RPL_WHOISCHANNELS][:value] ||
|
27
|
+
string.slice(0..string.index(' ')-1) ==RFC[:RPL_WHOISIDENTIFIED][:value] ||
|
28
|
+
string.slice(0..string.index(' ')-1) ==RFC[:RPL_ENDOFWHOIS][:value])
|
29
|
+
string.slice!(0..string.index(' '))
|
30
|
+
end
|
31
|
+
case string.slice!(0..string.index(' ')-1)
|
32
|
+
whenRFC[:RPL_WHOISUSER][:value]
|
33
|
+
string.slice!(0)
|
34
|
+
string.slice!(0..string.index(' '))
|
35
|
+
nick = find_model(string.slice!(0..string.index(' ')-1))
|
36
|
+
string.slice!(0)
|
37
|
+
nick.username = string.slice!(0..string.index(' ')-1)
|
38
|
+
string.slice!(0)
|
39
|
+
nick.address = string.slice!(0..string.index(' ')-1)
|
40
|
+
string.slice!(0..string.index(':'))
|
41
|
+
nick.real_name = string
|
42
|
+
nick.save_changes
|
43
|
+
@cache[nick.nick] = Messages::Incoming::Whois.new(nick)
|
44
|
+
@cache[nick.nick].raw_push(orig)
|
45
|
+
whenRFC[:RPL_WHOISCHANNELS][:value]
|
46
|
+
2.times{string.slice!(0..string.index(' '))}
|
47
|
+
nick = find_model(string.slice!(0..string.index(' ')-1))
|
48
|
+
@cache[nick.nick] = Messages::Incoming::Whois.new(nick) unless @cache[nick.nick]
|
49
|
+
string.slice!(0..string.index(':'))
|
50
|
+
string.split.each do |c|
|
51
|
+
channel = find_model(['@','+'].include?(c.slice(0)) ? c.slice(1..c.size) : c)
|
52
|
+
channel.add_nick(nick)
|
53
|
+
@cache[nick.nick].channels_push(channel)
|
54
|
+
if(c[0].chr == '@')
|
55
|
+
m = Models::NickMode.find_or_create(:nick_id => nick.pk, :channel_id => channel.pk)
|
56
|
+
m.set_mode('o')
|
57
|
+
elsif(c[0].chr == '+')
|
58
|
+
m = Models::NickMode.find_or_create(:nick_id => nick.pk, :channel_id => channel.pk)
|
59
|
+
m.set_mode('v')
|
60
|
+
else
|
61
|
+
m = Models::NickMode.find_or_create(:nick_id => nick.pk, :channel_id => channel.pk)
|
62
|
+
m.clear_modes
|
63
|
+
end
|
64
|
+
end
|
65
|
+
@cache[nick.nick].raw_push(orig)
|
66
|
+
whenRFC[:RPL_WHOISSERVER][:value]
|
67
|
+
2.times{string.slice!(0..string.index(' '))}
|
68
|
+
nick = find_model(string.slice!(0..string.index(' ')-1))
|
69
|
+
string.slice!(0)
|
70
|
+
@cache[nick.nick] = Messages::Incoming::Whois.new(nick) unless @cache[nick.nick]
|
71
|
+
nick.connected_to = string.slice!(0..string.index(' ')-1)
|
72
|
+
nick.save_changes
|
73
|
+
@cache[nick.nick].raw_push(orig)
|
74
|
+
whenRFC[:RPL_WHOISIDENTIFIED][:value]
|
75
|
+
2.times{string.slice!(0..string.index(' '))}
|
76
|
+
nick = find_model(string.slice!(0..string.index(' ')-1))
|
77
|
+
@cache[nick.nick] = Messages::Incoming::Whois.new(nick) unless @cache[nick.nick]
|
78
|
+
nick.auth.services_identified = true
|
79
|
+
@cache[nick.nick].raw_push(orig)
|
80
|
+
whenRFC[:RPL_WHOISIDLE][:value]
|
81
|
+
2.times{string.slice!(0..string.index(' '))}
|
82
|
+
nick = find_model(string.slice!(0..string.index(' ')-1))
|
83
|
+
string.slice!(0)
|
84
|
+
@cache[nick.nick] = Messages::Incoming::Whois.new(nick) unless @cache[nick.nick]
|
85
|
+
nick.seconds_idle = string.slice!(0..string.index(' ')-1).to_i
|
86
|
+
string.slice!(0)
|
87
|
+
nick.connected_at = Time.at(string.slice!(0..string.index(' ')-1).to_i)
|
88
|
+
nick.save_changes
|
89
|
+
@cache[nick.nick].raw_push(orig)
|
90
|
+
whenRFC[:RPL_WHOISOPERATOR][:value]
|
91
|
+
2.times{string.slice!(0..string.index(' '))}
|
92
|
+
nick = find_model(string.slice!(0..string.index(' ')-1))
|
93
|
+
string.slice!(0)
|
94
|
+
@cache[nick.nick] = Messages::Incoming::Whois.new(nick) unless @cache[nick.nick]
|
95
|
+
@cache[nick.nick].raw_push(orig)
|
96
|
+
whenRFC[:RPL_ENDOFWHOIS][:value]
|
97
|
+
2.times{string.slice!(0..string.index(' '))}
|
98
|
+
nick = find_model(string.slice!(0..string.index(' ')-1))
|
99
|
+
@cache[nick.nick] = Messages::Incoming::Whois.new(nick) unless @cache[nick.nick]
|
100
|
+
@cache[nick.nick].raw_push(orig)
|
101
|
+
message = @cache[nick.nick]
|
102
|
+
message.lock
|
103
|
+
@cache.delete(nick.nick)
|
104
|
+
return message
|
105
|
+
else
|
106
|
+
Logger.error("Failed to parse WHOIS type reply. Unknown part found: #{orig}")
|
107
|
+
end
|
108
|
+
return nil
|
109
|
+
rescue Object => boom
|
110
|
+
Logger.error("Failed to parse WHOIS type reply: #{orig}")
|
111
|
+
raise Exceptions::GeneralException.new(boom)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'mod_spox/handlers/Handler'
|
2
|
+
require 'mod_spox/messages/incoming/YourHost'
|
3
|
+
module ModSpox
|
4
|
+
module Handlers
|
5
|
+
class YourHost < Handler
|
6
|
+
def initialize(handlers)
|
7
|
+
handlers[RFC[:RPL_YOURHOST][:value]] = self
|
8
|
+
end
|
9
|
+
|
10
|
+
def process(string)
|
11
|
+
if(string =~ /:Your host is (\S+), running version (.+)$/)
|
12
|
+
return Messages::Incoming::YourHost.new(string, $1, $2)
|
13
|
+
else
|
14
|
+
Logger.warn('Failed to match Your Host message')
|
15
|
+
return nil
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'mod_spox/messages/incoming/Message'
|
2
|
+
module ModSpox
|
3
|
+
module Messages
|
4
|
+
module Incoming
|
5
|
+
class BadNick < Message
|
6
|
+
# nick that failed (string)
|
7
|
+
attr_reader :bad_nick
|
8
|
+
def initialize(raw, nick)
|
9
|
+
super(raw)
|
10
|
+
@bad_nick = nick
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'mod_spox/messages/incoming/Message'
|
2
|
+
module ModSpox
|
3
|
+
module Messages
|
4
|
+
module Incoming
|
5
|
+
class Bounce < Message
|
6
|
+
# server to connect to
|
7
|
+
attr_reader :server
|
8
|
+
# port to connect to
|
9
|
+
attr_reader :port
|
10
|
+
def initialize(raw, server, port)
|
11
|
+
super(raw)
|
12
|
+
@server = server
|
13
|
+
@port = port
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'mod_spox/messages/incoming/Message'
|
2
|
+
module ModSpox
|
3
|
+
module Messages
|
4
|
+
module Incoming
|
5
|
+
class Created < Message
|
6
|
+
# date server was created
|
7
|
+
attr_reader :date
|
8
|
+
def initialize(raw, date)
|
9
|
+
super(raw)
|
10
|
+
@date = date
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'mod_spox/messages/incoming/Message'
|
2
|
+
module ModSpox
|
3
|
+
module Messages
|
4
|
+
module Incoming
|
5
|
+
class Invite < Message
|
6
|
+
# source nick of invite
|
7
|
+
attr_reader :source
|
8
|
+
# target nick of invite
|
9
|
+
attr_reader :target
|
10
|
+
# channel invited to
|
11
|
+
attr_reader :channel
|
12
|
+
def initialize(raw, source, target, channel)
|
13
|
+
super(raw)
|
14
|
+
@source = source
|
15
|
+
@target = target
|
16
|
+
@channel = channel
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'mod_spox/messages/incoming/Message'
|
2
|
+
module ModSpox
|
3
|
+
module Messages
|
4
|
+
module Incoming
|
5
|
+
class Join < Message
|
6
|
+
# channel that nick joined
|
7
|
+
attr_reader :channel
|
8
|
+
# nick that joined channel
|
9
|
+
attr_reader :nick
|
10
|
+
|
11
|
+
def initialize(raw, channel, nick)
|
12
|
+
super(raw)
|
13
|
+
@channel = channel
|
14
|
+
@nick = nick
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'mod_spox/messages/incoming/Message'
|
2
|
+
module ModSpox
|
3
|
+
module Messages
|
4
|
+
module Incoming
|
5
|
+
class Kick < Message
|
6
|
+
# channel user was kicked from
|
7
|
+
attr_reader :channel
|
8
|
+
# nick that performed the kick
|
9
|
+
attr_reader :kicker
|
10
|
+
# nick that was kicked
|
11
|
+
attr_reader :kickee
|
12
|
+
# reason for kick
|
13
|
+
attr_reader :reason
|
14
|
+
|
15
|
+
def initialize(raw, channel, kicker, kickee, reason)
|
16
|
+
super(raw)
|
17
|
+
@channel = channel
|
18
|
+
@kicker = kicker
|
19
|
+
@kickee = kickee
|
20
|
+
@reason = reason
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'mod_spox/messages/incoming/Message'
|
2
|
+
module ModSpox
|
3
|
+
module Messages
|
4
|
+
module Incoming
|
5
|
+
class LuserChannels < Message
|
6
|
+
# number of channels
|
7
|
+
attr_reader :channels
|
8
|
+
def initialize(raw, num)
|
9
|
+
super(raw)
|
10
|
+
@channels = num
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'mod_spox/messages/incoming/Message'
|
2
|
+
module ModSpox
|
3
|
+
module Messages
|
4
|
+
module Incoming
|
5
|
+
class LuserClient < Message
|
6
|
+
# number of visible users
|
7
|
+
attr_reader :users
|
8
|
+
# number of invisible users
|
9
|
+
attr_reader :invisible
|
10
|
+
# number of servers
|
11
|
+
attr_reader :servers
|
12
|
+
# number of services
|
13
|
+
attr_reader :services
|
14
|
+
def initialize(raw, user, invis, servers, services)
|
15
|
+
super(raw)
|
16
|
+
@users = user
|
17
|
+
@invisible = invis
|
18
|
+
@servers = servers
|
19
|
+
@services = services
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'mod_spox/messages/incoming/Message'
|
2
|
+
module ModSpox
|
3
|
+
module Messages
|
4
|
+
module Incoming
|
5
|
+
class LuserMe < Message
|
6
|
+
# number of clients on server
|
7
|
+
attr_reader :clients
|
8
|
+
# number of servers
|
9
|
+
attr_reader :servers
|
10
|
+
def initialize(raw, clients, servers)
|
11
|
+
super(raw)
|
12
|
+
@clients = clients
|
13
|
+
@servers = servers
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'mod_spox/messages/incoming/Message'
|
2
|
+
module ModSpox
|
3
|
+
module Messages
|
4
|
+
module Incoming
|
5
|
+
class LuserOp < Message
|
6
|
+
# number of operators visible
|
7
|
+
attr_reader :ops
|
8
|
+
def initialize(raw, num)
|
9
|
+
super(raw)
|
10
|
+
@ops = num
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'mod_spox/messages/incoming/Message'
|
2
|
+
module ModSpox
|
3
|
+
module Messages
|
4
|
+
module Incoming
|
5
|
+
class LuserUnknown < Message
|
6
|
+
# number of unknown users
|
7
|
+
attr_reader :unknown
|
8
|
+
def initialize(raw, num)
|
9
|
+
super(raw)
|
10
|
+
@unknown = num
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module ModSpox
|
2
|
+
module Messages
|
3
|
+
module Incoming
|
4
|
+
|
5
|
+
class Message
|
6
|
+
|
7
|
+
# raw string from server
|
8
|
+
attr_reader :raw_content
|
9
|
+
|
10
|
+
# time of message creation
|
11
|
+
attr_reader :time
|
12
|
+
|
13
|
+
def initialize(content)
|
14
|
+
@raw_content = content
|
15
|
+
@time = Time.now
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'mod_spox/messages/incoming/Message'
|
2
|
+
module ModSpox
|
3
|
+
module Messages
|
4
|
+
module Incoming
|
5
|
+
class Mode < Message
|
6
|
+
|
7
|
+
# mode string (will be two or more characters matching: /^[+\-][A-Za-z]+$/)
|
8
|
+
attr_reader :mode
|
9
|
+
|
10
|
+
# mode channel (nil if target is nick (basically modes for the bot))
|
11
|
+
attr_reader :channel
|
12
|
+
|
13
|
+
# nick mode is applied to (nil if mode change is for channel only)
|
14
|
+
# if multiple modes are applied to multiple nicks, this will be
|
15
|
+
# an array holding the nicks in order the mode string was applied
|
16
|
+
attr_reader :target
|
17
|
+
|
18
|
+
# nick that applied the mode change
|
19
|
+
attr_reader :source
|
20
|
+
|
21
|
+
def initialize(raw, mode, source, target, channel)
|
22
|
+
super(raw)
|
23
|
+
@mode = mode
|
24
|
+
@channel = channel
|
25
|
+
@source = source
|
26
|
+
@target = target
|
27
|
+
end
|
28
|
+
|
29
|
+
# If mode is for a nick
|
30
|
+
def for_nick?
|
31
|
+
return @channel.nil?
|
32
|
+
end
|
33
|
+
|
34
|
+
# If mode is for a channel
|
35
|
+
def for_channel?
|
36
|
+
return @target.nil?
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'mod_spox/messages/incoming/Message'
|
2
|
+
module ModSpox
|
3
|
+
module Messages
|
4
|
+
module Incoming
|
5
|
+
class Motd < Message
|
6
|
+
# Message of the day
|
7
|
+
attr_reader :motd
|
8
|
+
# Server message is from
|
9
|
+
attr_reader :server
|
10
|
+
def initialize(raw, motd, server)
|
11
|
+
super(raw)
|
12
|
+
@motd = motd
|
13
|
+
@server = server
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'mod_spox/messages/incoming/Message'
|
2
|
+
module ModSpox
|
3
|
+
module Messages
|
4
|
+
module Incoming
|
5
|
+
class MyInfo < Message
|
6
|
+
# name of server connected to
|
7
|
+
attr_reader :servername
|
8
|
+
# version of server connected to
|
9
|
+
attr_reader :version
|
10
|
+
# user modes supported by server
|
11
|
+
attr_reader :user_modes
|
12
|
+
# channel modes supported by server
|
13
|
+
attr_reader :channel_modes
|
14
|
+
def initialize(raw, server, version, umodes, cmodes)
|
15
|
+
super(raw)
|
16
|
+
@servername = server
|
17
|
+
@version = version
|
18
|
+
@user_modes = umodes
|
19
|
+
@channel_modes = cmodes
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'mod_spox/messages/incoming/Message'
|
2
|
+
module ModSpox
|
3
|
+
module Messages
|
4
|
+
module Incoming
|
5
|
+
class Names < Message
|
6
|
+
# channel names are from
|
7
|
+
attr_reader :channel
|
8
|
+
# nicks in the channel
|
9
|
+
attr_reader :nicks
|
10
|
+
# ops in the channel
|
11
|
+
attr_reader :ops
|
12
|
+
# voiced nicks in channel
|
13
|
+
attr_reader :voiced
|
14
|
+
def initialize(raw, channel, nicks, ops, voiced)
|
15
|
+
super(raw)
|
16
|
+
@channel = channel
|
17
|
+
@nicks = nicks
|
18
|
+
@ops = ops
|
19
|
+
@voiced = voiced
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'mod_spox/messages/incoming/Message'
|
2
|
+
module ModSpox
|
3
|
+
module Messages
|
4
|
+
module Incoming
|
5
|
+
class Nick < Message
|
6
|
+
|
7
|
+
# previous nick
|
8
|
+
attr_reader :original_nick
|
9
|
+
# new nick
|
10
|
+
attr_reader :new_nick
|
11
|
+
|
12
|
+
## make sure old_nick is the source here
|
13
|
+
## in the processor breaking the raw message
|
14
|
+
|
15
|
+
# old_nick:: this should be the source
|
16
|
+
# new_nick:: this should be the target
|
17
|
+
def initialize(raw, old_nick, new_nick)
|
18
|
+
super(raw)
|
19
|
+
@original_nick = old_nick
|
20
|
+
@new_nick = new_nick
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'mod_spox/messages/incoming/Message'
|
2
|
+
module ModSpox
|
3
|
+
module Messages
|
4
|
+
module Incoming
|
5
|
+
class NickInUse < Message
|
6
|
+
# nick that is in use (string)
|
7
|
+
attr_reader :nick
|
8
|
+
def initialize(raw, nick)
|
9
|
+
super(raw)
|
10
|
+
@nick = nick
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|