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.

Error on script

Help for those learning Tcl or writing their own scripts.
X
XtremeSeb
Voice
Posts: 10
Joined: Sat Jun 11, 2016 11:26 am
Location: Romania

Error on script

Post by XtremeSeb »

Hello guys, i need a little help with 2 scripts . The first one:

Code: Select all

package require http 

setudef flag horoscop 

 bind pub -|- !horoscop check_zodie 

 proc check_zodie {nick uhost hand chan arg} { 
    if {![channel get $chan horoscop]} { return 0 } 

        set target [lindex [split [string tolower $arg]] 0] 
    if {$target eq "" || ![regexp {^(berbec|taur|gemeni|rac|leu|fecioara|balanta|scorpion|sagetator|capricorn|varsator|pesti)$} $target]} { 
        putserv "NOTICE $nick :Foloseste: !horoscop <semn zodiacal>" 
        return 0 
        } 
        
        set pagina "http://www.zodii.ro/zodiac/$target*zodie_$target-horoscop_zilnic.html" 
        set http [http::config -useragent "Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; PPC; 240x320)"] 
        set http [http::geturl $pagina -timeout [expr {1000*5}]] 
        set html [http::data $http] 
        http::cleanup $http 
        
        regsub -all -- "\n" $html "" html 
        regexp {</iframe><br />(.*?)</div>} $html a horoscopo 
        putserv "NOTICE $nick :[string toupper $target]: $horoscopo" 
      return 0 
 } 
  
 putlog "Horoscop loaded sucessfully. Created by Costin" 
Tcl error [check_zodie]: can't read "horoscopo": no such variable.

The second :

Code: Select all

bind join - * hymaster 

proc hymaster {nick uhost hand chan} { 
   global botnick 

   if {[string equal -nocase $nick $botnick]} {return} elseif { 
      [check:N:gl $hand]} {puthelp "PRIVMSG $chan :4WoOoW ...7 $nick 2este al meu 4Global 14MANAGER  4A2scundeti-va  de \0034$nick4;2)"} elseif { 
      [check:n:gl $hand]} {puthelp "PRIVMSG $chan :4WoOoW ...10 $nick 2este al meu 4Global 10Owner  4S2alut $nick 4:2)"} elseif { 
      [check:m:gl $hand]} {puthelp "PRIVMSG $chan :4WoOoW ...5 $nick 2este al meu 4Global 5Master  4S2alut $nick 4;2))"} 
} 
Tcl error [hymaster]: invalid command name "check:N:gl"
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

You get that error on first cos the regexp doesn't match anything and thus he doesn't create the horoscopo and gives you an error when trying to use something hasn't been defined.

Haven't tested so give a try to:

Code: Select all

namespace eval zodiac {
	package require http
	setudef flag horoscop
	bind pub -|- !horoscop [namespace current]::fetch

	proc fetch {nick uhost hand chan text} {
		if {![channel get $chan horoscop]} return
		if {[scan $text {%s} sign] != 1} {
			putserv "NOTICE $nick :Syntax: !horoscop <zodiac sign>"
			return
		}
		set signs [list "berbec" "taur" "gemeni" "rac" "leu" "fecioara" "balanta" "scorpion" "sagetator" "capricorn" "varsator" "pesti"]
		set sign [string tolower $sign]
		if {[lsearch $signs $sign] == -1} {
			putserv "NOTICE $nick :Error, $sign is a uknown sign. Pick another."
			return
		}
		set http [::http::geturl "http://www.zodii.ro/zodiac/$sign*zodie_$sign-horoscop_zilnic.html"]
		set data [::http::data $http]
		::http::cleanup $http
		regexp -nocase {<div class="textArticol">(.*?)</div>} $data text
		set result [lrange $text 2 end-1]
		putserv "NOTICE $nick :[string toupper $sign]: $result"
	} 
}
I'm not a regexp guru so I bet someone will come with a better solution than mine. :)

As for the second, you are missing a chunk of that script cos it's not finding the check:m:gl function (proc).

Edit: Fixed typo.
Last edited by caesar on Sun Jun 12, 2016 2:31 am, edited 1 time in total.
Once the game is over, the king and the pawn go back in the same box.
X
XtremeSeb
Voice
Posts: 10
Joined: Sat Jun 11, 2016 11:26 am
Location: Romania

Post by XtremeSeb »

I get this error now - Tcl error [::zodiac::fetch]: can't read "html": no such variable
X
XtremeSeb
Voice
Posts: 10
Joined: Sat Jun 11, 2016 11:26 am
Location: Romania

Post by XtremeSeb »

If anyone has a horoscope tcl that works , please post it.
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Post by juanamores »

XtremeSeb wrote:If anyone has a horoscope tcl that works , please post it.
The problem with all scripts who use sockets is that web pages change and the code stops working.
I have tried several but none worked.
I hope you have luck and someone shares one that works.
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
X
XtremeSeb
Voice
Posts: 10
Joined: Sat Jun 11, 2016 11:26 am
Location: Romania

Post by XtremeSeb »

The same script works fine on another eggdrop. But the owner is offline for a lot of time..
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

As I was testing stuff mixed variables and now should work fine. Replace:

Code: Select all

regexp -nocase {<div class="textArticol">(.*?)</div>} $html text
with:

Code: Select all

regexp -nocase {<div class="textArticol">(.*?)</div>} $data text
Once the game is over, the king and the pawn go back in the same box.
X
XtremeSeb
Voice
Posts: 10
Joined: Sat Jun 11, 2016 11:26 am
Location: Romania

Post by XtremeSeb »

Yees its working fine, thank you so much caesar. But he answers to the user with notice. Can he reply on main?
X
XtremeSeb
Voice
Posts: 10
Joined: Sat Jun 11, 2016 11:26 am
Location: Romania

Post by XtremeSeb »

Done! Its working great. Thanks again.
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

As for the other script I take it the check:N:gl, check:n:gl and check:m:gl is a proc that basically is checking if the user has the global N, n or m flag.

Easy to change things so instead of check:N:gl $hand can dirrectly use matchattr $hand N and for the other two matchattr $hand n and matchattr $hand m.

Oh and instead of:

Code: Select all

if {[string equal -nocase $nick $botnick]} {return}
I would actually use:

Code: Select all

if {[isbotnick $nick]} return
Once the game is over, the king and the pawn go back in the same box.
X
XtremeSeb
Voice
Posts: 10
Joined: Sat Jun 11, 2016 11:26 am
Location: Romania

Post by XtremeSeb »

Yes! Its working great. Thank you for your help caesar
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Post by juanamores »

XtremeSeb wrote:Yes! Its working great. Thank you for your help caesar
You did it, XtremeSeb !
I 'll make a post to see if anyone help me with sockets.
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
X
XtremeSeb
Voice
Posts: 10
Joined: Sat Jun 11, 2016 11:26 am
Location: Romania

Post by XtremeSeb »

Yes juanamores, this time :D
X
XtremeSeb
Voice
Posts: 10
Joined: Sat Jun 11, 2016 11:26 am
Location: Romania

Post by XtremeSeb »

I don`t want to open a new topic so i will write here, i have a new problem with a code that worked fine untill the shell went down. I`ve re-uploaded but give`s me an error. This is the code:


if {![info exists anuntpublic:show_running]} {
timer $black(anunttime) anuntpublic:show
set anuntpublic:show_running 1




Error: can't read "black(anunt_time)": no such element in array
while executing
"timer $black(anunt_time) anuntpublic_show "
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Post by Arnold_X-P »

hi caesar
It is possible that your tcl
You can modify and read from :

>>> http://www.horoscope.com/


thanks
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
Post Reply