Fix bot module loading in Guile 1.9.x+
[clinton/bobotpp.git] / source / ScriptCommands.C
index 4eb4c72..502a9f8 100644 (file)
@@ -1,6 +1,6 @@
 // ScriptCommands.C  -*- C++ -*-
 // Copyright (c) 1998 Etienne BERNARD
-// Copyright (C) 2002,2005 Clinton Ebadi
+// Copyright (C) 2002,2005,2008,2009 Clinton Ebadi
 
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -14,7 +14,8 @@
 
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+// 02110-1301, USA.
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 
 #ifdef USESCRIPTS
 
-#include "Utils.H"
-#include "Server.H"
-#include "ServerList.H"
-#include "ServerQueue.H"
 #include "ScriptCommands.H"
-#include "Interp.H"
-#include "DCCPerson.H"
-#include "DCCManager.H"
-#include "Parser.H"
+
+#include <libguile.h>
+
+#include "Bot.H"
+#include "BotInterp.H"
+#include "ChannelList.H"
 #include "Commands.H"
+#include "DCCManager.H"
+#include "DCCPerson.H"
+#include "Interp.H"
 #include "Message.H"
-#include <libguile.h>
+#include "Parser.H"
+#include "Server.H"
+#include "ServerConnection.H"
+#include "ServerList.H"
+#include "ServerQueue.H"
+#include "User.H"
+#include "Utils.H"
 
-#define VERIFY_STRING(par) if (!SCM_STRINGP((par))) \
-                             return scm_long2num(-17)
+#define VERIFY_STRING(par) if (!scm_is_string((par))) \
+                             return scm_from_int(-17)
 
 #define VERIFY_NUMBER(par) if (!SCM_NUMBERP((par))) \
-                             return scm_long2num(-17)
+                             return scm_from_int(-17)
 
 SCM
 ScriptCommands::Action(SCM channel, SCM message)
@@ -48,7 +56,7 @@ ScriptCommands::Action(SCM channel, SCM message)
   VERIFY_STRING(message);
   Message m = Commands::Action(Interp::bot, Utils::scm2str(channel),
                                Utils::scm2str(message));
-  return scm_long2num(m.getCode());
+  return scm_from_int(m.getCode());
 }
 
 SCM
@@ -81,15 +89,14 @@ ScriptCommands::AddUser(SCM who, SCM maskChannel, SCM level,
       if (!eexpire) eexpire = -1;
     }
 
-  int protect = scm_num2int (prot, SCM_ARG1, "ScriptCommands::AddUser");
-  bool aaop = SCM_NFALSEP (aop);
-  int llevel = scm_num2int (level, SCM_ARG1, 
-                                 "ScriptCommands::AddUser");
+  int protect = scm_to_int (prot);
+  bool aaop = scm_is_true (aop);
+  int llevel = scm_to_int (level);
 
   Message m = Commands::AddUser (Interp::bot, wwho, mask, llevel, 
                                 protect, aaop, eexpire, passwd);
 
-  return scm_long2num(m.getCode ());
+  return scm_from_int(m.getCode ());
 }
 
 SCM
@@ -97,11 +104,11 @@ ScriptCommands::AddServer(SCM servername, SCM port)
 {
   int p = 6667;
   if (SCM_NUMBERP(port))
-    p = scm_num2long(port, SCM_ARG1, "ScriptCommands::AddServer");
+    p = scm_to_int (port);
   Message m = Commands::AddServer(Interp::bot,
                                   Utils::scm2str(servername),
                                   p);
-  return scm_long2num(m.getCode());
+  return scm_from_int(m.getCode());
 }
 
 SCM
