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 

Bracket Conflict

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Conc
Voice


Joined: 31 Oct 2009
Posts: 6

PostPosted: Sat Oct 31, 2009 4:48 pm    Post subject: Bracket Conflict Reply with quote

I made a "say" script.

it works so:

botnick say text

Part of code:
Code:

putserv "PRIVMSG $c :[lrange $t 1 end]"


but this has a problem, look at this:
Quote:
<Conc> Egg say [Hi]
<Egg> {[Hi]}


Why does it says {} when i type a bracket?
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sat Oct 31, 2009 4:52 pm    Post subject: Reply with quote

Because lrange operates on lists (not strings), and returns a list (not a string).
At minimum, you should use join to merge the list into a single string.
Also, if $t is simply the text you wrote to trigger the binding, then you must also use split to convert it into a list before using lrange.
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Conc
Voice


Joined: 31 Oct 2009
Posts: 6

PostPosted: Sat Oct 31, 2009 5:00 pm    Post subject: Reply with quote

$t isnt just the text to send... it has also the word "say".

Well... i am not very good with tcl, can you do it for me?
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sat Oct 31, 2009 5:02 pm    Post subject: Reply with quote

I suppose you'd like something like this...
Code:
bind pub - "egg" someproc
proc someproc {nick host handle channel text} {
  puthelp "PRIVMSG $channel :[join [lrange [split $text] 1 end]]"
}

_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Conc
Voice


Joined: 31 Oct 2009
Posts: 6

PostPosted: Sat Oct 31, 2009 5:10 pm    Post subject: Reply with quote

It works fine.

Thanks Smile
Back to top
View user's profile Send private message
blake
Master


Joined: 23 Feb 2009
Posts: 201

PostPosted: Fri Dec 04, 2009 10:04 am    Post subject: Reply with quote

I also get this problem but i use

Code:
bind msg ho|ho act cmd:act
proc cmd:act {nick uhost hand arg} {
  set chan [lindex [split $arg] 0]
  set text [lrange [split $arg] 1 end]
  putserv "PRIVMSG botserv act $chan $text (Issued By $nick"
}


tried adding it like this

Code:
bind msg ho|ho act cmd:act
proc cmd:act {nick uhost hand arg} {
  set chan [lindex [split $arg] 0]
  set text [join [lrange [split $arg] 1 end]
  putserv "PRIVMSG botserv act $chan $text (Issued By $nick"
}


but get error on partyline Tcl error [cmd:act]: missing close-bracket
_________________
Blake
UKEasyHosting UKStormWatch
Back to top
View user's profile Send private message Visit poster's website
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Fri Dec 04, 2009 10:54 am    Post subject: Reply with quote

Code:
set text [join [lrange [split $arg] 1 end]

should be
Code:
set text [join [lrange [split $arg] 1 end]]

You should also consider adding ":" before the privmsg text (i.e. "privmsg botserv :act ...").
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
blake
Master


Joined: 23 Feb 2009
Posts: 201

PostPosted: Fri Dec 04, 2009 12:05 pm    Post subject: Reply with quote

Cool thanks sir_fz also changed act to :act
_________________
Blake
UKEasyHosting UKStormWatch
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
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