| View previous topic :: View next topic |
| Author |
Message |
XtremeSeb Voice
Joined: 11 Jun 2016 Posts: 10 Location: Romania
|
Posted: Sat Jun 11, 2016 12:11 pm Post subject: Error on script |
|
|
Hello guys, i need a little help with 2 scripts . The first one:
| Code: | 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: | 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" |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Sat Jun 11, 2016 12:14 pm Post subject: |
|
|
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: |
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. _________________ Once the game is over, the king and the pawn go back in the same box.
Last edited by caesar on Sun Jun 12, 2016 2:31 am; edited 1 time in total |
|
| Back to top |
|
 |
XtremeSeb Voice
Joined: 11 Jun 2016 Posts: 10 Location: Romania
|
Posted: Sat Jun 11, 2016 12:25 pm Post subject: |
|
|
| I get this error now - Tcl error [::zodiac::fetch]: can't read "html": no such variable |
|
| Back to top |
|
 |
XtremeSeb Voice
Joined: 11 Jun 2016 Posts: 10 Location: Romania
|
Posted: Sat Jun 11, 2016 12:57 pm Post subject: |
|
|
| If anyone has a horoscope tcl that works , please post it. |
|
| Back to top |
|
 |
juanamores Master
Joined: 15 Mar 2015 Posts: 317
|
Posted: Sat Jun 11, 2016 7:29 pm Post subject: |
|
|
| 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  |
|
| Back to top |
|
 |
XtremeSeb Voice
Joined: 11 Jun 2016 Posts: 10 Location: Romania
|
Posted: Sat Jun 11, 2016 7:41 pm Post subject: |
|
|
| The same script works fine on another eggdrop. But the owner is offline for a lot of time.. |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Sun Jun 12, 2016 2:34 am Post subject: |
|
|
As I was testing stuff mixed variables and now should work fine. Replace:
| Code: |
regexp -nocase {<div class="textArticol">(.*?)</div>} $html text
|
with:
| Code: |
regexp -nocase {<div class="textArticol">(.*?)</div>} $data text
|
_________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
XtremeSeb Voice
Joined: 11 Jun 2016 Posts: 10 Location: Romania
|
Posted: Sun Jun 12, 2016 3:06 am Post subject: |
|
|
| Yees its working fine, thank you so much caesar. But he answers to the user with notice. Can he reply on main? |
|
| Back to top |
|
 |
XtremeSeb Voice
Joined: 11 Jun 2016 Posts: 10 Location: Romania
|
Posted: Sun Jun 12, 2016 3:29 am Post subject: |
|
|
| Done! Its working great. Thanks again. |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Sun Jun 12, 2016 5:39 am Post subject: |
|
|
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: |
if {[string equal -nocase $nick $botnick]} {return}
|
I would actually use:
| Code: |
if {[isbotnick $nick]} return
|
_________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
XtremeSeb Voice
Joined: 11 Jun 2016 Posts: 10 Location: Romania
|
Posted: Sun Jun 12, 2016 10:08 am Post subject: |
|
|
| Yes! Its working great. Thank you for your help caesar |
|
| Back to top |
|
 |
juanamores Master
Joined: 15 Mar 2015 Posts: 317
|
Posted: Sat Jun 18, 2016 12:56 am Post subject: |
|
|
| 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  |
|
| Back to top |
|
 |
XtremeSeb Voice
Joined: 11 Jun 2016 Posts: 10 Location: Romania
|
Posted: Mon Jun 20, 2016 4:20 pm Post subject: |
|
|
Yes juanamores, this time  |
|
| Back to top |
|
 |
XtremeSeb Voice
Joined: 11 Jun 2016 Posts: 10 Location: Romania
|
Posted: Mon Jun 20, 2016 4:26 pm Post subject: |
|
|
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 "
|
|
| Back to top |
|
 |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Mon Jun 20, 2016 6:48 pm Post subject: |
|
|
hi caesar
It is possible that your tcl
You can modify and read from :
>>> http://www.horoscope.com/
thanks _________________
thanks to that they help, that others learn  |
|
| Back to top |
|
 |
|