@@ -114,7 +121,7 @@ ScriptCommands::AddShit(SCM mask, SCM maskChannel, SCM level,
   VERIFY_NUMBER (level);
   String mmask = Utils::scm2str (mask);
   String mmaskChannel = Utils::scm2str (maskChannel);
-  int llevel = scm_num2int (level, SCM_ARG1, "ScriptCommands::AddShit");
+  int llevel = scm_to_int (level);
   std::time_t expire;
   String rreason;
 
@@ -136,7 +143,7 @@ ScriptCommands::AddShit(SCM mask, SCM maskChannel, SCM level,
   Message m = Commands::AddShit (Interp::bot, mmask, mmaskChannel,
                                 llevel, expire, rreason);
 
-  return scm_long2num(m.getCode ());
+  return scm_from_int(m.getCode ());
 }
 
 SCM
@@ -146,7 +153,7 @@ ScriptCommands::Ban(SCM channel, SCM who)
   VERIFY_STRING(who);
   Message m = Commands::Ban(Interp::bot, Utils::scm2str(channel),
                             Utils::scm2str(who));
-  return scm_long2num(m.getCode());
+  return scm_from_int(m.getCode());
 }
 
 SCM
@@ -155,9 +162,8 @@ ScriptCommands::ChangeCommandLevel(SCM command, SCM level)
   VERIFY_STRING (command);
   VERIFY_NUMBER (level);
 
-  SCM_STRING_COERCE_0TERMINATION_X (command);
-  std::string ccommand = SCM_STRING_CHARS (command);
-  unsigned int llevel = scm_num2uint (level, 0, "ScriptCommands::ChangeCommandLevel");
+  std::string ccommand = scm_to_locale_string (command);
+  unsigned int llevel = scm_to_uint (level);
 
   if (llevel > 4)
     return SCM_BOOL_F;
@@ -176,12 +182,73 @@ ScriptCommands::ChangeCommandLevel(SCM command, SCM level)
   return SCM_BOOL_T;
 }
 
+
+void
+ScriptCommands::collect_channel_users::operator() (SCM *list, User user)
+  const
+{
+  *list = scm_cons (scm_list_n (Utils::str2scm (user.get_nick()),
+                               Utils::str2scm (user.get_userhost ()),
+                               scm_from_int (user.get_mode ()),
+                               SCM_UNDEFINED),
+                   *list);
+}
+
+SCM
+ScriptCommands::ChannelUsers (SCM channel_name)
+{
+  VERIFY_STRING (channel_name);
+
+  Channel *channel = Interp::bot->channelList->getChannel (Utils::scm2str (channel_name));
+
+  if (!channel)
+    return SCM_BOOL_F;
+
+  SCM* list = (SCM*)scm_gc_malloc (sizeof (SCM), "ScriptCommands::ChannelUsers");
+  *list = SCM_EOL;
+
+  collect_channel_users c;
+  
+  channel->for_each_channel_users (std::bind1st (c, list));
+                                                
+  scm_remember_upto_here_1 (list);
+  return scm_reverse_x (*list, SCM_UNDEFINED);
+}
+
+SCM
+ScriptCommands::CTCP(SCM to, SCM command , SCM message)
+{
+  VERIFY_STRING(to);
+  VERIFY_STRING(command);
+  VERIFY_STRING(message);
+
+  Commands::CTCP (Interp::bot, Utils::scm2str (to), 
+                     Utils::scm2str (command),
+                     Utils::scm2str (message));
+
+  return SCM_UNSPECIFIED;
+}
+
+SCM
+ScriptCommands::CTCPReply (SCM to, SCM command , SCM message)
+{
+  VERIFY_STRING(to);
+  VERIFY_STRING(command);
+  VERIFY_STRING(message);
+
+  Commands::CTCPReply (Interp::bot, Utils::scm2str (to), 
+                      Utils::scm2str (command),
+                      Utils::scm2str (message));
+
+  return SCM_UNSPECIFIED;
+}
+
 SCM
 ScriptCommands::Cycle(SCM channel)
 {
   VERIFY_STRING(channel);
   Message m = Commands::Cycle(Interp::bot, Utils::scm2str(channel));
-  return scm_long2num(m.getCode());
+  return scm_from_int(m.getCode());
 }
 
 SCM
