<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/13209" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2007-03-08T21:10:10-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/13209</id>

		<entry>
		<author><name><![CDATA[MenzAgitat]]></name></author>
		<updated>2007-03-08T21:10:10-04:00</updated>

		<published>2007-03-08T21:10:10-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=71112#p71112</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=71112#p71112"/>
		<title type="html"><![CDATA[AcronymFetcher (current version: 1.0)]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=71112#p71112"><![CDATA[
 <br>Fetches the meaning of a given acronym by using "acronyms.thefreedictionary.com".<br><div class="codebox"><p>Code: </p><pre><code> ################################################                                               ##         A C R O N Y M   F E T C H E R         ##       v1.0 (08/03/2007)   by MenzAgitat       ##                                               ##          http://www.boulets-roxx.com          ##          IRC: irc.teepi.net #boulets          ##                                               # ################################################ The Tinyurl procedure has been written by# Tomekk (tomekk@oswiecim.eu.org), thanks to him.## Description en français#   Affiche la signification d'un acronyme.## English description#   Display the meaning of an acronym.## Changelog:#   1.0: First version# LICENCE:#   This program is free software; you can redistribute it and/or modify#   it under the terms of the GNU General Public License as published by#   the Free Software Foundation; either version 2 of the License, or#   (at your option) any later version.##   This program is distributed in the hope that it will be useful,#   but WITHOUT ANY WARRANTY; without even the implied warranty of#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the#   GNU General Public License for more details.##   You should have received a copy of the GNU General Public License#   along with this program; if not, write to the Free Software#   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA############################    SETTINGS         ################################# Public commandset acronymcmd "!acronym"##### Channels on which the translator will be activeset acronymchans "#chan1 #chan2 #chan3"##### Number of displayed resultsset maxdef 4#################################################################                                                              ## DO NOT MODIFY ANYTHING BELOW THIS BOX IF YOU DON'T KNOW TCL  ##                                                              #################################################################package require httpset acronymversion "1.0"set DEBUGMODE 0set useragent "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1"set acronymurl "http://acronyms.thefreedictionary.com/"bind pub -|- $acronymcmd pub:acronym##### Main procedureproc pub:acronym {nick host hand chan arg}  {##### Do we have permission to use this command on this chan ?set permission_result [channel_check_acronym $chan]if {$permission_result == 0} {return}set arg [string trim $arg]  if {$arg == ""} {  acronym_syntax $chan} else {global useragent DEBUGMODE acronymurl acronymcmd maxdef  putcmdlog "$nick@$chan $acronymcmd $arg"set res ""##### URL constructionset arg [string map {      " "     "%20""\""    "%22""#"     "%23""$"     "%24""%"     "%25"      "&amp;"     "%26"   "'"     "%27""\("    "%28"   "\)"    "%29"   "*"     "%2A"      "+"     "%2B"   ","     "%2C"   "."     "%2E"   "\/"    "%2F"   ":"     "%3A"      ";"     "%3B"   "&lt;"     "%3C"   "="     "%3D"   "&gt;"     "%3E"   "?"     "%3F"      "@"     "%40"   "\["    "%5B"   "\\"    "%5C"   "\]"    "%5D""^""%5E"      "\{"    "%7B"   "|"     "%7C"   "\}"    "%7D"   "~"     "%7E"   "¡"     "%A1"      "¢""%A2""£""%A3""¤""%A4""¥""%A5""¦""%A6""§""%A7""¨""%A8""©""%A9""ª""%AA""«""%AB""¬""%AC""­""%AD""®""%AE""¯""%AF""°""%B0""±""%B1""²""%B2""³""%B3""´""%B4""µ""%B5""¶""%B6""·""%B7""¸""%B8""¹""%B9""º""%BA""»""%BB""¼""%BC""½""%BD""¾""%BE""¿""%BF""À""%C0""Á""%C1""Â""%C2""Ã""%C3""Ä""%C4""Å""%C5""Æ""%C6""Ç""%C7""È""%C8""É""%C9""Ê""%CA""Ë""%CB""Ì""%CC""Í""%CD""Î""%CE""Ï""%CF""Ð""%D0""Ñ""%D1""Ò""%D2""Ó""%D3""Ô""%D4""Õ""%D5""Ö""%D6""×""%D7""Ø""%D8""Ù""%D9""Ú""%DA""Û""%DB""Ü""%DC""Ý""%DD""Þ""%DE""ß""%DF""à""%E0""á""%E1""â""%E2""ã""%E3""ä""%E4""å""%E5""æ""%E6""ç""%E7""è""%E8""é""%E9""ê""%EA""ë""%EB""ì""%EC""í""%ED""î""%EE""ï""%EF""ð""%F0""ñ""%F1""ò""%F2""ó""%F3""ô""%F4""õ""%F5""ö""%F6""÷""%F7""ø""%F8""ù""%F9""ú""%FA""û""%FB""ü""%FC""ý""%FD""þ""%FE""ÿ""%FF"} $arg]  set url "$acronymurl$arg"if $DEBUGMODE {putlog "\00304\[BABEL DEBUG\]\003 url = $url"}##### we send the request to the socket  ::http::config -useragent $useragentset token [::http::geturl "$url"]##### if the connexion is established, we process the received data.if {[::http::status $token] == "ok"} {    regexp "&lt;tr&gt;&lt;th&gt;Acronym&lt;/th&gt;&lt;th&gt;Definition&lt;/th&gt;&lt;/tr&gt;(.+?)&lt;/table&gt;" [::http::data $token] resif $DEBUGMODE {putlog "\00304\[BABEL DEBUG\]\003 \037PRE-REGSUB\037 $res"}    if { $res != ""  } {regsub -all "&lt;th&gt;Acronym&lt;/th&gt;&lt;th&gt;Definition&lt;/th&gt;" $res "" resregsub -all "&lt;/td&gt;&lt;/tr&gt;" $res "\n" resregsub -all "&lt;/td&gt;&lt;td&gt;" $res " \00312—\003 " resregsub -all "&lt;\[^&lt;\]*&gt;" $res "" res      set res [encoding convertfrom "utf-8" $res ]if $DEBUGMODE {putlog "\00304\[BABEL DEBUG\]\003 \037POST-REGSUB\037 $res"}      if {$res != ""} {set numresults [scount "\n" $res]      set res [split $res "\n"]       set counter 1   if {$numresults == 1} {   puthelp "privmsg $chan :\00314\037$numresults result\037 :\003"   } elseif {$numresults &gt;1} {   puthelp "privmsg $chan :\00314\037$numresults results\037 :\003"   }   foreach line $res {      if {[string trim $line] != "" &amp;&amp; [string trim $line] != " "} {if $DEBUGMODE {putlog "\00304\[BABEL DEBUG\]\003 counter=$counter maxdef=$maxdef"}if {($counter &gt;= $maxdef) &amp;&amp; ($numresults &gt; $maxdef)} { set line "$line \00304(...)\003" }      puthelp "privmsg $chan :$line"if {($counter &gt;= $maxdef) &amp;&amp; ($numresults &gt; $maxdef)} {            set url [tinyurl_conversion [lindex $url]]puthelp "privmsg $chan :\00314more: \00312\037$url\037\003"return -code break}incr counter}      }}} else {  puthelp "privmsg $chan :\00314$nick &gt; No results\003"}} else {puthelp "privmsg $chan :\00314The connexion to \002The Free Dictionnary\002 can't be established. Maybe the website suffer technical difficulties. Try again later.\003"}::http::cleanup $token}}proc scount {subs string} {regsub -all $subs $string $subs string}##### Syntaxproc acronym_syntax { chan } {puthelp "privmsg $chan :\037Syntax :\037 \002!acronym\002 \00314&lt;\003acronym\00314&gt; \00307| \003Display the meaning of a given acronym. eg. \002!acronym lol\002"return done}##### Check if the chan is in the allowed chans listproc channel_check_acronym { chan } {global acronymchansif {[lsearch -exact $acronymchans $chan] != -1} {set permission 1} else {set permission 0}return $permission}##### Conversion of the url into a shorter version.##### If www.tinyurl.com does not respond quickly enough (10 seconds),##### the plain url is used instead.proc tinyurl_conversion { url } {  global useragent  set get_url_timeout "10"  set url [string map -nocase {  "&amp;""&amp;"  } $url]set tiny_query "http://tinyurl.com/create.php?url=${url}"set tiny_token [http::config -useragent $useragent]set tiny_token [http::geturl $tiny_query -timeout [expr $get_url_timeout * 1000]]set html_data [http::data $tiny_token]set all_n [split $html_data \n]  set tiny_link ""foreach tiny_lines $all_n {if {[regexp -all -nocase "name\=tinyurl" $tiny_lines]} {regsub -all -nocase "&lt;input type=hidden name=tinyurl value=\"" $tiny_lines "" tiny_linkregsub -all -nocase "\"&gt;" $tiny_link "" tiny_link    }}if {$tiny_link != "0" &amp;&amp; $tiny_link != ""} {return $tiny_link} {return "!!!${url}"}}putlog "\002*Acronym Fetcher v$acronymversion*\002 by MenzAgitat (\037\00312http://www.boulets-roxx.com\003\037) has been loaded"</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7933">MenzAgitat</a> — Thu Mar 08, 2007 9:10 pm</p><hr />
]]></content>
	</entry>
	</feed>
