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 

adding a search
Goto page Previous  1, 2
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
streamish
Voice


Joined: 03 Dec 2010
Posts: 21

PostPosted: Fri Mar 25, 2011 2:50 am    Post subject: Reply with quote

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

Code:
[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
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Fri Mar 25, 2011 2:55 am    Post subject: Reply with quote

Try this instead...
Code:
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... Laughing
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
streamish
Voice


Joined: 03 Dec 2010
Posts: 21

PostPosted: Fri Mar 25, 2011 3:01 am    Post subject: Reply with quote

Hahaha, no problem. I should have caught that myself =P
Back to top
View user's profile Send private message
streamish
Voice


Joined: 03 Dec 2010
Posts: 21

PostPosted: Tue Mar 29, 2011 7:22 pm    Post subject: Reply with quote

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:
<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
Back to top
View user's profile Send private message
streamish
Voice


Joined: 03 Dec 2010
Posts: 21

PostPosted: Wed Mar 30, 2011 1:30 pm    Post subject: Reply with quote

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

Code:
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?
Back to top
View user's profile Send private message
caesar
Mint Rubber


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

PostPosted: Wed Mar 30, 2011 1:33 pm    Post subject: Reply with quote

Quote:

<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. Smile
_________________
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
streamish
Voice


Joined: 03 Dec 2010
Posts: 21

PostPosted: Wed Mar 30, 2011 1:39 pm    Post subject: Reply with quote

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:
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:
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
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Wed Mar 30, 2011 1:43 pm    Post subject: Reply with quote

Code:
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
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
streamish
Voice


Joined: 03 Dec 2010
Posts: 21

PostPosted: Wed Mar 30, 2011 1:46 pm    Post subject: Reply with quote

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

Code:
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
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Wed Mar 30, 2011 1:57 pm    Post subject: Reply with quote

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:
# 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]"
}

_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
streamish
Voice


Joined: 03 Dec 2010
Posts: 21

PostPosted: Wed Mar 30, 2011 2:08 pm    Post subject: Reply with quote

Used your code exactly.

Launches fine

Code:
[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:
[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.
Back to top
View user's profile Send private message
streamish
Voice


Joined: 03 Dec 2010
Posts: 21

PostPosted: Wed Mar 30, 2011 2:09 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Wed Mar 30, 2011 2:59 pm    Post subject: Reply with quote

syllable3 wrote:

Rehash fails
Code:
[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.. Wink

note: You can likely #comment or remove all those $version checks as your likely not using such an ancient eggdrop. Very Happy
_________________
speechles' eggdrop tcl archive


Last edited by speechles on Wed Mar 30, 2011 3:08 pm; edited 1 time in total
Back to top
View user's profile Send private message
streamish
Voice


Joined: 03 Dec 2010
Posts: 21

PostPosted: Wed Mar 30, 2011 3:02 pm    Post subject: Reply with quote

Alright, thanks for all your help
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 -> Scripting Help All times are GMT - 4 Hours
Goto page Previous  1, 2
Page 2 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