@@ -191,17 +258,15 @@ ScriptCommands::Deban(SCM channel, SCM who)
   VERIFY_STRING(who);
   Message m = Commands::Deban(Interp::bot, Utils::scm2str(channel),
                               Utils::scm2str(who));
-  return scm_long2num(m.getCode());
+  return scm_from_int(m.getCode());
 }
 
 SCM
 ScriptCommands::DelServer(SCM number)
 {
   VERIFY_NUMBER(number);
-  Message m = Commands::DelServer(Interp::bot, 
-                                 scm_num2long(number, SCM_ARG1, 
-                                              "ScriptCommands::DelServer"));
-  return scm_long2num(m.getCode());
+  Message m = Commands::DelServer(Interp::bot, scm_to_int (number));
+  return scm_from_int(m.getCode());
 }
 
 SCM
@@ -211,7 +276,7 @@ ScriptCommands::DelUser(SCM who, SCM maskChannel)
   VERIFY_STRING(maskChannel);
   Message m = Commands::DelUser(Interp::bot, Utils::scm2str(who),
                                 Utils::scm2str(maskChannel));
-  return scm_long2num(m.getCode());
+  return scm_from_int(m.getCode());
 }
 
 SCM
@@ -221,7 +286,7 @@ ScriptCommands::DelShit(SCM who, SCM maskChannel)
   VERIFY_STRING(maskChannel);
   Message m = Commands::DelShit(Interp::bot, Utils::scm2str(who),
                                 Utils::scm2str(maskChannel));
-  return scm_long2num(m.getCode());
+  return scm_from_int(m.getCode());
 }
 
 SCM
@@ -231,17 +296,17 @@ ScriptCommands::Deop(SCM channel, SCM who)
   VERIFY_STRING(who);
   Message m = Commands::Deop(Interp::bot, Utils::scm2str(channel),
                              Utils::scm2str(who));
-  return scm_long2num(m.getCode());
+  return scm_from_int(m.getCode());
 }
 
 SCM
 ScriptCommands::Die(SCM reason)
 {
   String r = "Leaving";
-  if (SCM_STRINGP(reason))
+  if (scm_is_string(reason))
     r = Utils::scm2str(reason);
   Message m = Commands::Die(Interp::bot, r);
-  return scm_long2num(m.getCode());
+  return scm_from_int(m.getCode());
 }
 
 SCM
@@ -249,7 +314,7 @@ ScriptCommands::Do(SCM command)
 {
   VERIFY_STRING(command);
   Message m = Commands::Do(Interp::bot, Utils::scm2str(command));
-  return scm_long2num(m.getCode());
+  return scm_from_int(m.getCode());
 }
 
 SCM
@@ -259,7 +324,7 @@ ScriptCommands::Invite(SCM channel, SCM who)
   VERIFY_STRING(who);
   Message m = Commands::Invite(Interp::bot, Utils::scm2str(channel),
                                Utils::scm2str(who));
-  return scm_long2num(m.getCode());
+  return scm_from_int(m.getCode());
 }
 
 SCM
@@ -267,11 +332,11 @@ ScriptCommands::Join(SCM channel, SCM key)
 {
   VERIFY_STRING(channel);
   String k = "";
-  if (SCM_STRINGP(key))
+  if (scm_is_string(key))
     k = Utils::scm2str(key);
   Message m = Commands::Join(Interp::bot, Utils::scm2str(channel),
                              k);
-  return scm_long2num(m.getCode());
+  return scm_from_int(m.getCode());
 }
 
 SCM
@@ -281,7 +346,7 @@ ScriptCommands::Keep(SCM channel, SCM modes)
   VERIFY_STRING(modes);
   Message m = Commands::Keep(Interp::bot, Utils::scm2str(channel),
                              Utils::scm2str(modes));
-  return scm_long2num(m.getCode());
+  return scm_from_int(m.getCode());
 }
 
 SCM
