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

	<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>2004-09-13T23:18:45-04:00</updated>

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

		<entry>
		<author><name><![CDATA[awyeah]]></name></author>
		<updated>2004-09-13T23:18:45-04:00</updated>

		<published>2004-09-13T23:18:45-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=40899#p40899</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=40899#p40899"/>
		<title type="html"><![CDATA[regexp check]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=40899#p40899"><![CDATA[
By the way I forgot to mention:<br><div class="codebox"><p>Code: </p><pre><code>if {([string match "*\[*\]*" $text]) || ([string match "*\{*\}*" $text])} { sendcmd "PRIVMSG $chan :Illegal characters in nick: \[\]\ \{\}\ "; return 0 } </code></pre></div>Will match nicks like:<br>- aw[ye]ah<br>- Al[cher]a<br>- awe{so}me<br>- [p][r]<em class="text-italics">[n][c][e]<br>- a{s}s{k}i{c}k{e}r<br>- aw[[y]]eah etc...<br><br>If you only want to match nicks like:<br>- [awyeah]<br>- {Alchera}<br>- [elite] and etc...<br><br>You will need to use something like:</em><br><div class="codebox"><p>Code: </p><pre><code>if {(([string equal "\[" [string index $nick 0]) &amp;&amp; ([string equal "\]" [string index [expr [string length $nick] - 1]]])) || (([string equal "\{" [string index $nick 0]) &amp;&amp; ([string equal "\}" [string index [expr [string length $nick] - 1]]]))} { sendcmd "PRIVMSG $chan :Illegal characters in nick: \[\]\ \{\}\ "; return 0 }</code></pre></div>Meaning you have to check the first and last characters of the nick by using string index. If the first and last character of the nick equals to [ and ] or { and } then you can go ahead and do your stuff.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=4875">awyeah</a> — Mon Sep 13, 2004 11:18 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[awyeah]]></name></author>
		<updated>2004-09-13T21:53:07-04:00</updated>

		<published>2004-09-13T21:53:07-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=40897#p40897</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=40897#p40897"/>
		<title type="html"><![CDATA[regexp check]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=40897#p40897"><![CDATA[
Well you can use string match as well Alchera if you don't want to add users in the bot which have [ ] { } in their nicks.<br><div class="codebox"><p>Code: </p><pre><code>if {([string match "*\[*\]*" $text]) || ([string match "*\{*\}*" $text])} { sendcmd "PRIVMSG $chan :Illegal characters in nick: \[\]\ \{\}\ "; return 0 }</code></pre></div>Alternatively, you can also do a foreach loop and assign a list to the characters you want to exempt *\[*\]*  *\{*\}* bla bla and then do a string match for each character if you don't want to use the || function.<br><br>I am not sure, but I think || (OR) will be faster than running the loop if I am correct. (faster in milli/nano seconds, heh)<br><br>regexp only matches for complex structures here the one you are using is not complex and quite simple. Furthermore regexp is quite slower than string match (has been proved on the forum), so I suggest you use string match here!  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_razz.gif" width="15" height="15" alt=":P" title="Razz"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=4875">awyeah</a> — Mon Sep 13, 2004 9:53 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Alchera]]></name></author>
		<updated>2004-09-13T18:39:10-04:00</updated>

		<published>2004-09-13T18:39:10-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=40891#p40891</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=40891#p40891"/>
		<title type="html"><![CDATA[regexp check]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=40891#p40891"><![CDATA[
I'm not that good with regexp but have this line of code and am wondering whether it could be done better. The aim being to exclude adding users to the bot with either [] or {} in their nick(s).<div class="codebox"><p>Code: </p><pre><code>if {[regexp -nocase -- {[\[\]\{\}\]]+} $text]} {sendcmd "privmsg $chan :Illegal characters in nick: \[\]\ \{\}\ ";return}</code></pre></div>The above does work very well btw. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>The "sendcmd" procedure is a custom one of mine.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3646">Alchera</a> — Mon Sep 13, 2004 6:39 pm</p><hr />
]]></content>
	</entry>
	</feed>
