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

	<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>2010-03-03T23:58:15-04:00</updated>

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

		<entry>
		<author><name><![CDATA[CharlesZink]]></name></author>
		<updated>2010-03-03T23:58:15-04:00</updated>

		<published>2010-03-03T23:58:15-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=92357#p92357</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=92357#p92357"/>
		<title type="html"><![CDATA[Thanks]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=92357#p92357"><![CDATA[
Thank you for taking the time to give me that voice code. Once I start putting the bot on multiple channels, I will use that. Off to remove the colon <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=11123">CharlesZink</a> — Wed Mar 03, 2010 11:58 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[arfer]]></name></author>
		<updated>2010-03-03T19:19:01-04:00</updated>

		<published>2010-03-03T19:19:01-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=92355#p92355</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=92355#p92355"/>
		<title type="html"><![CDATA[My Channel Operations Script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=92355#p92355"><![CDATA[
Out of interest, the following code for voicing users is what I would call more complete. It outputs pretty much every type of error that can occur in using the command and it lends much more scope in the possible syntax.<br><br>The bind requires that the user has global operator status in the bot's userfile (user flag o).<br><br>The other commands such as op, deop, devoice can be written in a similar way.<br><div class="codebox"><p>Code: </p><pre><code># !voice --&gt; voice yourself in the command source channel# !voice nick --&gt; voice the specified nick in the command source channel# !voice #channel --&gt; voice yourself in the specified channel# !voice nick #channel --&gt; voice the specified nick in the specified channelbind PUB o !voice pCommandsVoiceproc pCommandsVoice {nick uhost hand chan text} {    set arguments [regsub -all -- {[\s]{2,}} [string trim $text] { }]    switch -- [llength [split $arguments]] {        0 {            set tnick $nick            set tchan $chan        }        1 {            if {[regexp -- {^#} $arguments]} {                set tnick $nick                set tchan $arguments            } else {                set tnick $arguments                set tchan $chan            }        }        2 {            set tnick [lindex [split $arguments] 0]            set tchan [lindex [split $arguments] 1]        }        default {            putserv "PRIVMSG $chan :Incorrect syntax, use !voice ?nick? ?#channel?"            return 0        }    }    if {[string equal -nocase $nick $tnick]} {set nprefix "You are"} else {set nprefix "$tnick is"}    if {[string equal -nocase $chan $tchan]} {set cprefix "here"} else {set cprefix "on $tchan"}    if {[regexp -- {^#} $tchan]} {        if {[validchan $tchan]} {            if {[botonchan $tchan]} {                if {[botisop $tchan]} {                    if {[regexp -- {^[\x41-\x7D][-\d\x41-\x7D]*$} $tnick]} {                        if {[onchan $tnick $tchan]} {                            if {![isvoice $tnick $tchan]} {                                putserv "MODE $tchan +v $tnick"                            } else {putserv "PRIVMSG $chan :$nprefix already voice'd $cprefix"}                        } else {putserv "PRIVMSG $chan :$nprefix not $cprefix"}                    } else {putserv "PRIVMSG $chan :$tnick is not a valid nick"}                } else {putserv "PRIVMSG $chan :I need to be op'd $cprefix to do that"}            } else {putserv "PRIVMSG $chan :I am not currently on $tchan"}        } else {putserv "PRIVMSG $chan :$tchan is not a valid bot channel"}    } else {putserv "PRIVMSG $chan :$tchan is not a valid channel name"}    return 0}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5705">arfer</a> — Wed Mar 03, 2010 7:19 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[arfer]]></name></author>
		<updated>2010-03-03T18:24:02-04:00</updated>

		<published>2010-03-03T18:24:02-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=92354#p92354</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=92354#p92354"/>
		<title type="html"><![CDATA[My Channel Operations Script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=92354#p92354"><![CDATA[
The putserv statement has a superfluous colon. Sorry, I didn't notice that. This is the same used in a public command tcl shell.<br><br>[22:21] &lt;@arfer&gt; % putserv "MODE #eggtcl -v Hestia"<br>[22:21] * Baal sets mode: -v Hestia<br><br>Just remove the :<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5705">arfer</a> — Wed Mar 03, 2010 6:24 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[CharlesZink]]></name></author>
		<updated>2010-03-03T18:09:36-04:00</updated>

		<published>2010-03-03T18:09:36-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=92353#p92353</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=92353#p92353"/>
		<title type="html"><![CDATA[WHAT THE HELL?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=92353#p92353"><![CDATA[
Woah! My bot is totally freaking out! I copied the voice code you edited and showed me and this is what I'm getting<br><blockquote class="uncited"><div>&lt;~TheNerdTV&gt; !voice advcomp2019<br>* Terminator sets mode: +p-s</div></blockquote>And it does different stuff depending on each person?<br><blockquote class="uncited"><div>&lt;~TheNerdTV&gt; !voice SamsTechAnswers<br>* Terminator sets mode: +smcT</div></blockquote>Any idea why? Once again, this is what I'm using...<br><div class="codebox"><p>Code: </p><pre><code>proc voice_nick {nick host handle channel testes  } {putserv "MODE $channel :+v [string trim $testes]"return 0} </code></pre></div>Crazy!<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11123">CharlesZink</a> — Wed Mar 03, 2010 6:09 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[CharlesZink]]></name></author>
		<updated>2010-03-03T14:40:25-04:00</updated>

		<published>2010-03-03T14:40:25-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=92350#p92350</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=92350#p92350"/>
		<title type="html"><![CDATA[Thanks]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=92350#p92350"><![CDATA[
Thanks for the help! I will re-code it all and see if it works. Much appreciated.<br><br>This page, <a href="http://www.egginfo.org/?page=tcl" class="postlink">http://www.egginfo.org/?page=tcl</a>, has an amazing amount of info on some of the commands too.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11123">CharlesZink</a> — Wed Mar 03, 2010 2:40 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[arfer]]></name></author>
		<updated>2010-03-03T14:25:00-04:00</updated>

		<published>2010-03-03T14:25:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=92349#p92349</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=92349#p92349"/>
		<title type="html"><![CDATA[My Channel Operations Script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=92349#p92349"><![CDATA[
Yes that would work fine, providing you used the command !voice &lt;name&gt; where &lt;name&gt; was the nick of the user you wished the bot to voice.<br><br>I would tend to trim the argument before using it because some IRC clients insert a space after the nick when using autocomplete.<br><div class="codebox"><p>Code: </p><pre><code>proc voice_nick {nick host handle channel testes  } {putserv "MODE $channel :+v [string trim $testes]"return 0}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5705">arfer</a> — Wed Mar 03, 2010 2:25 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[CharlesZink]]></name></author>
		<updated>2010-03-03T14:17:30-04:00</updated>

		<published>2010-03-03T14:17:30-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=92348#p92348</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=92348#p92348"/>
		<title type="html"><![CDATA[RE]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=92348#p92348"><![CDATA[
Ok, thanks.<br><br>I partially understand what your saying, but how should I make this apply to the other commands like !voice and such?<br><br>Would this work:<br><div class="codebox"><p>Code: </p><pre><code>proc voice_nick {nick host handle channel testes  } {putserv "MODE $channel :+v $testes"return 0}</code></pre></div>For some reason I just don't think it's going to. I've done mIRC all my life, and TCL has thrown me for a total loop <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_biggrin.gif" width="15" height="15" alt=":-D" title="Very Happy"><br><br>Thanks for all your help, and I'll change the 'cycle' to 'restart' because when it leaves and comes back in, I want it to refresh all the scripts and such too, so it will see any changes, so I guess thats a restart not a cycle.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11123">CharlesZink</a> — Wed Mar 03, 2010 2:17 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[arfer]]></name></author>
		<updated>2010-03-03T04:42:20-04:00</updated>

		<published>2010-03-03T04:42:20-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=92343#p92343</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=92343#p92343"/>
		<title type="html"><![CDATA[My Channel Operations Script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=92343#p92343"><![CDATA[
Good effort.<br><br>Some of the things I've noticed :-<br><br>Although Tcl lists are in fact strings because Tcl can only have string data types, they are different in structure. You can't safely use string commands on lists or list commands on normal strings. The additional 'text' argument passed to a proc from a PUB bind, as well as other bind types, is a normal string. If you want to use list commands on it, you will need to split it into a list first. You may choose to join it back into a normal string before outputting, though this may not matter.<br><br>Your code :-<div class="codebox"><p>Code: </p><pre><code>proc set_topic {user host handle channel testes} {set what [lrange $testes 0 end]putserv "TOPIC $channel :$what"return 1}</code></pre></div>Correct code :-<div class="codebox"><p>Code: </p><pre><code>proc set_topic {user host handle channel testes} {  set what [join [lrange [split $testes] 0 end]]  putserv "TOPIC $channel :$what"  return 0}</code></pre></div>In actual fact, in this particular case it is pointless.<br><br><span style="color:green">[join [lrange [split $testes] 0 end]] == $testes</span><br><br>You may just as well do the following :-<br><div class="codebox"><p>Code: </p><pre><code>proc set_topic {user host handle channel testes} {  putserv "TOPIC $channel :$testes"  return 0}</code></pre></div>Better still you might want to test if the command user actually included a topic with the command, as follows :-<br><div class="codebox"><p>Code: </p><pre><code>proc set_topic {user host handle channel testes} {  if {[string length [string trim $testes]] != 0} {    putserv "TOPIC $channel :[string trim $testes]"  } else {    putserv "PRIVMSG $channel :correct syntax is !topic &lt;topic&gt;"  }  return 0}</code></pre></div>A good document to read on the subject of strings vs lists and how to avoid such issues choking scripts is :-<br><br><a href="http://www.peterre.info/characters.html" class="postlink">http://www.peterre.info/characters.html</a><br><br>Note also that I have returned 0 rather than 1. Some bind types (including PUB) behave differently if the proc returns 1. Simply a good habit, unless you deliberately want to return 1.<br><br>Take a look at tcl-commands.html in your bots doc/html subdirectory under the heading Binds b. Return values.<br><br>Your cycle command should probably be renamed to a restart command. There is no need to restart the bot if all you want to do is cycle an IRC channel.<br><br>To cycle the bot :-<div class="codebox"><p>Code: </p><pre><code>putserv "PART #channelname"</code></pre></div>The bot will immediately rejoin the channel because it still retains a record for the channel.<br><br>It is possible to control how long the bot stays out  by, instead of the above, programmatically setting the channel +inactive then using a timer to reset the channel -inactive (normally the default value).<br><br>Generally, I would avoid overuse of the strange characters used to format text output (as in your kick command). Mainly because it makes the script difficult to read. There is an excellent text formatting document in the Scripting FAQ section of this forum.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5705">arfer</a> — Wed Mar 03, 2010 4:42 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[CharlesZink]]></name></author>
		<updated>2010-03-02T22:01:21-04:00</updated>

		<published>2010-03-02T22:01:21-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=92341#p92341</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=92341#p92341"/>
		<title type="html"><![CDATA[My Channel Operations Script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=92341#p92341"><![CDATA[
Hi guys,<br><br>I've posted a couple questions around here and the help has been great! I just started trying to learn TCL. I've mostly learned from reading other peoples scripts, and trial &amp; error.<br><br>This is my first attempt at a script and it works..  Sorta. Some commands don't work at all, and other do only once. Not sure what is wrong, can you take a look and help out please?<br><br>(I've compiled this from some of my own stuff, and copying out of some other scripts.)<br><div class="codebox"><p>Code: </p><pre><code>### BINDS #### All I can say is, change with caution.bind pub o !op op_nickbind pub o !deop deop_nickbind pub o !voice voice_nickbind pub o !devoice devoice_nickbind pub o !kick kick_nickbind pub o !topic set_topicbind pub o !cycle cycle_bot### CODE #### Don't edit my work, please.#----- OP -----#proc op_nick {nick host handle channel testes} {putserv "MODE $channel +o $nick"return 1}#----- DEOP -----#proc deop_nick {nick host handle channel testes} {putserv "MODE $channel -o $nick"return 1}#----- VOICE -----#proc voice_nick {nick host handle channel testes  } {putserv "MODE $channel +v $nick"return 1}#----- DEVOICE -----#proc devoice_nick {nick host handle channel testes} {putserv "MODE $channel -v $nick"return 1}#----- KICK -----#proc kick_nick {nick uhost hand chan arg} {global botnickset who [lindex $arg 0]set why [lrange $arg 1 end]putserv "KICK $chan $who :$why 1 5,1•4•5•14,1.:X:. 14,1Gô15,1G14,1eR4,1.:X:. 5,1•4•5•"return 1}#----- TOPIC -----#proc set_topic {user host handle channel testes} {set what [lrange $testes 0 end]putserv "TOPIC $channel :$what"return 1}#----- CYCLE -----#proc cycle_bot  {nick host handle channel testes} {  global botnick set who [lindex $testes 0] if {$who == ""} { restart return 1}}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11123">CharlesZink</a> — Tue Mar 02, 2010 10:01 pm</p><hr />
]]></content>
	</entry>
	</feed>
