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.

Horoscope tcl error

Support & discussion of released scripts, and announcements of new releases.
Post Reply
d
doni
Voice
Posts: 13
Joined: Tue Aug 21, 2018 4:13 am

Horoscope tcl error

Post by doni »

Hi guys!

I get this error in PL:

Code: Select all

 Tcl error [oroscopo:request]: can't read "segno": no such variable 
Someone can help me, please?

Code: Select all

###########################################################
#
#    Oroscopo 1.3 tcl for eggdrop (13/06/2005)
#    by lnx85 at #lnxlabs on Azzurra (irc.azzurra.org)
#    E-mail: lnx85@lnxlabs.it
#
#    Per attivare lo script è necessario impostare il flag "+oroscopo" al canale 
#    (.chanset #chan +oroscopo)
#
###########################################################

### GLOBALS ###
set oroscopo(version) 1.3 

package require http
http::config -useragent "Mozilla/1.0"
### END GLOBALS ###

### FLAGS ###
setudef flag oroscopo
### END FLAGS###

### BINDS ###
bind pub - !oroscopo oroscopo:request
### END BINDS ###

### PROCS ###
proc strlastpos { string char {max 0} } {
	if { $max == 0} { set max [ string length $string ] }
	if { [ string length $string ] <= $max } { return [ string length $string ] }
	for { set i 0 } { $i < $max } { incr i } {
		if { [ string index $string [ expr $max - $i ] ] == $char } {
			return [ expr $max - $i ]
		}
	}
	return $max
}

proc max:privmsg:chars { target } {
	return [ expr 500 - 1 - [ string length $::nick ] - 30 - [ string length $target ] - 2 ]
}

proc oroscopo:request { nick uhost hand chan arg } {
	if { [ lsearch -exact [ channel info $chan ] "+oroscopo" ] == -1 } { return }
	putlog "OROSCOPO :: request \"!oroscopo $arg\" from $nick!$uhost on $chan"
	if { $arg == "" || $arg == "help" } {
		 putserv "NOTICE $nick :\002\0034-\0035-\00314O\002roscopo HELP\002\0035:\002\00314 Mostra l'oroscopo per un dato segno zodiacale\
		 \037Utilizzo:\037 !oroscopo segno"
		 return
	}
	regsub -all -- " " $arg "%20" args
	set url "http://www.oroscopi.com/oroscopo/oroscopo_giorno.php?segno=$args"
	set http [ http::geturl $url ]
	set html [ http::data $http ]
	set flag 0
  if { [ regexp -nocase -- {<font face="Verdana"  size="2"><b>([^<]+)</b> <br>([^<]+)</td>} $html all segno testo ] } {
    set risposta "\002\0034-\0035-\00314O\002roscopo \037[ string toupper $segno ]\037\002\0035:\002\00314 $testo"
    set flag 1
  }
	if { $flag == 0 } {
		putserv "PRIVMSG $chan :\002\0034-\0035-\00314O\002roscopo \037[ string toupper $segno ]\037\002\0035:\002\00314 Segno zodiacale non trovato"
	} else {
		set max_chars [ max:privmsg:chars $chan ]
		while { [ string length $risposta ] > 0 } {
			set limit [ strlastpos $risposta " " $max_chars ]
			set risptemp [ string range $risposta 0 $limit ]
			set risposta [ string range $risposta $limit end ]
			if { [ string length $risposta ] != 0 } {
				putserv "PRIVMSG $chan :$risptemp ..."
			} else {
				putserv "PRIVMSG $chan :$risptemp"
			}
		}
	}
}
### END PROCS ###

### INITIAL ###
putlog "\037OROSCOPO\037 \002::\002 \037LOADED\037 version $oroscopo(version) by lnx85"
User avatar
CrazyCat
Revered One
Posts: 1217
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

The template of the page has changed.
May work with something like:

Code: Select all

