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.

some help needed

Old posts that have not been replied to for several years.
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Sir_Fz wrote:how to catch the channel add ?

Code: Select all

if {[catch {channel add invalidName} var]} {
  # an error occured, $var is the error message
} else {
  # everything went fine...var contains the value returned by the command
}
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

ok I got it, but i didn't understand "{channel add invalidName}"

how does it work ? like is there a list for these catches ?
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

syntax: catch {command(s)} name_of_variable_holding_the_result

"invalidName" was just an example of a invalid channel name...you should replace it with "$chan" or whatever holds your channel name.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

so this code is correct?

Code: Select all

bind msg m .join pub_join 

proc pub_join {nick uhost hand arg} { 
set chan [lindex [split $arg] 0] 
if {[catch {channel add $chan} var]} { 
  puthelp "PRIVMSG $nick :$var - use prefix: \002#\002"  
} else { 
  channel add $chan
  puthelp "PRIVMSG $nick :Succesfully join $chan"
}
or

Code: Select all

bind msg m .join pub_join 

proc pub_join {nick uhost hand arg} { 
set chan [lindex [split $arg] 0] 
if {[catch {channel add $chan} "*Invalid channel*"]} { 
  puthelp "PRIVMSG $nick :Invalid Channel - use prefix: \002#\002"  
} else { 
  channel add $chan
  puthelp "PRIVMSG $nick :Succesfully join $chan"
}
?
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

Sir_Fz wrote:so this code is correct?

Code: Select all

bind msg m .join pub_join 

proc pub_join {nick uhost hand arg} { 
set chan [lindex [split $arg] 0] 
if {[catch {channel add $chan} var]} { 
  puthelp "PRIVMSG $nick :$var - use prefix: \002#\002"  
} else { 
  channel add $chan
  puthelp "PRIVMSG $nick :Succesfully join $chan"
}
or

Code: Select all

bind msg m .join pub_join 

proc pub_join {nick uhost hand arg} { 
set chan [lindex [split $arg] 0] 
if {[catch {channel add $chan} "*Invalid channel*"]} { 
  puthelp "PRIVMSG $nick :Invalid Channel - use prefix: \002#\002"  
} else { 
  channel add $chan
  puthelp "PRIVMSG $nick :Succesfully join $chan"
}
?
The first one was closer, however on successful completion of the 'channel add' command from within the catch claus, you do not want to execute 'channel add' again.. Remove it from the 'else' branch, and it will be fine.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

ok so this should do it:

Code: Select all

bind msg m .join pub_join 

proc pub_join {nick uhost hand arg} { 
set chan [lindex [split $arg] 0] 
if {[catch {channel add $chan} var]} { 
  puthelp "PRIVMSG $nick :$var - use prefix: \002#\002"  
} else { 
  puthelp "PRIVMSG $nick :Succesfully joined $chan" 
}
thanx :)
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Sir_Fz wrote:

Code: Select all

proc pub_join {nick uhost hand arg} { 
set chan [lindex [split $arg] 0] 
if {[catch {channel add $chan} var]} { 
  puthelp "PRIVMSG $nick :$var - use prefix: \002#\002"  
} else { 
  puthelp "PRIVMSG $nick :Succesfully joined $chan" 
}
Properly indenting the code would probably make you add another "}" without even thinking about it :wink:
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

lol, yeah... but I was thinking this time, which made me forget it :P :D
Locked