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.

chanset via pub command

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

chanset via pub command

Post by simo »

i was using this nice small tcl wich sets chanset via pub command but somehow doesnt set all chansettings for example this doesnt seem to work:

.chanset ap:repeatl 2:10 60 k:kb 2

it sets the first param only 2:10

Code: Select all

bind pub n|n .chanset pub:chanset

proc pub:chanset {nick uhost hand chan arg} {
 foreach {set value} [split $arg] {break}
 if {![info exists value]} {
  catch {channel set $chan $set} error
 } {
  catch {channel set $chan $set $value} error
 }
 if {$error == ""} {
  putnow "NOTICE $nick :Successfully set $arg"
 } {
  putnow "NOTICE $nick :Error setting $arg: [lindex $error 0]..."
 }
}
User avatar
CrazyCat
Revered One
Posts: 1216
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

The split command cut $args in 5 pieces (split is on " ") and set the first to $set (bad idea of variable name) and the second to $value (bad idea too). The script wasn't thought for complex values.

You can use scan and a regexp to set $set and $value, or do it in 2 times whith:

Code: Select all

set set [lindex [split $arg] 0]
set value [join [lrange [split $arg] 1 end]]
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

excellent tnx CrazyCat
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

You shouldn't use set, arg or args cos they have special meanings in TCL.

Here's a nice trick with lassign:

Code: Select all

% set text "ap:repeatl 2:10 60 k:kb 2"
ap:repeatl 2:10 60 k:kb 2
% set value [lassign $text mode]
2:10 60 k:kb 2
% puts $mode
ap:repeatl
% puts $value
2:10 60 k:kb 2
Once the game is over, the king and the pawn go back in the same box.
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

you mean like this caesar:

Code: Select all

proc pub:chanset {nick host hand chan text} {
set text [lindex [split $text] 0]
set value [lassign $text mode]
 if {![info exists value]} {
  catch {channel set $chan $set} error
 } {
  catch {channel set $chan $set $value} error
 }
 if {$error == ""} {
  putnow "NOTICE $nick :Successfully set $text"
 } {
  putnow "NOTICE $nick :Error setting $text: [lindex $error 0]..."
 }
}
User avatar
CrazyCat
Revered One
Posts: 1216
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

No, he means (if I'm not wrong):

Code: Select all

proc pub:chanset {nick host hand chan text} {
   set value [lassign $text mode]
   if {![info exists value] || $value eq ""} {
      catch {channel set $chan $mode} error
   } else {
      catch {channel set $chan $mode $value} error
   }
   if {$error == ""} {
      putnow "NOTICE $nick :Successfully set $text"
   } else {
      putnow "NOTICE $nick :Error setting $text: [lindex $error 0]..."
   }
}
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

tnx for that crazycat tried that didnt seem to work properly tho same result of just setting parts of the settings
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Did you add a putlog line to see what mode and value would be set and what error do you get? Something like:

Code: Select all

putlog "trying to set $mode to $value"
Once the game is over, the king and the pawn go back in the same box.
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

ive added this caesar but it didnt output anything

putserv "privmsg $chan :trying to set $mode to $value"
User avatar
CrazyCat
Revered One
Posts: 1216
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

I think you don't know how to debug a script...

Try this code, and copy us the command you type in chan and what happens in party-line

Code: Select all

proc pub:chanset {nick host hand chan text} {
   set value [lassign $text mode]
   putlog "getting mode: *$mode* and value: *$value*"
   if {![info exists value] || $value eq ""} {
      putlog "value seems to not be set"
      catch {channel set $chan $mode} error
   } else {
      putlog "ok, value is set"
      catch {channel set $chan $mode $value} error
   }
   putlog "error is *$error*"
   if {$error == ""} {
      putnow "NOTICE $nick :Successfully set $text"
   } else {
      putnow "NOTICE $nick :Error setting $text: [lindex $error 0]..."
   }
}
Using .console +d is a good way to see errors. And if an error appear, type .set errorInfo to have more detals
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

tried your last posted code and didnt output any error CrazyCat
User avatar
CrazyCat
Revered One
Posts: 1216
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

And what did you get in party-line ?
I can't help you without these infos
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

list doesn't contain element 2
while executing
"lreplace $items 2 2"
User avatar
CrazyCat
Revered One
Posts: 1216
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

So you have an error, but not in that proc, because there is no lreplace in it.
You'd better give us your full script, or find which of your script did this error.
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

cleared all tcls and left only the chanset one and seems to work now
Post Reply