This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

help in tcl netsplit-- solved

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

help in tcl netsplit-- solved

Post by Arnold_X-P »

this is a remote very good one and try to make it work almost similar to an already made tcl:

Code: Select all

on 1:QUIT: {
  if (((.net isin $1) || (.com isin $1) || (.org isin $1) || (.edu isin $1) || (irc.* isin $1) || (*.irc isin $1)) && ((.net isin $2) || (.com isin $2) || (.org isin $2) || (.edu isin $2) || (irc. isin $2) || (.irc isin $2)) && (($3- == $null) && (/ !isin $1-))) {  
    if ($1- == %split) { halt }
    .set %server1 $gettok($1,1,46) | .set %server2 $gettok($2,1,46)
    echo -se  $+ $hl $+ Netsplit detected14 %server1 y14 %server2 $+  $ztime
    ame 9,1 S15plit 9Netsplit detected in 9«15  $+ %server1 $+ 9» «15 $+ %server2 $+ 
    set %split $1-
    .timer 1 5 unset %split
    halt
  }
}

Code: Select all

### codex tcl for awyeah ##
# please someone who helps me with the tcl to be similar to the remote mirc that this one arrives ##

#########################################################################
### Please do not edit anything below this line even if you know tcl! ###
#########################################################################

set netsplit(auth) "\x61\x77\x79\x65\x61\x68"
set netsplit(ver) "v3.75.b"

bind raw - QUIT netsplit:detect

proc netsplit:detect {from key arg} {
 global netsplit
 if {[info exists netsplit(detected)]} { return 0 }
 set arg [string trimleft [stripcodes bcruag [split $arg]] :]
 if {[string equal "Quit:" [string range $arg 0 4]]} { return 0 }
 if {![regexp {^([[:alnum:][:punct:]]+)[[:space:]]([[:alnum:][:punct:]]+)$} $arg _arg server1 server2]} { return 0 }
 
 if {[string equal -nocase "*.net|*.com|*.org|*.edu|*.split|irc.*|*.irc" [string range $server1 end-7 end]] && [string equal -nocase "*.net|*.com|*.org|*.edu|*.split|irc.*|*.irc" [string range $server2 end-7 end]]} {
  foreach chan [channels] {
   puthelp "NOTICE $chan :Netsplit detected: «\002$server1\002» just split from «\002$server2\002»" -next
  }
  set netsplit(detected) 1
  utimer 25 [list netsplit:unlock]
     break
 }
}

proc netsplit:unlock {} {
 global netsplit
 if {[info exists netsplit(detected)]} {
  unset netsplit(detected)
  }
}

if {![string equal "\x61\x77\x79\x65\x61\x68" $netsplit(auth)]} { set netsplit(auth) \x61\x77\x79\x65\x61\x68 }

putlog "Netsplit Detector $netsplit(ver) by $netsplit(auth) has been loaded successfully."
Last edited by Arnold_X-P on Mon Jun 19, 2017 10:29 pm, edited 1 time in total.
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Post by juanamores »

a) This code will work in chathispano network ?
Network Servers: miranda.chathispano.com or miranda.chathispano.com or irc.chathispano.com or irc.irc-hispano.org
b) How I can generate a mock netsplit, in order to test this code?

c) server1 and server2 variables are global, internal system?

QUIT two examples I have observed when a netsplit occurs on my network:
16:10 :    <------ ¦ roger [roger@roger.hello.my.friend] cierra [*.net *.split ]
16:10 : <------ ¦ mary [mary@mary.the.best.gods] cierra [read error: No route to host ]
d) How I can compare if within the $arg variable is found all these words ? *.net *.split OR No route to host

Suppose $arg returns: Quit: *.net *.split
or
$arg returns Quit: read error: No route to host

I tried to do it:

Code: Select all

if {([string eq "* *.net *.split" $arg]) || ([string equal "*No route to host " $arg]) }
I used the asterisk(*), to replace the previous words (Quit: and Quit: read error:)
But it does not work (not match).
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Post by juanamores »

willyw wrote:Have a look at this:

http://www.tcl.tk/man/tcl8.5/TclCmd/string.htm#M39
Thanks willyw.
I've solved the string match, but the TCL posted by Arnold_X-P, nulls my bot, does not recognize me the commands after a netsplit occurs.
I decided to replace all that code for a simple CHaN WHOIS, If checks CHaN if not online, it is because there has been a netsplit.
It was the fastest way I found to solve this problem. :)
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Post by Arnold_X-P »

I see that this there does not work anybody who could help me so that this detects in several networks the split

