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.

TCL needed help

Old posts that have not been replied to for several years.
Locked
User avatar
WeiJie
Halfop
Posts: 73
Joined: Thu May 20, 2004 9:30 pm
Location: Singapore

TCL needed help

Post by WeiJie »

I'm a noob in TCL scripting... Hope someone else out there would be able to help out in my "tcl"... This TCL must be able to detect netsplit and set +m to the channel (#abc) and after 30secs, bot must set -m to the channel...

Code: Select all

bind raw - *QUIT

if {([string match "*.*.galaxynet.org" [lindex $reason 0]]) && ([string match "*.*.galaxynet.org" [lindex $reason 1]]) && ([llength $reason] == 2]) && ([lindex $reason 2] == "")} { 
putquick "MODE #abc +m" -next
putserv "PRIVMSG #abc :Netsplit Detected, Channel Will Set To Moderate For 30 Seconds"
timer 30 "putquick \"MODE #abc -m\"" 
}
WeiJie
Admin of IntelFusion
Http://dj-online.org
#Sparks@Boatquay @ mIRC Galaxynet
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

You might want to use bind splt and bind rejn to detect netsplit/rejoins.
See doc/tcl-commands.doc in your eggdrop dir for details.
User avatar
YooHoo
Owner
Posts: 939
Joined: Thu Feb 13, 2003 10:07 pm
Location: Redwood Coast

Re: TCL needed help

Post by YooHoo »

WeiJie wrote:

Code: Select all

bind raw - *QUIT
This is not correct. To bind to a signoff/quit message, you should use the bind SIGN...
(10) SIGN (stackable)
bind sign <flags> <mask> <proc>
procname <nick> <user@host> <handle> <channel> <reason>

Description: triggered by a signoff, or possibly by someone who got
netsplit and never returned. The signoff message is the last
argument to the proc. Wildcards can be used in the mask, which is
matched against '#channel nick!user@host'.
Module: irc
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Something like this, but not tested. :mrgreen:

Code: Select all

bind sign - * netsplit:lock

proc netsplit:lock {nick uhost hand chan text {reason ""}} {
 global botnick netsplit_lock
  set checkmode [string trim [lindex [split [getchanmode $chan]] 0] "+"]
  if {(![info exists netsplit_lock]) && ([lsearch -exact $checkmode "m"] == -1) && ([string match "*.*.galaxynet.org" [lindex $reason 0]]) && ([string match "*.*.galaxynet.org" [lindex $reason 1]]) && ([llength $reason] == 2]) && ([lindex $reason 2] == "")} {
 putquick "MODE $chan +m" -next; set netsplit_lock 1
 putquick "NOTICE $chan :Netsplit detected, channel set to +m for 10 secs. ;)" -next
 utimer 10 [list putquick "MODE $chan -m" -next]
 utimer 15 [list unset netsplit_lock]
 }
 return 0
}
For more security you can check if control codes are not present in the message, or if any upper-case character is not present and string range or lrange and match the reason. :P
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
WeiJie
Halfop
Posts: 73
Joined: Thu May 20, 2004 9:30 pm
Location: Singapore

Re: TCL needed help

Post by WeiJie »

YooHoo wrote:
WeiJie wrote:

Code: Select all

bind raw - *QUIT
This is not correct. To bind to a signoff/quit message, you should use the bind SIGN...
(10) SIGN (stackable)
bind sign <flags> <mask> <proc>
procname <nick> <user@host> <handle> <channel> <reason>

Description: triggered by a signoff, or possibly by someone who got
netsplit and never returned. The signoff message is the last
argument to the proc. Wildcards can be used in the mask, which is
matched against '#channel nick!user@host'.
Module: irc
Oh okie... Thanks ;)
WeiJie
Admin of IntelFusion
Http://dj-online.org
#Sparks@Boatquay @ mIRC Galaxynet
User avatar
WeiJie
Halfop
Posts: 73
Joined: Thu May 20, 2004 9:30 pm
Location: Singapore

Post by WeiJie »

awyeah wrote:Something like this, but not tested. :mrgreen:

Code: Select all

bind sign - * netsplit:lock

