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.

On Part not working

Help for those learning Tcl or writing their own scripts.
Post Reply
e
everythingdaniel
Voice
Posts: 8
Joined: Mon Aug 17, 2009 3:41 pm

On Part not working

Post by everythingdaniel »

Hi, I have the below code that posts if a user leaves or joins a channel. The only problem is that it works fine on a join, but on a part it does nothing. Any ideas?

Code: Select all

bind JOIN - * joinr
bind PART - * partr

proc joinr {jnick jhost jhandle jchannel} { 
      putserv "PRIVMSG #AR_Staff :\002\00303$jnick joined $jchannel"  
}

proc partr {pnick phost phandle pchannel} { 
      putserv "PRIVMSG #AR_Staff :\002\00304$pnick left $pchannel"  
}
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

A part bind passes 5 arguments to the proc it calls. You only had 4. Always check the syntax in tcl-commands.html before you use a bind that you are unfamiliar with. It is also always a good idea to keep track of what's going on in the partyline while a new script is being executed, I'm pretty sure you would have seen an error telling you what was wrong.

Code: Select all

bind JOIN - * joinr 
bind PART - * partr 

proc joinr {jnick jhost jhandle jchannel} { 
      putserv "PRIVMSG #AR_Staff :\002\00303$jnick joined $jchannel"  
} 

proc partr {pnick phost phandle pchannel pmsg} { 
      putserv "PRIVMSG #AR_Staff :\002\00304$pnick left $pchannel"  
}
I must have had nothing to do
e
everythingdaniel
Voice
Posts: 8
Joined: Mon Aug 17, 2009 3:41 pm

Post by everythingdaniel »

Thanks for the reply! But the PART part still does not work.
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

I see nothing else wrong.

Don't forget that a PART bind triggers only for users leaving a channel and not for those quitting (SIGN bind) or those split from your server (SPLT bind).
I must have had nothing to do
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

Another note on the subject.

A PART bind does NOT seem to trigger if the bot parts, unlike a JOIN bind which does trigger if the bot joins. This was news to me until I just experimented on another script I am coding.
I must have had nothing to do
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

Code: Select all

# report.tcl

# set here the channel the bot reports joins/parts to
set vReportChan #eggtcl

bind JOIN - * pReportJoin
bind RAW - PART pReportPart

proc pReportJoin {nick uhost hand chan} {
    global vReportChan
    if {[botonchan $vReportChan]} {
        putserv "PRIVMSG $vReportChan :\002\00303$nick joined $chan\003\002"
    }
    return 0
}

proc pReportPart {from keyword text} {
    global vReportChan
    if {[botonchan $vReportChan]} {
      set nick [lindex [split $from !] 0]
      set chan [string trim [lindex [split $text :] 0]]
      putserv "PRIVMSG $vReportChan :\002\00304$nick parted $chan\003\002"
    }
    return 0
}

putlog "report.tcl loaded"

# eof
The above script has been tested and works using a RAW bind with keyword PART instead of a PART bind. As already stated, NOT for quits, splits, kicks etc.

I have still not got to the bottom of the PART bind. I have a Windrop 1.6.19 for which the PART bind does not trigger for the bot itself parting and I have an Eggdrop 1.6.19+ctcpfix for which the PART bind does trigger. The mind boggles!
I must have had nothing to do
Post Reply