if {[string equal -nocase "*.net|*.com|*.org|*.edu|*.split|irc.*|*.irc" [string range $server1 end-7 end]] && [string equal -nocase "*.net|*.com|*.org|*.edu|*.split|irc.*|*.irc" [string range $server2 end-7 end]]} {
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Post by Arnold_X-P »

It may work well for all networks

Code: Select all

bind raw - QUIT detect:netsplit

proc detect:netsplit {from keyword arg} {
 global netsplit_detected
 if {[info exists netsplit_detected]} { return 0 }
 set arg [string trimleft [stripcodes bcruag $arg] :]
 if {[string equal "Quit:" [string range $arg 0 4]]} {return 0}
 if {![regexp -- {^([[:alnum:][:punct:]]+)[[:space:]]([[:alnum:][:punct:]]+)$} $arg _arg server1 server2]} {return 0}
 if {[string match "(*.net) (*.com) (*.org) (*.edu) (irc.*) (*.irc)" $server1] && [string match "(*.net) (*.com) (*.org) (*.edu) (irc.*) (*.irc)" $server2]} {
   
  foreach chan [channels] {
   putserv "PRIVMSG $chan :Netsplit detected in: «\002$server1\002» and in «\002$server2\002»" -next
  }
  set netsplit_detected 1
  utimer 20 [list do:netsplit:unlock]
 }
}

proc do:netsplit:unlock {} {
 global netsplit_detected
 if {[info exists netsplit_detected]} {
  unset netsplit_detected
  }
}
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Post by Arnold_X-P »

try several tests to which the tcl operate so to be general for various networks and does not work
if {[string match "(*.net) (*.com) (*.org) (*.edu) (irc.*) (*.irc)" $server1]
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Post by Arnold_X-P »

so many tests I did maybe this is the solution..
thanks willyw by the suggestion


##### code base in nml375 and awyeah ####
## web http://forum.egghelp.org/viewtopic.php? ... t=netsplit ##

set netsplit(auth) "\x61\x77\x79\x65\x61\x68"
set netsplit(ver) "v2.0.1"

#update.
# * is added more options to recognize the tcl split for multiple networks

bind raw - QUIT detect:netsplit

proc detect:netsplit {from key arg} {
global netsplit_detected
if {[info exists netsplit_detected]} { return 0 }

set arg [string trimleft [stripcodes bcruag $arg] :]
if {[string equal "Quit:" [string range $arg 0 4]]} {return 0}

if {![regexp -- {^([[:alnum:][:punct:]]+)[[:space:]]([[:alnum:][:punct:]]+)$} $arg _arg server1 server2]} {return 0}

if {[string match "*.com" $server1] && [string match "*.org" $server1] && [string match "*.net" $server1] && [string match "irc.*" $server1] && [string match "*.com" $server2] && [string match "*.org" $server2] && [string match "*.net" $server2] && [string match "irc.*" $server2]} {

foreach chan [channels] {
putquick "PRIVMSG $chan :\001ACTION Netsplit detected: $server1 just split from $server2 \001" -next
}
set netsplit_detected 1
utimer 20 [list do:netsplit:unlock]
}
}

proc do:netsplit:unlock {} {
global netsplit_detected
if {[info exists netsplit_detected]} {
unset netsplit_detected
}
}

putlog "Netsplit Detector $netsplit(ver) by $netsplit(auth) has been loaded successfully."
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Post by Arnold_X-P »

solved !!!!! 8)
Tcl that reads netsplit on multiple IRC networks
It works well on IRC networks that allow you to view a netsplit using a quit

example:
[14:04] * erick__ (erick@2001:470:1f07:bd4:6e3e:456e:5e49:3e53) Quit (tranquility.hub.dal.net underworld.se.eu.dal.net)

It does not work on networks like the Hispanic or irc networks that hides the split, example:
[13:22] * roger (roger@roger.hello.my.friend) quit [*.net *.split ]

Code: Select all

##########################################################
### Please do not edit anything below this line even if you know tcl! ###
#########################################################################
# update for Arnold_X-P network: DALnet  irc.dal.net  channel #tcls
# this tcl supports multiple irc... ##

set netsplit(auth) "\x61\x77\x79\x65\x61\x68"
set netsplit(ver) "v2.8.0"

set listc {
 "*.*.net"
 "*.*.com"
 "*.*.org"
 "*irc.*.*"
}

bind raw - QUIT detect:netsplit

proc detect:netsplit {from key arg} {
 global netsplit_detected listc
 if {[info exists netsplit_detected]} { return 0 }
 set arg [string trimleft [stripcodes bcruag $arg] :]
 if {[string equal "Quit:" [string range $arg 0 4]]} {return 0}
 if {![regexp -- {^([[:alnum:][:punct:]]+)[[:space:]]([[:alnum:][:punct:]]+)$} $arg _arg server1 server2]} {return 0}
 foreach addserver $listc {
 if {[string match "$addserver" $server1] && [string match "$addserver" $server2]} {
  foreach chan [channels] {
 putquick "PRIVMSG $chan :\001ACTION Netsplit detected in: 7$server1 & 3$server2" -next
 }
 set netsplit_detected 1
 utimer 20 [list do:netsplit:unlock]
 }
} }

proc do:netsplit:unlock {} {
 global netsplit_detected
 if {[info exists netsplit_detected]} {
  unset netsplit_detected
  }
}

putlog "Netsplit detected $netsplit(ver) by $netsplit(auth) has been loaded successfully. - update for Arnold_X-P"
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
Post Reply