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

	<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>2012-08-31T18:09:35-04:00</updated>

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

		<entry>
		<author><name><![CDATA[SpiKe^^]]></name></author>
		<updated>2012-08-31T18:09:35-04:00</updated>

		<published>2012-08-31T18:09:35-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99961#p99961</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99961#p99961"/>
		<title type="html"><![CDATA[Search txt file for matching text and display]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99961#p99961"><![CDATA[
Edited the above code some...<br>You should get the code again.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7749">SpiKe^^</a> — Fri Aug 31, 2012 6:09 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[BigToe]]></name></author>
		<updated>2012-08-31T17:28:26-04:00</updated>

		<published>2012-08-31T17:28:26-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99960#p99960</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99960#p99960"/>
		<title type="html"><![CDATA[Search txt file for matching text and display]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99960#p99960"><![CDATA[
Perfect Spike^^!<br><br>Great job, appreciate it!<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11473">BigToe</a> — Fri Aug 31, 2012 5:28 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[SpiKe^^]]></name></author>
		<updated>2012-08-31T18:08:21-04:00</updated>

		<published>2012-08-31T17:00:28-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99959#p99959</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99959#p99959"/>
		<title type="html"><![CDATA[Cats, take 2]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99959#p99959"><![CDATA[
You're right, that code won't run.<br>Had a few string match issues:)<br>This code should run without error.<br><div class="codebox"><p>Code: </p><pre><code># set the route and file name of the categories file #set cats(file) "scripts/Categories.txt"# set the command to list all the categories #set cats(ccmd) "!categories"# set the command to read one of the categories #set cats(rcmd) "!category"# set the user file flags required to use this script ("-" = everyone) #set cats(flag) "-"###### END OF SETTINGS ######set cats(cats) ""if {![file exists $cats(file)]} {  return  }set cats(tm-open) [open $cats(file)]while {![eof $cats(tm-open)]} { set cats(tm-line) [string trim [gets $cats(tm-open)]] if {[string match {\[*\]} $cats(tm-line)]} {   lappend cats(cats) [string range $cats(tm-line) 1 end-1] }}close $cats(tm-open)if {$cats(cats) eq ""} {  return  }bind pub $cats(flag) $cats(ccmd) cats:listcatsproc cats:listcats {nk uh hn ch tx} {  global cats if {$cats(cats) eq ""} {  return  } puthelp "PRIVMSG $ch :[join $cats(cats) ", "]."}bind pub $cats(flag) $cats(rcmd) cats:readacatproc cats:readacat {nk uh hn ch tx} {  global cats if {$cats(cats) eq ""} {  return  } set tx [string trim [string tolower $tx]] if {$tx eq ""} {   puthelp "PRIVMSG $ch :${nk}: Use:  $cats(rcmd) &lt;category-name&gt;"   return } set pexact 0 if {[lsearch -exact [string tolower $cats(cats)] $tx]&gt;"-1"} {  set patrn $tx  ;  set pexact 1 } elseif {[lsearch [string tolower $cats(cats)] $tx*]&gt;"-1"} {  set patrn $tx* } elseif {[lsearch [string tolower $cats(cats)] *$tx*]&gt;"-1"} {  set patrn *$tx* } else {   puthelp "PRIVMSG $ch :${nk}: No matching category found."   return } set open [open $cats(file)]  ;  set found 0 while {![eof $open]} {  set line [string trim [gets $open]]  if {$line eq ""} {  continue  }  set x ""  if {[string match {\[*\]} $line]} {  set x [string range $line 1 end-1]  }  if {$x ne "" &amp;&amp; [string match -nocase $patrn $x]} {  set found 1  ;  set z $x  } elseif {$x ne ""} {    if {$found&gt;"0"} {  break  }  } elseif {$found&gt;"0"} {    if {$found=="1"} {  set found 2      if {$pexact=="0"} {  puthelp "PRIVMSG $ch :Reading category:  $z"  }    }    puthelp "PRIVMSG $ch :$line"  } } close $open}putlog "cats.tcl v1.1 loaded."</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7749">SpiKe^^</a> — Fri Aug 31, 2012 5:00 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[BigToe]]></name></author>
		<updated>2012-08-31T02:24:53-04:00</updated>

		<published>2012-08-31T02:24:53-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99956#p99956</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99956#p99956"/>
		<title type="html"><![CDATA[Search txt file for matching text and display]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99956#p99956"><![CDATA[
Hey SpiKe^^,<br><br>Thanks for the reply.<br><br>I've loaded a script and created Categories.txt in the following format:<br><br>[Fruits]<br>Banana<br>Apple<br>[Old Movies]<br>Kill Bill<br>Matrix<br><br>Tried to trigger it via !Categories, it did not work. Also tried !category Fruits and that didn't work either<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11473">BigToe</a> — Fri Aug 31, 2012 2:24 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[SpiKe^^]]></name></author>
		<updated>2012-08-30T22:36:43-04:00</updated>

		<published>2012-08-30T22:36:43-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99955#p99955</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99955#p99955"/>
		<title type="html"><![CDATA[Search txt file for matching text and display]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99955#p99955"><![CDATA[
Try this and see what we have so far:)<br><div class="codebox"><p>Code: </p><pre><code># set the route and file name of the categories file #set cats(file) "scripts/Categories.txt"# set the command to list all the categories #set cats(ccmd) "!categories"# set the command to read one of the categories #set cats(rcmd) "!category"# set the user file flags required to use this script ("-" = everyone) #set cats(flag) "-"###### END OF SETTINGS ######set cats(cats) ""if {![file exists $cats(file)]} {  return  }set cats(tm-open) [open $cats(file)]while {![eof $cats(tm-open)]} { set cats(tm-line) [gets $cats(tm-open)] if {[string match \[*\] $cats(tm-line)]} {   lappend cats(cats) [string range $cats(tm-line) 1 end-1] }}close $cats(tm-open)if {$cats(cats) eq ""} {  return  }bind pub $cats(flag) $cats(ccmd) cats:listcats proc cats:listcats {nk uh hn ch tx} {  if {$cats(cats) eq ""} {  return  } puthelp "PRIVMSG $ch :[join $cats(cats) ", "]."}bind pub $cats(flag) $cats(rcmd) cats:readacat proc cats:readacat {nk uh hn ch tx} {  if {$cats(cats) eq ""} {  return  } set tx [string trim $tx] if {[lsearch -exact $cats(cats) $tx]&gt;"-1"} {  set patrn \[$tx\] } elseif {[lsearch $cats(cats) $tx*]&gt;"-1"} {  set patrn \[$tx*\] } elseif {[lsearch $cats(cats) *$tx*]&gt;"-1"} {  set patrn \[*$tx*\] } else {  return  } set open [open $cats(file)]  ;  set found 0 while {![eof $open]} {  set line [gets $open]  if {$line eq ""} {  continue  }  if {[string match $patrn $line]} {  set found 1  } elseif {[string match \[*\] $line]} {    if {$found&gt;"0"} {  break  }  } elseif {$found&gt;"0"} {      puthelp "PRIVMSG $ch :$line"  } } close $open}putlog "cats.tcl v1.1 loaded."</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7749">SpiKe^^</a> — Thu Aug 30, 2012 10:36 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[BigToe]]></name></author>
		<updated>2012-08-30T10:39:17-04:00</updated>

		<published>2012-08-30T10:39:17-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99954#p99954</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99954#p99954"/>
		<title type="html"><![CDATA[Search txt file for matching text and display]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99954#p99954"><![CDATA[
Hi, I`m looking for a script to work with the following format of a text file:<br><br>[Category1]<br>line1<br>line2<br>line3<br>[Category2]<br>line1<br>line2<br>line3<br><br>When a user types !categories<br><br>The bot will display all the existing [Category] that exists in a text file (the text file name is "scripts/Categories.txt") to the user<br><br><br>After displaying the categories, or even before  (if a user knows what the categories are without asking for displaying them), the user can pick a category via !search Category1 and the bot will display to him all the lines in that category.<br><br>Example:<br><br>Categories.txt format is as following:<br><br>[Fruits]<br>Apple<br>Banana<br>Orange<br>[Movies]<br>Matrix<br>Kill Bill<br>Fast and Furious<br>[Music]<br>Oasis<br>Metallica<br>Aerosmith<br><br><blockquote class="uncited"><div>&lt;User&gt; !categories<br>&lt;Bot&gt; Fruits, Movies, Music.<br><br>&lt;User&gt; !Category Fruits<br>&lt;Bot&gt; Apple<br>&lt;Bot&gt; Banana<br>&lt;Bot&gt; Orange<br>&lt;User&gt; !Category Music<br>&lt;Bot&gt; Oasis<br>&lt;Bot&gt; Metallica<br>&lt;Bot&gt; Aerosmith</div></blockquote>* In addition, a !randCategory function that will display 1 random line from 1 random category, would be brilliant as-well.<br>Please make sure the interval of displaying is such that will not force him to quit due to flood.<br><br>Thanks!<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11473">BigToe</a> — Thu Aug 30, 2012 10:39 am</p><hr />
]]></content>
	</entry>
	</feed>
