Here is the script which I have currently made in accordance with the bind splt and rejn mechanisms. I am not sure if it will work or not, since haven't tested it, because netsplits don't occur when you want them too obviously.
So I'm just pasting the code and if anyone can follow up, have a look and browse through to let me know would this work or not. Once more I'll give info:
This script is basically detects fast mass joining hosts from bots, which have more than 1 host and removes all bots which joined the channel.
Code: Select all
set mjointrigger "3:5"
bind join - "*" mass:join:chan
proc mass:join:chan {nick uhost hand chan} {
global botnick mjointrigger joinflood kickno net_split
if {[isbotnick $nick] || [info exists net_split]} { return 0 }
set host "*!*@[lindex [split [maskhost $uhost] @] 1]"
set user [string tolower $chan]
if {[string match -nocase "#*" $chan]} {
if {![info exists joinflood($user)]} {
set joinflood($user) 0
}
utimer [lindex [split $mjointrigger :] 1] [list mass:join:list $user]
if {[incr joinflood($user)] >= [lindex [split $mjointrigger :] 0]} {
if {[botisop $chan]} {
putquick "MODE $chan +b $host" -next
set clonenicks [list]; set clonenum 0
foreach person [chanlist $chan] {
if {[string match -nocase *$host* "$person![getchanhost $person $chan]"] && ![isop $person $chan] && ![isvoice $person $chan]} {
incr clonenum; lappend clonenicks $person:$clonenum
}
}
foreach clone $clonenicks {
putquick "KICK $chan [lindex [split $clone :] 0] :0,1 Clone Mass Join Flood 12,0 - You 2joined with6 [lindex [split $mjointrigger :] 0] clients 2or more 12in less than6 [lindex [split $mjointrigger :] 1] secs 12from the host 6*!*@[lindex [split $uhost @] 1] 12- (Clone2 #[lindex [split $clone :] 1] 12of2 #[llength $clonenicks]12)" -next
}
unset clonenicks; unset clonenum
timer 60 [list putquick "MODE $chan -b $host"]
}
if {[info exists joinflood($user)]} { unset joinflood($user) }
}
}
}
proc mass:join:list {user} {
global joinflood
if {[info exists joinflood($user)]} { incr joinflood($user) -1 }
}
bind splt "*" - mass:join:split
bind rejn "*" - mass:join:rejoin
proc mass:join:split {nick host hand chan} {
global net_split
if {[info exists net_split]} {
return 0
} elseif {![info exists net_split] && [onchansplit $nick $chan]} {
set net_split 1
}
}
proc mass:join:rejoin {nick host hand chan} {
global net_split
if {[info exists net_split]} {
utimer 5 [list "unset net_split"]
}
}
Moreover, I searched the forum for rejn and splt and found Wcc gave a small snipplet for detecting netsplits. It basically uses RAW with keyword QUIT. I think bind splt would be more relevant to detect netsplits than just use raw.
Code: Select all
bind raw - QUIT raw:netsplit
proc raw:netsplit {from keyword text} {
if {![regexp "(.*) (.*)" $text match server1 server2]} { return 0 }
foreach chan [channels] {
putserv "PRIVMSG $chan :Netsplit detected: $server1 just split from $server2"
}
return 1
}
Here is what I came up with to detect users which have split:
Code: Select all
bind raw - QUIT raw:netsplit
proc raw:netsplit {from keyword text} {
global detect_netsplit
if {![info exists detect_netsplit]} {
if {[string equal "2" [llength $text]] && [regexp {^(.*) (.*)$} $text] && [string is lower [string map {"." "" " " ""} $text]] && [string equal "0" [regexp -all {[0-9]} $text]] && ([regexp -all {\.} [lindex $text 0]] > 3) && ([regexp -all {\.} [lindex $text 1]] > 3)} {
foreach chan [channels] {
putserv "PRIVMSG $chan :Netsplit detected: $server1 just split from $server2"
if {![info exists detect_netsplit]} { set detect_netsplit 1 }
utimer 10 [list "unset detect_netsplit"]; return 1
}
}
}
}
Also is it NECESSARY to include a bind on SIGN for the nicks which didn't join back from the netsplit on REJN (users which quit IRC after the servers split). And how would I implement that?
Example of a netsplit rejoin:
Code: Select all
* PapaJaHaT- (one@64.18.135.100) has joined #chatzone
* mariahilal (tin@208.98.24.223) has joined #chatzone
* Uk_Dude (vdn@[censored].this.is.an.all-out-war.net) has joined #chatzone
* Toyong^Hasibuan (Toyong@208.98.12.236) has joined #chatzone
* }-|-{ (united@im.coming.back.home.kg) has joined #chatzone
* Ramoo (sam@Harami.org) has joined #chatzone
* brain.hub.eu.dal.net sets mode: +ovo The^Lovely^Slut Forecast[V23] DenDen
* brain.hub.eu.dal.net sets mode: +b *!*@60.53.52.62
* Hong24 (~Hong24_C_@37.248.208.218.klj02-home.tm.net.my) has joined #chatzone
When server sets channel modes, the channel rejoin from the netsplit is complete. Can I also do something like using bind MODE instead of bind REJN, so that I don't need to add a delay to unset the global var net_split. Coz bind rejn will detect the first user joining and for channels with big user counts, lots of people will rejoin, so I have to make the script run after everyone has rejoined from the netsplit.
Code: Select all
bind mode - "*" server:mode:on:rejoin
proc server:mode:on:rejoin {nick uhost hand chan mode arg} {
global net_split
if {([regexp -all {\.} $nick] > 3) && [regexp {o|v|b} $arg]} {
#which will match the nick as the server setting chanmode
#the only time server sets mode on DALnet is after netsplit rejoins
if {[info exists net_split]} {
unset net_split
}
}
}