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.

how to solve this .chanset #chan +/-

Help for those learning Tcl or writing their own scripts.
Post Reply
A
Angel
Voice
Posts: 13
Joined: Sat Jul 31, 2010 5:39 pm

how to solve this .chanset #chan +/-

Post by Angel »

the syntax +/-bmotion is for example to this script and maybe used for other script too.
the use of this is just to msg the bot to do the chanset thing for the script to work on every channel..and no need to go to partyline or telnet the bot..

been bugging me for a couple of days but i can't get it to work.

Code: Select all

#syntax:/msg bot chanset channel +/-bmotion



bind msg n set chan

proc chan {nick host hand text} {

   set chan [lindex split $text] 0]

   if {![string length $chan]} {

      putserv "PRIVMSG $nick :no specified channel."

   }

   if {[validchan $chan]} {

      if {[channel get $chan "active"]} {

         channel set $chan +bmotion

      }
     
     channel set  $chan +bmotion

      putserv "PRIVMSG $nick :$chan bmotion activated."

      return 0

   }

   

} 
Last edited by Angel on Thu Aug 19, 2010 3:27 pm, edited 3 times in total.
L
Luminous
Op
Posts: 146
Joined: Fri Feb 12, 2010 1:00 pm

Post by Luminous »

Okay, I see two issues right off the bat. First one is that you have named your proc the name of an already existing proc. I have done this several times myself. "Chanset" is already a dcc command, so that could very well be messing things up for you. Avoid using pre-existing command names for your procs.

Issues two I see is this:

Code: Select all

channel chanset $chan 


"Channel chanset" is not a tcl command. I assume you meant to do something like:

Code: Select all

channel set $chan -/+setting
, like you did the first time, when you turned off inactive chanset.
A
Angel
Voice
Posts: 13
Joined: Sat Jul 31, 2010 5:39 pm

Post by Angel »

Code: Select all

#syntax:/msg bot chanset channel +/-bmotion



bind msg n set chan 

proc chan {nick host hand text} { 

   set chan [join [lindex [split $text] 0]] 

   if {![string length $chan]} { 

      putserv "PRIVMSG $nick :no specified channel." 

      return 0 

   } 

   if {[validchan $chan]} { 

      if {[channel get $chan "inactive"]} { 

         channel set $chan -inactive 

         return 0 

      } 

      putserv "PRIVMSG $nick :$chan bmotion activated." 

      return 0 

   } 

   channel set  $chan +/-setting

} 
already edited but still error and not working :(

got a headache now figuring out what is wrong

help please
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

A few more things to fix:
  • lindex returns a single list item, not a list. Don't use join here.
  • Whenever you call return, the proc will immediately exit without running the following code. Thus, if the channel is +inactive, it will be set -inactive, but the rest of the code will not be executed. If the channel is already -inactive, it will print the "bmotion activated" message and then exit, not executing the channel set command further down.
  • "+/-setting" is not a valid channel setting, enter the actual setting you are trying to alter (perhaps +bmotion ?).
NML_375
A
Angel
Voice
Posts: 13
Joined: Sat Jul 31, 2010 5:39 pm

Post by Angel »

so what will be the coding then?

Code: Select all

#syntax:/msg bot chanset channel +/-bmotion



bind msg n set chan

proc chan {nick host hand text} {

   set chan [split $text] 0]]

   if {![string length $chan]} {

      putserv "PRIVMSG $nick :no specified channel."

   }

   if {[validchan $chan]} {

      if {[channel get $chan "active"]} {

         channel set $chan -inactive

         return 0

      }
     
     channel set  $chan +bmotion

      putserv "PRIVMSG $nick :$chan bmotion activated."

      return 0

   }

   

} 

i hope i ddidn't screw the whole yet on this 1....
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Code: Select all

set chan [split $text] 0]]
You lost the lindex command, and you've got a stray ] at the end of the line:

Code: Select all

set chan [lindex [split $text] 0]

Code: Select all

if {[channel get $chan "active"]} {
  channel set $chan -inactive
  return 0
}
This will still cause the script to end before the channel is set +bmotion in case it's set +inactive. It is set -inactive however. I'm not sure if this is the behaviour you intended?
NML_375
A
Angel
Voice
Posts: 13
Joined: Sat Jul 31, 2010 5:39 pm

Post by Angel »

first post i edited....

deleted some return added lindex and +bmotion i hope it will do it
L
Luminous
Op
Posts: 146
Joined: Fri Feb 12, 2010 1:00 pm

Post by Luminous »

I was a tab unclear myself... looks like nml got it though.
A
Angel
Voice
Posts: 13
Joined: Sat Jul 31, 2010 5:39 pm

Post by Angel »

can someone pls post the final coding of this script please
Post Reply