<?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/21000" />

	<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>2021-06-27T10:29:44-04:00</updated>

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

		<entry>
		<author><name><![CDATA[ComputerTech]]></name></author>
		<updated>2021-06-27T10:29:44-04:00</updated>

		<published>2021-06-27T10:29:44-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=110031#p110031</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=110031#p110031"/>
		<title type="html"><![CDATA[reducing usage of set/variable]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=110031#p110031"><![CDATA[
That works perfect caesar! thanks a ton mate  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=":wink:" title="Wink"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12849">ComputerTech</a> — Sun Jun 27, 2021 10:29 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2021-06-27T03:45:51-04:00</updated>

		<published>2021-06-27T03:45:51-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=110028#p110028</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=110028#p110028"/>
		<title type="html"><![CDATA[reducing usage of set/variable]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=110028#p110028"><![CDATA[
Most likely cos you are doing a cleanup on $data2, instead of $data.. anyway your variables confuses me so I made it from scratch.<div class="codebox"><p>Code: </p><pre><code>proc IP:proc {nick host hand chan text} {variable apiif {[scan $text {%s} ip] &lt; 1} returnset url "http://api.ipstack.com/$ip?access_key=$api&amp;hostname=1"catch {set http [::http::geturl $url -timeout 6000]} errorset data [::http::data $http]set dict [::json::json2dict $data]::http::cleanup $httpforeach key [dict keys $dict] {set result($key) [dict get $dict $key]}putout "$result(ip)"}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Sun Jun 27, 2021 3:45 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ComputerTech]]></name></author>
		<updated>2021-06-26T20:33:50-04:00</updated>

		<published>2021-06-26T20:33:50-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=110026#p110026</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=110026#p110026"/>
		<title type="html"><![CDATA[reducing usage of set/variable]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=110026#p110026"><![CDATA[
Still don't understand why it generates a error in Partyline.<div class="codebox"><p>Code: </p><pre><code>[01:32:57] Tcl error [::CT-IP::IP:proc]: can't define "ip 2001:bc8:32d7:26c:: hostname 2001:bc8:32d7:26c:: type ipv6 continent_code EU continent_name Europe country_code FR country_name France region_code IDF region_name ÃŽle-de-France city Saint-Ouen zip 75008 latitude 48.861000061035156 longitude 2.3380000591278076 location {geoname_id 2977824 capital Paris languages {{code fr name French native FranÃ§ais}} country_flag http://assets.i</code></pre></div>With this code<div class="codebox"><p>Code: </p><pre><code>namespace eval CT-IP {   ############################   #  Start of configuration  #   #--------------------------#   ##########################   # Trigger   ##   variable trig "!ip"   ##########################   # API   ##   variable api "2bbd882cec5fa5f26d53fe6049a21343"   ##########################   # Flags   ##   # n = Owner   # m = Master   # o = Op   # h = Halfop   # v = Voice   # f = Friend   # - = Everyone   ##   variable flag "-|-"   ##########################   # Output   ##   # M = Message   # N = Notice   # N = Nick   # C = Channel   ##   variable outp "MC"   ############################   #   End of configuration   #   #--------------------------#   ###############################################################################   variable author "ComputerTech"   variable version "v0.1"   variable name "CT-IP"   package require http   package require json   bind PUB $flag $trig [namespace current]::IP:proc   proc putout {text} {      variable outp      upvar 1 nick nick chan chan      switch -- [string index $outp 0] {         "M" {variable action "PRIVMSG"}         "N" {variable action "NOTICE"}      }      switch -- [string index $outp 1] {         "N" {variable target $nick}         "C" {variable target $chan}      }      putserv "${action} ${target} :$text"   }   proc IP:proc {nick host hand chan text} {      variable api                       variable url "http://api.ipstack.com/[lindex $text 0]?access_key=$api&amp;hostname=1"      variable data [http::data [http::geturl "$url" -timeout 10000]]      variable data2 [::json::json2dict $data]      http::cleanup $data2                        foreach key [dict keys $data2] {                        set ip($key) [dict get $data2 $key]}        putout "$ip(ip)"   }   putlog "$name $version by $author Loaded!"}</code></pre></div> <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_rolleyes.gif" width="15" height="15" alt=":roll:" title="Rolling Eyes"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12849">ComputerTech</a> — Sat Jun 26, 2021 8:33 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ComputerTech]]></name></author>
		<updated>2021-06-26T10:26:11-04:00</updated>

		<published>2021-06-26T10:26:11-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=110025#p110025</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=110025#p110025"/>
		<title type="html"><![CDATA[reducing usage of set/variable]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=110025#p110025"><![CDATA[
oh damn lol, i missed that  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_lol.gif" width="15" height="15" alt=":lol:" title="Laughing"> <br><br>Thanks caesar  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_razz.gif" width="15" height="15" alt=":P" title="Razz"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12849">ComputerTech</a> — Sat Jun 26, 2021 10:26 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2021-06-26T02:58:01-04:00</updated>

		<published>2021-06-26T02:58:01-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=110024#p110024</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=110024#p110024"/>
		<title type="html"><![CDATA[reducing usage of set/variable]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=110024#p110024"><![CDATA[
He said <div class="codebox"><p>Code: </p><pre><code>set ip($varname) [dict get $data2 $varname]</code></pre></div>and you used:<div class="codebox"><p>Code: </p><pre><code>variable ip($varname) [dict get $data2 $varname] </code></pre></div>To make it less confusing I would replace <em class="text-italics">varname</em> with <em class="text-italics">key</em>, since that's what you are looping over the keys  from that dictionary.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Sat Jun 26, 2021 2:58 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ComputerTech]]></name></author>
		<updated>2021-06-25T19:38:15-04:00</updated>

		<published>2021-06-25T19:38:15-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=110023#p110023</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=110023#p110023"/>
		<title type="html"><![CDATA[reducing usage of set/variable]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=110023#p110023"><![CDATA[
Okay so, i tried it and i get this error<div class="codebox"><p>Code: </p><pre><code>[00:37:20] Tcl error [::CT-IP::IP:proc]: can't define "ip(ip)": name refers to an element in an array</code></pre></div>with this code<div class="codebox"><p>Code: </p><pre><code>namespace eval CT-IP {#############################  Start of configuration  ##--------------------------############################ Trigger##variable trig "!ip"########################### API##variable api "2bbd882cec5fa5f26d53fe6049a21343"########################### Flags### n = Owner# m = Master# o = Op# h = Halfop# v = Voice# f = Friend# - = Everyone##variable flag "-|-"########################### Output### M = Message# N = Notice# N = Nick# C = Channel##variable outp "MC"#############################   End of configuration   ##--------------------------################################################################################variable author "ComputerTech"variable version "v0.1"variable name "CT-IP"package require httppackage require jsonbind PUB $flag $trig [namespace current]::IP:procproc putout {text} {variable outpupvar 1 nick nick chan chanswitch -- [string index $outp 0] {"M" {variable action "PRIVMSG"}"N" {variable action "NOTICE"}}switch -- [string index $outp 1] {"N" {variable target $nick}"C" {variable target $chan}}putserv "${action} ${target} :$text"}proc IP:proc {nick host hand chan text} {variable api                       variable url "http://api.ipstack.com/[lindex $text 0]?access_key=$api&amp;hostname=1"variable data [http::data [http::geturl "$url" -timeout 10000]]variable data2 [::json::json2dict $data]http::cleanup $data2                        foreach varname [dict keys $data2] {                        variable ip($varname) [dict get $data2 $varname]}        putout "$ip(ip)"}putlog "$name $version by $author Loaded!"}</code></pre></div>And here's a example from the json output<div class="codebox"><p>Code: </p><pre><code>{  "ip": "2a07:4840::1:0:0:0:2f",  "hostname": "2a07:4840::1:0:0:0:2f",  "type": "ipv6",  "continent_code": "EU",  "continent_name": "Europe",  "country_code": "GB",  "country_name": "United Kingdom",  "region_code": "ENG",  "region_name": "England",  "city": "Maidenhead",  "zip": "SL6",  "latitude": 51.531681060791016,  "longitude": -0.7307500243186951,  "location": {    "geoname_id": 2643186,    "capital": "London",    "languages": [      {        "code": "en",        "name": "English",        "native": "English"      }    ],    "country_flag": "http://assets.ipstack.com/flags/gb.svg",    "country_flag_emoji": "🇬🇧",    "country_flag_emoji_unicode": "U+1F1EC U+1F1E7",    "calling_code": "44",    "is_eu": true  }}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12849">ComputerTech</a> — Fri Jun 25, 2021 7:38 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ComputerTech]]></name></author>
		<updated>2021-06-25T19:19:28-04:00</updated>

		<published>2021-06-25T19:19:28-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=110022#p110022</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=110022#p110022"/>
		<title type="html"><![CDATA[reducing usage of set/variable]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=110022#p110022"><![CDATA[
That looks perfect CrazyCat, i'll go test it <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_biggrin.gif" width="15" height="15" alt=":D" title="Very Happy"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12849">ComputerTech</a> — Fri Jun 25, 2021 7:19 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[CrazyCat]]></name></author>
		<updated>2021-06-25T15:16:41-04:00</updated>

		<published>2021-06-25T15:16:41-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=110021#p110021</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=110021#p110021"/>
		<title type="html"><![CDATA[reducing usage of set/variable]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=110021#p110021"><![CDATA[
You don't want to name all the variables in the dict ?<div class="codebox"><p>Code: </p><pre><code>foreach varname [dict keys $data2] {   set ip($varname) [dict get $data2 $varname]}</code></pre></div>And after, use $ip(ip), $ip(hostname), ...<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=691">CrazyCat</a> — Fri Jun 25, 2021 3:16 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ComputerTech]]></name></author>
		<updated>2021-06-25T14:30:29-04:00</updated>

		<published>2021-06-25T14:30:29-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=110020#p110020</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=110020#p110020"/>
		<title type="html"><![CDATA[reducing usage of set/variable]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=110020#p110020"><![CDATA[
Anyway possible to not use <strong class="text-strong">variable</strong> soo many times, maybe like this.<div class="codebox"><p>Code: </p><pre><code>foreach {foo bar moo} [split $args] {break}</code></pre></div>For this code<div class="codebox"><p>Code: </p><pre><code>namespace eval CT-IP {#############################  Start of configuration  ##--------------------------############################ Trigger##variable trig "!ip"########################### API ##variable api "2bbd882cec5fa5f26d53fe6049a21343"########################### Flags### n = Owner# m = Master# o = Op# h = Halfop# v = Voice# f = Friend# - = Everyone##variable flag "-|-"########################### Output### M = Message# N = Notice# N = Nick# C = Channel##variable outp "MC" #############################   End of configuration   ##--------------------------################################################################################variable author "ComputerTech"variable version "v0.1"variable name "CT-IP"package require httppackage require jsonbind PUB $flag $trig [namespace current]::IP:procproc putout {text} {variable outpupvar 1 nick nick chan chanswitch -- [string index $outp 0] {"M" {variable action "PRIVMSG"}"N" {variable action "NOTICE"}}switch -- [string index $outp 1] {"N" {variable target $nick}"C" {variable target $chan}}putserv "${action} ${target} :$text"}proc IP:proc {nick host hand chan text} { variable api variable url "http://api.ipstack.com/" variable params [::http::formatQuery q [lindex $text 0] $api] variable data [http::data [http::geturl "$url?$params" -timeout 10000]]      variable data2 [::json::json2dict $data]      http::cleanup $data2  variable ip [dict get $data2 "ip"]  variable hostname [dict get $data2 "hostname"]  variable type [dict get $data2 "type"]  variable continent [dict get $data2 "continent_name"]  variable country [dict get $data2 "country_name"]  variable region [dict get $data2 "region_name"]  variable city [dict get $data2 "city"]  variable latitude [dict get $data2 "latitude"]  variable longitude [dict get $data2 "longitude"]  variable location [dict get $data2 "location"]  variable language [dict get $location "languages"]   variable name [dict get $language "name"]putout "\002IP\002: $ip | \002Hostname\002: $hostname | \002Type\002: $type"putout "\002Continent\002: $continent | \002Country\002: $country | \002Region\002: $region"putout "\002City\002: $city | \002Latitude\002: $latitude | \002Longitude\002 $longitude |\002Language\002 $name"  }putlog "$name $version by $author Loaded!"}</code></pre></div>Imo it looks messy with multiple usage of <strong class="text-strong">variable or set</strong><br>thanks in advanced  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_razz.gif" width="15" height="15" alt=":P" title="Razz"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12849">ComputerTech</a> — Fri Jun 25, 2021 2:30 pm</p><hr />
]]></content>
	</entry>
	</feed>
