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.

adding a search

Help for those learning Tcl or writing their own scripts.
s
streamish
Voice
Posts: 21
Joined: Fri Dec 03, 2010 4:33 pm

Post by streamish »

Not sure what happened with that snippet of code. Eggdrop crashed, and I'm getting this error:

Code: Select all

[23:49:49] Tcl error in file 'oldskewl.conf':
[23:49:49] invalid character "}"
in expression "0}"
    (parsing expression "0}")
    invoked from within
"if [catch {set shoefile [http::geturl "http://www.oldskewl.info/links.txt" -timeout 5000]} error]} {
  putlog "ERROR: Cannot create link list ( $erro..."
    (file "scripts/SorgIS.tcl" line 50)
    invoked from within
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Try this instead...

Code: Select all

package require http
if {[catch {set shoefile [::http::geturl "http://www.whateverdomain.com/links.txt" -timeout 5000]} error]} {
  putlog "ERROR: Cannot create link list ( $error )"
  set shoelace [list] ; unset shoefile
} else {
  set shoelace [split [http::data $shoefile] "\n"]
  ::http::cleanup $shoefile ; unset shoefile
}
That's what giving advice at midnight does to me.. lmfao

I missed a leading start brace { to lead the "if" expression containing the catch. My bad.. sorry to have caused your bot to crash... :lol:
s
streamish
Voice
Posts: 21
Joined: Fri Dec 03, 2010 4:33 pm

Post by streamish »

Hahaha, no problem. I should have caught that myself =P
s
streamish
Voice
Posts: 21
Joined: Fri Dec 03, 2010 4:33 pm

Post by streamish »

I'm having a super weird problem with my script, and it's been happening from the beginning of usage, I just figured it was something random.
Every time I .rehash the bot crashes with the following errors:

Code: Select all

<oldskewl> [16:18:17] *** Can't load Userinfo TCL v1.07 -- At least Eggdrop v1.4.3 required
<oldskewl> [16:18:17] Loading netbots.tcl v4.10...
<oldskewl> [16:18:17] Tcl error in file 'oldskewl.conf':
<oldskewl> [16:18:17] can't read "version": no such variable
<oldskewl>     while executing
<oldskewl> "split $version"
<oldskewl>     invoked from within
<oldskewl> "if {[string trimleft [lindex [split $version] 1] 0] < 1032200} {
<oldskewl>   die "*** netbots.tcl $nb_ver requires eggdrop 1.3.22 or later. Please upgrade your ..."
<oldskewl>     (file "netbots/netbots.tcl" line 13)
<oldskewl>     invoked from within
<oldskewl> "source netbots/netbots.tcl"
<oldskewl>     (file "oldskewl.conf" line 1374)
<oldskewl> [16:18:17] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)
*** Connection closed
I have absolutely no idea what this might be, because its two totally different scripts which are not communicating with each other. Also, this only happens when I load the TCL in question. If I disable i can start/rehash with no problems. Eggdrop version is 1.6.20
s
streamish
Voice
Posts: 21
Joined: Fri Dec 03, 2010 4:33 pm

Post by streamish »

Actually I take it back. All of these conflicts seem to be due to this piece of code

Code: Select all

package require http 
if [catch {set shoefile [::http::geturl "http://www.whateverdomain.com/links.txt" -timeout 5000]} error]} { 
  putlog "ERROR: Cannot create link list ( $error )" 
  set shoelace [list] ; unset shoefile 
} else { 
  set shoelace [split [http::data $shoefile] "\n"] 
  ::http::cleanup $shoefile ; unset shoefile 
}
Any possible reasons?
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

<oldskewl> die "*** netbots.tcl $nb_ver requires eggdrop 1.3.22 or later. Please upgrade your ..."
<oldskewl> (file "netbots/netbots.tcl" line 13)
<oldskewl> invoked from within
<oldskewl> "source netbots/netbots.tcl"
The error clearly states the contrary to what you think is the culprit. :)
Once the game is over, the king and the pawn go back in the same box.
s
streamish
Voice
Posts: 21
Joined: Fri Dec 03, 2010 4:33 pm

Post by streamish »

You would think so, and thats why this issue is so odd. When I disable the script and restart the eggdrop there are no errors, and i can rehash fine. Only when the script is loaded will it crash the bot with the errors, unrelating to the script.

Also, when I changed

Code: Select all

package require http 
if [catch {set shoefile [::http::geturl "http://www.whatever.com/links.txt" -timeout 5000]} error]} { 
  putlog "ERROR: Cannot create link list ( $error )" 
  set shoelace [list] ; unset shoefile 
} else { 
  set shoelace [split [http::data $shoefile] "\n"] 
  ::http::cleanup $shoefile ; unset shoefile 
}
To

Code: Select all

set shoefile [open "scripts/links.txt" r] 
set shoelace [split [read -nonewline $shoefile] "\n"] 
close $shoefile ; unset shoefile
There are no longer errors. This is why I assume it must be in the first set of code.
Last edited by streamish on Wed Mar 30, 2011 1:43 pm, edited 1 time in total.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

