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 

Hhelp with strip char

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
whittinghamj
Op


Joined: 21 May 2006
Posts: 103

PostPosted: Mon Feb 19, 2007 7:42 pm    Post subject: Hhelp with strip char Reply with quote

Hi guys. when I am logging a line of text from #channel to logfile. How do I strip of the last charactor before writing the line to the logfile?

Some of my users have this dam annoying script which puts [ and ] start and end of every line they type.

Now I can miss out the first [ by lindex $text 1 end] and it works perfectly - just need to drop the VERY last char which happens to be a ] - as its logged in the file as \] - which is very annoying and very ugly.

Any help please --- I looked around the board for the strip syntax but I am either not really understanding it right or the posted did not seem line they would help any.

Thanks guys -

PS - its about time but I am writing my own darn script and not just requesting the full script this time he he - yay Quest
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Mon Feb 19, 2007 8:18 pm    Post subject: Reply with quote

First off, don't ever use lrange (or lindex for that matter) in that fashion!
lrange is supposed to be used on lists, not plain text. What you should be using is 'string range' or possibly 'string strip'.

As for getting correct ranges for either lrange or string range, use end-1 as end-of-range argument to drop the last char (string range) or list item (lrange).

Manpage for 'string' can be found here
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
whittinghamj
Op


Joined: 21 May 2006
Posts: 103

PostPosted: Mon Feb 19, 2007 10:06 pm    Post subject: Reply with quote

thank you so much for the tips - i am changing my script as needed.

One other question.

How do i take the spaces from the irc line and convert them into a period

eg

hello i am new here

would become in the log file

hello.i.am.new.here

any su8ggestions? point me in the right direction / have any sample code i can use as a base to work from please?
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Tue Feb 20, 2007 12:49 am    Post subject: Reply with quote

'string map' would probably be your friend here, assuming you've got tcl8.2 or later installed.
Code:
string map [list " " "."] $string

If 'string map' is not available on your system, you could use regsub instead. Keep in mind that regular expressions can be abit "tricky" however...
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Tue Feb 20, 2007 5:30 am    Post subject: Reply with quote

Or you can use
Code:
join [split $string] .

_________________
Follow me on GitHub

- Opposing

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


Joined: 21 May 2006
Posts: 103

PostPosted: Wed Feb 28, 2007 12:11 am    Post subject: Reply with quote

hi guys

I am trying to use both of those examples but running into issues - no idea how to use them


here is what i have so fare

maybe u can see where i going wrong

Code:

proc pub:addpreannounce {nick host hand chan arg} {
  global mysql
set pregroup [string range [lindex $arg 0] [expr {[string last - [lindex $arg 0]] + 1}] end ]
set rlstime [unixtime]
set string map [list " " "."] $arg
set rlsname [lindex $string 10]
set rlssection [lindex $arg 6]


there is some code after this but that part works fine

cheers
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Wed Feb 28, 2007 1:24 am    Post subject: Reply with quote

set string map [list " " "."] $arg

should be

set varname [string map {" " "."} $arg]


No clue what this is trying to accomplish:

set pregroup [string range [lindex $arg 0] [expr {[string last - [lindex $arg 0]] + 1}] end ]


Maybe try reading the manpages for 'string' and 'lindex' instead of just randomly mix-mashing these together like that.
Back to top
View user's profile Send private message
whittinghamj
Op


Joined: 21 May 2006
Posts: 103

PostPosted: Wed Feb 28, 2007 1:48 am    Post subject: Reply with quote

I got it thank you Very Happy

I was not thinking right - been at this tcl for 9 hours non stop lol
Back to top
View user's profile Send private message
metroid
Owner


Joined: 16 Jun 2004
Posts: 771

PostPosted: Wed Feb 28, 2007 1:50 pm    Post subject: Reply with quote

sigh.

If we are truely supposed to be against helping people setting up things related to warez, why are we still helping them?
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Wed Feb 28, 2007 7:59 pm    Post subject: Reply with quote

metroid wrote:
sigh.
If we are truely supposed to be against helping people setting up things related to warez, why are we still helping them?

Guess I didn't think of it in that light.
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
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