Selaa lähdekoodia

Merge pull request #1 from ScottSteiner/master

Fixed help message in slang.tcl, various fixes in wiki.tcl
Will Storey 13 vuotta sitten
vanhempi
commit
bff8c754e4
2 muutettua tiedostoa jossa 6 lisäystä ja 5 poistoa
  1. 2 2
      slang.tcl
  2. 4 3
      wiki.tcl

+ 2 - 2
slang.tcl

@@ -16,7 +16,7 @@ package require http
 
 namespace eval ud {
 	# set this to !ud or whatever you want
-	variable trigger "slang"
+	variable trigger ".ud"
 
 	# maximum lines to output
 	variable max_lines 1
@@ -56,7 +56,7 @@ proc ud::handler {nick uhost hand chan argv} {
 	}
 
 	if {[llength $argv] == 1 && [string is digit [lindex $argv 0]]} {
-		$ud::output_cmd "PRIVMSG $chan :Usage: slang \[#\] <query> (or just slang for random definition)"
+		$ud::output_cmd "PRIVMSG $chan :Usage: $ud::trigger \[#\] <query> (or just $ud::trigger for random definition)"
 		return
 	}
 

+ 4 - 3
wiki.tcl

@@ -16,8 +16,9 @@ package require htmlparse
 
 namespace eval wiki {
 	variable max_lines 1
+	variable max_chars 400
 	variable output_cmd "putserv"
-	variable url "http://en.wikipedia.org/wiki/"
+	variable url "https://en.wikipedia.org/wiki/"
 
 	bind pub -|- "!w" wiki::search
 	bind pub -|- "!wiki" wiki::search
@@ -32,7 +33,7 @@ proc wiki::fetch {term {url {}}} {
 	if {$url != ""} {
 		set token [http::geturl $url -timeout 10000]
 	} else {
-		set query [http::formatQuery $term]
+		set query [http::formatQuery [regsub -all -- {\s} $term "_"]]
 		set token [http::geturl ${wiki::url}${query} -timeout 10000]
 	}
 	set data [http::data $token]
@@ -99,7 +100,7 @@ proc wiki::search {nick uhost hand chan argv} {
 		return
 	}
 
-	foreach line [wiki::split_line 400 [dict get $data result]] {
+	foreach line [wiki::split_line $wiki::max_chars [dict get $data result]] {
 		if {[incr count] > $wiki::max_lines} {
 			$wiki::output_cmd "PRIVMSG $chan :Output truncuated. [dict get $data url]"
 			break