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.
Help for those learning Tcl or writing their own scripts.
XtremeSeb
Voice
Posts: 10 Joined: Sat Jun 11, 2016 11:26 am
Location: Romania
Post
by XtremeSeb » Sat Jun 11, 2016 12:11 pm
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"
caesar
Mint Rubber
Posts: 3778 Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory
Post
by caesar » Sat Jun 11, 2016 12:14 pm
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 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.
XtremeSeb
Voice
Posts: 10 Joined: Sat Jun 11, 2016 11:26 am
Location: Romania
Post
by XtremeSeb » Sat Jun 11, 2016 12:25 pm
I get this error now - Tcl error [::zodiac::fetch]: can't read "html": no such variable
XtremeSeb
Voice
Posts: 10 Joined: Sat Jun 11, 2016 11:26 am
Location: Romania
Post
by XtremeSeb » Sat Jun 11, 2016 12:57 pm
If anyone has a horoscope tcl that works , please post it.
juanamores
Master
Posts: 317 Joined: Sun Mar 15, 2015 9:59 am
Post
by juanamores » Sat Jun 11, 2016 7:29 pm
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
XtremeSeb
Voice
Posts: 10 Joined: Sat Jun 11, 2016 11:26 am
Location: Romania
Post
by XtremeSeb » Sat Jun 11, 2016 7:41 pm
The same script works fine on another eggdrop. But the owner is offline for a lot of time..
caesar
Mint Rubber
Posts: 3778 Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory
Post
by caesar » Sun Jun 12, 2016 2:34 am
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.
XtremeSeb
Voice
Posts: 10 Joined: Sat Jun 11, 2016 11:26 am
Location: Romania
Post
by XtremeSeb » Sun Jun 12, 2016 3:06 am
Yees its working fine, thank you so much caesar. But he answers to the user with notice. Can he reply on main?
XtremeSeb
Voice
Posts: 10 Joined: Sat Jun 11, 2016 11:26 am
Location: Romania
Post
by XtremeSeb » Sun Jun 12, 2016 3:29 am
Done! Its working great. Thanks again.
caesar
Mint Rubber
Posts: 3778 Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory
Post
by caesar » Sun Jun 12, 2016 5:39 am
As for the other script I take it the
check:N:gl ,
check:n:gl and
check 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:
Once the game is over, the king and the pawn go back in the same box.
XtremeSeb
Voice
Posts: 10 Joined: Sat Jun 11, 2016 11:26 am
Location: Romania
Post
by XtremeSeb » Sun Jun 12, 2016 10:08 am
Yes! Its working great. Thank you for your help caesar
juanamores
Master
Posts: 317 Joined: Sun Mar 15, 2015 9:59 am
Post
by juanamores » Sat Jun 18, 2016 12:56 am
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
XtremeSeb
Voice
Posts: 10 Joined: Sat Jun 11, 2016 11:26 am
Location: Romania
Post
by XtremeSeb » Mon Jun 20, 2016 4:20 pm
Yes
juanamores , this time
XtremeSeb
Voice
Posts: 10 Joined: Sat Jun 11, 2016 11:26 am
Location: Romania
Post
by XtremeSeb » Mon Jun 20, 2016 4:26 pm
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 "
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 » Mon Jun 20, 2016 6:48 pm
hi caesar
It is possible that your tcl
You can modify and read from :
>>>
http://www.horoscope.com/
thanks