@@ -291,12 +356,12 @@ ScriptCommands::Kick(SCM channel, SCM who, SCM reason)
   VERIFY_STRING(who);
 
   String r = "";
-  if (SCM_STRINGP(reason))
+  if (scm_is_string(reason))
     r = Utils::scm2str(reason);
 
   Message m = Commands::Kick(Interp::bot, Utils::scm2str(channel),
                              Utils::scm2str(who), r);
-  return scm_long2num(m.getCode());
+  return scm_from_int(m.getCode());
 }
 
 SCM
@@ -305,11 +370,11 @@ ScriptCommands::KickBan(SCM channel, SCM who, SCM reason)
   VERIFY_STRING(channel);
   VERIFY_STRING(who);
   String r = "";
-  if (SCM_STRINGP(reason))
+  if (scm_is_string(reason))
     r = Utils::scm2str(reason);
   Message m = Commands::KickBan(Interp::bot, Utils::scm2str(channel),
                                 Utils::scm2str(who), r);
-  return scm_long2num(m.getCode());
+  return scm_from_int(m.getCode());
 }
 
 SCM
@@ -317,7 +382,7 @@ ScriptCommands::Lock(SCM channel)
 {
   VERIFY_STRING(channel);
   Message m = Commands::Lock(Interp::bot, Utils::scm2str(channel));
-  return scm_long2num(m.getCode());
+  return scm_from_int(m.getCode());
 }
 
 SCM
@@ -333,7 +398,7 @@ ScriptCommands::Mode(SCM channel, SCM mode)
   VERIFY_STRING(mode);
   Message m = Commands::Mode(Interp::bot, Utils::scm2str(channel),
                              Utils::scm2str(mode));
-  return scm_long2num(m.getCode());
+  return scm_from_int(m.getCode());
 }
 
 SCM
@@ -343,7 +408,7 @@ ScriptCommands::Msg(SCM nick, SCM message)
   VERIFY_STRING(message);
   Message m = Commands::Msg(Interp::bot, Utils::scm2str(nick),
                             Utils::scm2str(message));
-  return scm_long2num(m.getCode());
+  return scm_from_int(m.getCode());
 
 }
 
@@ -351,7 +416,7 @@ SCM
 ScriptCommands::NextServer(void)
 {
   Message m = Commands::NextServer(Interp::bot);
-  return scm_long2num(m.getCode());
+  return scm_from_int(m.getCode());
 }
 
 SCM
@@ -359,7 +424,20 @@ ScriptCommands::Nick(SCM nick)
 {
   VERIFY_STRING(nick);
   Message m = Commands::Nick(Interp::bot, Utils::scm2str(nick));
-  return scm_long2num(m.getCode());
+  return scm_from_int(m.getCode());
+}
+
+SCM
+ScriptCommands::Notice (SCM to, SCM message)
+{
+  VERIFY_STRING (to);
+  VERIFY_STRING (message);
+
+  return (scm_from_int 
+         (Commands::Notice (Interp::bot, 
+                            Utils::scm2str (to),
+                            Utils::scm2str (message)).getCode ()));
+  
 }
 
 SCM
@@ -369,7 +447,7 @@ ScriptCommands::Op(SCM channel, SCM who)
   VERIFY_STRING(who);
   Message m = Commands::Op(Interp::bot, Utils::scm2str(channel),
                            Utils::scm2str(who));
-  return scm_long2num(m.getCode());
+  return scm_from_int(m.getCode());
 }
 
 SCM
@@ -377,14 +455,14 @@ ScriptCommands::Part(SCM channel)
 {
   VERIFY_STRING(channel);
   Message m = Commands::Part(Interp::bot, Utils::scm2str(channel));
-  return scm_long2num(m.getCode());
+  return scm_from_int(m.getCode());
 }
 
 SCM
 ScriptCommands::Reconnect(void)
 {
   Message m = Commands::Reconnect(Interp::bot);
-  return scm_long2num(m.getCode());
+  return scm_from_int(m.getCode());
 }
 
 SCM
