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 ::http::geturl

Help for those learning Tcl or writing their own scripts.
Post Reply
M
Merky
Voice
Posts: 17
Joined: Sun Jan 21, 2007 9:07 am

Help ::http::geturl

Post by Merky »

Code: Select all

package require http
package require tls
::http::register https 443 tls:socket 

bind pub - .adzan pub:sholat

proc tls:socket args { 
   set opts [lrange $args 0 end-2] 
   set host [lindex $args end-1] 
   set port [lindex $args end] 
   ::tls::socket -servername $host {*}$opts $host $port 
}
	
proc pub:sholat {nick uhost hand chan text} {
	global snamadaerah skodedaerah
	set skodedaerah ""
	set snamadaerah ""
	if {$text == ""} {
          puthelp "NOTICE $nick :Gunakan: !adzan kisaran"
          return 0
	 }
set namanih [string tolower $text]
switch -- $namanih {
	"ambarawa" { set skodedaerah "1" 
	set snamadaerah "Ambarawa" }
	"ambon" { set skodedaerah "2" 
	set snamadaerah "Ambon" }
	"amlapura" { set skodedaerah "3" 
	set snamadaerah "Amlapura" }
	"amuntai" { set skodedaerah "4" 
	set snamadaerah "Amuntai" }
	"argamakmur" { set skodedaerah "5" 
	set snamadaerah "Argamakmur" }
	"atambua" { set skodedaerah "6" 
	set snamadaerah "Atambua" }
	"babo" { set skodedaerah "7" 
	set snamadaerah "Babo" }
	"bagan siapiapi" { set skodedaerah "8" 
	set snamadaerah "Bagan Siapiapi" }
	"bajawa" { set skodedaerah "9" 
	set snamadaerah "Bajawa" }
	"balige" { set skodedaerah "10" 
	set snamadaerah "Balige" }

	default { 
		set skodedaerah "140" 	 
		set snamadaerah "Kisaran" 
		}
	}	
	Pub:ShareAdzan $skodedaerah $snamadaerah $chan
}

proc Pub:ShareAdzan {skodedaerah snamadaerah chan} {
global sharesubuh sharedzuhur shareashar sharemaghrib shareisya
#	set connect [::http::geturl http://jadwal-sholat.info/daily.php?id=$skodedaerah]
#	set connect [::http::geturl http://jadwalsholatimsak.com/daily.php?id=$skodedaerah]
	set connect [::http::geturl https://www.jadwalsholat.org/adzan/daily.php?id=$skodedaerah]
	set files [::http::data $connect]
#	set l [regexp -all -inline -- {.*?<tr class="table_light" align="center"><td><b>.*?</b></td><td>.*?</td><td>(.*?):(.*?)</td><td>(.*?):(.*?)</td><td>(.*?):(.*?)</td><td>(.*?):(.*?)</td><td>(.*?):(.*?)</td></tr>.*?<tr class="table_block_title"><td colspan="7">} $files]
	set l [regexp -all -inline -- {.*?<tr class="table_light" align="center"><td><b>.*?</b></td><td>.*?</td><td>(.*?):(.*?)</td><td>.*?</td><td>.*?</td><td>(.*?):(.*?)</td><td>(.*?):(.*?)</td><td>(.*?):(.*?)</td><td>(.*?):(.*?)</td></tr>.*?<tr class="table_block_title"><td colspan="9">} $files]
	   if {[llength $l] != 0} {
			foreach {black a b c d e f g h i j} $l {
			set a [string trim $a " \n"]
			set b [string trim $b " \n"]
			set c [string trim $c " \n"]
			set d [string trim $d " \n"]
			set e [string trim $e " \n"]
			set f [string trim $f " \n"]
			set g [string trim $g " \n"]
			set h [string trim $h " \n"]
			set i [string trim $i " \n"]
			set j [string trim $j " \n"]

			regsub -all {<.+?>} $a {} a	
			regsub -all {<.+?>} $b {} b
			regsub -all {<.+?>} $c {} c
			regsub -all {<.+?>} $d {} d
			regsub -all {<.+?>} $e {} e
			regsub -all {<.+?>} $f {} f
			regsub -all {<.+?>} $g {} g
			regsub -all {<.+?>} $h {} h
			regsub -all {<.+?>} $i {} i
			regsub -all {<.+?>} $j {} j
			
			putlog "Ambil Data Manual Dari http://jadwalsholatimsak.com/"
			
			set sharesubuh "$a:$b:00"
			set sharedzuhur "$c:$d:00"
			set shareashar "$e:$f:00"
			set sharemaghrib "$g:$h:00"
			set shareisya "$i:$j:00"
			
			
			puthelp "PRIVMSG $chan :\[Jadwal Sholat \00307$snamadaerah\003 Dan Sekitarnya\] Subuh: $sharesubuh - Dzuhur: $sharedzuhur - Ashar: $shareashar - Maghrib: $sharemaghrib - Isya: $shareisya"
			set skodedaerah ""
			set snamadaerah ""	
		}	
	}
}
   

Code: Select all

Tcl error [pub:sholat]: wrong # args: should be "tls::socket ?options? host port"
this tcl work in centos7
but not work in Ubuntu 14.04.5 LTS

can anybody help me?
thnks
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

This is some info found on this page -> https://nikit.tcl-lang.org/page/tls
Using TLS in 2016
•Starting with TLS 1.7 SSLv2 and SSLv3 are disabled by default
•TLSv1, TLSv1.1, and TLSv1.2 are enabled by default
•(tls 1.7.11) There is -autoservername true option which will perform the needed "-servername $host" work done in tls::socket, getting rid of the proc below, now you can do: http::register https 443 [list ::tls::socket -autoservername true]
•Building under Windows see BAWT Build Automation With Tcl / Batteries included [1]
Try replacing your ::http::register line with this ->

Code: Select all

http::register https 443 [list ::tls::socket -autoservername true]
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
M
Merky
Voice
Posts: 17
Joined: Sun Jan 21, 2007 9:07 am

Post by Merky »

same problem too

Code: Select all

[01:26:37] Tcl error [pub:sholat]: wrong # args: should be "tls::socket ?options? host port"
wrong # args: should be "tls::socket ?options? host port"
Post Reply