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

	<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>2018-04-14T12:18:23-04:00</updated>

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

		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2018-04-14T12:18:23-04:00</updated>

		<published>2018-04-14T12:18:23-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=106805#p106805</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=106805#p106805"/>
		<title type="html"><![CDATA[Voice/Devoice on Nick Change With Multiple 'Variables'?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=106805#p106805"><![CDATA[
1. Your <em class="text-italics">string compare -length 4 "User" $nick</em> doesn't seem to be working as you would expect:<div class="codebox"><p>Code: </p><pre><code>% set nick "User123"User123% string compare -length 4 "User" $nick0% set nick foofoo% string compare -length 4 "User" $nick-1</code></pre></div>so, instead should use something like:<div class="codebox"><p>Code: </p><pre><code>set test [string equal "User" [string range $nick 0 3]]</code></pre></div>and results are:<div class="codebox"><p>Code: </p><pre><code>% string equal "User" [string range $nick 0 3]1% set nick foofoo% string equal "User" [string range $nick 0 3]0</code></pre></div>2. This code:<div class="codebox"><p>Code: </p><pre><code>if {![string compare -length 5 "Guest" $nick]} {if {![string compare -length 6 "Andro|" $nick]} { </code></pre></div>doesn't reach Andro part because it doesn't get past the first if check.<br><br>3. Grabbing the first "letter" from a nick means that nicks like "|Something" won't get voiced because the | is grabbed first, so instead of:<div class="codebox"><p>Code: </p><pre><code>set letter [lindex [split $nick ""] 0]set test [string is upper $letter] </code></pre></div>would be safer to go with:<div class="codebox"><p>Code: </p><pre><code>set test [regexp -all {[A-Z]} $nick]</code></pre></div>If you got let's say a list of names that you want to check, for example User, Guest and Andro|, then something like this should do the job you are looking for:<div class="codebox"><p>Code: </p><pre><code>set match 0foreach n [split $myList] {set len [string length $n]if {[string equal $n [string range $nick 0 [expr $len - 1]]]} {incr matchbreak}}</code></pre></div>Thus your code becomes:<div class="codebox"><p>Code: </p><pre><code>proc case:action {chan nick} {if {[isbotnick $nick] || ![botisop $chan]} returnset match 0set myList "User Guest Andro|"foreach n [split $myList] {set len [string length $n]if {[string equal $n [string range $nick 0 [expr $len - 1]]]} {incr matchbreak}}if {$match} returnset test [regexp -all {[A-Z]} $nick]if {$test} {if {![isvoice $nick $chan]} {pushmode $chan +v $nick}} else {if {[isvoice $nick $chan]} {pushmode $chan -v $nick}}}</code></pre></div>Haven't tested much so let me know if something is wrong.<br><br>Edit: As for a blacklist:<div class="codebox"><p>Code: </p><pre><code>set blacklist "Someone Something Another"if {[lsearch -nocase $blacklist $nick]} return</code></pre></div>before the <em class="text-italics">set match 0</em> line should do the trick.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Sat Apr 14, 2018 12:18 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Dizmo]]></name></author>
		<updated>2018-04-14T09:03:07-04:00</updated>

		<published>2018-04-14T09:03:07-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=106804#p106804</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=106804#p106804"/>
		<title type="html"><![CDATA[Voice/Devoice on Nick Change With Multiple 'Variables'?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=106804#p106804"><![CDATA[
Hi, back in 2016 I posted a thread asking for help with a script that voices/devoices users depending on their nick. Rather than spam this thread with the one I created in 2016, I'll just post a link: <a href="http://forum.egghelp.org/viewtopic.php?t=20132" class="postlink">Voice/Devoice on Nickname Change mIRC to TCL</a><br><br>I'd like to first start by thanking, once again <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile">, the following people that helped me get the script up and running:<br><br>simo, caesar and willyw, cheers for your help. P.S, I think you pretty much wrote the script with very little to no input from me (so I can't really take any credit for doing anything what so ever). <br><br>Below is the script (after some modifications, no doubt that they are poor ones at that) that I'm currently using and I would like to make it a little bit more advanced, allowing me to add multiple 'inputs'/'criteria' and the ability to 'blacklist' specific nicks.<br><div class="codebox"><p>Code: </p><pre><code>bind join * * case:joinedbind nick * * case:nickproc case:joined {nick uhost hand chan} {# we trigger our special function to do the testing when someone just joined the channel   case:action $chan $nick}proc case:nick {nick uhost hand chan newnick} {   # we trigger our special function to do the testing when someone just changed his nick to a new one   case:action $chan $newnick}proc case:action {chan nick} {   # check if bot is the one that joined the channel and then check if he's a channel operator (has @)   if {[isbotnick $nick] || ![botisop $chan]} return   # we split the nick in sepatate elements (let's call them letters) and grab only the first one   set letter [lindex [split $nick ""] 0]   # we test if the letter we previously grabbed is in uppercase (result will be 1) or lowercase (result will be 0)   set test [string is upper $letter]   if {![string compare -length 4 "User" $nick]} {   set test 0}   # if the result is 1 then proceed to the next step   if {$test} {      # test if the nick isn't already voiced      if {![isvoice $nick $chan]} {         # nick isn't already voiced so give him voice (+v)         pushmode $chan +v $nick      }   # the previous test failed thus we do something else in return   } else {      # test if nick has voice (+v) on the channel      if {[isvoice $nick $chan]} {         # and now we actually remove his voice (+v) status         pushmode $chan -v $nick      }   }}</code></pre></div>At the moment the bot voices any user that has a nick starting with a Capital letter (f.ex 'Dizmo') and then devoices any nick that have lowercase first letters (f.ex 'dizmo'). The bot also ignores anyone with a nick that starts with 'User' (f.ex 'User392823'), ignoring the capital letter and by not voicing said users.<br><br>I'd like to make it possible to add more 'variables', such as:<div class="codebox"><p>Code: </p><pre><code>if {![string compare -length 5 "Guest" $nick]} {if {![string compare -length 6 "Andro|" $nick]} { </code></pre></div>I've tried adding the above to the script (not just like that however the bot seems to only pick up on 'User' nicks). <br><br>Also I'd like to be able to blacklist specific users (just by adding the nicks manually to the script, it doesn't need to be anything fancy like a channel/msg command). This function will, hopefully, get the bot to ignore said user so that if they change their nick to uppercase, it won't voice them.<br><br>I would appreciate anyone’s expertise on this one, like before, I am extremely grateful for any help that anyone can offer.  <br><br>Regards, <br>Dizmo.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12617">Dizmo</a> — Sat Apr 14, 2018 9:03 am</p><hr />
]]></content>
	</entry>
	</feed>
