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

	<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>2006-02-12T21:03:32-04:00</updated>

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

		<entry>
		<author><name><![CDATA[Kappa007]]></name></author>
		<updated>2006-02-12T21:03:32-04:00</updated>

		<published>2006-02-12T21:03:32-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=60383#p60383</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=60383#p60383"/>
		<title type="html"><![CDATA[Module output by using Tcl]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=60383#p60383"><![CDATA[
Synopsis:<br>----------<br>This article is for Eggdrop module developers.<br>This article covers Module &lt;-&gt; Tcl interaction in concern of server output routines.<br><br>As an example: A posibility how to output encrypted text from an Eggdrop module<br>by utilizing a 3rd party Tcl encryption script e.g. Mircryption/McEggdrop .<br><br><br><br>Motivation:<br>------------<br>dprintf(DP_SERVER, ... ) sends directly to the output socket.<br>No Tcl evaluation is performed, no scripts are invoked.<br><br>So unless we encrypt the text we want to send ourself, the bot will recognize encrypted commands<br>but respond in plaintext. That's kinda ugly if you ask me <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"><br>Even if we would use the blowfish module to encrypt the text we still got the problem that we don't have the keys.<br><br><br><br>Solution:<br>----------<br>We do NOT use dprintf() to send to the server but instead stuff our output into the Tcl Interpreter.<br>This is done by using Tcl_GlobalEval() as the ".tcl" command on the partyline does.<br><br>Change<br><br>dprintf(DP_SERVER, "PRIVMSG #chan :text")<br><br>to<br><br>Tcl_GlobalEval(interp, "putserv {PRIVMSG #chan :text}" )<br><br>and you're set.<br>If you care: Tcl_GlobalEval and Tcl_GlobalEvalObj are older procedures that are now deprecated. [from Tcl 8.4 manual]<br>use Tcl_EvalEx( interp, "putserv {PRIVMSG #chan :text}", -1, TCL_EVAL_GLOBAL ) instead.<br><br><br><br>Additional notes:<br>------------------<br>Be aware that scripts might rename/rebind/change/whatever the tcl commands.<br>So this solution could be classified as 'hack'.<br>Also you have to take care about escaping.<br>Replacing \ by \\ and afterwards { and } by \{ and \} could be sufficient when using {&lt;string&gt;}<br><br>A neat feature of that method could be not to use {&lt;string&gt;} but "&lt;string&gt;".<br>Then the Tcl interpreter would evaluate it, which means you could use Tcl statements in your output.<br>Designing your modules to only output Tcl variable names like $MyWelcomeText and using a separate Tcl file<br>which you either load by using "readtclprog()" or via the eggdrop config you could easily change the output<br>or add multi-language support to your module.<br><br><br>Regards,<br>Kappa007<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6524">Kappa007</a> — Sun Feb 12, 2006 9:03 pm</p><hr />
]]></content>
	</entry>
	</feed>