@@ -394,31 +472,30 @@ ScriptCommands::Say(SCM channel, SCM message)
   VERIFY_STRING(message);
   Message m = Commands::Say(Interp::bot, Utils::scm2str(channel),
                             Utils::scm2str(message));
-  return scm_long2num(m.getCode());
+  return scm_from_int(m.getCode());
 }
 
 SCM
 ScriptCommands::Server(SCM number)
 {
   VERIFY_NUMBER(number);
-  Message m = Commands::Server(Interp::bot, gh_scm2long(number));
-  return scm_long2num(m.getCode());
+  Message m = Commands::Server(Interp::bot, scm_to_int(number));
+  return scm_from_int(m.getCode());
 }
 
 SCM
 ScriptCommands::SetFloodRate(SCM rate)
 {
   VERIFY_NUMBER(rate);
-  Message m = Commands::SetFloodRate(Interp::bot, scm_num2uint 
-                                    (rate, 0, "SetFloodRate"));
-  return scm_long2num(m.getCode());
+  Message m = Commands::SetFloodRate(Interp::bot, scm_to_uint (rate));
+  return scm_from_int(m.getCode());
 }
 
 SCM
 ScriptCommands::SetVersion(SCM version)
 {
   Message m = Commands::SetVersion(Interp::bot, Utils::scm2str(version));
-  return scm_long2num(m.getCode());
+  return scm_from_int(m.getCode());
 }
 
 SCM
@@ -428,8 +505,8 @@ ScriptCommands::TBan(SCM channel, SCM who, SCM seconds)
   VERIFY_STRING(who);
   VERIFY_NUMBER(seconds);
   Message m = Commands::TBan(Interp::bot, Utils::scm2str(channel),
-                             Utils::scm2str(who), gh_scm2long(seconds));
-  return scm_long2num(m.getCode());
+                             Utils::scm2str(who), scm_to_int(seconds));
+  return scm_from_int(m.getCode());
 }
 
 SCM
@@ -439,12 +516,12 @@ ScriptCommands::TKBan(SCM channel, SCM who, SCM seconds, SCM reason)
   VERIFY_STRING(who);
   VERIFY_NUMBER(seconds);
   String r = "";
-  if (SCM_STRINGP(reason))
+  if (scm_is_string(reason))
     r = Utils::scm2str(reason);
   Message m = Commands::TKBan(Interp::bot, Utils::scm2str(channel),
                               Utils::scm2str(who),
-                              gh_scm2long(seconds), r);
-  return scm_long2num(m.getCode());
+                              scm_to_int(seconds), r);
+  return scm_from_int(m.getCode());
 }
 
 SCM
@@ -454,7 +531,7 @@ ScriptCommands::Topic(SCM channel, SCM topic)
   VERIFY_STRING(topic);
   Message m = Commands::Topic(Interp::bot, Utils::scm2str(channel),
                               Utils::scm2str(topic));
-  return scm_long2num(m.getCode());
+  return scm_from_int(m.getCode());
 }
 
 SCM
@@ -462,7 +539,27 @@ ScriptCommands::Unlock(SCM channel)
 {
   VERIFY_STRING(channel);
   Message m = Commands::Unlock(Interp::bot, Utils::scm2str(channel));
-  return scm_long2num(m.getCode());
+  return scm_from_int(m.getCode());
+}
+
+SCM
+ScriptCommands::Who (SCM target)
+{
+  VERIFY_STRING (target);
+
+  Message m = Commands::Who (Interp::bot, Utils::scm2str (target));
+
+  return scm_from_int (m.getCode ());
+}
+
+SCM
+ScriptCommands::Whois (SCM nick)
+{
+  VERIFY_STRING (nick);
+
+  Message m = Commands::Whois (Interp::bot, Utils::scm2str (nick));
+
+  return scm_from_int (m.getCode ());
 }
 
 SCM
