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

	<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>2017-03-06T08:41:02-04:00</updated>

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

		<entry>
		<author><name><![CDATA[Madalin]]></name></author>
		<updated>2017-03-06T08:41:02-04:00</updated>

		<published>2017-03-06T08:41:02-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105858#p105858</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105858#p105858"/>
		<title type="html"><![CDATA[Play text file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105858#p105858"><![CDATA[
If someone will want to use it in the future i will make it public. He/She just needs to ask it. Don`t want to post it because maybe im gonna improve it so no need for older version posted here.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6396">Madalin</a> — Mon Mar 06, 2017 8:41 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2017-03-06T04:36:43-04:00</updated>

		<published>2017-03-06T04:36:43-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105856#p105856</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105856#p105856"/>
		<title type="html"><![CDATA[Play text file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105856#p105856"><![CDATA[
Hey, sorry for the late reply.. Been busy with work and stuff and didn't get the chance to have a look on the code to adapt it to fit the requirements.<br><br>If it's done then why not share it? <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Mon Mar 06, 2017 4:36 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Madalin]]></name></author>
		<updated>2017-02-28T04:43:29-04:00</updated>

		<published>2017-02-28T04:43:29-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105838#p105838</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105838#p105838"/>
		<title type="html"><![CDATA[Play text file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105838#p105838"><![CDATA[
Its done .. Thanks<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6396">Madalin</a> — Tue Feb 28, 2017 4:43 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Madalin]]></name></author>
		<updated>2017-02-27T13:48:47-04:00</updated>

		<published>2017-02-27T13:48:47-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105837#p105837</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105837#p105837"/>
		<title type="html"><![CDATA[Play text file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105837#p105837"><![CDATA[
Thats what i tryed to do. I mean i saved everything in array and started from there <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"> but i dont know where im getting it wrong.<br><br>If you take a closer look at the code i posted is something similar <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"> yet not working as it should.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6396">Madalin</a> — Mon Feb 27, 2017 1:48 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2017-02-27T13:41:04-04:00</updated>

		<published>2017-02-27T13:41:04-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105836#p105836</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105836#p105836"/>
		<title type="html"><![CDATA[Play text file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105836#p105836"><![CDATA[
When you <em class="text-italics">pause</em> you can save the offset into a channel string, for instance in your code you got:<div class="codebox"><p>Code: </p><pre><code>setudef str playOffset</code></pre></div>and when pausing:<div class="codebox"><p>Code: </p><pre><code>channel set $chan playOffset $x</code></pre></div>where $x is the last index you just pulled. As for when resuming just grab the number from there.<div class="codebox"><p>Code: </p><pre><code>set last [channel get $chan playOffset]# and play from thisset result [lineRead $filename $index [expr $last + 1] ]</code></pre></div>I imagine you use some sort of timed messaging to prevent the bot to flood the server or itself, so this should be easy to implement.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Mon Feb 27, 2017 1:41 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Madalin]]></name></author>
		<updated>2017-02-27T13:31:30-04:00</updated>

		<published>2017-02-27T13:31:30-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105835#p105835</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105835#p105835"/>
		<title type="html"><![CDATA[Play text file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105835#p105835"><![CDATA[
Its a script im making for a friend .. he wants to play maximum 100 lines. He just wants stop/start/pause/resume commands, so nothing major.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6396">Madalin</a> — Mon Feb 27, 2017 1:31 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2017-02-27T13:09:08-04:00</updated>

		<published>2017-02-27T13:09:08-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105834#p105834</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105834#p105834"/>
		<title type="html"><![CDATA[Play text file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105834#p105834"><![CDATA[
Like i said this is binary, so from 0 to 10 is the first line, from 10 to 20 the second and from 20 to 28 the third, or that's how I imagine things are. I had a line with 6 lines and the output of <em class="text-italics">lineindex</em> was <em class="text-italics">0 8 16 24 32 40 41</em> and thus my silly explanation makes some sense after all. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>You need to alter the second piece of code to "point" it to the opened file:<div class="codebox"><p>Code: </p><pre><code>proc lineRead {filename index line} {set fp [open $filename]seek $fp [lindex $index $line]set data [gets $fp]close $fpset data}</code></pre></div>And then build the index and call the above code to grab whatever line you want.<div class="codebox"><p>Code: </p><pre><code>set filename "class"# build lines indexset index [lineindex $filename]# read 3rd line from fileset result [lineRead $filename $index 3]</code></pre></div>The <em class="text-italics">set res</em> will just return the output, just like a <em class="text-italics">return $res</em>. <br><br>How many lines and how long are them in text file you want to read anyway? If this is running on linux I'm sure there are better ways to use the system tools to get the same results at a lower CPU/RAM usage if that's your concern.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Mon Feb 27, 2017 1:09 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Madalin]]></name></author>
		<updated>2017-02-27T12:30:29-04:00</updated>

		<published>2017-02-27T12:30:29-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105833#p105833</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105833#p105833"/>
		<title type="html"><![CDATA[Play text file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105833#p105833"><![CDATA[
Yeah that would be nice .. i tryed to test the code ... yet i have for three lines<br><div class="codebox"><p>Code: </p><pre><code>proc lineindex filename {    set res 0    set fp [open $filename]    while {[gets $fp line]&gt;=0} {lappend res [tell $fp]}    close $fp    set res }</code></pre></div>[14:26:55] 0 10 20 28 <br><br>And why <strong class="text-strong">set rest</strong> at the end of this proc ?<br><br>But i dont know how to use the second proc from the example <br><div class="codebox"><p>Code: </p><pre><code>proc lineread {fp index line} {    seek $fp [lindex $index $line]    gets $fp }</code></pre></div>I mean .tcl lineread class 0 1, where class is the file it doesnt work.<br><br><br>PS: Starting from this example i can create my own array index and get the numbers from there var(1) "text" and get everything from there.. yet it would increase the memory of the eggdrop for a while<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6396">Madalin</a> — Mon Feb 27, 2017 12:30 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2017-02-27T10:39:41-04:00</updated>

		<published>2017-02-27T10:39:41-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105832#p105832</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105832#p105832"/>
		<title type="html"><![CDATA[Play text file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105832#p105832"><![CDATA[
What you are looking for is called <em class="text-italics">offset</em> and as far as I know this can be accomplished only with <a href="https://www.tcl.tk/man/tcl8.6/TclCmd/seek.htm" class="postlink"><em class="text-italics">seek</em></a>, but since this is binary you basically need to make an index of where the each line starts and ends.<br><br>Long story told short, have a look at a good example from <a href="http://wiki.tcl.tk/9027" class="postlink">here</a> and you will easily figure out based on that example how to read any given line.<br><br>If stuck drop a reply. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Mon Feb 27, 2017 10:39 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Madalin]]></name></author>
		<updated>2017-02-27T07:50:23-04:00</updated>

		<published>2017-02-27T07:50:23-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105831#p105831</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105831#p105831"/>
		<title type="html"><![CDATA[Play text file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105831#p105831"><![CDATA[
Im trying to make a text file to play on a channel with commands like !start !stop !resume and !pause<br><br>!start and !stop no problem ... but !pause and !resume i cant really figure it out <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"> i messed the code so far that i didnt know what ive done good or wrong..<br><br>This is the code i managed to save upon now..<br><div class="codebox"><p>Code: </p><pre><code>bind PUB - !start pub:prestartbind PUB - !pause pub:pausebind PUB - !resume pub:resumebind PUB - !stop pub:stopproc pub:prestart {nick uhost hand chan arg} {global classset class(end) 0set class(numara) -1set class(linie) -1class:start $chan $nick}proc class:start {chan nick} {global classset of [open class]incr class(numara)while {[gets $of line] ne -1} {incr class(linie)if {$class(end)} { close $of; putlog "Ne oprim"; return }if {$class(numara) eq $class(linie)} {putserv "PRIVMSG $chan :$line"close $of}}class:start $chan $nick}proc pub:stop {nick uhost hand chan arg} {global classif {![info exists class(start)]} { putquick "PRIVMSG $chan :\002::\002 Nu ruleaza nimic nu am ce opri"; return }set class(end) 1putquick "PRIVMSG $chan :\002::\002 Am oprit cu succes"}</code></pre></div>If someone can give me some HINTS ill apreaciate<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6396">Madalin</a> — Mon Feb 27, 2017 7:50 am</p><hr />
]]></content>
	</entry>
	</feed>
