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 

Horoscope tcl error

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
doni
Voice


Joined: 21 Aug 2018
Posts: 13

PostPosted: Tue Dec 03, 2019 2:44 am    Post subject: Horoscope tcl error Reply with quote

Hi guys!

I get this error in PL:
Code:
 Tcl error [oroscopo:request]: can't read "segno": no such variable


Someone can help me, please?

Code:
###########################################################
#
#    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"
Back to top
View user's profile Send private message
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 852
Location: France

PostPosted: Tue Dec 03, 2019 4:27 am    Post subject: Reply with quote

The template of the page has changed.
May work with something like:
Code:
if { [ regexp -nocase -- {<div class="oroscopo">.+<h1>(.+)<span.+<p>([^<]+)</p>} $html all segno testo ] } {

_________________
https://www.eggdrop.fr
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
doni
Voice


Joined: 21 Aug 2018
Posts: 13

PostPosted: Tue Dec 03, 2019 2:24 pm    Post subject: Reply with quote

CrazyCat wrote:
The template of the page has changed.
May work with something like:
Code:
if { [ regexp -nocase -- {<div class="oroscopo">.+<h1>(.+)<span.+<p>([^<]+)</p>} $html all segno testo ] } {


reply is empty:

Code:
[19:18:11] <@doni> !oroscopo vergine
[19:18:12] <Toolz> --Oroscopo VERGINE:
Back to top
View user's profile Send private message
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 852
Location: France

PostPosted: Tue Dec 03, 2019 7:04 pm    Post subject: Reply with quote

Try using the following regex:
Code:
(?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
_________________
https://www.eggdrop.fr
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
doni
Voice


Joined: 21 Aug 2018
Posts: 13

PostPosted: Wed Dec 04, 2019 5:11 pm    Post subject: Reply with quote

i have fixed in this way:
Code:
if { [ regexp -nocase -- {<p>([^<]+)</p>} $html all segno testo ] } {
Back to top
View user's profile Send private message
MrBeta
Voice


Joined: 28 Dec 2013
Posts: 35

PostPosted: Thu Sep 10, 2020 3:49 am    Post subject: Reply with quote

it stopped working for me Confused
Back to top
View user's profile Send private message Visit poster's website
Suratka
Voice


Joined: 25 Jun 2016
Posts: 19

PostPosted: Sat Dec 19, 2020 5:08 pm    Post subject: Reply with quote

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

????

helpme

Code:
###########################################################
#
#    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"
Back to top
View user's profile Send private message Visit poster's website AIM Address
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases All times are GMT - 4 Hours
Page 1 of 1

 
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