egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

chanset via pub command
Goto page 1, 2  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
simo
Owner


Joined: 22 Mar 2015
Posts: 514

PostPosted: Mon Sep 14, 2020 11:30 am    Post subject: chanset via pub command Reply with quote

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:

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]..."
 }
}

_________________
Coming together is a beginning, staying together is progress, working together is succes.
Back to top
View user's profile Send private message
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 601
Location: France

PostPosted: Mon Sep 14, 2020 12:18 pm    Post subject: Reply with quote

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:
set set [lindex [split $arg] 0]
set value [join [lrange [split $arg] 1 end]]

_________________
https://www.eggdrop.fr - French speaking IRC network
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 514

PostPosted: Mon Sep 14, 2020 1:55 pm    Post subject: Reply with quote

excellent tnx CrazyCat
_________________
Coming together is a beginning, staying together is progress, working together is succes.
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3659
Location: Mint Factory

PostPosted: Tue Sep 15, 2020 4:23 am    Post subject: Reply with quote

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

Here's a nice trick with lassign:
Code:

% 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.
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 514

PostPosted: Tue Sep 15, 2020 3:01 pm    Post subject: Reply with quote

you mean like this caesar:

Code:

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]..."
 }
}

_________________
Coming together is a beginning, staying together is progress, working together is succes.
Back to top
View user's profile Send private message
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 601
Location: France

PostPosted: Tue Sep 15, 2020 6:17 pm    Post subject: Reply with quote

No, he means (if I'm not wrong):
Code:
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]..."
   }
}

_________________
https://www.eggdrop.fr - French speaking IRC network
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 514

PostPosted: Tue Sep 15, 2020 7:16 pm    Post subject: Reply with quote

tnx for that crazycat tried that didnt seem to work properly tho same result of just setting parts of the settings
_________________
Coming together is a beginning, staying together is progress, working together is succes.
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3659
Location: Mint Factory

PostPosted: Wed Sep 16, 2020 12:54 am    Post subject: Reply with quote

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

putlog "trying to set $mode to $value"

_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 514

PostPosted: Wed Sep 16, 2020 10:44 am    Post subject: Reply with quote

ive added this caesar but it didnt output anything

putserv "privmsg $chan :trying to set $mode to $value"
_________________
Coming together is a beginning, staying together is progress, working together is succes.
Back to top
View user's profile Send private message
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 601
Location: France

PostPosted: Wed Sep 16, 2020 11:04 am    Post subject: Reply with quote

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:
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
_________________
https://www.eggdrop.fr - French speaking IRC network
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 514

PostPosted: Wed Sep 16, 2020 12:35 pm    Post subject: Reply with quote

tried your last posted code and didnt output any error CrazyCat
_________________
Coming together is a beginning, staying together is progress, working together is succes.
Back to top
View user's profile Send private message
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 601
Location: France

PostPosted: Wed Sep 16, 2020 12:42 pm    Post subject: Reply with quote

And what did you get in party-line ?
I can't help you without these infos
_________________
https://www.eggdrop.fr - French speaking IRC network
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 514

PostPosted: Wed Sep 16, 2020 12:45 pm    Post subject: Reply with quote

list doesn't contain element 2
while executing
"lreplace $items 2 2"
_________________
Coming together is a beginning, staying together is progress, working together is succes.
Back to top
View user's profile Send private message
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 601
Location: France

PostPosted: Wed Sep 16, 2020 12:51 pm    Post subject: Reply with quote

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.
_________________
https://www.eggdrop.fr - French speaking IRC network
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 514

PostPosted: Wed Sep 16, 2020 1:06 pm    Post subject: Reply with quote

cleared all tcls and left only the chanset one and seems to work now
_________________
Coming together is a beginning, staying together is progress, working together is succes.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber