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

	<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-11-17T16:55:15-04:00</updated>

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

		<entry>
		<author><name><![CDATA[KrzychuG]]></name></author>
		<updated>2004-11-17T16:54:23-04:00</updated>

		<published>2004-11-17T16:54:23-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=42843#p42843</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=42843#p42843"/>
		<title type="html"><![CDATA[escaping special characters in strings]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=42843#p42843"><![CDATA[
Maybe that will help:<div class="codebox"><p>Code: </p><pre><code>set arg [string map {\\ \\\\ \{ \\\{ \} \\\} \[ \\\[ \] \\\] \" \\\"} $arg]</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3672">KrzychuG</a> — Wed Nov 17, 2004 4:54 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2004-11-17T16:55:15-04:00</updated>

		<published>2004-11-17T16:49:06-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=42842#p42842</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=42842#p42842"/>
		<title type="html"><![CDATA[escaping special characters in strings]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=42842#p42842"><![CDATA[
Hmmm, ok.<br><br>Even with elaborate experimenting I couldn't get it right... so I changed my script like this, and it works perfectly:<br><div class="codebox"><p>Code: </p><pre><code>bind pubm - "*" tr:reacttextbind pub M !addtextreact tr:addreactionbind pub M !deltextreact tr:delreaction## Configuration#set textReactionsFile "data/textreactions/textreactions.txt"set textReactionsSaveTimer 30## This needs executing at start to read the current binds#if { [file exists $textReactionsFile]} {        set fp [open $textReactionsFile r]        while {[eof $fp] == 0} {                set line [gets $fp]                if { [string length $line] &gt; 0 } {                        set splitpos [string first "|" $line]                        if { $splitpos == -1 } {                                putlog "TEXTSTRINGS: Invalid entry in datafile: '$line'"                                exit                        }                        set trigger [string range $line 0 [expr $splitpos - 1]]                        set response [string range $line [expr $splitpos + 1] end]                        set textreactions($trigger) $response                        putlog "TEXTSTRINGS: Added '$trigger' =&gt; '$response'"                }        }        close $fp}## Set a timer for saving#timer $textReactionsSaveTimer tr:savereactions## Functions#proc tr:addreaction { nick uhost hand chan arg } {        global textreactions        set splitpos [string first "=" $arg]        if { $splitpos == -1 } {                puthelp "NOTICE $nick :You can't do it that way Dave... Correct syntax is !addtextreact trigger = reaction..."        } else {                set trigger [string trim [string range $arg 0 [expr $splitpos - 1]]]                set response [string trim [string range $arg [expr $splitpos + 1] end]]                set textreactions($trigger) $response                puthelp "NOTICE $nick :Oookaaay... I've added your weird idea... I'll now respond to it, too ;p"                putlog "TEXTTRIGGER: Added '$trigger' =&gt; '$response' by $nick"        }}proc tr:delreaction { nick uhost hand chan arg } {        global textreactions        set trigger [string tolower $arg]        unset textreactions($trigger)        putlog "TEXTTRIGGER: Deleted '$trigger'"        puthelp "NOTICE $nick :Hmm.. What did you say? I think I've forgotten something..."}proc tr:savereactions {} {        global textReactionsSaveTimer textReactionsFile textreactions        set fp [open $textReactionsFile w]        foreach trigger [array names textreactions] {                puts $fp "$trigger|$textreactions($trigger)"        }        close $fp        timer $textReactionsSaveTimer tr:savereactions        putlog "TEXTSTRINGS: Saving strings..."}proc tr:reacttext {nick uhost hand chan arg } {        global textreactions        foreach trigger [array names textreactions] {                if { [string match -nocase "*$trigger*" $arg] == 1 } {                        putchan $chan $textreactions($trigger)                }        }}</code></pre></div><p>Statistics: Posted by Guest — Wed Nov 17, 2004 4:49 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[demond]]></name></author>
		<updated>2004-11-17T16:10:32-04:00</updated>

		<published>2004-11-17T16:10:32-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=42841#p42841</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=42841#p42841"/>
		<title type="html"><![CDATA[escaping special characters in strings]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=42841#p42841"><![CDATA[
<blockquote class="uncited"><div>Any hints on how i should save this in the data file?</div></blockquote>as user suggested, <a href="http://tcl.tk/man/tcl8.5/TclCmd/join.htm" class="postlink">join</a>ed<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5056">demond</a> — Wed Nov 17, 2004 4:10 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[greenbear]]></name></author>
		<updated>2004-11-17T15:33:15-04:00</updated>

		<published>2004-11-17T15:33:15-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=42840#p42840</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=42840#p42840"/>
		<title type="html"><![CDATA[escaping special characters in strings]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=42840#p42840"><![CDATA[
<a href="http://forum.egghelp.org/viewtopic.php?t=2603" class="postlink">*Click*</a><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=24">greenbear</a> — Wed Nov 17, 2004 3:33 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2004-11-17T15:20:30-04:00</updated>

		<published>2004-11-17T15:20:30-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=42839#p42839</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=42839#p42839"/>
		<title type="html"><![CDATA[escaping special characters in strings]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=42839#p42839"><![CDATA[
Hmmm. okay.<br><br>Any hints on how i should save this in the data file?<br><br>Currently, there are things in it like<br><div class="codebox"><p>Code: </p><pre><code>"bad bot" bad humanoid</code></pre></div>so that 'bad bot' is the trigger... Because I'm still getting the {}...<p>Statistics: Posted by Guest — Wed Nov 17, 2004 3:20 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[user]]></name></author>
		<updated>2004-11-17T15:03:25-04:00</updated>

		<published>2004-11-17T15:03:25-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=42838#p42838</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=42838#p42838"/>
		<title type="html"><![CDATA[escaping special characters in strings]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=42838#p42838"><![CDATA[
<a href="http://tcl.tk/man/tcl8.5/TclCmd/lindex.htm" class="postlink">lindex</a> and <a href="http://tcl.tk/man/tcl8.5/TclCmd/lrange.htm" class="postlink">lrange</a> expect a list as input and you feed it a string. Use <a href="http://tcl.tk/man/tcl8.5/TclCmd/split.htm" class="postlink">split</a> to turn your string into a list...and <a href="http://tcl.tk/man/tcl8.5/TclCmd/join.htm" class="postlink">join</a> to make the list returned by 'lrange' a string.<div class="codebox"><p>Code: </p><pre><code>set args [split $arg]lindex $args N...</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2878">user</a> — Wed Nov 17, 2004 3:03 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2004-11-17T14:16:32-04:00</updated>

		<published>2004-11-17T14:16:32-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=42837#p42837</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=42837#p42837"/>
		<title type="html"><![CDATA[escaping special characters in strings]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=42837#p42837"><![CDATA[
Hello all,<br><br>I'm fiddling a bit with TCL to create a script that allows the bot to trigger on any 'keyword' said in any sentence. Also adding 'add' and 'remove' binds for it.<br><br>Works like a charm, tho for some weird reason when using special characters, the bot replies them with { } around them, eg:<br><blockquote class="uncited"><div>&lt;devilkin&gt; !addtextreact meow *purrrrr* ;)<br>&lt;devilkin&gt; meow<br>&lt;thebot&gt; *purrrrrrrr* {;)}</div></blockquote>Any idea how I can deal with that? Same happens with the strings read from the datafile...<br><div class="codebox"><p>Code: </p><pre><code>bind pubm - "*" tr:reacttextbind pub M !addtextreact tr:addreactionbind pub M !deltextreact tr:delreaction## Configuration#set textReactionsFile "data/textreactions/textreactions.txt"set textReactionsSaveTimer 30## This needs executing at start to read the current binds#if { [file exists $textReactionsFile]} {        set fp [open $textReactionsFile r]        while {[eof $fp] == 0} {                set line [gets $fp]                set trigger [lindex $line 0]                set response [lrange $line 1 end]                set textreactions($trigger) $response        }        close $fp}## Set a timer for saving#timer $textReactionsSaveTimer tr:savereactions## Functions#proc tr:addreaction { nick uhost hand chan arg } {        global textreactions        set trigger [string tolower [lindex $arg 0]]        set reaction [lrange $arg 1 end]        set textreactions($trigger) $reaction        putlog "TEXTTRIGGER: Added '$trigger' =&gt; '$reaction'"}proc tr:delreaction { nick uhost hand chan arg } {        global textreactions        set trigger [string tolower $arg]        unset textreactions($trigger)        putlog "TEXTTRIGGER: Deleted '$trigger'"}# TODOproc tr:savereactions {} {        global textReactionsSaveTimer        putlog "SAVE"        timer $textReactionsSaveTimer tr:savereactions}proc tr:reacttext {nick uhost hand chan arg } {        global textreactions        foreach trigger [array names textreactions] {                if { [string match -nocase "*$trigger*" $arg] == 1 } {                        putchan $chan $textreactions($trigger)                }        }}</code></pre></div><p>Statistics: Posted by Guest — Wed Nov 17, 2004 2:16 pm</p><hr />
]]></content>
	</entry>
	</feed>
