mod_spox 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/INSTALL +9 -0
- data/README +33 -0
- data/bin/mod_spox +60 -0
- data/data/mod_spox/extras/Tester.rb +14 -0
- data/data/mod_spox/plugins/Authenticator.rb +245 -0
- data/data/mod_spox/plugins/BotNick.rb +18 -0
- data/data/mod_spox/plugins/Initializer.rb +41 -0
- data/data/mod_spox/plugins/Joiner.rb +13 -0
- data/data/mod_spox/plugins/Parter.rb +22 -0
- data/data/mod_spox/plugins/PluginLoader.rb +136 -0
- data/data/mod_spox/plugins/Ponger.rb +14 -0
- data/data/mod_spox/plugins/Quitter.rb +14 -0
- data/lib/mod_spox/Action.rb +73 -0
- data/lib/mod_spox/BaseConfig.rb +48 -0
- data/lib/mod_spox/Bot.rb +472 -0
- data/lib/mod_spox/BotConfig.rb +54 -0
- data/lib/mod_spox/ConfigurationWizard.rb +178 -0
- data/lib/mod_spox/Database.rb +25 -0
- data/lib/mod_spox/Exceptions.rb +35 -0
- data/lib/mod_spox/Helpers.rb +35 -0
- data/lib/mod_spox/Loader.rb +79 -0
- data/lib/mod_spox/Logger.rb +31 -0
- data/lib/mod_spox/MessageFactory.rb +73 -0
- data/lib/mod_spox/Monitors.rb +59 -0
- data/lib/mod_spox/Pipeline.rb +148 -0
- data/lib/mod_spox/Plugin.rb +18 -0
- data/lib/mod_spox/PluginManager.rb +105 -0
- data/lib/mod_spox/Pool.rb +50 -0
- data/lib/mod_spox/Socket.rb +171 -0
- data/lib/mod_spox/Timer.rb +138 -0
- data/lib/mod_spox/handlers/BadNick.rb +16 -0
- data/lib/mod_spox/handlers/Bounce.rb +15 -0
- data/lib/mod_spox/handlers/Created.rb +16 -0
- data/lib/mod_spox/handlers/Handler.rb +31 -0
- data/lib/mod_spox/handlers/Invite.rb +19 -0
- data/lib/mod_spox/handlers/Join.rb +30 -0
- data/lib/mod_spox/handlers/Kick.rb +24 -0
- data/lib/mod_spox/handlers/LuserChannels.rb +16 -0
- data/lib/mod_spox/handlers/LuserClient.rb +16 -0
- data/lib/mod_spox/handlers/LuserMe.rb +14 -0
- data/lib/mod_spox/handlers/LuserOp.rb +16 -0
- data/lib/mod_spox/handlers/LuserUnknown.rb +16 -0
- data/lib/mod_spox/handlers/Mode.rb +47 -0
- data/lib/mod_spox/handlers/Motd.rb +30 -0
- data/lib/mod_spox/handlers/MyInfo.rb +21 -0
- data/lib/mod_spox/handlers/Names.rb +54 -0
- data/lib/mod_spox/handlers/Nick.rb +24 -0
- data/lib/mod_spox/handlers/NickInUse.rb +16 -0
- data/lib/mod_spox/handlers/Notice.rb +32 -0
- data/lib/mod_spox/handlers/Part.rb +19 -0
- data/lib/mod_spox/handlers/Ping.rb +16 -0
- data/lib/mod_spox/handlers/Pong.rb +16 -0
- data/lib/mod_spox/handlers/Privmsg.rb +27 -0
- data/lib/mod_spox/handlers/Quit.rb +21 -0
- data/lib/mod_spox/handlers/Topic.rb +29 -0
- data/lib/mod_spox/handlers/Welcome.rb +34 -0
- data/lib/mod_spox/handlers/Who.rb +60 -0
- data/lib/mod_spox/handlers/Whois.rb +63 -0
- data/lib/mod_spox/handlers/YourHost.rb +17 -0
- data/lib/mod_spox/messages/incoming/BadNick.rb +15 -0
- data/lib/mod_spox/messages/incoming/Bounce.rb +17 -0
- data/lib/mod_spox/messages/incoming/Created.rb +14 -0
- data/lib/mod_spox/messages/incoming/Invite.rb +20 -0
- data/lib/mod_spox/messages/incoming/Join.rb +18 -0
- data/lib/mod_spox/messages/incoming/Kick.rb +25 -0
- data/lib/mod_spox/messages/incoming/LuserChannels.rb +14 -0
- data/lib/mod_spox/messages/incoming/LuserClient.rb +23 -0
- data/lib/mod_spox/messages/incoming/LuserMe.rb +17 -0
- data/lib/mod_spox/messages/incoming/LuserOp.rb +14 -0
- data/lib/mod_spox/messages/incoming/LuserUnknown.rb +14 -0
- data/lib/mod_spox/messages/incoming/Message.rb +22 -0
- data/lib/mod_spox/messages/incoming/Mode.rb +41 -0
- data/lib/mod_spox/messages/incoming/Motd.rb +17 -0
- data/lib/mod_spox/messages/incoming/MyInfo.rb +23 -0
- data/lib/mod_spox/messages/incoming/Names.rb +23 -0
- data/lib/mod_spox/messages/incoming/Nick.rb +25 -0
- data/lib/mod_spox/messages/incoming/NickInUse.rb +14 -0
- data/lib/mod_spox/messages/incoming/Notice.rb +8 -0
- data/lib/mod_spox/messages/incoming/Part.rb +20 -0
- data/lib/mod_spox/messages/incoming/Ping.rb +17 -0
- data/lib/mod_spox/messages/incoming/Pong.rb +8 -0
- data/lib/mod_spox/messages/incoming/Privmsg.rb +64 -0
- data/lib/mod_spox/messages/incoming/Quit.rb +17 -0
- data/lib/mod_spox/messages/incoming/Topic.rb +20 -0
- data/lib/mod_spox/messages/incoming/TopicInfo.rb +20 -0
- data/lib/mod_spox/messages/incoming/Welcome.rb +26 -0
- data/lib/mod_spox/messages/incoming/Who.rb +17 -0
- data/lib/mod_spox/messages/incoming/Whois.rb +47 -0
- data/lib/mod_spox/messages/incoming/YourHost.rb +17 -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/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 +8 -0
- data/lib/mod_spox/messages/internal/NickResponse.rb +14 -0
- data/lib/mod_spox/messages/internal/PluginLoadRequest.rb +20 -0
- data/lib/mod_spox/messages/internal/PluginLoadResponse.rb +16 -0
- data/lib/mod_spox/messages/internal/PluginModuleRequest.rb +13 -0
- data/lib/mod_spox/messages/internal/PluginModuleResponse.rb +17 -0
- data/lib/mod_spox/messages/internal/PluginReload.rb +8 -0
- data/lib/mod_spox/messages/internal/PluginRequest.rb +17 -0
- data/lib/mod_spox/messages/internal/PluginResponse.rb +20 -0
- data/lib/mod_spox/messages/internal/PluginUnloadRequest.rb +8 -0
- data/lib/mod_spox/messages/internal/PluginUnloadResponse.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 +9 -0
- data/lib/mod_spox/messages/internal/StatusResponse.rb +17 -0
- data/lib/mod_spox/messages/internal/TimerAdd.rb +27 -0
- data/lib/mod_spox/messages/internal/TimerClear.rb +8 -0
- data/lib/mod_spox/messages/internal/TimerRemove.rb +15 -0
- data/lib/mod_spox/messages/internal/TimerResponse.rb +26 -0
- data/lib/mod_spox/messages/internal/TriggersUpdate.rb +8 -0
- data/lib/mod_spox/messages/outgoing/Admin.rb +15 -0
- data/lib/mod_spox/messages/outgoing/Away.rb +10 -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 +11 -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 +10 -0
- data/lib/mod_spox/messages/outgoing/Pong.rb +17 -0
- data/lib/mod_spox/messages/outgoing/Privmsg.rb +19 -0
- data/lib/mod_spox/messages/outgoing/Quit.rb +10 -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 +19 -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/migration/001_create_auths.rb +13 -0
- data/lib/mod_spox/migration/001_create_channel.rb +13 -0
- data/lib/mod_spox/migration/001_create_channel_modes.rb +13 -0
- data/lib/mod_spox/migration/001_create_config.rb +13 -0
- data/lib/mod_spox/migration/001_create_nick_channels.rb +13 -0
- data/lib/mod_spox/migration/001_create_nick_modes.rb +13 -0
- data/lib/mod_spox/migration/001_create_nicks.rb +13 -0
- data/lib/mod_spox/migration/001_create_servers.rb +13 -0
- data/lib/mod_spox/migration/001_create_settings.rb +13 -0
- data/lib/mod_spox/migration/001_create_signatures.rb +13 -0
- data/lib/mod_spox/migration/001_create_triggers.rb +13 -0
- data/lib/mod_spox/models/Auth.rb +79 -0
- data/lib/mod_spox/models/AuthGroup.rb +15 -0
- data/lib/mod_spox/models/Channel.rb +47 -0
- data/lib/mod_spox/models/ChannelMode.rb +14 -0
- data/lib/mod_spox/models/Config.rb +31 -0
- data/lib/mod_spox/models/Group.rb +13 -0
- data/lib/mod_spox/models/Nick.rb +110 -0
- data/lib/mod_spox/models/NickChannel.rb +43 -0
- data/lib/mod_spox/models/NickMode.rb +18 -0
- data/lib/mod_spox/models/Server.rb +12 -0
- data/lib/mod_spox/models/Setting.rb +40 -0
- data/lib/mod_spox/models/Signature.rb +30 -0
- data/lib/mod_spox/models/Trigger.rb +9 -0
- data/lib/mod_spox/rfc2812.rb +171 -0
- metadata +261 -0
@@ -0,0 +1,63 @@
|
|
1
|
+
module ModSpox
|
2
|
+
module Handlers
|
3
|
+
class Whois < Handler
|
4
|
+
def initialize(handlers)
|
5
|
+
handlers[RPL_WHOISUSER] = self
|
6
|
+
handlers[RPL_WHOISSERVER] = self
|
7
|
+
handlers[RPL_WHOISOPERATOR] = self
|
8
|
+
handlers[RPL_WHOISIDLE] = self
|
9
|
+
handlers[RPL_WHOISCHANNELS] = self
|
10
|
+
handlers[RPL_WHOISIDENTIFIED] = self
|
11
|
+
handlers[RPL_ENDOFWHOIS] = self
|
12
|
+
@cache = Hash.new
|
13
|
+
@raw = Hash.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def process(string)
|
17
|
+
if(string =~ /#{RPL_WHOISUSER}\s\S+\s(\S+)\s(\S+)\s(\S+)\s\*\s:(.+)$/)
|
18
|
+
nick = find_model($1)
|
19
|
+
nick.username = $2
|
20
|
+
nick.address = $3
|
21
|
+
nick.real_name = $4
|
22
|
+
@cache[$1] = Messages::Incoming::Whois.new(nick)
|
23
|
+
@cache[$1].raw_push(string)
|
24
|
+
elsif(string =~ /#{RPL_WHOISCHANNELS}\s\S+\s(\S+)\s:(.+)$/)
|
25
|
+
nick = $1
|
26
|
+
$2.split(/\s/).each{|chan|
|
27
|
+
channel = find_model(chan.gsub(/^[@\+]/, ''))
|
28
|
+
@cache[nick].channels_push(channel)
|
29
|
+
if(chan[0].chr == '@')
|
30
|
+
Models::NickMode.find_or_create(:nick_id => @cache[nick].pk, :mode => 'o', :channel_id => channel.pk)
|
31
|
+
elsif(chan[0].chr == '+')
|
32
|
+
Models::NickMode.find_or_create(:nick_id => @cache[nick].pk, :mode => 'v', :channel_id => channel.pk)
|
33
|
+
else
|
34
|
+
Models::NickMode.filter(:nick_id => @cache[nick].nick.pk, :channel_id => channel.pk).each{|m| m.destroy}
|
35
|
+
end
|
36
|
+
}
|
37
|
+
@cache[$1].raw_push(string)
|
38
|
+
elsif(string =~ /#{RPL_WHOISSERVER}\s\S+\s(\S+)\s(\S+)\s:(.+)$/)
|
39
|
+
@cache[$1].nick.connected_to = $2
|
40
|
+
@cache[$1].raw_push(string)
|
41
|
+
elsif(string =~ /#{RPL_WHOISIDENTIFIED}\s\S+\s(\S+)\s/)
|
42
|
+
@cache[$1].nick.auth.services_identified = true
|
43
|
+
@cache[$1].raw_push(string)
|
44
|
+
elsif(string =~ /#{RPL_WHOISIDLE}\s\S+\s(\S+)\s(\d+)\s(\d+)\s:(.+?),(.+?)/)
|
45
|
+
@cache[$1].nick.seconds_idle = $2.to_i
|
46
|
+
@cache[$1].nick.connected_at = Time.at($3.to_i)
|
47
|
+
@cache[$1].raw_push(string)
|
48
|
+
elsif(string =~ /#{RPL_WHOISOPERATOR}\s\S+\s(\S+)/)
|
49
|
+
@cache[$1].raw_push(string)
|
50
|
+
elsif(string =~ /#{RPL_ENDOFWHOIS}\s\S+\s(\S+)\s:/)
|
51
|
+
@cache[$1].raw_push(string)
|
52
|
+
message = @cache[$1]
|
53
|
+
message.lock
|
54
|
+
@cache[$1].nick.save
|
55
|
+
@cache.delete($1)
|
56
|
+
return message
|
57
|
+
else
|
58
|
+
Logger.log('Failed to parse WHOIS type reply')
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ModSpox
|
2
|
+
module Handlers
|
3
|
+
class YourHost < Handler
|
4
|
+
def initialize(handlers)
|
5
|
+
handlers[RPL_YOURHOST] = self
|
6
|
+
end
|
7
|
+
|
8
|
+
def process(string)
|
9
|
+
if(string =~ /:Your host is (\S+), running version (.+)$/)
|
10
|
+
return Messages::Incoming::YourHost.new(string, $1, $2)
|
11
|
+
else
|
12
|
+
Logger.log('Failed to match Your Host message')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ModSpox
|
2
|
+
module Messages
|
3
|
+
module Incoming
|
4
|
+
class Bounce < Message
|
5
|
+
# server to connect to
|
6
|
+
attr_reader :server
|
7
|
+
# port to connect to
|
8
|
+
attr_reader :port
|
9
|
+
def initialize(raw, server, port)
|
10
|
+
super(raw)
|
11
|
+
@server = server
|
12
|
+
@port = port
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module ModSpox
|
2
|
+
module Messages
|
3
|
+
module Incoming
|
4
|
+
class Invite < Message
|
5
|
+
# source nick of invite
|
6
|
+
attr_reader :source
|
7
|
+
# target nick of invite
|
8
|
+
attr_reader :target
|
9
|
+
# channel invited to
|
10
|
+
attr_reader :channel
|
11
|
+
def initialize(raw, source, target, channel)
|
12
|
+
super(raw)
|
13
|
+
@source = source
|
14
|
+
@target = target
|
15
|
+
@channel = channel
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module ModSpox
|
2
|
+
module Messages
|
3
|
+
module Incoming
|
4
|
+
class Join < Message
|
5
|
+
# channel that nick joined
|
6
|
+
attr_reader :channel
|
7
|
+
# nick that joined channel
|
8
|
+
attr_reader :nick
|
9
|
+
|
10
|
+
def initialize(raw, channel, nick)
|
11
|
+
super(raw)
|
12
|
+
@channel = channel
|
13
|
+
@nick = nick
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module ModSpox
|
2
|
+
module Messages
|
3
|
+
module Incoming
|
4
|
+
class Kick < Message
|
5
|
+
# channel user was kicked from
|
6
|
+
attr_reader :channel
|
7
|
+
# nick that performed the kick
|
8
|
+
attr_reader :kicker
|
9
|
+
# nick that was kicked
|
10
|
+
attr_reader :kickee
|
11
|
+
# reason for kick
|
12
|
+
attr_reader :reason
|
13
|
+
|
14
|
+
def initialize(raw, channel, kicker, kickee, reason)
|
15
|
+
super(raw)
|
16
|
+
@channel = channel
|
17
|
+
@kicker = kicker
|
18
|
+
@kickee = kickee
|
19
|
+
@reason = reason
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ModSpox
|
2
|
+
module Messages
|
3
|
+
module Incoming
|
4
|
+
class LuserClient < Message
|
5
|
+
# number of visible users
|
6
|
+
attr_reader :users
|
7
|
+
# number of invisible users
|
8
|
+
attr_reader :invisible
|
9
|
+
# number of servers
|
10
|
+
attr_reader :servers
|
11
|
+
# number of services
|
12
|
+
attr_reader :services
|
13
|
+
def initialize(raw, user, invis, servers, services)
|
14
|
+
super(raw)
|
15
|
+
@users = user
|
16
|
+
@invisible = invis
|
17
|
+
@servers = servers
|
18
|
+
@services = services
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ModSpox
|
2
|
+
module Messages
|
3
|
+
module Incoming
|
4
|
+
class LuserMe < Message
|
5
|
+
# number of clients on server
|
6
|
+
attr_reader :clients
|
7
|
+
# number of servers
|
8
|
+
attr_reader :servers
|
9
|
+
def initialize(raw, clients, servers)
|
10
|
+
super(raw)
|
11
|
+
@clients = clients
|
12
|
+
@servers = servers
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
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,41 @@
|
|
1
|
+
module ModSpox
|
2
|
+
module Messages
|
3
|
+
module Incoming
|
4
|
+
class Mode < Message
|
5
|
+
|
6
|
+
# mode string (will be two or more characters matching: /^[+\-][A-Za-z]+$/)
|
7
|
+
attr_reader :mode
|
8
|
+
|
9
|
+
# mode channel (nil if target is nick (basically modes for the bot))
|
10
|
+
attr_reader :channel
|
11
|
+
|
12
|
+
# nick mode is applied to (nil if mode change is for channel only)
|
13
|
+
# if multiple modes are applied to multiple nicks, this will be
|
14
|
+
# an array holding the nicks in order the mode string was applied
|
15
|
+
attr_reader :target
|
16
|
+
|
17
|
+
# nick that applied the mode change
|
18
|
+
attr_reader :source
|
19
|
+
|
20
|
+
def initialize(raw, mode, source, target, channel)
|
21
|
+
super(raw)
|
22
|
+
@mode = mode
|
23
|
+
@channel = channel
|
24
|
+
@source = source
|
25
|
+
@target = target
|
26
|
+
end
|
27
|
+
|
28
|
+
# If mode is for a nick
|
29
|
+
def for_nick?
|
30
|
+
return @channel.nil?
|
31
|
+
end
|
32
|
+
|
33
|
+
# If mode is for a channel
|
34
|
+
def for_channel?
|
35
|
+
return @target.nil?
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ModSpox
|
2
|
+
module Messages
|
3
|
+
module Incoming
|
4
|
+
class Motd < Message
|
5
|
+
# Message of the day
|
6
|
+
attr_reader :motd
|
7
|
+
# Server message is from
|
8
|
+
attr_reader :server
|
9
|
+
def initialize(raw, motd, server)
|
10
|
+
super(raw)
|
11
|
+
@motd = motd
|
12
|
+
@server = server
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ModSpox
|
2
|
+
module Messages
|
3
|
+
module Incoming
|
4
|
+
class MyInfo < Message
|
5
|
+
# name of server connected to
|
6
|
+
attr_reader :servername
|
7
|
+
# version of server connected to
|
8
|
+
attr_reader :version
|
9
|
+
# user modes supported by server
|
10
|
+
attr_reader :user_modes
|
11
|
+
# channel modes supported by server
|
12
|
+
attr_reader :channel_modes
|
13
|
+
def initialize(raw, server, version, umodes, cmodes)
|
14
|
+
super(raw)
|
15
|
+
@servername = server
|
16
|
+
@version = version
|
17
|
+
@user_modes = umodes
|
18
|
+
@channel_modes = cmodes
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ModSpox
|
2
|
+
module Messages
|
3
|
+
module Incoming
|
4
|
+
class Names < Message
|
5
|
+
# channel names are from
|
6
|
+
attr_reader :channel
|
7
|
+
# nicks in the channel
|
8
|
+
attr_reader :nicks
|
9
|
+
# ops in the channel
|
10
|
+
attr_reader :ops
|
11
|
+
# voiced nicks in channel
|
12
|
+
attr_reader :voiced
|
13
|
+
def initialize(raw, channel, nicks, ops, voiced)
|
14
|
+
super(raw)
|
15
|
+
@channel = channel
|
16
|
+
@nicks = nicks
|
17
|
+
@ops = ops
|
18
|
+
@voiced = voiced
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module ModSpox
|
2
|
+
module Messages
|
3
|
+
module Incoming
|
4
|
+
class Nick < Message
|
5
|
+
|
6
|
+
# previous nick
|
7
|
+
attr_reader :original_nick
|
8
|
+
# new nick
|
9
|
+
attr_reader :new_nick
|
10
|
+
|
11
|
+
## make sure old_nick is the source here
|
12
|
+
## in the processor breaking the raw message
|
13
|
+
|
14
|
+
# old_nick:: this should be the source
|
15
|
+
# new_nick:: this should be the target
|
16
|
+
def initialize(raw, old_nick, new_nick)
|
17
|
+
super(raw)
|
18
|
+
@original_nick = @source_nick
|
19
|
+
@new_nick = @target
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module ModSpox
|
2
|
+
module Messages
|
3
|
+
module Incoming
|
4
|
+
class Part < Message
|
5
|
+
# channel user parted from
|
6
|
+
attr_reader :channel
|
7
|
+
# nick that parted from channel
|
8
|
+
attr_reader :nick
|
9
|
+
# reason for parting
|
10
|
+
attr_reader :reason
|
11
|
+
def initialize(raw, channel, nick, reason)
|
12
|
+
super(raw)
|
13
|
+
@channel = channel
|
14
|
+
@nick = nick
|
15
|
+
@reason = reason
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ModSpox
|
2
|
+
module Messages
|
3
|
+
module Incoming
|
4
|
+
class Ping < Message
|
5
|
+
# server of origin
|
6
|
+
attr_reader :server
|
7
|
+
# string
|
8
|
+
attr_reader :string
|
9
|
+
def initialize(raw, server, string)
|
10
|
+
super(raw)
|
11
|
+
@server = server
|
12
|
+
@string = string
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module ModSpox
|
2
|
+
module Messages
|
3
|
+
module Incoming
|
4
|
+
class Privmsg < Message
|
5
|
+
|
6
|
+
# source of the message
|
7
|
+
attr_reader :source
|
8
|
+
# target of the message
|
9
|
+
attr_reader :target
|
10
|
+
# the message sent
|
11
|
+
attr_reader :message
|
12
|
+
def initialize(raw, source, target, message)
|
13
|
+
super(raw)
|
14
|
+
@source = source
|
15
|
+
@target = target
|
16
|
+
if(message =~ /^\001ACTION\s(.+)\001/)
|
17
|
+
@message = $1
|
18
|
+
@action = true
|
19
|
+
else
|
20
|
+
@message = message
|
21
|
+
@action = false
|
22
|
+
end
|
23
|
+
botnick = Models::Nick.filter(:botnick => true).first
|
24
|
+
if(botnick)
|
25
|
+
@addressed = @message =~ /^#{botnick.nick}/i
|
26
|
+
else
|
27
|
+
@addressed = false
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Is message addressing the bot
|
32
|
+
def addressed?
|
33
|
+
return @addressed || is_private?
|
34
|
+
end
|
35
|
+
|
36
|
+
# Is this is private message
|
37
|
+
def is_private?
|
38
|
+
return @target.is_a?(Models::Nick)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Is this a public message
|
42
|
+
def is_public?
|
43
|
+
return @target.is_a?(Model::Channel)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Does the message contain colors
|
47
|
+
def is_colored?
|
48
|
+
return @message =~ /\cC\d\d?(?:,\d\d?)?/
|
49
|
+
end
|
50
|
+
|
51
|
+
# Message with coloring stripped
|
52
|
+
def message_nocolor
|
53
|
+
return @message.gsub(/\cC\d\d?(?:,\d\d?)?/, '')
|
54
|
+
end
|
55
|
+
|
56
|
+
# Is this message an action message
|
57
|
+
def is_action?
|
58
|
+
@action
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ModSpox
|
2
|
+
module Messages
|
3
|
+
module Incoming
|
4
|
+
class Quit < Message
|
5
|
+
# nick that quit
|
6
|
+
attr_reader :nick
|
7
|
+
# quit message
|
8
|
+
attr_reader :message
|
9
|
+
def initialize(raw, nick, message)
|
10
|
+
super(raw)
|
11
|
+
@nick = nick
|
12
|
+
@message = message
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module ModSpox
|
2
|
+
module Messages
|
3
|
+
module Incoming
|
4
|
+
class Topic < Message
|
5
|
+
|
6
|
+
# channel topic was set
|
7
|
+
attr_reader :channel
|
8
|
+
# topic messages
|
9
|
+
attr_reader :topic
|
10
|
+
|
11
|
+
def initialize(raw, channel, topic)
|
12
|
+
super(raw)
|
13
|
+
@channel = @channel
|
14
|
+
@topic = @topic
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module ModSpox
|
2
|
+
module Messages
|
3
|
+
module Incoming
|
4
|
+
class TopicInfo < Message
|
5
|
+
# channel topic info is for
|
6
|
+
attr_reader :channel
|
7
|
+
# last nick to set topic
|
8
|
+
attr_reader :nick
|
9
|
+
# time topic was set
|
10
|
+
attr_reader :time
|
11
|
+
def initialize(raw, channel, nick, time)
|
12
|
+
super(raw)
|
13
|
+
@channel = channel
|
14
|
+
@nick = nick
|
15
|
+
@time = time
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module ModSpox
|
2
|
+
module Messages
|
3
|
+
module Incoming
|
4
|
+
class Welcome < Message
|
5
|
+
# server bot is connected to
|
6
|
+
attr_reader :server
|
7
|
+
# welcome message from server
|
8
|
+
attr_reader :message
|
9
|
+
# nick of the bot
|
10
|
+
attr_reader :nick
|
11
|
+
# username of the bot
|
12
|
+
attr_reader :username
|
13
|
+
# hostname of the bot
|
14
|
+
attr_reader :hostname
|
15
|
+
def initialize(raw, server, message, nick, username, hostname)
|
16
|
+
super(raw)
|
17
|
+
@server = server
|
18
|
+
@message = message
|
19
|
+
@nick = nick
|
20
|
+
@username = username
|
21
|
+
@hostname = hostname
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|