|
@@ -8,6 +8,8 @@
|
|
|
#
|
|
#
|
|
|
# Must .chanset #channel +ud
|
|
# Must .chanset #channel +ud
|
|
|
#
|
|
#
|
|
|
|
|
+# Uses is.gd to shorten long definition URL if isgd.tcl package present
|
|
|
|
|
+#
|
|
|
|
|
|
|
|
package require htmlparse
|
|
package require htmlparse
|
|
|
package require http
|
|
package require http
|
|
@@ -34,6 +36,9 @@ namespace eval ud {
|
|
|
|
|
|
|
|
setudef flag ud
|
|
setudef flag ud
|
|
|
bind pub -|- $ud::trigger ud::handler
|
|
bind pub -|- $ud::trigger ud::handler
|
|
|
|
|
+
|
|
|
|
|
+ # 0 if isgd package is present
|
|
|
|
|
+ variable isgd_disabled [catch {package require isgd}]
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
proc ud::handler {nick uhost hand chan argv} {
|
|
proc ud::handler {nick uhost hand chan argv} {
|
|
@@ -60,7 +65,7 @@ proc ud::handler {nick uhost hand chan argv} {
|
|
|
foreach line [ud::split_line $ud::line_length [dict get $result definition]] {
|
|
foreach line [ud::split_line $ud::line_length [dict get $result definition]] {
|
|
|
if {[incr output] > $ud::max_lines} {
|
|
if {[incr output] > $ud::max_lines} {
|
|
|
if {$ud::show_truncate} {
|
|
if {$ud::show_truncate} {
|
|
|
- $ud::output_cmd "PRIVMSG $chan :Output truncated. ${ud::url}?[http::formatQuery term $query defid [dict get $result number]]"
|
|
|
|
|
|
|
+ $ud::output_cmd "PRIVMSG $chan :Output truncated. [ud::def_url $query $result]"
|
|
|
}
|
|
}
|
|
|
break
|
|
break
|
|
|
}
|
|
}
|
|
@@ -103,6 +108,19 @@ proc ud::parse {query raw_definition} {
|
|
|
return [list number $number definition "$query is $definition"]
|
|
return [list number $number definition "$query is $definition"]
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+proc ud::def_url {query result} {
|
|
|
|
|
+ set raw_url ${ud::url}?[http::formatQuery term $query defid [dict get $result number]]
|
|
|
|
|
+ if {$ud::isgd_disabled} {
|
|
|
|
|
+ return $raw_url
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if {[catch {isgd::shorten $raw_url} shortened]} {
|
|
|
|
|
+ return "$raw_url (is.gd error)"
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return $shortened
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
# by fedex
|
|
# by fedex
|
|
|
proc ud::split_line {max str} {
|
|
proc ud::split_line {max str} {
|
|
|
set last [expr {[string length $str] -1}]
|
|
set last [expr {[string length $str] -1}]
|