proc netsplit:lock {nick uhost hand chan text {reason ""}} {
 global botnick netsplit_lock
  set checkmode [string trim [lindex [split [getchanmode $chan]] 0] "+"]
  if {(![info exists netsplit_lock]) && ([lsearch -exact $checkmode "m"] == -1) && ([string match "*.*.galaxynet.org" [lindex $reason 0]]) && ([string match "*.*.galaxynet.org" [lindex $reason 1]]) && ([llength $reason] == 2]) && ([lindex $reason 2] == "")} {
 putquick "MODE $chan +m" -next; set netsplit_lock 1
 putquick "NOTICE $chan :Netsplit detected, channel set to +m for 10 secs. ;)" -next
 utimer 10 [list putquick "MODE $chan -m" -next]
 utimer 15 [list unset netsplit_lock]
 }
 return 0
}
For more security you can check if control codes are not present in the message, or if any upper-case character is not present and string range or lrange and match the reason. :P
Hmm, but how do i add in those channel that I want the bot to work on?
Does...

Code: Select all

 utimer 10 [list putquick "MODE #abc -m" -next]
works?
WeiJie
Admin of IntelFusion
Http://dj-online.org
#Sparks@Boatquay @ mIRC Galaxynet
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

For those working channels you need to an another lsearch -exact to check if the channel the script is triggered on the channel which is in the working channel list.

Yes utimer with list should work.
Your channel is not #abc, its $chan.

Replace all #abc in your script by $chan.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
WeiJie
Halfop
Posts: 73
Joined: Thu May 20, 2004 9:30 pm
Location: Singapore

Post by WeiJie »

Oh, mmm...
So the codes that u post previously works on every channels that the bot is in?
WeiJie
Admin of IntelFusion
Http://dj-online.org
#Sparks@Boatquay @ mIRC Galaxynet
User avatar
WeiJie
Halfop
Posts: 73
Joined: Thu May 20, 2004 9:30 pm
Location: Singapore

Post by WeiJie »

Oh ya, does this works?

Code: Select all

bind sign - * netsplit:lock
bind pub n|m !ns ns_switch

proc netsplit:lock {nick uhost hand chan text {reason ""}} { 
 global botnick netsplit_lock 
  set checkmode [string trim [lindex [split [getchanmode $chan]] 0] "+"] 
  if {(![info exists netsplit_lock]) && ([lsearch -exact $checkmode "m"] == -1) && ([string match "*.*.galaxynet.org" [lindex $reason 0]]) && ([string match "*.*.galaxynet.org" [lindex $reason 1]]) && ([llength $reason] == 2]) && ([lindex $reason 2] == "")} { 
 putquick "MODE $chan +m" -next; set netsplit_lock 1 
 putquick "NOTICE $chan :Netsplit detected, channel set to +m for 10 secs. ;)" -next 
 utimer 10 [list putquick "MODE $chan -m" -next] 
 utimer 15 [list unset netsplit_lock] 
 } 
 return 0 
} 

proc ns_switch {nick uhost hand chan text} {
 global ns
        switch [lindex $text 0] {
                on {    channel set $chan +ns
                        putserv "PRIVMSG $chan :Netsplit Detectors ACTIVATED"
                }
                off {
                        channel set $chan -ns
                        putserv "PRIVMSG $chan :Netsplit Detectors DEACTIVATED"
                }
                "" {
                        if {[lsearch -exact [channel info $chan] +ns] > -1} {
                                putserv "PRIVMSG $chan :Netsplit Detectors ACTIVATED"
                        } else {putserv "PRIVMSG $chan :Netsplit Detectors DEACTIVATED"
                        }
                }

                default { putserv "NOTICE $nick :Commands \: on|off - or nothing for status" }
        }
}
WeiJie
Admin of IntelFusion
Http://dj-online.org
#Sparks@Boatquay @ mIRC Galaxynet
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

WeiJie wrote:Oh, mmm...
So the codes that u post previously works on every channels that the bot is in?
Yes.

Code: Select all

bind pub n|m !ns ns_switch
No this will not work, because the script will try to match a netsplit message, not a public trigger bind. Only if your trigger message has the same text as a netsplit message and nothing else. Moreover {reason ""} would be replaced simply by reason or text if you like.

You would need to add something like this:

Code: Select all

set netsplitchans "#chan1 #chan2 #chan3"

