mod_spox 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +31 -1
- data/LICENSE +674 -0
- data/README.rdoc +73 -0
- data/bin/mod_spox +28 -28
- data/data/mod_spox/extras/AOLSpeak.rb +2 -3
- data/data/mod_spox/extras/AutoKick.rb +10 -23
- data/data/mod_spox/extras/AutoMode.rb +12 -23
- data/data/mod_spox/extras/Bash.rb +55 -0
- data/data/mod_spox/extras/Bouncer.rb +85 -57
- data/data/mod_spox/extras/Bullshit.rb +1 -1
- data/data/mod_spox/extras/Bytes.rb +1 -2
- data/data/mod_spox/extras/Confess.rb +27 -29
- data/data/mod_spox/extras/DCC.rb +11 -20
- data/data/mod_spox/extras/DevWatch.rb +21 -23
- data/data/mod_spox/extras/DownForEveryoneOrJustMe.rb +47 -0
- data/data/mod_spox/extras/EightBall.rb +1 -1
- data/data/mod_spox/extras/FML.rb +35 -0
- data/data/mod_spox/extras/Headers.rb +31 -50
- data/data/mod_spox/extras/Karma.rb +81 -29
- data/data/mod_spox/extras/Logger.rb +2 -2
- data/data/mod_spox/extras/LolSpeak.rb +1 -2
- data/data/mod_spox/extras/PhpCli.rb +138 -8
- data/data/mod_spox/extras/PhpFuncLookup.rb +20 -23
- data/data/mod_spox/extras/Pinger.rb +1 -1
- data/data/mod_spox/extras/Quotes.rb +8 -10
- data/data/mod_spox/extras/RegexTracker.rb +2 -4
- data/data/mod_spox/extras/Roulette.rb +20 -27
- data/data/mod_spox/extras/RubyCli.rb +93 -0
- data/data/mod_spox/extras/Search.rb +17 -3
- data/data/mod_spox/extras/Seen.rb +150 -0
- data/data/mod_spox/extras/SlashdotHeadlineGenerator.rb +500 -0
- data/data/mod_spox/extras/Talk.rb +2 -4
- data/data/mod_spox/extras/Topten.rb +10 -12
- data/data/mod_spox/extras/TracTicket.rb +3 -5
- data/data/mod_spox/extras/Translate.rb +20 -22
- data/data/mod_spox/extras/Twitter.rb +118 -33
- data/data/mod_spox/extras/UrbanDictionary.rb +8 -17
- data/data/mod_spox/extras/Weather.rb +1 -2
- data/data/mod_spox/plugins/Authenticator.rb +93 -98
- data/data/mod_spox/plugins/Banner.rb +26 -56
- data/data/mod_spox/plugins/Helper.rb +5 -6
- data/data/mod_spox/plugins/Initializer.rb +4 -14
- data/data/mod_spox/plugins/Joiner.rb +1 -1
- data/data/mod_spox/plugins/Nicker.rb +13 -0
- data/data/mod_spox/plugins/Parter.rb +2 -2
- data/data/mod_spox/plugins/Permissions.rb +60 -0
- data/data/mod_spox/plugins/PluginLoader.rb +7 -12
- data/data/mod_spox/plugins/Ponger.rb +51 -0
- data/data/mod_spox/plugins/Quitter.rb +1 -2
- data/data/mod_spox/plugins/Servers.rb +57 -0
- data/data/mod_spox/plugins/Status.rb +3 -2
- data/data/mod_spox/plugins/Triggers.rb +9 -9
- data/lib/mod_spox/Bot.rb +109 -33
- data/lib/mod_spox/BotConfig.rb +2 -2
- data/lib/mod_spox/ConfigurationWizard.rb +12 -12
- data/lib/mod_spox/Database.rb +1 -4
- data/lib/mod_spox/Exceptions.rb +26 -0
- data/lib/mod_spox/Helpers.rb +29 -68
- data/lib/mod_spox/Loader.rb +23 -24
- data/lib/mod_spox/Logger.rb +19 -17
- data/lib/mod_spox/MessageFactory.rb +50 -24
- data/lib/mod_spox/Pipeline.rb +21 -7
- data/lib/mod_spox/Plugin.rb +27 -3
- data/lib/mod_spox/PluginManager.rb +28 -15
- data/lib/mod_spox/PriorityQueue.rb +69 -0
- data/lib/mod_spox/Socket.rb +93 -51
- data/lib/mod_spox/Sockets.rb +76 -63
- data/lib/mod_spox/Timer.rb +21 -141
- data/lib/mod_spox/Version.rb +14 -0
- data/lib/mod_spox/handlers/BadNick.rb +1 -1
- data/lib/mod_spox/handlers/Bounce.rb +5 -5
- data/lib/mod_spox/handlers/Created.rb +13 -5
- data/lib/mod_spox/handlers/Handler.rb +12 -3
- data/lib/mod_spox/handlers/Invite.rb +14 -8
- data/lib/mod_spox/handlers/Join.rb +24 -20
- data/lib/mod_spox/handlers/Kick.rb +22 -13
- data/lib/mod_spox/handlers/Mode.rb +42 -36
- data/lib/mod_spox/handlers/Motd.rb +4 -0
- data/lib/mod_spox/handlers/Names.rb +66 -39
- data/lib/mod_spox/handlers/Nick.rb +20 -14
- data/lib/mod_spox/handlers/Part.rb +25 -8
- data/lib/mod_spox/handlers/Ping.rb +11 -5
- data/lib/mod_spox/handlers/Pong.rb +9 -5
- data/lib/mod_spox/handlers/Privmsg.rb +25 -17
- data/lib/mod_spox/handlers/Quit.rb +13 -8
- data/lib/mod_spox/handlers/Topic.rb +4 -0
- data/lib/mod_spox/handlers/Welcome.rb +16 -24
- data/lib/mod_spox/handlers/Who.rb +64 -48
- data/lib/mod_spox/handlers/Whois.rb +92 -60
- data/lib/mod_spox/messages/incoming/Nick.rb +2 -2
- data/lib/mod_spox/messages/incoming/Privmsg.rb +1 -1
- data/lib/mod_spox/messages/incoming/Whois.rb +1 -0
- data/lib/mod_spox/messages/internal/EstablishConnection.rb +1 -1
- 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/UnqueueSocket.rb +8 -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 +16 -46
- data/lib/mod_spox/models/AuthMask.rb +13 -0
- data/lib/mod_spox/models/Channel.rb +46 -27
- data/lib/mod_spox/models/Config.rb +10 -19
- data/lib/mod_spox/models/Group.rb +20 -8
- data/lib/mod_spox/models/Models.rb +1 -1
- data/lib/mod_spox/models/Nick.rb +105 -113
- data/lib/mod_spox/models/NickMode.rb +23 -9
- data/lib/mod_spox/models/Server.rb +12 -1
- data/lib/mod_spox/models/Setting.rb +12 -16
- data/lib/mod_spox/models/Signature.rb +28 -8
- 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 +34 -0
- data/tests/models/tc_Channel.rb +52 -0
- data/tests/models/tc_Config.rb +19 -0
- data/tests/models/tc_Nick.rb +142 -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 +4 -0
- metadata +284 -212
- data/README +0 -36
- data/lib/mod_spox/Cache.rb +0 -57
- data/lib/mod_spox/Monitors.rb +0 -84
- data/lib/mod_spox/Pool.rb +0 -164
- data/lib/mod_spox/models/AuthGroup.rb +0 -16
- data/lib/mod_spox/models/ChannelMode.rb +0 -14
- data/lib/mod_spox/models/NickChannel.rb +0 -45
- data/lib/mod_spox/models/NickGroup.rb +0 -16
@@ -1,16 +1,24 @@
|
|
1
1
|
require 'mod_spox/handlers/Handler'
|
2
|
+
require 'time'
|
2
3
|
module ModSpox
|
3
4
|
module Handlers
|
4
5
|
class Created < Handler
|
5
6
|
def initialize(handlers)
|
6
7
|
handlers[RPL_CREATED] = self
|
7
8
|
end
|
9
|
+
# :not.configured 003 spox :This server was created Tue Mar 24 2009 at 15:42:36 PDT'
|
8
10
|
def process(string)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
string = string.dup
|
12
|
+
begin
|
13
|
+
orig = string.dup
|
14
|
+
2.times{string.slice!(0..string.index(':'))}
|
15
|
+
4.times{string.slice!(0..string.index(' '))}
|
16
|
+
time = Time.parse(string)
|
17
|
+
time = nil if Time.now == time
|
18
|
+
return time.nil? ? nil : Messages::Incoming::Created.new(orig, time)
|
19
|
+
rescue Object => boom
|
20
|
+
Logger.error("Failed to parse RPL_CREATED message: #{orig}")
|
21
|
+
raise boom
|
14
22
|
end
|
15
23
|
end
|
16
24
|
end
|
@@ -1,12 +1,19 @@
|
|
1
1
|
require 'mod_spox/rfc2812'
|
2
|
+
require 'mod_spox/Helpers'
|
2
3
|
module ModSpox
|
3
4
|
module Handlers
|
4
5
|
|
5
6
|
class Handler
|
6
|
-
|
7
|
+
|
8
|
+
# handlers:: array of handlers
|
9
|
+
# initialize handler and add self to available
|
10
|
+
# handlers
|
7
11
|
def initialize(handlers)
|
12
|
+
raise Exceptions::NotImplemented.new('Method has not been implemented')
|
8
13
|
end
|
9
|
-
|
14
|
+
|
15
|
+
# data:: string of data
|
16
|
+
# Process the string and create the proper object
|
10
17
|
def process(data)
|
11
18
|
raise Exceptions::NotImplemented.new('Method has not been implemented')
|
12
19
|
end
|
@@ -18,7 +25,9 @@ module ModSpox
|
|
18
25
|
end
|
19
26
|
|
20
27
|
protected
|
21
|
-
|
28
|
+
|
29
|
+
# deprecated. here basically so old handlers
|
30
|
+
# don't break
|
22
31
|
def find_model(string)
|
23
32
|
Helpers.find_model(string)
|
24
33
|
end
|
@@ -5,15 +5,21 @@ module ModSpox
|
|
5
5
|
def initialize(handlers)
|
6
6
|
handlers[:INVITE] = self
|
7
7
|
end
|
8
|
+
# :spax!~spox@host INVITE spox :#m
|
8
9
|
def process(string)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
orig = string.dup
|
11
|
+
string = string.dup
|
12
|
+
begin
|
13
|
+
string.slice!(0)
|
14
|
+
source = find_model(string.slice!(0..string.index('!')-1))
|
15
|
+
2.times{ string.slice!(0..string.index(' ')) }
|
16
|
+
target = find_model(string.slice!(0..string.index(' ')-1))
|
17
|
+
string.slice!(0..string.index(':'))
|
18
|
+
channel = find_model(string.strip)
|
19
|
+
return Messages::Incoming::Invite.new(orig, source, target, channel)
|
20
|
+
rescue Object => boom
|
21
|
+
Logger.error("Failed to parse INVITE message: #{orig}")
|
22
|
+
raise boom
|
17
23
|
end
|
18
24
|
end
|
19
25
|
end
|
@@ -5,27 +5,31 @@ module ModSpox
|
|
5
5
|
def initialize(handlers)
|
6
6
|
handlers[:JOIN] = self
|
7
7
|
end
|
8
|
+
|
9
|
+
# :mod_spox!~mod_spox@host JOIN :#m
|
10
|
+
|
8
11
|
def process(string)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
12
|
+
orig = string.dup
|
13
|
+
string = string.dup
|
14
|
+
begin
|
15
|
+
string.slice!(0)
|
16
|
+
source = string.slice!(0..string.index(' ')-1)
|
17
|
+
string.slice!(0..string.index(':'))
|
18
|
+
channel = find_model(string.strip)
|
19
|
+
nick = find_model(source.slice(0..source.index('!')-1))
|
20
|
+
nick.source = source.dup
|
21
|
+
source.slice!(0..source.index('!'))
|
22
|
+
nick.username = source.slice!(0..source.index('@')-1)
|
23
|
+
source.slice!(0)
|
24
|
+
nick.address = source.slice!(0..source.size)
|
25
|
+
nick.visible = true
|
26
|
+
nick.save_changes
|
27
|
+
channel.add_nick(nick)
|
28
|
+
channel.save
|
29
|
+
return Messages::Incoming::Join.new(orig, channel, nick)
|
30
|
+
rescue Object => boom
|
31
|
+
Logger.warn("Failed to parse JOIN message: #{orig}")
|
32
|
+
raise boom
|
29
33
|
end
|
30
34
|
end
|
31
35
|
end
|
@@ -5,20 +5,29 @@ module ModSpox
|
|
5
5
|
def initialize(handlers)
|
6
6
|
handlers[:KICK] = self
|
7
7
|
end
|
8
|
+
# :spax!~spox@host KICK #m spox :foo
|
8
9
|
def process(string)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
channel =
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
10
|
+
orig = string.dup
|
11
|
+
string = string.dup
|
12
|
+
begin
|
13
|
+
string.slice!(0)
|
14
|
+
source = string.slice!(0..string.index(' ')-1)
|
15
|
+
2.times{string.slice!(0..string.index(' '))}
|
16
|
+
channel = string.slice!(0..string.index(' ')-1)
|
17
|
+
string.slice!(0)
|
18
|
+
kickee = string.slice!(0..string.index(' ')-1)
|
19
|
+
string.slice!(0..string.index(':'))
|
20
|
+
kicker = find_model(source[0..source.index('!')-1])
|
21
|
+
channel = find_model(channel)
|
22
|
+
kickee = find_model(kickee)
|
23
|
+
channel.remove_nick(kickee)
|
24
|
+
kickee.visible = false if kickee.channels.empty?
|
25
|
+
kickee.save_changes
|
26
|
+
channel.save_changes
|
27
|
+
return Messages::Incoming::Kick.new(orig, channel, kicker, kickee, string)
|
28
|
+
rescue Object => boom
|
29
|
+
Logger.warn("Failed to parse KICK message: #{orig}")
|
30
|
+
raise boom
|
22
31
|
end
|
23
32
|
end
|
24
33
|
end
|
@@ -5,50 +5,56 @@ module ModSpox
|
|
5
5
|
def initialize(handlers)
|
6
6
|
handlers[:MODE] = self
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
|
+
# :spax!~spox@host MODE #m +o spax
|
10
|
+
# :spax MODE spax :+iw
|
9
11
|
def process(string)
|
12
|
+
orig = string.dup
|
13
|
+
string = string.dup
|
10
14
|
begin
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
string.slice!(0)
|
16
|
+
if(string.index('!').nil?) # looks like self mode
|
17
|
+
source = find_model(string.slice!(0..string.index(' ')-1))
|
18
|
+
2.times{string.slice!(0..string.index(' '))}
|
19
|
+
target = find_model(string.slice!(0..string.index(' ')-1))
|
20
|
+
string.slice!(0..string.index(':'))
|
21
|
+
action = string.slice!(0)
|
22
|
+
action == '+' ? target.set_mode(string) : target.unset_mode(string)
|
23
|
+
return Messages::Incoming::Mode.new(orig, "#{action}#{string}", source, target, nil)
|
24
|
+
else
|
25
|
+
source = find_model(string.slice!(0..string.index('!')-1))
|
26
|
+
2.times{string.slice!(0..string.index(' '))}
|
27
|
+
channel = find_model(string.slice!(0..string.index(' ')-1))
|
28
|
+
string.slice!(0)
|
29
|
+
modes = string.index(' ').nil? ? string.dup : string.slice!(0..string.index(' ')-1)
|
30
|
+
string[0] == ' ' ? string.slice!(0) : string = ''
|
31
|
+
action = modes.slice!(0)
|
32
|
+
if(string.size > 0) #nick modes
|
33
|
+
nicks = []
|
34
|
+
string.split.each do |n|
|
35
|
+
ni = find_model(n)
|
36
|
+
ni.add_channel(channel)
|
37
|
+
nicks << ni
|
38
|
+
end
|
39
|
+
i = 0
|
40
|
+
modes.each_char do |m|
|
41
|
+
nm = Models::NickMode.find_or_create(:channel_id => channel.pk, :nick_id => nicks[i].pk)
|
42
|
+
action == '+' ? nm.set_mode(m) : nm.unset_mode(m)
|
43
|
+
i += 1
|
20
44
|
end
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
source = find_model($1)
|
27
|
-
channel = find_model($2)
|
28
|
-
full_modes = $3
|
29
|
-
targets = $4
|
30
|
-
action = full_modes[0].chr
|
31
|
-
nicks = Array.new
|
32
|
-
full_modes.sub(/^./, '').length.times do |i|
|
33
|
-
nick = find_model(targets.scan(/\S+/)[i])
|
34
|
-
nicks << nick
|
35
|
-
if(nick.is_a?(Models::Nick))
|
36
|
-
mode = full_modes[i + 1].chr
|
37
|
-
Models::NickMode.find_or_create(:channel_id => channel.pk, :nick_id => nick.pk, :mode => mode) if action == '+'
|
38
|
-
if(action == '-' && model = Models::NickMode.filter(:channel_id => channel.pk, :nick_id => nick.pk, :mode => mode).first)
|
39
|
-
model.destroy
|
40
|
-
end
|
45
|
+
nicks = nicks[0] if nicks.size == 1
|
46
|
+
return Messages::Incoming::Mode.new(orig, "#{action}#{modes}", source, nicks, channel)
|
47
|
+
else #channel modes
|
48
|
+
modes.each_char do |m|
|
49
|
+
action == '+' ? channel.set_mode(m) : channel.unset_mode(c)
|
41
50
|
end
|
51
|
+
return Messages::Incoming::Mode.new(orig, "#{action}#{modes}", source, nil, channel)
|
42
52
|
end
|
43
|
-
nicks = nicks[0] if nicks.size == 1
|
44
|
-
return Messages::Incoming::Mode.new(string, full_modes, source, nicks, channel)
|
45
|
-
else
|
46
|
-
Logger.warn('Failed to parse MODE message')
|
47
53
|
end
|
48
54
|
rescue Object => boom
|
49
|
-
Logger.warn("Failed to
|
55
|
+
Logger.warn("Failed to parse MODE message: #{orig}")
|
56
|
+
raise boom
|
50
57
|
end
|
51
|
-
return nil
|
52
58
|
end
|
53
59
|
end
|
54
60
|
end
|
@@ -15,10 +15,14 @@ module ModSpox
|
|
15
15
|
@raw[$1] = [string]
|
16
16
|
return nil
|
17
17
|
elsif(string =~ /^:(\S+) #{RPL_MOTD.to_s}.*?:-\s?(.+)$/)
|
18
|
+
@motds[$1] ||= []
|
19
|
+
@raw[$1] ||= []
|
18
20
|
@motds[$1] << $2
|
19
21
|
@raw[$1] << string
|
20
22
|
return nil
|
21
23
|
elsif(string =~ /^:(\S+) #{RPL_ENDOFMOTD.to_s}/)
|
24
|
+
@raw[$1] ||= []
|
25
|
+
@motds[$1] ||= []
|
22
26
|
@raw[$1] << string
|
23
27
|
message = Messages::Incoming::Motd.new(@raw[$1].join("\n"), @motds[$1].join("\n"), $1)
|
24
28
|
@motds.delete($1)
|
@@ -8,49 +8,76 @@ module ModSpox
|
|
8
8
|
@names = Hash.new
|
9
9
|
@raw = Hash.new
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def process(string)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
if(
|
19
|
-
|
13
|
+
orig = string.dup
|
14
|
+
string = string.dup
|
15
|
+
begin
|
16
|
+
string.slice!(0..string.index(' '))
|
17
|
+
type = string.slice!(0..string.index(' ')-1)
|
18
|
+
if(type == RPL_NAMREPLY)
|
19
|
+
3.times{ string.slice!(0..string.index(' ')) }
|
20
|
+
chan = string.slice!(0..string.index(' ')-1)
|
21
|
+
string.slice!(0..string.index(':'))
|
22
|
+
@names[chan] = Array.new unless @names[chan]
|
23
|
+
@raw[chan] = Array.new unless @raw[chan]
|
24
|
+
@raw[chan] << orig
|
25
|
+
@names[chan] += string.split
|
26
|
+
return nil
|
20
27
|
else
|
21
|
-
|
28
|
+
2.times{ string.slice!(0..string.index(' ')) }
|
29
|
+
chan = string.slice!(0..string.index(' ')-1)
|
30
|
+
channel = find_model(chan)
|
31
|
+
@raw[chan] << orig if @raw[chan]
|
32
|
+
nicks = Array.new
|
33
|
+
ops = Array.new
|
34
|
+
voice = Array.new
|
35
|
+
raw = @raw[chan].dup if @raw[chan]
|
36
|
+
@names[chan] = [] unless @names[chan].is_a?(Array)
|
37
|
+
@names[chan].each do |n|
|
38
|
+
nick = Models::Nick.find_or_create(:nick => n.gsub(/^[@+]/, ''))
|
39
|
+
nick.visible = true
|
40
|
+
nicks << nick
|
41
|
+
if(n[0] == '@')
|
42
|
+
ops << nick
|
43
|
+
m = Models::NickMode.find_or_create(:nick_id => nick.pk, :channel_id => channel.pk)
|
44
|
+
m.set_mode('o')
|
45
|
+
elsif(n[0] == '+')
|
46
|
+
voice << nick
|
47
|
+
m = Models::NickMode.find_or_create(:nick_id => nick.pk, :channel_id => channel.pk)
|
48
|
+
m.set_mode('v')
|
49
|
+
else
|
50
|
+
m = Models::NickMode.find_or_create(:nick_id => nick.pk, :channel_id => channel.pk)
|
51
|
+
m.clear_modes
|
52
|
+
end
|
53
|
+
nick.add_channel(channel)
|
54
|
+
nick.refresh
|
55
|
+
channel.refresh
|
56
|
+
end
|
57
|
+
check_visibility(nicks, channel)
|
58
|
+
@names.delete(chan)
|
59
|
+
@raw.delete(chan)
|
60
|
+
return Messages::Incoming::Names.new(raw, channel, nicks, ops, voice)
|
22
61
|
end
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
voice << nick
|
41
|
-
Models::NickMode.find_or_create(:nick_id => nick.pk, :channel_id => channel.pk, :mode => 'v')
|
42
|
-
else
|
43
|
-
Models::NickMode.filter(:nick_id => nick.pk, :channel_id => channel.pk).each{|m|
|
44
|
-
m.destroy
|
45
|
-
}
|
62
|
+
rescue Object => boom
|
63
|
+
Logger.error("Failed to parse NAMES message: #{orig}")
|
64
|
+
raise boom
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# nicks:: list of nicks in channel
|
69
|
+
# channel:: channel nicks are in
|
70
|
+
# Remove visibility from any nicks that aren't really
|
71
|
+
# in the channel
|
72
|
+
def check_visibility(nicks, channel)
|
73
|
+
channel.nicks.each do |nick|
|
74
|
+
unless(nicks.include?(nick))
|
75
|
+
channel.remove_nick(nick)
|
76
|
+
unless(nick.botnick)
|
77
|
+
nick.refresh
|
78
|
+
nick.update(:visible => false) if (Models::Nick.filter(:botnick => true).first.channels & nick.channels).empty?
|
46
79
|
end
|
47
|
-
|
48
|
-
}
|
49
|
-
@names.delete(chan)
|
50
|
-
@raw.delete(chan)
|
51
|
-
return Messages::Incoming::Names.new(raw, channel, nicks, ops, voice)
|
52
|
-
else
|
53
|
-
return nil
|
80
|
+
end
|
54
81
|
end
|
55
82
|
end
|
56
83
|
end
|
@@ -5,16 +5,23 @@ module ModSpox
|
|
5
5
|
def initialize(handlers)
|
6
6
|
handlers[:NICK] = self
|
7
7
|
end
|
8
|
+
# :spox!~spox@some.random.host NICK :flock_of_deer
|
8
9
|
def process(string)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
orig = string.dup
|
11
|
+
string = string.dup
|
12
|
+
begin
|
13
|
+
string.slice!(0)
|
14
|
+
old_nick = find_model(string.slice!(0..string.index('!')-1))
|
15
|
+
string.slice!(0..string.index(':'))
|
16
|
+
new_nick = find_model(string)
|
13
17
|
old_nick.channels.each do |channel|
|
14
|
-
|
15
|
-
|
16
|
-
Models::NickMode.
|
17
|
-
|
18
|
+
channel.remove_nick(old_nick)
|
19
|
+
channel.add_nick(new_nick)
|
20
|
+
m = Models::NickMode.filter(:nick_id => old_nick.pk, :channel_id => channel.pk).first
|
21
|
+
if(m)
|
22
|
+
m.nick_id = new_nick.pk
|
23
|
+
m.save
|
24
|
+
end
|
18
25
|
end
|
19
26
|
new_nick.username = old_nick.username
|
20
27
|
new_nick.address = old_nick.address
|
@@ -23,19 +30,18 @@ module ModSpox
|
|
23
30
|
new_nick.away = old_nick.away
|
24
31
|
new_nick.visible = true
|
25
32
|
new_nick.save_changes
|
26
|
-
Models::Nick.transfer_groups(old_nick, new_nick)
|
27
33
|
old_nick.visible = false
|
28
|
-
old_nick.
|
34
|
+
old_nick.remove_all_channels
|
29
35
|
if(old_nick.botnick == true)
|
30
36
|
old_nick.botnick = false
|
31
37
|
new_nick.botnick = true
|
32
38
|
end
|
33
39
|
new_nick.save
|
34
40
|
old_nick.save
|
35
|
-
return Messages::Incoming::Nick.new(
|
36
|
-
|
37
|
-
Logger.
|
38
|
-
|
41
|
+
return Messages::Incoming::Nick.new(orig, old_nick, new_nick)
|
42
|
+
rescue Object => boom
|
43
|
+
Logger.error("Failed to parse NICK message: #{orig}")
|
44
|
+
raise boom
|
39
45
|
end
|
40
46
|
end
|
41
47
|
end
|