Searches Wikipedia and displays result for search.
Based on FordLawnmower's version
bind pub - !wiki wiki
proc wiki {nick host hand chan arg} {
package require http
set arg [string map {{ } \%20} $arg]
set url "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&rsz=large&q=$arg+site:en.wikipedia.org"
set page [http::data [http::geturl $url]]
if {[regexp {\"url\":\"([^\"]*)\"} $page a link]} {
if {[regexp {wikipedia\.org} $link]} { putserv "PRIVMSG $chan :[wikipedia $link]" }
} else { putserv "PRIVMSG $chan :Nothing found on Wikipedia! Please refine your search and check your spelling." }
}
proc wikipedia {url} {
package require http
set page [http::data [http::geturl $url]]
if {[regexp {may refer to:} $page] || [regexp {HTTP\/1\.0 403} $page]} {
return "Nothing found on Wikipedia! Please refine your search and check your spelling."
} elseif {[regexp -line {<b>(.*)</p>} $page a result] || [regexp -line {<p>(.*)</p>} $page a result]} {
set result [dehex [strip $result]]
set result [shorten $result 50]
return "Wikipedia: $result : $url"
}
}
proc shorten {text limit} {
foreach i $text { incr start
lappend wiki $i
if {$start == $limit} { return $wiki }
}
return $wiki
}
proc dehex {string} {
regsub -all {[\[\]]} $string "" string
set string [subst [regsub -nocase -all {\&#([0-9]{3});} $string {[format %c \1]}]]
return [string map {&quo\te; \"} $string]
}
proc strip {string} {
regsub -all {<[^<>]+>} $string "" string
regsub -all {\[\d+\]} $string "" string
return $string
}
putlog "WikiPedia Search"
Could you please post credits on the posts that you borrowed code from.
Just glancing at it, these are all from my posts.
http://www.hawkee.com/snippet/9549/
http://www.hawkee.com/snippet/9548/
http://www.hawkee.com/snippet/9547/
http://www.hawkee.com/snippet/9545/
http://www.hawkee.com/snippet/9540/
@FordLawnmower Did he change enough that he added value to them? If not I'll remove them.
is right always indicate the source from which it was taken the code of even a single alias ... Often many scripters exert their code also inspired by others. Better indicate those coming from this theory, in the case in which the code is improved ...
This will surely regard to both and to the global community, who has produced and who was ripped. I mean not just change the name of the script, but I mean those who use the structure of the non-proprietary codes for any function.
Many begin with the rip and evolve with their ideas and then I admit this, but I will not tolerate this by advanced programmers ....
What can I say more ... Ford is known throughout the world for scripts that often carefully explains the individual functions, perhaps too detailed.
It happens the code theory it is possible to rewrite it in countless mode, at times equal or similar in some points because of the limitations of the technology.
Just copy does not lead to anything, if only to a very bad shape as evident in this case.
In any case, I wanted to tell you that I think you all have ripped the theorem of Pythagoras to reach your intellectual level and this I will never forgive LoL
@Hawkee The scripts I mentioned were changed to use the tcl package http instead of the raw socket method that I use. This is useful for people who would prefer to use http.
@Gecko321 Thanks for posting the credit. I'm sorry I was so rude. I had a long day and took it out on your post. I will edit my comment to not be so harsh.
@Stewie1k94 Actually my tcl versions of these scripts were based on my mIRC versions. These were based on my tcl scripts.
Also, http://www.mediawiki.org/wiki/API - no need to use a google search for this TBH.