Procházet zdrojové kódy

* Add tcl eval command over DCC

Bryan Drewery před 15 roky
rodič
revize
05f98b2c87
3 změnil soubory, kde provedl 22 přidání a 0 odebrání
  1. 1 0
      doc/UPDATES
  2. 3 0
      doc/help.txt
  3. 18 0
      src/cmds.c

+ 1 - 0
doc/UPDATES

@@ -1,6 +1,7 @@
 * Added SSL support
 * Added SSL support
   This includes new set options: 'servers-ssl', 'servers6-ssl', 'server-port-ssl', 'server-use-ssl'
   This includes new set options: 'servers-ssl', 'servers6-ssl', 'server-port-ssl', 'server-use-ssl'
 * libcrypto (openssl) is now loaded at startup and is required.
 * libcrypto (openssl) is now loaded at startup and is required.
+* Added TCL support. This is *only* a .tcl command currently, no scripts are loadable yet.
 
 
 1.3.2 - http://wraith.botpack.net/milestone/1.3.2
 1.3.2 - http://wraith.botpack.net/milestone/1.3.2
   * Add an extra 2 second delay before releasing nick to aide in syncing and time to type /nick
   * Add an extra 2 second delay before releasing nick to aide in syncing and time to type /nick

+ 3 - 0
doc/help.txt

@@ -1844,6 +1844,9 @@ See also: die, conf, botcmd
     -Users will not see channels that are +s or +p unless they have op access there
     -Users will not see channels that are +s or +p unless they have op access there
  
  
 See also: find
 See also: find
+::tcl
+###  $btcl$b script
+   Executes the given string and returns the result.
 :leaf:topic
 :leaf:topic
 ###  $btopic$b <text>
 ###  $btopic$b <text>
    Changes the channel's topic, assuming the bot is a chanop or the
    Changes the channel's topic, assuming the bot is a chanop or the

+ 18 - 0
src/cmds.c

@@ -57,6 +57,7 @@
 #include "socket.h"
 #include "socket.h"
 #include "traffic.h" /* egg_traffic_t */
 #include "traffic.h" /* egg_traffic_t */
 #include "core_binds.h"
 #include "core_binds.h"
+#include "libtcl.h"
 #include "src/mod/console.mod/console.h"
 #include "src/mod/console.mod/console.h"
 #include "src/mod/server.mod/server.h"
 #include "src/mod/server.mod/server.h"
 #include "src/mod/irc.mod/irc.h"
 #include "src/mod/irc.mod/irc.h"
@@ -4527,6 +4528,22 @@ void cmd_test(int idx, char *par)
   putlog(LOG_CMDS, "*", "#%s# test", dcc[idx].nick);
   putlog(LOG_CMDS, "*", "#%s# test", dcc[idx].nick);
 }
 }
 
 
+void cmd_tcl(int idx, char *par)
+{
+  if (!isowner(dcc[idx].nick)) {
+    dprintf(idx, "tcl is only available to permanent owners.\n");
+    return;
+  }
+
+  putlog(LOG_CMDS, "*", "#%s# tcl", dcc[idx].nick);
+
+  bd::String result(tcl_eval(par));
+  if (dcc[idx].irc && strcmp(dcc[idx].u.chat->con_chan, "*")) {
+      privmsg(dcc[idx].u.chat->con_chan, tcl_eval(par).c_str(), DP_SERVER);
+  } else
+    dprintf(idx, result.c_str(), DP_SERVER);
+}
+
 void cmd_botlink(int idx, char *par)
 void cmd_botlink(int idx, char *par)
 {
 {
   putlog(LOG_CMDS, "*", "#%s# botlink %s", dcc[idx].nick, par);
   putlog(LOG_CMDS, "*", "#%s# botlink %s", dcc[idx].nick, par);
@@ -4649,6 +4666,7 @@ cmd_t C_dcc[] =
   {"w", 		"n", 	(Function) cmd_w, 		NULL, 0},
   {"w", 		"n", 	(Function) cmd_w, 		NULL, 0},
   {"channels", 		"", 	(Function) cmd_channels, 	NULL, 0},
   {"channels", 		"", 	(Function) cmd_channels, 	NULL, 0},
   {"test",		"",	(Function) cmd_test,		NULL, 0},
   {"test",		"",	(Function) cmd_test,		NULL, 0},
+  {"tcl",		"a",	(Function) cmd_tcl,		NULL, AUTH_ALL},
   {"botlink",		"a",	(Function) cmd_botlink,		NULL, 0},
   {"botlink",		"a",	(Function) cmd_botlink,		NULL, 0},
   {"randstring", 	"", 	(Function) cmd_randstring, 	NULL, AUTH_ALL},
   {"randstring", 	"", 	(Function) cmd_randstring, 	NULL, AUTH_ALL},
   {"hash",		"",	(Function) cmd_hash,		NULL, AUTH_ALL},
   {"hash",		"",	(Function) cmd_hash,		NULL, AUTH_ALL},