if { [ regexp -nocase -- {<div class="oroscopo">.+<h1>(.+)<span.+<p>([^<]+)</p>} $html all segno testo ] } {
d
doni
Voice
Posts: 13
Joined: Tue Aug 21, 2018 4:13 am

Post by doni »

CrazyCat wrote:The template of the page has changed.
May work with something like:

Code: Select all

if { [ regexp -nocase -- {<div class="oroscopo">.+<h1>(.+)<span.+<p>([^<]+)</p>} $html all segno testo ] } {
reply is empty:

Code: Select all

[19:18:11] <@doni> !oroscopo vergine
[19:18:12] <Toolz> --Oroscopo VERGINE: 
User avatar
CrazyCat
Revered One
Posts: 1217
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Try using the following regex:

Code: Select all

(?Us)<div class="oroscopo">.+<h1>(.+)<span.+<p>([^<]+)</p>
Not sure on how tcl interprets the (?Us), but it works on regex101: https://regex101.com/r/gim0ua/1
d
doni
Voice
Posts: 13
Joined: Tue Aug 21, 2018 4:13 am

Post by doni »

i have fixed in this way:

Code: Select all

if { [ regexp -nocase -- {<p>([^<]+)</p>} $html all segno testo ] } {
User avatar
MrBeta
Voice
Posts: 35
Joined: Sat Dec 28, 2013 2:16 pm
Contact:

Post by MrBeta »

it stopped working for me :?
S
Suratka
Voice
Posts: 19
Joined: Sat Jun 25, 2016 4:56 pm
Contact:

Post by Suratka »

-NOTICE- *** Cannot send to #siamosolonoi: your message contains too many capital letters (93% >= 50%)

????

helpme

Code: Select all

###########################################################
#
#    Oroscopo 1.3 tcl for eggdrop (13/06/2005)
#    by lnx85 at #lnxlabs on Azzurra (irc.azzurra.org)
#    E-mail: lnx85@lnxlabs.it
#
#    Per attivare lo script è necessario impostare il flag "+oroscopo" al canale
#    (.chanset #chan +oroscopo)
#
###########################################################

### GLOBALS ###
set oroscopo(version) 1.3

package require http
http::config -useragent "Mozilla/1.0"
### END GLOBALS ###

### FLAGS ###
setudef flag oroscopo
### END FLAGS###

### BINDS ###
bind pub - !oroscopo oroscopo:request
### END BINDS ###

### PROCS ###
proc strlastpos { string char {max 0} } {
   if { $max == 0} { set max [ string length $string ] }
   if { [ string length $string ] <= $max } { return [ string length $string ] }
   for { set i 0 } { $i < $max } { incr i } {
      if { [ string index $string [ expr $max - $i ] ] == $char } {
         return [ expr $max - $i ]
      }
   }
   return $max
}

proc max:privmsg:chars { target } {
   return [ expr 500 - 1 - [ string length $::nick ] - 30 - [ string length $target ] - 2 ]
}

proc oroscopo:request { nick uhost hand chan arg } {
   if { [ lsearch -exact [ channel info $chan ] "+oroscopo" ] == -1 } { return }
   putlog "OROSCOPO :: request \"!oroscopo $arg\" from $nick!$uhost on $chan"
   if { $arg == "" || $arg == "help" } {
       putserv "NOTICE $nick :\002\0034-\0035-\00314O\002roscopo HELP\002\0035:\002\00314 Mostra l'oroscopo per un dato segno zodiacale\
       \037Utilizzo:\037 !oroscopo segno"
       return
   }
   regsub -all -- " " $arg "%20" args
   set url "http://www.oroscopi.com/oroscopo/oroscopo_giorno.php?segno=$args"
   set http [ http::geturl $url ]
   set html [ http::data $http ]
   set flag 0
if { [ regexp -nocase -- {<p>([^<]+)</p>} $html all segno testo ] } {
    set risposta "\002\0034-\0035-\00314O\002roscopo \037[ string toupper $segno ]\037\002\0035:\002\00314 $testo"
    set flag 1
  }
   if { $flag == 0 } {
      putserv "PRIVMSG $chan :\002\0034-\0035-\00314O\002roscopo \037[ string toupper $segno ]\037\002\0035:\002\00314 Segno zodiacale non trovato"
   } else {
      set max_chars [ max:privmsg:chars $chan ]
      while { [ string length $risposta ] > 0 } {
         set limit [ strlastpos $risposta " " $max_chars ]
         set risptemp [ string range $risposta 0 $limit ]
         set risposta [ string range $risposta $limit end ]
         if { [ string length $risposta ] != 0 } {
            putserv "PRIVMSG $chan :$risptemp ..."
         } else {
            putserv "PRIVMSG $chan :$risptemp"
         }
      }
   }
}
### END PROCS ###

### INITIAL ###
putlog "\037OROSCOPO\037 \002::\002 \037LOADED\037 version $oroscopo(version) by lnx85"
Post Reply