--- ../../scripts/title_pub.tcl.orig	2015-11-03 20:08:10.000000000 +0000
+++ ../../scripts/title_pub.tcl	2016-02-09 06:05:26.000000000 +0000
@@ -32,7 +32,7 @@
 variable deftemplate {\002Title\002:}
 # защита от флуда (в секундах)
 variable flood 3
-# канальный флаг, разрешающий/запрещающий работу скрипта
+# канальный флаг, разрешающий/запрещающий работу скрипта (.chanset #chan +title)
 variable chflag [namespace tail [namespace current]]
 
 #################
@@ -41,6 +41,7 @@
 
 
 package require http 2.7
+if {[catch {package require zlib} err]} {putlog "Package ZLIB not loaded. compressed paged not supported. Info: $err."}
 if {![catch {package require tls} err]} {::http::register https 443 ::tls::socket; variable using_ssl 1} else {putlog "Package TLS not loaded. 'https://' not supported. Info: $err."; variable using_ssl 0}
 setudef flag $chflag
 setudef flag nobadtitle
@@ -71,8 +72,8 @@
     foreach _ $domains {
         if {![string match "*$_*" "$text"]} {continue}
         if {[string match "*$_*" "$text"]} {return 0}
-}
-return 1
+    }
+    return 1
 }
 
 
@@ -83,7 +84,7 @@
     regsub -all {[\[\]\{\}\(\)\"\'\>\<]} $text "" text
     set text [stripcodes bcruag $text]
     foreach _ $denyprefixes {
-        if {[string index $text 0] eq $_} {if {$debug} {putlog "::title:: \[main\] Found denied prefix. Not responding."};return}
+        if {[string index $text 0] eq $_} {if {$debug} {log "::title:: \[main\] Found denied prefix. Not responding."};return}
 }
 if {![string match "*http://*" $text] && ![string match "*https://*" $text] && ![string match "*www.*" $text] && ![string match "*wap.*" $text] && [nodomain $text]} {if {$debug} {putlog "::title:: \[main\] Links not found."}; return}
 variable flood
@@ -103,8 +104,12 @@
 
 proc request {url nick uhost chan} {
     variable useragent; variable debug; variable timeout; variable readlimit
-    if {[string range $url 0 7] eq "http://-"} {set url "http://[string range [string trim $url "-"] 8 end]"}
-    if {[string range $url 0 6] ne "http://"} {set url "http://$url"}
+    if {[string range $url 0 7] eq "http://-"} {
+        set url "http://[string range [string trim $url "-"] 8 end]"
+    } elseif {[string range $url 0 7] eq "https://"} {
+    } elseif {[string range $url 0 6] ne "http://"} {
+        set url "http://$url"
+    }
     set extra [list $nick $uhost $chan $url]
     ::http::config -useragent $useragent
     if {$debug} {putlog "::title \[request\] Extra: $extra."}
@@ -119,7 +124,14 @@
     set status [::http::status $token]
     set ncode [::http::ncode $token]
     array set meta [::http::meta $token]
-    if {$debug} {putlog "::title:: \[data\] status: $status\; metacode: $ncode\."}
+    if {$debug} {
+        if {$status == "error"} {
+            set err [regsub -all \n [::http::error $token] |]
+            putlog "::title:: \[data\] status: $status\; error: $err\; metacode: $ncode\."
+        } else {
+            putlog "::title:: \[data\] status: $status\; metacode: $ncode\."
+        }
+    }
     if {![info exists meta(Content-Length)]} {set Size "Unknown size"} else {set Size [fsize $meta(Content-Length)]}
     if {[info exists meta(Content-Range)]} {set Size [fsize [lindex [regexp -inline -- {bytes.*?\/(.+?)$} $meta(Content-Range)] 1]]}
     if {[info exists meta(Content-Type)]} {set Type $meta(Content-Type)} else {set Type "Unknown type"}
@@ -147,7 +159,7 @@
             set url $link
             ::http::cleanup $token
             ::title::request $url $nick $uhost $chan
-}
+    }
 } else {
     if {$debug} {putlog "::title:: \[data\] Data received. Processing..."}
     catch {array unset meta; unset -nocomplain meta}
@@ -172,23 +184,24 @@
 }
 
 switch -glob -- [string range $html 0 19] {
-    "GIF8*" {set title [gif_dimensions $html]; set sh_size 1}
-    "\x89PNG\r\n\x1a\n*" {set title [png_dimensions $html]; set sh_size 1}
-    "\xFF\xD8\xFF*" {set title [jpeg_dimensions $html]; set sh_size 1}
-    "BM*" {set title [bmp_dimensions $html]; set sh_size 1}
+    #"GIF8*" {set title [gif_dimensions $html]; set sh_size 1}
+    #"\x89PNG\r\n\x1a\n*" {set title [png_dimensions $html]; set sh_size 1}
+    #"\xFF\xD8\xFF*" {set title [jpeg_dimensions $html]; set sh_size 1}
+    #"BM*" {set title [bmp_dimensions $html]; set sh_size 1}
     default {set title [::title::decode $html $charset]; set template $deftemplate; set sh_size 0}
 }
 
 
 if {$title ne ""} {
-    if {[channel get $chan nobadtitle] && [DetectMat [encoding convertto cp1251 $title]]} {set title "\[censored\]"}
+    #if {[channel get $chan nobadtitle] && [DetectMat [encoding convertto cp1251 $title]]} {set title "\[censored\]"}
+    if {[channel get $chan nobadtitle] && [DetectMat [encoding convertto utf-8 $title]]} {set title "\[censored\]"}
     if {$sh_size} {append title " @ $Size"}
     putserv "PRIVMSG $chan :[subst $template] $title"
 
     variable redir
     set redir 0
 } else {
-    putserv "PRIVMSG $chan :\002File\002: \037Type\037: $Type @ $Size"
+    #putserv "PRIVMSG $chan :\002File\002: \037Type\037: $Type @ $Size"
     return
 }
 }
@@ -341,7 +354,7 @@
 
     set t [string map -nocase {{&mdash;} {-} {&raquo;} {»} {&laquo;} {«} {&quot;} {"}  \
             {&lt;} {<} {&gt;} {>} {&nbsp;} { } {&amp;} {&} {&copy;} {©} {&#169;} {©} {&bull;} {•} {&#183;} {-} {&sect;} {§} {&reg;} {®} \
-            &#8214;    || \
+            &#8214;  {&#x202a;} {} {&#x202c;} {} {&rlm;} {} {&rln;} {}    || \
             &#38;      &     &#91;      (     &#92;      /     &#93;      )      &#123;     (     &#125;     ) \
             &#163;     Ј     &#168;     Ё     &#169;     ©     &#171;     «      &#173;     ­     &#174;     ® \
             &#161;     Ў     &#191;     ї     &#180;     ґ     &#183;     ·      &#185;     №     &#187;     » \