@@ -477,9 +574,9 @@ ScriptCommands::getServer(void)
   ::Server *serv = Interp::bot->serverList->currentServer();
   int serverNumber = Interp::bot->serverList->currentNumber;
 
-  return gh_list(scm_long2num(serverNumber),
+  return scm_list_n(scm_from_int(serverNumber),
                  Utils::str2scm(serv->getHostName()),
-                 scm_long2num(serv->getPort()),
+                 scm_from_int(serv->getPort()),
                  Utils::str2scm(serv->getPassword()),
                  SCM_UNDEFINED);
 }
@@ -487,20 +584,23 @@ ScriptCommands::getServer(void)
 SCM
 ScriptCommands::getServerList(void)
 {
-  SCM res = gh_list(SCM_UNDEFINED);
+  SCM res = scm_list_n(SCM_UNDEFINED);
   ::Server *s;
   int i = 0;
-  std::vector<class Server *>::iterator it = Interp::bot->serverList->begin();
+  std::vector<class Server *>::iterator it = 
+    Interp::bot->serverList->begin();
 
   for ( ; it != Interp::bot->serverList->end(); ++it) {
     s = (*it);
-    res = gh_append2(res,
-                     gh_list(gh_list(scm_long2num(i++),
-                                     Utils::str2scm(s->getHostName()),
-                                     scm_long2num(s->getPort()),
-                                     Utils::str2scm(s->getPassword()),
-                                     SCM_UNDEFINED), SCM_UNDEFINED));
-  }
+    res = 
+      scm_append 
+      (scm_list_2 (res,
+                  scm_list_n(scm_list_n(scm_from_int(i++),
+                                        Utils::str2scm(s->getHostName()),
+                                        scm_from_int(s->getPort()),
+                                        Utils::str2scm(s->getPassword()),
+                                        SCM_UNDEFINED), SCM_UNDEFINED)));
+       }
   return res;
 }
 
@@ -526,8 +626,8 @@ ScriptCommands::random(SCM scm_max)
   int max = 0;
   //srand(time(NULL));
   if (SCM_NUMBERP(scm_max))
-    max = gh_scm2int(scm_max);
-  return scm_long2num(max ? rand() % max : 0);
+    max = scm_to_int(scm_max);
+  return scm_from_int(max ? rand() % max : 0);
 }
 
 SCM
