mod_spox 0.1.0.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +36 -0
- data/INSTALL +2 -2
- data/README +0 -1
- data/bin/mod_spox +51 -12
- data/data/mod_spox/extras/AOLSpeak.rb +5 -18
- data/data/mod_spox/extras/AutoKick.rb +44 -23
- data/data/mod_spox/extras/AutoMode.rb +2 -5
- data/data/mod_spox/extras/AutoRejoin.rb +21 -0
- data/data/mod_spox/extras/Bouncer.rb +10 -10
- data/data/mod_spox/extras/Bytes.rb +12 -0
- data/data/mod_spox/extras/Confess.rb +131 -52
- data/data/mod_spox/extras/DCC.rb +189 -0
- data/data/mod_spox/extras/DevWatch.rb +32 -33
- data/data/mod_spox/extras/FloodKicker.rb +129 -0
- data/data/mod_spox/extras/GoogleIt.rb +13 -0
- data/data/mod_spox/extras/Headers.rb +31 -4
- data/data/mod_spox/extras/Karma.rb +103 -49
- data/data/mod_spox/extras/Logger.rb +45 -30
- data/data/mod_spox/extras/LolSpeak.rb +1 -1
- data/data/mod_spox/extras/NickServ.rb +83 -0
- data/data/mod_spox/extras/PhpCli.rb +12 -15
- data/data/mod_spox/extras/PhpFuncLookup.rb +57 -25
- data/data/mod_spox/extras/Quotes.rb +5 -4
- data/data/mod_spox/extras/RegexTracker.rb +160 -0
- data/data/mod_spox/extras/Roulette.rb +22 -23
- data/data/mod_spox/extras/Search.rb +3 -2
- data/data/mod_spox/extras/Slashdot.rb +35 -0
- data/data/mod_spox/extras/Topten.rb +5 -5
- data/data/mod_spox/extras/TracTicket.rb +68 -0
- data/data/mod_spox/extras/Translate.rb +69 -30
- data/data/mod_spox/extras/Twitter.rb +372 -0
- data/data/mod_spox/extras/UrbanDictionary.rb +21 -12
- data/data/mod_spox/extras/Weather.rb +1 -1
- data/data/mod_spox/plugins/Authenticator.rb +63 -30
- data/data/mod_spox/plugins/Banner.rb +164 -151
- data/data/mod_spox/plugins/Helper.rb +18 -7
- data/data/mod_spox/plugins/PluginLoader.rb +46 -22
- data/data/mod_spox/plugins/PoolConfig.rb +52 -0
- data/data/mod_spox/plugins/Quitter.rb +1 -1
- data/data/mod_spox/plugins/Status.rb +28 -0
- data/lib/mod_spox/Action.rb +20 -3
- data/lib/mod_spox/BaseConfig.rb +1 -0
- data/lib/mod_spox/Bot.rb +98 -75
- data/lib/mod_spox/BotConfig.rb +14 -6
- data/lib/mod_spox/ConfigurationWizard.rb +94 -105
- data/lib/mod_spox/Database.rb +33 -13
- data/lib/mod_spox/Helpers.rb +67 -38
- data/lib/mod_spox/Loader.rb +25 -5
- data/lib/mod_spox/Logger.rb +20 -62
- data/lib/mod_spox/MessageFactory.rb +34 -25
- data/lib/mod_spox/Monitors.rb +5 -0
- data/lib/mod_spox/Pipeline.rb +40 -51
- data/lib/mod_spox/Plugin.rb +40 -9
- data/lib/mod_spox/PluginManager.rb +46 -38
- data/lib/mod_spox/Pool.rb +129 -143
- data/lib/mod_spox/Socket.rb +41 -50
- data/lib/mod_spox/Sockets.rb +211 -0
- data/lib/mod_spox/Timer.rb +86 -69
- data/lib/mod_spox/handlers/BadNick.rb +1 -1
- data/lib/mod_spox/handlers/Created.rb +1 -1
- data/lib/mod_spox/handlers/Handler.rb +9 -0
- data/lib/mod_spox/handlers/Invite.rb +1 -1
- data/lib/mod_spox/handlers/Join.rb +2 -2
- data/lib/mod_spox/handlers/Kick.rb +1 -1
- data/lib/mod_spox/handlers/LuserChannels.rb +1 -1
- data/lib/mod_spox/handlers/LuserOp.rb +1 -1
- data/lib/mod_spox/handlers/LuserUnknown.rb +1 -1
- data/lib/mod_spox/handlers/Mode.rb +2 -2
- data/lib/mod_spox/handlers/MyInfo.rb +1 -1
- data/lib/mod_spox/handlers/Names.rb +1 -1
- data/lib/mod_spox/handlers/Nick.rb +20 -3
- data/lib/mod_spox/handlers/NickInUse.rb +3 -3
- data/lib/mod_spox/handlers/Notice.rb +5 -15
- data/lib/mod_spox/handlers/Part.rb +1 -1
- data/lib/mod_spox/handlers/Ping.rb +1 -1
- data/lib/mod_spox/handlers/Pong.rb +1 -1
- data/lib/mod_spox/handlers/Privmsg.rb +2 -2
- data/lib/mod_spox/handlers/Quit.rb +1 -1
- data/lib/mod_spox/handlers/Topic.rb +2 -1
- data/lib/mod_spox/handlers/Welcome.rb +3 -3
- data/lib/mod_spox/handlers/Who.rb +9 -7
- data/lib/mod_spox/handlers/Whois.rb +29 -16
- data/lib/mod_spox/handlers/YourHost.rb +1 -1
- data/lib/mod_spox/messages/incoming/Privmsg.rb +38 -19
- 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/StatusRequest.rb +2 -1
- data/lib/mod_spox/messages/outgoing/Privmsg.rb +21 -5
- data/lib/mod_spox/migrations/001_initialize_models.rb +115 -0
- data/lib/mod_spox/models/Auth.rb +24 -16
- data/lib/mod_spox/models/AuthGroup.rb +4 -3
- data/lib/mod_spox/models/Channel.rb +20 -12
- data/lib/mod_spox/models/ChannelMode.rb +2 -2
- data/lib/mod_spox/models/Config.rb +11 -3
- data/lib/mod_spox/models/Group.rb +6 -1
- data/lib/mod_spox/models/Nick.rb +93 -33
- data/lib/mod_spox/models/NickChannel.rb +8 -6
- data/lib/mod_spox/models/NickGroup.rb +16 -0
- data/lib/mod_spox/models/NickMode.rb +3 -3
- data/lib/mod_spox/models/Server.rb +6 -2
- data/lib/mod_spox/models/Setting.rb +12 -6
- data/lib/mod_spox/models/Signature.rb +7 -13
- data/lib/mod_spox/models/Trigger.rb +1 -1
- metadata +125 -100
@@ -4,10 +4,19 @@ module ModSpox
|
|
4
4
|
|
5
5
|
class Handler
|
6
6
|
|
7
|
+
def initialize(handlers)
|
8
|
+
end
|
9
|
+
|
7
10
|
def process(data)
|
8
11
|
raise Exceptions::NotImplemented.new('Method has not been implemented')
|
9
12
|
end
|
10
13
|
|
14
|
+
# data:: any expected data
|
15
|
+
# Preprocessing allows for actions to be taken
|
16
|
+
# while messages are still in a synchronized state
|
17
|
+
def preprocess(data)
|
18
|
+
end
|
19
|
+
|
11
20
|
protected
|
12
21
|
|
13
22
|
def find_model(string)
|
@@ -20,11 +20,11 @@ module ModSpox
|
|
20
20
|
channel.nick_add(nick)
|
21
21
|
return Messages::Incoming::Join.new(string, channel, nick)
|
22
22
|
else
|
23
|
-
Logger.
|
23
|
+
Logger.warn('Failed to parse source on JOIN message')
|
24
24
|
return nil
|
25
25
|
end
|
26
26
|
else
|
27
|
-
Logger.
|
27
|
+
Logger.warn('Failed to parse JOIN message')
|
28
28
|
return nil
|
29
29
|
end
|
30
30
|
end
|
@@ -9,7 +9,7 @@ module ModSpox
|
|
9
9
|
if(string =~ /(\d+)\s:channels/)
|
10
10
|
return Messages::Incoming::LuserChannels.new(string, $1.to_i)
|
11
11
|
else
|
12
|
-
Logger.
|
12
|
+
Logger.warn('Failed to match RPL_LUSERCHANNELS message')
|
13
13
|
return nil
|
14
14
|
end
|
15
15
|
end
|
@@ -9,7 +9,7 @@ module ModSpox
|
|
9
9
|
if(string =~ /(\d+) :.*[Uu]nknown/)
|
10
10
|
return Messages::Incoming::LuserUnknown.new(string, $1.to_i)
|
11
11
|
else
|
12
|
-
Logger.
|
12
|
+
Logger.warn('Failed to match RPL_LUSERUNKNOWN message')
|
13
13
|
return nil
|
14
14
|
end
|
15
15
|
end
|
@@ -43,10 +43,10 @@ module ModSpox
|
|
43
43
|
nicks = nicks[0] if nicks.size == 1
|
44
44
|
return Messages::Incoming::Mode.new(string, full_modes, source, nicks, channel)
|
45
45
|
else
|
46
|
-
Logger.
|
46
|
+
Logger.warn('Failed to parse MODE message')
|
47
47
|
end
|
48
48
|
rescue Object => boom
|
49
|
-
Logger.
|
49
|
+
Logger.warn("Failed to process MODE message. Reason: #{boom}")
|
50
50
|
end
|
51
51
|
return nil
|
52
52
|
end
|
@@ -14,7 +14,7 @@ module ModSpox
|
|
14
14
|
channelmodes = $4
|
15
15
|
return Messages::Incoming::MyInfo.new(string, servername, version, usermodes, channelmodes)
|
16
16
|
else
|
17
|
-
Logger.
|
17
|
+
Logger.warn('Failed to match My Info message')
|
18
18
|
return nil
|
19
19
|
end
|
20
20
|
end
|
@@ -9,15 +9,32 @@ module ModSpox
|
|
9
9
|
if(string =~ /^:([^!]+)!\S+\sNICK\s:(.+)$/)
|
10
10
|
old_nick = find_model($1)
|
11
11
|
new_nick = find_model($2)
|
12
|
+
new_nick.visible = true
|
13
|
+
old_nick.channels.each do |channel|
|
14
|
+
new_nick.channel_add(channel)
|
15
|
+
Models::NickMode.find_or_create(:nick_id => new_nick.pk, :channel_id => channel.pk, :mode => 'o') if old_nick.is_op?(channel)
|
16
|
+
Models::NickMode.find_or_create(:nick_id => new_nick.pk, :channel_id => channel.pk, :mode => 'v') if old_nick.is_voice?(channel)
|
17
|
+
Models::NickMode.filter(:nick_id => old_nick.pk, :channel_id => channel.pk).destroy
|
18
|
+
end
|
19
|
+
new_nick.username = old_nick.username
|
20
|
+
new_nick.address = old_nick.address
|
21
|
+
new_nick.real_name = old_nick.real_name
|
22
|
+
new_nick.connected_to = old_nick.connected_to
|
23
|
+
new_nick.away = old_nick.away
|
24
|
+
new_nick.visible = true
|
25
|
+
new_nick.save_changes
|
26
|
+
Models::Nick.transfer_groups(old_nick, new_nick)
|
27
|
+
old_nick.visible = false
|
28
|
+
old_nick.clear_channels
|
12
29
|
if(old_nick.botnick == true)
|
13
30
|
old_nick.botnick = false
|
14
|
-
old_nick.save
|
15
31
|
new_nick.botnick = true
|
16
|
-
new_nick.save
|
17
32
|
end
|
33
|
+
new_nick.save
|
34
|
+
old_nick.save
|
18
35
|
return Messages::Incoming::Nick.new(string, old_nick, new_nick)
|
19
36
|
else
|
20
|
-
Logger.
|
37
|
+
Logger.warn('Failed to parse NICK message')
|
21
38
|
return nil
|
22
39
|
end
|
23
40
|
end
|
@@ -3,13 +3,13 @@ module ModSpox
|
|
3
3
|
module Handlers
|
4
4
|
class NickInUse < Handler
|
5
5
|
def initialize(handlers)
|
6
|
-
handlers[
|
6
|
+
handlers[ERR_NICKNAMEINUSE] = self
|
7
7
|
end
|
8
8
|
def process(string)
|
9
|
-
if(string =~ /#{
|
9
|
+
if(string =~ /#{ERR_NICKNAMEINUSE}\s\S+\s(\S+)\s:/)
|
10
10
|
return Messages::Incoming::NickInUse.new(string, $1)
|
11
11
|
else
|
12
|
-
Logger.
|
12
|
+
Logger.warn('Failed to parse ERR_NICKNAMEINUSE message')
|
13
13
|
return nil
|
14
14
|
end
|
15
15
|
end
|
@@ -14,20 +14,10 @@ module ModSpox
|
|
14
14
|
if(base_source =~ /\!/)
|
15
15
|
source = find_model(base_source.gsub(/!.+$/, ''))
|
16
16
|
if(base_source =~ /!(.+)@(.+)$/)
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
unless(source.address == $2)
|
23
|
-
source.address = $2
|
24
|
-
do_save = true
|
25
|
-
end
|
26
|
-
unless(source.source == base_source)
|
27
|
-
source.source = base_source
|
28
|
-
do_save = true
|
29
|
-
end
|
30
|
-
source.save if do_save
|
17
|
+
source.username == $1
|
18
|
+
source.address = $2
|
19
|
+
source.source = base_source
|
20
|
+
source.save_changes
|
31
21
|
end
|
32
22
|
target = find_model(target)
|
33
23
|
else
|
@@ -35,7 +25,7 @@ module ModSpox
|
|
35
25
|
end
|
36
26
|
return Messages::Incoming::Notice.new(string, source, target, message)
|
37
27
|
else
|
38
|
-
Logger.
|
28
|
+
Logger.warn('Failed to match NOTICE message')
|
39
29
|
return nil
|
40
30
|
end
|
41
31
|
end
|
@@ -13,7 +13,7 @@ module ModSpox
|
|
13
13
|
base_source = $1
|
14
14
|
source = find_model(base_source.gsub(/!.+$/, ''))
|
15
15
|
if(base_source =~ /!(.+)@(.+)$/)
|
16
|
-
source.username
|
16
|
+
source.username = $1
|
17
17
|
source.address = $2
|
18
18
|
source.source = base_source
|
19
19
|
source.save_changes
|
@@ -21,7 +21,7 @@ module ModSpox
|
|
21
21
|
Models::NickChannel.find_or_create(:channel_id => target.pk, :nick_id => source.pk) if target.is_a?(ModSpox::Models::Channel)
|
22
22
|
return Messages::Incoming::Privmsg.new(string, source, target, message)
|
23
23
|
else
|
24
|
-
Logger.
|
24
|
+
Logger.warn('Failed to match PRIVMSG message')
|
25
25
|
return nil
|
26
26
|
end
|
27
27
|
end
|
@@ -11,6 +11,7 @@ module ModSpox
|
|
11
11
|
def process(string)
|
12
12
|
if(string =~ /#{RPL_TOPIC}.+?(\S+)\s:(.+)$/)
|
13
13
|
channel = find_model($1)
|
14
|
+
channel.update(:topic => $2)
|
14
15
|
return Messages::Incoming::Topic.new(string, channel, $2)
|
15
16
|
elsif(string =~ /#{RPL_NOTOPIC}.+?(\S+)\s:/)
|
16
17
|
channel = find_model($1)
|
@@ -21,7 +22,7 @@ module ModSpox
|
|
21
22
|
time = Time.at($3.to_i)
|
22
23
|
return Messages::Incoming::TopicInfo.new(string, channel, nick, time)
|
23
24
|
else
|
24
|
-
Logger.
|
25
|
+
Logger.warn('Failed to parse TOPIC type string')
|
25
26
|
return nil
|
26
27
|
end
|
27
28
|
end
|
@@ -16,7 +16,7 @@ module ModSpox
|
|
16
16
|
nick = $1
|
17
17
|
username = $2
|
18
18
|
hostname = $3
|
19
|
-
nick = Models::Nick.
|
19
|
+
nick = Models::Nick.locate(nick)
|
20
20
|
nick.botnick = true
|
21
21
|
nick.username = username
|
22
22
|
nick.address = hostname
|
@@ -24,11 +24,11 @@ module ModSpox
|
|
24
24
|
nick.save
|
25
25
|
return Messages::Incoming::Welcome.new(string, server, message, nick, username, hostname)
|
26
26
|
else
|
27
|
-
Logger.
|
27
|
+
Logger.warn('Failed to match user string in welcome message')
|
28
28
|
return nil
|
29
29
|
end
|
30
30
|
else
|
31
|
-
Logger.
|
31
|
+
Logger.warn('Failed to match welcome message')
|
32
32
|
return nil
|
33
33
|
end
|
34
34
|
end
|
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
['mod_spox/handlers/Handler', 'mod_spox/Monitors'].each{|f|require f}
|
2
|
+
|
2
3
|
module ModSpox
|
3
4
|
module Handlers
|
4
5
|
class Who < Handler
|
@@ -8,9 +9,8 @@ module ModSpox
|
|
8
9
|
@cache = Hash.new
|
9
10
|
@raw_cache = Hash.new
|
10
11
|
end
|
12
|
+
|
11
13
|
def process(string)
|
12
|
-
# :not.configured 352 mod_spox #foobar ~mod_spox 192.168.0.25 not.configured mod_spox H :0 mod_spox IRC bot
|
13
|
-
# :not.configured 352 mod_spox * ~mod_spox 192.168.0.25 not.configured mod_spox H :0 mod_spox IRC bot
|
14
14
|
if(string =~ /#{RPL_WHOREPLY}\s\S+\s(\S+|\*|\*\s\S+)\s(\S+)\s(\S+)\s(\S+)\s(\S+)\s(\S+)\s:(\d)\s(.+)$/)
|
15
15
|
# Items matched are as follows:
|
16
16
|
# 1: location
|
@@ -29,11 +29,12 @@ module ModSpox
|
|
29
29
|
nick.real_name = $8
|
30
30
|
nick.connected_to = $4
|
31
31
|
nick.away = info =~ /G/ ? true : false
|
32
|
-
nick.
|
32
|
+
nick.visible = true
|
33
|
+
nick.save_changes
|
33
34
|
key = location.nil? ? nick.nick : location
|
34
|
-
@cache[key] = Array.new unless @cache[
|
35
|
+
@cache[key] = Array.new unless @cache[key]
|
35
36
|
@cache[key] << nick
|
36
|
-
@raw_cache[key] = Array.new unless @raw_cache[
|
37
|
+
@raw_cache[key] = Array.new unless @raw_cache[key]
|
37
38
|
@raw_cache[key] << string
|
38
39
|
unless(location.nil?)
|
39
40
|
channel = find_model(location)
|
@@ -56,10 +57,11 @@ module ModSpox
|
|
56
57
|
@cache.delete(location)
|
57
58
|
return message
|
58
59
|
else
|
59
|
-
Logger.
|
60
|
+
Logger.warn('Failed to match RPL_WHO type message')
|
60
61
|
return nil
|
61
62
|
end
|
62
63
|
end
|
64
|
+
|
63
65
|
end
|
64
66
|
end
|
65
67
|
end
|
@@ -16,53 +16,66 @@ module ModSpox
|
|
16
16
|
|
17
17
|
def process(string)
|
18
18
|
if(string =~ /#{RPL_WHOISUSER}\s\S+\s(\S+)\s(\S+)\s(\S+)\s\*\s:(.+)$/)
|
19
|
+
key = $1
|
19
20
|
nick = find_model($1)
|
20
21
|
nick.username = $2
|
21
22
|
nick.address = $3
|
22
23
|
nick.real_name = $4
|
24
|
+
nick.save_changes
|
23
25
|
@cache[$1] = Messages::Incoming::Whois.new(nick)
|
24
26
|
@cache[$1].raw_push(string)
|
25
27
|
return nil
|
26
28
|
elsif(string =~ /#{RPL_WHOISCHANNELS}\s\S+\s(\S+)\s:(.+)$/)
|
27
29
|
nick = $1
|
30
|
+
@cache[nick] = Messages::Incoming::Whois.new(find_model(nick)) unless @cache[nick]
|
31
|
+
@cache[$1].raw_push(string)
|
28
32
|
$2.split(/\s/).each{|chan|
|
29
33
|
channel = find_model(chan.gsub(/^[@\+]/, ''))
|
30
34
|
@cache[nick].channels_push(channel)
|
31
35
|
if(chan[0].chr == '@')
|
32
|
-
Models::NickMode.find_or_create(:nick_id => @cache[nick].pk, :mode => 'o', :channel_id => channel.pk)
|
36
|
+
Models::NickMode.find_or_create(:nick_id => @cache[nick].nick.pk, :mode => 'o', :channel_id => channel.pk)
|
33
37
|
elsif(chan[0].chr == '+')
|
34
|
-
Models::NickMode.find_or_create(:nick_id => @cache[nick].pk, :mode => 'v', :channel_id => channel.pk)
|
38
|
+
Models::NickMode.find_or_create(:nick_id => @cache[nick].nick.pk, :mode => 'v', :channel_id => channel.pk)
|
35
39
|
else
|
36
40
|
Models::NickMode.filter(:nick_id => @cache[nick].nick.pk, :channel_id => channel.pk).each{|m| m.destroy}
|
37
41
|
end
|
38
42
|
}
|
39
|
-
@cache[$1].raw_push(string)
|
40
43
|
return nil
|
41
44
|
elsif(string =~ /#{RPL_WHOISSERVER}\s\S+\s(\S+)\s(\S+)\s:(.+)$/)
|
42
|
-
|
43
|
-
@cache[
|
45
|
+
nick = $1
|
46
|
+
@cache[nick] = Messages::Incoming::Whois.new(find_model(nick)) unless @cache[nick]
|
47
|
+
@cache[nick].nick.connected_to = $2
|
48
|
+
@cache[nick].raw_push(string)
|
44
49
|
return nil
|
45
50
|
elsif(string =~ /#{RPL_WHOISIDENTIFIED}\s\S+\s(\S+)\s/)
|
46
|
-
|
47
|
-
@cache[
|
51
|
+
nick = $1
|
52
|
+
@cache[nick] = Messages::Incoming::Whois.new(find_model(nick)) unless @cache[nick]
|
53
|
+
@cache[nick].nick.auth.services_identified = true
|
54
|
+
@cache[nick].raw_push(string)
|
48
55
|
return nil
|
49
56
|
elsif(string =~ /#{RPL_WHOISIDLE}\s\S+\s(\S+)\s(\d+)\s(\d+)\s:(.+?),(.+?)/)
|
50
|
-
|
51
|
-
@cache[
|
52
|
-
@cache[
|
57
|
+
nick = $1
|
58
|
+
@cache[nick] = Messages::Incoming::Whois.new(find_model(nick)) unless @cache[nick]
|
59
|
+
@cache[nick].nick.seconds_idle = $2.to_i
|
60
|
+
@cache[nick].nick.connected_at = Time.at($3.to_i)
|
61
|
+
@cache[nick].raw_push(string)
|
53
62
|
return nil
|
54
63
|
elsif(string =~ /#{RPL_WHOISOPERATOR}\s\S+\s(\S+)/)
|
55
|
-
|
64
|
+
nick = $1
|
65
|
+
@cache[nick] = Messages::Incoming::Whois.new(find_model(nick)) unless @cache[nick]
|
66
|
+
@cache[nick].raw_push(string)
|
56
67
|
return nil
|
57
68
|
elsif(string =~ /#{RPL_ENDOFWHOIS}\s\S+\s(\S+)\s:/)
|
58
|
-
|
59
|
-
|
69
|
+
nick = $1
|
70
|
+
@cache[nick] = Messages::Incoming::Whois.new(find_model(nick)) unless @cache[nick]
|
71
|
+
@cache[nick].raw_push(string)
|
72
|
+
message = @cache[nick]
|
60
73
|
message.lock
|
61
|
-
@cache[
|
62
|
-
@cache.delete(
|
74
|
+
@cache[nick].nick.save
|
75
|
+
@cache.delete(nick)
|
63
76
|
return message
|
64
77
|
else
|
65
|
-
Logger.
|
78
|
+
Logger.warn('Failed to parse WHOIS type reply')
|
66
79
|
return nil
|
67
80
|
end
|
68
81
|
end
|
@@ -10,7 +10,7 @@ module ModSpox
|
|
10
10
|
if(string =~ /:Your host is (\S+), running version (.+)$/)
|
11
11
|
return Messages::Incoming::YourHost.new(string, $1, $2)
|
12
12
|
else
|
13
|
-
Logger.
|
13
|
+
Logger.warn('Failed to match Your Host message')
|
14
14
|
return nil
|
15
15
|
end
|
16
16
|
end
|
@@ -3,23 +3,29 @@ module ModSpox
|
|
3
3
|
module Messages
|
4
4
|
module Incoming
|
5
5
|
class Privmsg < Message
|
6
|
-
|
6
|
+
|
7
7
|
# source of the message
|
8
8
|
attr_reader :source
|
9
9
|
# target of the message
|
10
10
|
attr_reader :target
|
11
|
-
#
|
12
|
-
attr_reader :
|
11
|
+
# message is CTCP
|
12
|
+
attr_reader :ctcp
|
13
|
+
# message CTCP type
|
14
|
+
attr_reader :ctcp_type
|
13
15
|
def initialize(raw, source, target, message)
|
14
16
|
super(raw)
|
15
17
|
@source = source
|
16
18
|
@target = target
|
17
|
-
|
18
|
-
|
19
|
-
|
19
|
+
@ctcp = false
|
20
|
+
@ctcp_type = nil
|
21
|
+
@action = false
|
22
|
+
if(@raw_content =~ /\x01(\S+)\s(.+)\x01/)
|
23
|
+
@ctcp = true
|
24
|
+
@ctcp_type = $1
|
25
|
+
@message = $2
|
26
|
+
@action = @ctcp_type.downcase == 'action'
|
20
27
|
else
|
21
28
|
@message = message
|
22
|
-
@action = false
|
23
29
|
end
|
24
30
|
botnick = Models::Nick.filter(:botnick => true).first
|
25
31
|
if(botnick)
|
@@ -28,43 +34,56 @@ module ModSpox
|
|
28
34
|
@addressed = false
|
29
35
|
end
|
30
36
|
end
|
31
|
-
|
37
|
+
|
32
38
|
# Is message addressing the bot
|
33
39
|
def addressed?
|
34
40
|
return @addressed || is_private?
|
35
41
|
end
|
36
|
-
|
42
|
+
|
37
43
|
# Is this is private message
|
38
44
|
def is_private?
|
39
|
-
return @target.is_a?(Models::Nick)
|
45
|
+
return @target.is_a?(Models::Nick) || @target.is_a?(String)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Is this a DCC message
|
49
|
+
def is_dcc?
|
50
|
+
return @target.is_a?(String)
|
40
51
|
end
|
41
|
-
|
52
|
+
|
42
53
|
# Is this a public message
|
43
54
|
def is_public?
|
44
55
|
return @target.is_a?(Models::Channel)
|
45
56
|
end
|
46
|
-
|
57
|
+
|
47
58
|
# Does the message contain colors
|
48
59
|
def is_colored?
|
49
60
|
return @message =~ /\cC\d\d?(?:,\d\d?)?/
|
50
61
|
end
|
51
|
-
|
62
|
+
|
52
63
|
# Message with coloring stripped
|
53
64
|
def message_nocolor
|
54
|
-
return @message.gsub(/\cC\d\d?(?:,\d\d?)?/, '')
|
65
|
+
return @message.gsub(/\cC\d\d?(?:,\d\d?)?/, '').tr("\x00-\x1f", '')
|
55
66
|
end
|
56
|
-
|
67
|
+
|
68
|
+
# the message sent
|
69
|
+
def message(color=false)
|
70
|
+
return color ? @message : message_nocolor
|
71
|
+
end
|
72
|
+
|
57
73
|
# Is this message an action message
|
58
74
|
def is_action?
|
59
75
|
@action
|
60
76
|
end
|
61
|
-
|
77
|
+
|
78
|
+
def is_ctcp?
|
79
|
+
@ctcp
|
80
|
+
end
|
81
|
+
|
62
82
|
# Convinence method for replying to the correct place
|
63
83
|
def replyto
|
64
|
-
return @
|
65
|
-
return @target if is_public?
|
84
|
+
return is_public? || is_dcc? ? @target : @source
|
66
85
|
end
|
67
|
-
|
86
|
+
|
68
87
|
end
|
69
88
|
end
|
70
89
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module ModSpox
|
2
|
+
module Messages
|
3
|
+
module Internal
|
4
|
+
class DCCSocket
|
5
|
+
# ID of the contained socket
|
6
|
+
attr_reader :socket_id
|
7
|
+
# Models::Nick this socket is connected to
|
8
|
+
attr_reader :nick
|
9
|
+
# socket
|
10
|
+
attr_reader :socket
|
11
|
+
def initialize(id, nick, socket)
|
12
|
+
@socket_id = id
|
13
|
+
@nick = nick
|
14
|
+
@socket = socket
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|