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.

setudef flag not working

Help for those learning Tcl or writing their own scripts.
Post Reply
d
daigo
Voice
Posts: 37
Joined: Fri Jun 27, 2014 8:02 pm

setudef flag not working

Post by daigo »

Code: Select all

setudef flag relay

set spy(home) "#daigo"

set spy(chan) "#helpops"

bind PUBM   -|- *                spychan:chat
bind CTCP   -|- "ACTION"         spychan:action
bind SIGN   -|- "$spy(chan) *"   spychan:sign
bind JOIN   -|- "$spy(chan) *"   spychan:join
bind PART   -|- "$spy(chan) *"   spychan:part
bind SPLT   -|- "$spy(chan) *"   spychan:split
bind KICK   -|- "$spy(chan) *"   spychan:kick
bind RAW     *  "MODE"           spychan:mode


proc spychan:part { nickname hostname handle channel reason } {
	global spy
	if {[string equal -nocase $channel $spy(chan)]} {
	putserv "PRIVMSG $spy(home) :\[$channel\] * $nickname ($hostname) has left $spy(chan)"
	}
       }


proc spychan:join { nickname hostname handle channel } {
	global spy
	if {[string equal -nocase $channel $spy(chan)]} {
	putserv "PRIVMSG $spy(home) :\[$channel\] * $nickname ($hostname) has joined $spy(chan)"
	}
       }

proc spychan:kick { nickname hostname handle channel target reason } {
	global spy
	if {[string equal -nocase $channel $spy(chan)]} {
	putserv "PRIVMSG $spy(home) :\[$channel\] * $target was kicked from $spy(chan) by $nickname ($reason)"
	}
       }

proc spychan:mode { from key arguments } {
	global spy
	set channel [string trim [lindex [split $arguments] 0]] 
	set modechange [string trim [lindex [split $arguments] 1]] 
	set victims [string trim [join [lrange [split $arguments] 2 end]]] 

	set nickname [string trim [lindex [split $from "!"] 0]] 
	set hostname [string trim [lindex [split $from "!"] 1]]
	if {[string equal -nocase $channel $spy(chan)]} {
	putserv "PRIVMSG $spy(home) :\[$channel\] * $nickname sets mode: $modechange $victims"
	}
       }

proc spychan:sign { nickname hostname handle channel reason } {
	global spy
	if {[string equal -nocase $channel $spy(chan)]} {
	putserv "PRIVMSG $spy(home) :\[$channel\] * $nickname ($hostname) has quit IRC ($reason)"
	}
       }

proc spychan:split { nickname hostname handle channel arguments } {
	global spy
	if {[string equal -nocase $channel $spy(chan)]} {
	putserv "PRIVMSG $spy(home) :\[$channel\] * $nickname has split from the network"
	}
       }

proc spychan:chat { nickname hostname handle channel arguments } {
	global spy
	if {[string equal -nocase $channel $spy(chan)]} {
        putserv "PRIVMSG $spy(home) :\[$channel\] <$nickname> $arguments"
        }
       }

proc spychan:action { nickname hostname handle channel keyword arguments } {
	global spy
	if {[string equal -nocase $channel $spy(chan)]} {
        putserv "PRIVMSG $spy(home) :\[$channel\] * $nickname $arguments"
        }
       }
Even though I didn't set the +relay flag in any channels (it's -relay in all channels), it still relays all the messages into #daigo from #helpops. I even restarted the bot but it still activates.
User avatar
heartbroken
Op
Posts: 110
Joined: Thu Jun 23, 2011 11:15 pm
Location: somewhere out there

Post by heartbroken »

setudef flag not working because :

there is only setudef flag ... line outside of the procs , it doesn't check if this defined channel flag activated on $chan in the procs...

there are only checks that : if $spy(chan) equivalence to $channel .. in every proc
-> https://www.tcl.tk/man/tcl8.6/TclCmd/string.htm

so how we gonna check this "user defined channel flags in procs?"

method 1 : "channel get" -> http://www.eggheads.org/support/egghtml ... l#chancmds

Code: Select all

if {[channel get $chan that-flag]} {
 .... 
method 2 : with "lsearch" -> http://www.tcl.tk/man/tcl8.6/TclCmd/lsearch.htm

Code: Select all

if {[lsearch -exact [channel info $chan] "+that-flag"] != -1} { 
Last edited by heartbroken on Tue Jul 29, 2014 2:59 am, edited 2 times in total.
Life iS Just a dReaM oN tHE wAy to DeaTh
d
daigo
Voice
Posts: 37
Joined: Fri Jun 27, 2014 8:02 pm

Post by daigo »

Is it better to use:

Code: Select all

if {[channel get $chan that-flag]} {
...
or

Code: Select all

if {![channel get $chan that-flag]} { return }
if ...
...
?
User avatar
heartbroken
Op
Posts: 110
Joined: Thu Jun 23, 2011 11:15 pm
Location: somewhere out there

Post by heartbroken »

well both are same actually... first one says" if $chan has that-flag,lets do this work..."

second one says " if we don't have that-flag ,won't do anything ..."
Life iS Just a dReaM oN tHE wAy to DeaTh
Post Reply