@@ -536,7 +636,7 @@ ScriptCommands::addCommand(SCM scm_commandName, SCM scm_function,
                            SCM scm_minLevel)
 {
   // We check that commandName is a string
-  if (!SCM_STRINGP(scm_commandName))
+  if (!scm_is_string(scm_commandName))
     return SCM_BOOL_F;
 
   // We check that the command does not exist
@@ -545,28 +645,28 @@ ScriptCommands::addCommand(SCM scm_commandName, SCM scm_function,
     return SCM_BOOL_F;
 
   // Next we check that needsChannel is a boolean
-  if (!gh_boolean_p(scm_needsChannel))
+  if (!scm_is_bool (scm_needsChannel))
     return SCM_BOOL_F;
-  bool needsChannel = gh_scm2bool(scm_needsChannel);
+  bool needsChannel = scm_to_bool(scm_needsChannel);
 
   // We check that minLevel is an integer and that it's
   // a valid level
   if (!SCM_NUMBERP(scm_minLevel))
     return SCM_BOOL_F;
 
-  int minLevel = gh_scm2long(scm_minLevel);
+  int minLevel = scm_to_int(scm_minLevel);
   if (minLevel < User::NONE || minLevel > User::MASTER)
     return SCM_BOOL_F;
 
   // We check that "scm_function" is a Scheme procedure
-  if (!gh_procedure_p(scm_function))
+  if (!scm_is_true (scm_procedure_p(scm_function)))
     return SCM_BOOL_F;
 
   // We check that args is an integer and is between 0 and 20 (arbitrary limit)
   if (!SCM_NUMBERP(scm_args))
     return SCM_BOOL_F;
 
-  int args = gh_scm2long(scm_args);
+  int args = scm_to_int(scm_args);
   if (args < 0 || args > 20)
     return SCM_BOOL_F;
 
@@ -581,7 +681,7 @@ SCM
 ScriptCommands::delCommand(SCM scm_commandName)
 {
   // We check that commandName is a string
-  if (!SCM_STRINGP(scm_commandName))
+  if (!scm_is_string(scm_commandName))
     return SCM_BOOL_F;
 
   // We check that the command does exist
@@ -604,12 +704,12 @@ ScriptCommands::AddHook(SCM type, SCM regex, SCM function, SCM pri, SCM fall,
   String rname = "DEFAULT";
 
   if (!SCM_UNBNDP (pri))
-    priority = scm_num2int (pri, SCM_ARG1, "ScriptCommands::AddHook");
+    priority = scm_to_int (pri);
   if (!SCM_UNBNDP (fall))
-    fallt = SCM_NFALSEP (fall);
+    fallt = scm_is_true (fall);
   if (!SCM_UNBNDP (name))
     rname = Utils::scm2str (name);
-  return SCM_BOOL (Interp::bot->botInterp->AddHook(gh_scm2long(type),
+  return scm_from_bool (Interp::bot->botInterp->AddHook(scm_to_int(type),
                                                   regex, function,
                                                   priority, fallt, rname));
 }
@@ -617,68 +717,27 @@ ScriptCommands::AddHook(SCM type, SCM regex, SCM function, SCM pri, SCM fall,
 SCM
 ScriptCommands::AddTimer(SCM when, SCM function)
 {
-  return Interp::bot->botInterp->AddTimer(gh_scm2long(when), function);
+  return Interp::bot->botInterp->AddTimer(scm_to_int(when), function);
 }
 
 SCM
 ScriptCommands::DelTimer(SCM timer)
 {
-  return SCM_BOOL (Interp::bot->botInterp->DelTimer(timer));
+  return scm_from_bool (Interp::bot->botInterp->DelTimer(timer));
 }
 
 SCM
 ScriptCommands::sendDCCChatMessage (SCM to, SCM message)
 {
 
-  return SCM_BOOL (Interp::bot->dccConnections->sendMessage 
+  return scm_from_bool (Interp::bot->dccConnections->sendMessage 
                   (Utils::scm2str (to),
                    Utils::scm2str (message)));
 }
 
-// Message sending
-// FIXME: write these
-
-#define IQUEUE Interp::bot->serverConnection->queue
-
-SCM
-ScriptCommands::sendCTCP(SCM to, SCM command , SCM message)
-{
-  VERIFY_STRING(to);
-  VERIFY_STRING(command);
-  VERIFY_STRING(message);
-
-  Commands::CTCP (Interp::bot, Utils::scm2str (to), 
-                     Utils::scm2str (command),
-                     Utils::scm2str (message));
-
-  return SCM_UNSPECIFIED;
-}
-
-SCM
-ScriptCommands::sendCTCPReply (SCM to, SCM command , SCM message)
-{
-  VERIFY_STRING(to);
-  VERIFY_STRING(command);
-  VERIFY_STRING(message);
 
-  Commands::CTCPReply (Interp::bot, Utils::scm2str (to), 
-                      Utils::scm2str (command),
-                      Utils::scm2str (message));
 
-  return SCM_UNSPECIFIED;
-}
 
 
-SCM
-ScriptCommands::sendNotice (SCM to, SCM message)
-{
-  VERIFY_STRING (to);
-  VERIFY_STRING (message);
 
-  return (scm_long2num 
-         (Commands::Notice (Interp::bot, 
-                            Utils::scm2str (to),
-                            Utils::scm2str (message)).getCode ()));
-  
-}
 #endif