proc bla:bla {nick .....................} {
 global netsplitchans
 if {([lsearch -exact [split [string tolower $netsplitchans]] [string tolower $chan]] == -1)} { return 0 }
 ...............................
 ........................
 ....................
 }
}
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
WeiJie
Halfop
Posts: 73
Joined: Thu May 20, 2004 9:30 pm
Location: Singapore

Post by WeiJie »

Code: Select all

set netsplitchans "#chan1 #chan2 #chan3" 

proc netsplit:lock {nick uhost hand chan text} { 
 global netsplitchans 
 if {([lsearch -exact [split [string tolower $netsplitchans]] [string tolower $chan]] == -1)} { return 0 } 
 ............................... 
 ........................ 
 .................... 
 } 
} 
Mmm... What does the last 3 lines of dots needed for...? :-?

Code: Select all

bind sign - "$netsplitchans *" splitchannel:sign

set netsplitchans "#chan1 #chan2 #chan3" 

proc splitchannel:sign {nick uhost hand chan text} { 
 global netsplitchans 
 if {([lsearch -exact [split [string tolower $netsplitchans]] [string tolower $chan]] == -1)} { return 0 } 
 ............................... 
 ........................ 
 .................... 
 } 
} 
:-? :roll:
WeiJie
Admin of IntelFusion
Http://dj-online.org
#Sparks@Boatquay @ mIRC Galaxynet
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Meaning add the rest of ur script in it.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
WeiJie
Halfop
Posts: 73
Joined: Thu May 20, 2004 9:30 pm
Location: Singapore

Post by WeiJie »

Oh ok, but I've tested this:

Code: Select all

bind sign - * netsplit:lock 

proc netsplit:lock {nick uhost hand chan text {reason ""}} { 
 global botnick netsplit_lock 
  set checkmode [string trim [lindex [split [getchanmode $chan]] 0] "+"] 
  if {(![info exists netsplit_lock]) && ([lsearch -exact $checkmode "m"] == -1) && ([string match "*.*.galaxynet.org" [lindex $reason 0]]) && ([string match "*.*.galaxynet.org" [lindex $reason 1]]) && ([llength $reason] == 2]) && ([lindex $reason 2] == "")} { 
 putquick "MODE $chan +m" -next; set netsplit_lock 1 
 putquick "NOTICE $chan :Netsplit detected, channel set to +m for 10 secs. ;)" -next 
 utimer 10 [list putquick "MODE $chan -m" -next] 
 utimer 15 [list unset netsplit_lock] 
 } 
 return 0 
} 
It got a error back...
Tcl error [netsplit:lock]: syntax error in expression "(![info exists netsplit_lock]) && ([lsearch -exact $checkmod"
WeiJie
Admin of IntelFusion
Http://dj-online.org
#Sparks@Boatquay @ mIRC Galaxynet
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Hmm try this:

Code: Select all

bind sign - * netsplit:lock

proc netsplit:lock {nick uhost hand chan text {reason ""}} {
 global botnick netsplit_lock
  set chan [string tolower $chan]
  set checkmode [string trim [lindex [split [getchanmode $chan]] 0] "+"]
  if {(![info exists netsplit_lock($chan)]) && ([lsearch -exact $checkmode "m"] == -1) && ([string match "*.*.galaxynet.org" [lindex $reason 0]]) && ([string match "*.*.galaxynet.org" [lindex $reason 1]]) && ([llength $reason] == 2]) && ([lindex $reason 2] == "")} {
 putquick "MODE $chan +m" -next; set netsplit_lock($chan) 1
 putquick "NOTICE $chan :Netsplit detected, channel set to +m for 10 secs. ;)" -next
 utimer 10 [list putquick "MODE $chan -m" -next]
 utimer 15 [list unset netsplit_lock($chan)]
 }
 return 0
}
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
WeiJie
Halfop
Posts: 73
Joined: Thu May 20, 2004 9:30 pm
Location: Singapore

Post by WeiJie »

Mmm... I still got this error after I edited the TCL...
Tcl error [netsplit:lock]: syntax error in expression "(![info exists netsplit_lock($chan)]) && ([lsearch -exact $c"
WeiJie
Admin of IntelFusion
Http://dj-online.org
#Sparks@Boatquay @ mIRC Galaxynet
Locked