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

	<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>2020-11-14T10:07:19-04:00</updated>

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

		<entry>
		<author><name><![CDATA[CrazyCat]]></name></author>
		<updated>2020-11-14T10:07:19-04:00</updated>

		<published>2020-11-14T10:07:19-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=109171#p109171</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=109171#p109171"/>
		<title type="html"><![CDATA[strip duplicate characters in nick and match against badnick]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=109171#p109171"><![CDATA[
Short remarks (or personnal preference)<blockquote class="uncited"><div>As a general rule of thumb generally it's a good idea to:<br>1. have variables inside an array, so you won't end up with stuff like this:<div class="codebox"><p>Code: </p><pre><code>global bnick bchan kickreason temp</code></pre></div>instead of having a cleaner:<div class="codebox"><p>Code: </p><pre><code>global something</code></pre></div>where <em class="text-italics">something</em> for example holds the following variables:<div class="codebox"><p>Code: </p><pre><code>set something(one) "1"set something(two) "2"# and so on.. you get the idea</code></pre></div></div></blockquote>I agree with caesar because of a pratical reason: if you use several scripts, you'll probably have variables with the same name but with a different usage.<br>Having <em class="text-italics">myscript(nicklist)</em> and <em class="text-italics">myscipt(delay)</em> is better than having <em class="text-italics">nicklist</em> and <em class="text-italics">delay</em> which could be use somewhere else.<br><br>Personnaly, I prefer use variables but call them using their namespace rather than use global. And having namespace for scripts, so when I use a variable, I know exactly where it comes from. $::username is not $::myscript::username.<br><br>A long time before, I was used to have global in my scripts, because I didn't know namespaces. But now, I think it's quite evil to use global <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=691">CrazyCat</a> — Sat Nov 14, 2020 10:07 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[simo]]></name></author>
		<updated>2020-11-14T09:50:09-04:00</updated>

		<published>2020-11-14T09:50:09-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=109170#p109170</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=109170#p109170"/>
		<title type="html"><![CDATA[strip duplicate characters in nick and match against badnick]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=109170#p109170"><![CDATA[
thanks caesar i cant figure it out for the moment but i will have a go at it perhaps another time for the moment ill use old code i do apreciate the efforts tho will  use that when i have some more clear mind to look at this<br><br>cheers.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12505">simo</a> — Sat Nov 14, 2020 9:50 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[simo]]></name></author>
		<updated>2020-11-14T09:47:05-04:00</updated>

		<published>2020-11-14T09:47:05-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=109169#p109169</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=109169#p109169"/>
		<title type="html"><![CDATA[strip duplicate characters in nick and match against badnick]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=109169#p109169"><![CDATA[
this is confusing thats why i dont use it<br><blockquote class="uncited"><div>set something(one) "1"<br>set something(two) "2"<br># and so on.. you get the idea</div></blockquote><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12505">simo</a> — Sat Nov 14, 2020 9:47 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2020-11-13T10:33:02-04:00</updated>

		<published>2020-11-13T10:33:02-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=109167#p109167</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=109167#p109167"/>
		<title type="html"><![CDATA[strip duplicate characters in nick and match against badnick]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=109167#p109167"><![CDATA[
As a general rule of thumb generally it's a good idea to:<br>1. have variables inside an array, so you won't end up with stuff like this:<div class="codebox"><p>Code: </p><pre><code>global bnick bchan kickreason temp</code></pre></div>instead of having a cleaner:<div class="codebox"><p>Code: </p><pre><code>global something</code></pre></div>where <em class="text-italics">something</em> for example holds the following variables:<div class="codebox"><p>Code: </p><pre><code>set something(one) "1"set something(two) "2"# and so on.. you get the idea</code></pre></div>2. use of the <a href="https://www.tcl.tk/man/tcl8.6/TclCmd/namespace.htm" class="postlink">namespace</a>, that's basically a collection of commands and variables and if given a unique name chances to end up at some point with two functions or variables having the same name are ZERO. will save you of a lot of hassle trying to figure out why your code isnt working properly<br><br>Next we got this:<div class="codebox"><p>Code: </p><pre><code>if {[lsearch -nocase $bchan $chan] || ![llength $bchan]} { # execute stuff}</code></pre></div>this is, for me at least, a bad approach on programming as it makes it harder for you to track if all the { have an}, if you got all the stuff you wanted to be executed in the right place and whatnot. At the top of the code before everything else is executed should have the sattements that validate the access to the next lines so it not only easier to follow but also to debug. The TCL interpreter doesn't care how you make the code as long as it's valid. Now let's intepret the statement and see what it dose:<div class="codebox"><p>Code: </p><pre><code>IF we can find a case in-sensitive match of the channel name in that list OR the list has at least one element THEN { execute this code }</code></pre></div>and let's see what happens:<div class="codebox"><p>Code: </p><pre><code>% set chan "foo"foo% set channels "something else in here"something else in here% lsearch -nocase $channels $chan-1% llength $channels4% if {[lsearch -nocase $channels $chan] || ![llength $channels]} { puts "I'm in" }I'm in</code></pre></div>As you can notice the channel isn't in the list, list has 4 elements and the code is executed nevertheless. The logic of the line is a bit flawed. At this point would like to point out that would be a lot easier to use the built-in mechanics we got and not hard-code variables that at some point we would like to change, so instead of this create a special flag like <em class="text-italics">setudef flag myFlag</em> and combined with <em class="text-italics">channel get $chan myFlag</em> for example you know if given channel should be allowed to execute the code.<div class="codebox"><p>Code: </p><pre><code>foreach i [string tolower $bnick] {</code></pre></div>I mentioned the <em class="text-italics">string tolower</em> in one of my previous posts, so no point in talking about it again, just remove it as your 'string match ' is done in a case in-sensitive manner so it's useless.<div class="codebox"><p>Code: </p><pre><code>if {!$temp} { return } {         putquick "MODE $chan  +b  *$badpart*!*@*"         putquick "KICK $chan $nick :$kickreason" } </code></pre></div>This is a gem, cos you are basically scratching your left ear with your right hand OVER your head:<div class="codebox"><p>Code: </p><pre><code>if $temp equals 0 we return ELSE execute this code</code></pre></div>Why bother with an IF-THEN-ELSE (it's IF statement THEN return ELSE { execute this code } basically) when you can just IF statement THEN { execute this code } directly. I see some of the stuff I previously mentioned didn't make the cut as well, so in the spirit of what CrazyCat suggested, don't expect me to spoon feed you the answers on this one. I mean, I could do just that but wouldn't help you in the long run.<br><br>As always, don't find my answers as patronizing you or anything like that. If you look at the history of my early posting you will see I got a lot of stupid questions and mistakes, but people like ppslim, user, stdragon, egghead to name a few had the patience and pushed me in the right direction without spoon feeding me every time. Just take this as a loving push in the right direction as well. <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> — Fri Nov 13, 2020 10:33 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[simo]]></name></author>
		<updated>2020-11-13T07:34:25-04:00</updated>

		<published>2020-11-13T07:34:25-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=109166#p109166</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=109166#p109166"/>
		<title type="html"><![CDATA[strip duplicate characters in nick and match against badnick]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=109166#p109166"><![CDATA[
this is what i came up with if its proper<div class="codebox"><p>Code: </p><pre><code> #--------------------------------------------------------------------------------------------------------------------##                                               BAD NICK SCRIPT BY RANA USMAN                                        ##--------------------------------------------------------------------------------------------------------------------##Author : RANA USMAN#Email : coolguy_rusman@yahoo.com#URL : www.ranausman.tk#Version : 1.2#Catch me on UNDERNET @ #VASTEYE my nick is ^Rana^Usman#################### Version History #####################The version before was not supporting Wildcards like ** ?? etc etc#So now in this version you can use wild cards too############################- CONFIGURATION SECTION -#####################################################################################################################- Enter the Bad nicks Below on which you want your bot to BAN  (Wild Cards Supported)-#########################################################################################set bnick {    "somenick"    "badnick"}###########################################################################################################                SET The channel on which you want this script to work                                #### Channels Separted by space...and if you want this script to work on all channels leave it as ""     ###########################################################################################################set bchan ""#################- Set Reason -#################set kickreason "4Bad Nick Detected"#--------------------------------------------------------------------------------------------------------------------##   SCRIPT STARTS FROM HERE...MAKE IT BETTER WITH YOUR SKILLS IF YOU CAN.I DONT RESTRICT YOU TO NOT TO TOUCH CODE!   ##--------------------------------------------------------------------------------------------------------------------#bind join - * join:RanaUsmanbind nick - * nick:tvrshproc nick:tvrsh {nick uhost hand chan newnick} {    join:RanaUsman $newnick $uhost $hand $chan}proc join:RanaUsman {nick uhost hand chan} {global bnick bchan kickreason temp regsub -all -- {(.)\1+} $nick {\1} nick2if {[lsearch -nocase $bchan $chan] || ![llength $bchan]} {  set temp 0   foreach i [string tolower $bnick] {    regexp -options { i } text -&gt; match   if {[string match -nocase *$match* $nick2]  &amp;&amp; ![string match -nocase *guest* $nick2]} {        set badpart $match   set temp 1    }    }}   if {!$temp} { return } {         putquick "MODE $chan  +b  *$badpart*!*@*"         putquick "KICK $chan $nick :$kickreason" }}putlog "=-\002 LOADED BAD NICK BY RANA USMAN (www.ranausman.tk)\002 -="#Author : RANA USMAN </code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12505">simo</a> — Fri Nov 13, 2020 7:34 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2020-11-13T01:55:49-04:00</updated>

		<published>2020-11-13T01:55:49-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=109165#p109165</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=109165#p109165"/>
		<title type="html"><![CDATA[strip duplicate characters in nick and match against badnick]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=109165#p109165"><![CDATA[
You mean have the regexp <em class="text-italics">pattern</em> in a separate variable?<div class="codebox"><p>Code: </p><pre><code>regexp -options { pattern } text -&gt; match</code></pre></div>Just remove the <em class="text-italics">pattern</em> you got right now and put a variable instead. Shouldn't be hard to figure out.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Fri Nov 13, 2020 1:55 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[simo]]></name></author>
		<updated>2020-11-12T14:05:30-04:00</updated>

		<published>2020-11-12T14:05:30-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=109164#p109164</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=109164#p109164"/>
		<title type="html"><![CDATA[strip duplicate characters in nick and match against badnick]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=109164#p109164"><![CDATA[
thanks caesar could a combination of the two be used ? like to have the words in a variable to go throu the regexp to  have freedom to add words in a more managable way<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12505">simo</a> — Thu Nov 12, 2020 2:05 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2020-11-12T13:21:32-04:00</updated>

		<published>2020-11-12T13:21:32-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=109163#p109163</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=109163#p109163"/>
		<title type="html"><![CDATA[strip duplicate characters in nick and match against badnick]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=109163#p109163"><![CDATA[
If you intend to drop the <em class="text-italics">foreach</em> loop and rely on the <em class="text-italics">regexp</em> line all you have to do is ... literally remove the <em class="text-italics">foreach</em> loop. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_lol.gif" width="15" height="15" alt=":lol:" title="Laughing"><br><br>Oh, before i forget, rename <em class="text-italics">bad</em> to <em class="text-italics">badpart</em> in the regexp line so you won't need have to change it in the <em class="text-italics">match &amp; punish</em> part of the code. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=":wink:" title="Wink"><br><br>Edit: If you still use that <em class="text-italics">regsub</em> CrazyCat helped you out wih might be a good idea to adjust the variable in the <em class="text-italics">regexp</em> line so it matches properly.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Thu Nov 12, 2020 1:21 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[simo]]></name></author>
		<updated>2020-11-12T10:01:01-04:00</updated>

		<published>2020-11-12T10:01:01-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=109162#p109162</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=109162#p109162"/>
		<title type="html"><![CDATA[strip duplicate characters in nick and match against badnick]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=109162#p109162"><![CDATA[
its not about not trying since i always try but when u have no clue where to add things or how to integrate something rather  than to have random guess and try things that arent proper i asked for how it would look like so i can use as an example for other codes to give me an idea how it would look like in code <br><br>thanks.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12505">simo</a> — Thu Nov 12, 2020 10:01 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[CrazyCat]]></name></author>
		<updated>2020-11-12T09:09:25-04:00</updated>

		<published>2020-11-12T09:09:25-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=109161#p109161</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=109161#p109161"/>
		<title type="html"><![CDATA[strip duplicate characters in nick and match against badnick]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=109161#p109161"><![CDATA[
<blockquote class="uncited"><div>how would it look like in the code caesar?</div></blockquote>Did you try to implement the part of code ?<br><br>I won't speak for caesar or others, but when I help, my intention is to teach something to the asker, not to just do it for him.<br>You ask a lot of things but seem to not try to understand what is done or how it works.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=691">CrazyCat</a> — Thu Nov 12, 2020 9:09 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[simo]]></name></author>
		<updated>2020-11-12T07:59:18-04:00</updated>

		<published>2020-11-12T07:59:18-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=109160#p109160</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=109160#p109160"/>
		<title type="html"><![CDATA[strip duplicate characters in nick and match against badnick]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=109160#p109160"><![CDATA[
how would it look like in the code caesar?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12505">simo</a> — Thu Nov 12, 2020 7:59 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2020-11-12T02:31:01-04:00</updated>

		<published>2020-11-12T02:31:01-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=109159#p109159</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=109159#p109159"/>
		<title type="html"><![CDATA[strip duplicate characters in nick and match against badnick]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=109159#p109159"><![CDATA[
I looked at your example and I don't understand how your match is working. From my limited understanding of regexp it should match <em class="text-italics">se</em> with something in the <em class="text-italics">()</em> but there's no <em class="text-italics">se</em> in the nick to begin with. I opened up a mIRC client and tested:<blockquote class="uncited"><div>//echo match for ds3kss: $regex("ds3kss",/(se(x|ks)|(s|f)uck|p(orn|enis)|h[0o]rny)/i)<br>match for ds3kss: 0</div></blockquote>In TCL this would be something like:<div class="codebox"><p>Code: </p><pre><code>set match [regexp -all {(se(x|ks)|(s|f)uck|p(orn|0rn|enis)|h[0o]rny)} $nick -&gt; bad]</code></pre></div>and if <em class="text-italics">$match</em> is 1 then in the <em class="text-italics">$bad</em> variable you got what it matched against.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Thu Nov 12, 2020 2:31 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[simo]]></name></author>
		<updated>2020-11-11T11:56:50-04:00</updated>

		<published>2020-11-11T11:56:50-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=109156#p109156</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=109156#p109156"/>
		<title type="html"><![CDATA[strip duplicate characters in nick and match against badnick]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=109156#p109156"><![CDATA[
tnx caesar i saw an msl code (mirc) using regex and it sets ban on the actual bad  part it matches against  i was hoping this could be done with tcl as well<blockquote class="uncited"><div>if ($regex($nick,/(se(x|ks)|(s|f)uck|p(orn|enis)|h[0o]rny)/i)) { mode $chan  +b $+ * $regml(1) $+ *!*@*  }  </div></blockquote>as regex matches a range of word paterns making it easier to manage words instead of using a huge list of word paterns<blockquote class="uncited"><div>17:14:20    Join :   ds3kss    <a href="mailto:Mibbit@RifSytes-h21.635.668.037.IP">Mibbit@RifSytes-h21.635.668.037.IP</a> <br>17:14:20  +[simo]  Sets Mode on  #opers  to:  +b *s3ks*!*@* <br>17:16:01    Join :   dseksq    <a href="mailto:Mibbit@RifSytes-h21.635.668.037.IP">Mibbit@RifSytes-h21.635.668.037.IP</a> <br>17:16:01  +[simo]  Sets Mode on  #opers  to:  +b *seks*!*@* </div></blockquote><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12505">simo</a> — Wed Nov 11, 2020 11:56 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2020-11-11T11:48:59-04:00</updated>

		<published>2020-11-11T11:48:59-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=109155#p109155</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=109155#p109155"/>
		<title type="html"><![CDATA[strip duplicate characters in nick and match against badnick]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=109155#p109155"><![CDATA[
That was expected since the <em class="text-italics">badpart</em> is what the nick was matched against. Change it and ban nick instead?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Wed Nov 11, 2020 11:48 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[simo]]></name></author>
		<updated>2020-11-11T08:14:21-04:00</updated>

		<published>2020-11-11T08:14:21-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=109150#p109150</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=109150#p109150"/>
		<title type="html"><![CDATA[strip duplicate characters in nick and match against badnick]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=109150#p109150"><![CDATA[
it sets a weird ban tho:<blockquote class="uncited"><div> @TCL-Tester  Sets Mode on  #opers  to:  +b *b[3e]dw[o0]rd*!*@*  </div></blockquote>while nick is badword or bedw0rd and so on making the ban invalid<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12505">simo</a> — Wed Nov 11, 2020 8:14 am</p><hr />
]]></content>
	</entry>
	</feed>