if [catch {set shoefile [::http::geturl "http://www.whateverdomain.com/links.txt" -timeout 5000]} error]} {
I thought you said you fixed that missing brace there son...

Notice, between if and [ is a missing { ...
We discussed this above, scroll up... This is the problem, that unaligned brace.. Fix it like you said you already did... Mark your thread [solved] once you do ... heh
s
streamish
Voice
Posts: 21
Joined: Fri Dec 03, 2010 4:33 pm

Post by streamish »

Sorry, I was copying the code from here rather than from my source. My code does have the bracket.

Code: Select all

package require http
if {[catch {set shoefile [::http::geturl "http://shoelace.org/picdump.txt" -timeout 5000]} error]} {
  putlog "ERROR: Cannot create link list ( $error )"
  set shoelace [list] ; unset shoefile
} else {
  set shoelace [split [http::data $shoefile] "\n"]
  ::http::cleanup $shoefile ; unset shoefile
}
But rehash is still crashing the bot with the odd errors
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

You missed a brace somewhere else then or otherwise made a small mistake. To remedy the issue, try the complete code below. This should work.

Code: Select all

# requires http package
package require http

# can we load our web sourced shoelace list?
if {[catch {set shoefile [::http::geturl "http://shoelace.org/picdump.txt" -timeout 5000]} error]} {
  # no, report error, empty the list
  putlog "ERROR: Cannot create link list ( $error )"
  set shoelace [list]
} else {
  # yes, success, build the list
  set shoelace [split [http::data $shoefile] "\n"]
  ::http::cleanup $shoefile ; unset shoefile
} 

bind pub - !shoelace pub_shoelace

proc pub_shoelace {nick mask hand channel text} {
  global shoelace

  if {[string length [string trim $text]]} {
    #user supplied a search-term
    set hits [lsearch -all $shoelace *[string trim $text]*]

    #test if we found any..
    if {[llength $hits] > 0} {
      #We've got atleast one match, pick a random one if we've got multiple ones
      set item [lindex $hits [rand [llength $hits]]] ; set status "SEARCH FOUND"
    } else {
      #No hits, pick a random line from the list
      set item [rand [llength $shoelace]] ; set status "RANDOMIZED"
    }
  } else {
    #No search-term supplied, pick a random item
    set item [rand [llength $shoelace]] ; set status "RANDOMIZED"
  }
  putserv "PRIVMSG $channel :\[$status\] [lindex $shoelace $item]"
}
s
streamish
Voice
Posts: 21
Joined: Fri Dec 03, 2010 4:33 pm

Post by streamish »

Used your code exactly.

Launches fine

Code: Select all

[11:05:49] Writing channel file...
[11:05:49] Userfile loaded, unpacking...
[11:05:49] === oldskewl: 3 channels, 349 users.
Launched into the background  (pid: 94069)
Rehash fails

Code: Select all

[oldskewl(dcc)] [11:06:29] Writing channel file...
[oldskewl(dcc)] [11:06:29] Listening at telnet port 42000 (all).
[oldskewl(dcc)] [11:06:29] Loading netbots.tcl v4.10...
[oldskewl(dcc)] [11:06:29] Tcl error in file 'oldskewl.conf':
[oldskewl(dcc)] [11:06:29] can't read "version": no such variable
[oldskewl(dcc)]     while executing
[oldskewl(dcc)] "split $version"
[oldskewl(dcc)]     invoked from within
[oldskewl(dcc)] "if {[string trimleft [lindex [split $version] 1] 0] < 1032200} {
[oldskewl(dcc)]   die "*** netbots.tcl $nb_ver requires eggdrop 1.3.22 or later. Please upgrade your ..."
[oldskewl(dcc)]     (file "netbots/netbots.tcl" line 13)
[oldskewl(dcc)]     invoked from within
[oldskewl(dcc)] "source netbots/netbots.tcl"
[oldskewl(dcc)]     (file "oldskewl.conf" line 1374)
[oldskewl(dcc)] [11:06:29] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)
*** Connection closed
I simply do not get it. lol

But like I said, if I change the code to read the file locally, everything works fine.
s
streamish
Voice
Posts: 21
Joined: Fri Dec 03, 2010 4:33 pm

Post by streamish »

On a side note, I have tried this on multiple eggdrops on different servers. Same result. The script itself runs fantastic. It only crashes when I need to rehash the eggdrop
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

syllable3 wrote: Rehash fails

Code: Select all

[oldskewl(dcc)] [11:06:29] Writing channel file...
[oldskewl(dcc)] [11:06:29] Listening at telnet port 42000 (all).
[oldskewl(dcc)] [11:06:29] Loading netbots.tcl v4.10...
[oldskewl(dcc)] [11:06:29] Tcl error in file 'oldskewl.conf':
[oldskewl(dcc)] [11:06:29] can't read "version": no such variable
[oldskewl(dcc)]     while executing
[oldskewl(dcc)] "split $version"
[oldskewl(dcc)]     invoked from within
[oldskewl(dcc)] "if {[string trimleft [lindex [split $version] 1] 0] < 1032200} {
[oldskewl(dcc)]   die "*** netbots.tcl $nb_ver requires eggdrop 1.3.22 or later. Please upgrade your ..."
[oldskewl(dcc)]     (file "netbots/netbots.tcl" line 13)
[oldskewl(dcc)]     invoked from within
[oldskewl(dcc)] "source netbots/netbots.tcl"
[oldskewl(dcc)]     (file "oldskewl.conf" line 1374)
[oldskewl(dcc)] [11:06:29] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)
*** Connection closed
I simply do not get it. lol

But like I said, if I change the code to read the file locally, everything works fine.
It isn't this script causing your issue. It's "netbots" causing your issue here. For some reason or another. You may need to contact "slennox" personally on this one. The owner of these very forums. "netbots" is his baby.. ;)

note: You can likely #comment or remove all those $version checks as your likely not using such an ancient eggdrop. :D
Last edited by speechles on Wed Mar 30, 2011 3:08 pm, edited 1 time in total.
s
streamish
Voice
Posts: 21
Joined: Fri Dec 03, 2010 4:33 pm

Post by streamish »

Alright, thanks for all your help
Post Reply