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.

post for a friend: need random read help

Old posts that have not been replied to for several years.
Locked
S
SmokeyOne
Halfop
Posts: 69
Joined: Tue Jan 14, 2003 6:04 am

post for a friend: need random read help

Post by SmokeyOne »

I'm posting this for a friend cause he needs a little help. I'm not sure on how to help him so i thought I would ask you guys.

He is useing the random read script by wcc, and all he wants to do is use for his channel. the problem is the other script that he is useing saves the utime into the file, he wants to know how do you modify the radom read script to remove the utime at the begining of the line. here is an example of how it looks

1056129388 test

so he wants to remove all thoses numbers from the line and keep the "test" text.

I told him he could filter out all numbers and only output the text from the string, but I thought someone would have a better way for him..

Thanks
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Using the lreplace like this:

Code: Select all

set line "1056129388 test"
set index [lsearch -exact $line [strlwr [lindex $line 0]]]
set line [lreplace $line $index $index]
and the result is from "test" to the end of the "$line"
Once the game is over, the king and the pawn go back in the same box.
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Hehe what are you trying to do caesar?

set line [join [lrange [split $line] 1 end]]
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

:oops: I have no ideea.. :roll: Guess is one of thouse BAD days.
Once the game is over, the king and the pawn go back in the same box.
S
SmokeyOne
Halfop
Posts: 69
Joined: Tue Jan 14, 2003 6:04 am

Post by SmokeyOne »

okay this is how wcc's randrom read works
##############
## COMMANDS ##
######################################################################
## DCC ## .chanset <channel> +/-randread ##
######### Enables or disables the sending of random messages to the ##
######### specified channel. ##
######################################################################

##########################################################
## Just load the script, edit the settings, and rehash. ##
##########################################################

##################################################
# Set the time in seconds between messages here. #
##################################################

set randread_setting(timer) "90"

############################################################################
# Set the file to read from here. This file must exist. NOTE: Changing the #
# contents of this file requires a rehash for the changes to take effect. #
############################################################################

set randread_setting(file) "./README"

####################
# Code begins here #
####################

if {![string match 1.6.* $version]} { putlog "\002RANDREAD:\002 \002WARNING:\002 This script is intended to run on eggdrop 1.6.x or later." }
if {[info tclversion] < 8.2} { putlog "\002RANDREAD:\002 \002WARNING:\002 This script is intended to run on Tcl Version 8.2 or later." }

set ::randread_data [split [read [set fd [open $::randread_setting(file) r]]] "\n"]
setudef flag randread

if {[lsearch -glob [utimers] "* randread_timeread *"] == -1} { utimer $randread_setting(timer) randread_timeread }

proc randread_timeread {} {
foreach chan [channels] {
set index [rand [llength $::randread_data]]
if {[botonchan $chan] && [lsearch -exact [channel info $chan] +randread] != -1} { putserv "PRIVMSG $chan :[join [lrange $::randread_data $index $index]]" }
}
if {[lsearch -glob [utimers] "* randread_timeread *"] == -1} { utimer $::randread_setting(timer) randread_timeread }
}

putlog "\002RANDREAD:\002 RandRead.tcl Version 1.1 by Wcc is loaded."


maybe someone can help

this will add randomly read from the database which each lined added into the database from the other scripts looks like this

1056129388 test
1056129388 test 2
1056129388 test 3
1056129388 test 4

it adds the utime to the begining everytime. This is what my friend told me to post for an asnwer... he's too lazy to do it himself i guess lol
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Huh? We already told you how to fix it :)
S
SmokeyOne
Halfop
Posts: 69
Joined: Tue Jan 14, 2003 6:04 am

Post by SmokeyOne »

but the first part of the line changes, 1056129388 was just an example from the file, will 105 stay the same if on every entry,

and can i try useing set line "*105*" and it would remove anything with 105 in it ?
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

SmokeyOne wrote:but the first part of the line changes, 1056129388 was just an example from the file
stdragon wrote:set line [join [lrange [split $line] 1 end]]
That line would remove the first word no matter what it is, so it should work if all your lines start with that timestamp you want removed.

btw: i don't see a "close $fd" in the script you pasted...that kinda sucks :P
(file opened on the 'set ::randread_data ...' line)
Locked