X-Git-Url: http://git.hcoop.net/clinton/bobotpp.git/blobdiff_plain/4edefeb6d696ccc7291ab9ae8bf5996907510d7b..606a8eec6da5209b70126e502f9a61b2e5fe2211:/source/Interp.C diff --git a/source/Interp.C b/source/Interp.C index 2940561..40886ae 100644 --- a/source/Interp.C +++ b/source/Interp.C @@ -14,7 +14,7 @@ // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #ifdef HAVE_CONFIG_H #include "config.h" @@ -32,6 +32,7 @@ // static class member initial definitions Bot * Interp::bot = 0; SCM Interp::bot_module = 0; + #ifdef MULTITHREAD pthread_mutex_t Interp::mutex = PTHREAD_MUTEX_INITIALIZER; #endif @@ -73,6 +74,17 @@ interp_init_helper (void* unused) scm_c_define ("bot:user-trusted", scm_long2num (User::TRUSTED_USER)); scm_c_define ("bot:user-friend", scm_long2num (User::FRIEND)); scm_c_define ("bot:user-master", scm_long2num (User::MASTER)); + + // protection + scm_c_define ("bot:protection/none", scm_long2num (User::NO_PROT)); + scm_c_define ("bot:protection/no-ban", scm_long2num (User::NO_BAN)); + scm_c_define ("bot:protection/no-kick", scm_long2num (User::NO_KICK)); + scm_c_define ("bot:protection/no-deop", scm_long2num (User::NO_DEOP)); + + // auto-op + scm_c_define ("bot:aop/yes", scm_long2num (true)); + scm_c_define ("bot:aop/no", scm_long2num (false)); + // sys-dir scm_c_define ("bot:sys-scripts-dir", scm_makfrom0str (String(PREFIX) + @@ -118,7 +130,8 @@ interp_init_helper (void* unused) scm_c_define_gsubr ("bot:addshit", 3, 2, 0, (SCMFunc)ScriptCommands::AddShit); bot_new_procedure ("bot:ban", (SCMFunc)ScriptCommands::Action, 2, 0, 0); - bot_new_procedure ("bot:change-command-level", (SCMFunc)ScriptCommands::ChangeCommandLevel, + bot_new_procedure ("bot:change-command-level", + (SCMFunc)ScriptCommands::ChangeCommandLevel, 2, 0, 0); bot_new_procedure ("bot:cycle", (SCMFunc)ScriptCommands::Action, 1, 0, 0); bot_new_procedure ("bot:deban", (SCMFunc)ScriptCommands::Deban, 2, 0, 0); @@ -141,6 +154,10 @@ interp_init_helper (void* unused) bot_new_procedure ("bot:nextserver", (SCMFunc)ScriptCommands::NextServer, 0, 0, 0); bot_new_procedure ("bot:nick", (SCMFunc)ScriptCommands::Nick, 1, 0, 0); + + scm_c_define_gsubr ("bot:notice", 2, 0, 0, + (SCMFunc)ScriptCommands::sendNotice); + bot_new_procedure ("bot:op", (SCMFunc)ScriptCommands::Op, 2, 0, 0); bot_new_procedure ("bot:part", (SCMFunc)ScriptCommands::Part, 1, 0, 0); bot_new_procedure ("bot:reconnect", (SCMFunc)ScriptCommands::Reconnect, @@ -198,18 +215,20 @@ interp_post_startup_helper (void *bot_module) SCM module = static_cast (bot_module); scm_c_define ("the-bot-module", module); scm_c_export ("the-bot-module", 0); + // load bobot-utils scm_primitive_load (scm_makfrom0str (String(PREFIX) + "/share/bobotpp/scripts/bobot-utils.scm")); - return 0; + return SCM_UNSPECIFIED; } void Interp::Startup() { bot_module = scm_c_define_module ("the-bot-module", - interp_init_helper, 0); + interp_init_helper, 0); + scm_c_call_with_current_module (bot_module, interp_post_startup_helper, bot_module); @@ -228,8 +247,10 @@ Interp::Execute(Bot *b, String command) // We get the lock pthread_mutex_lock(&mutex); #endif + bot = b; - gh_eval_str_with_catch(command, ErrorHandler); + gh_eval_str_with_catch (command, ErrorHandler); + #ifdef MULTITHREAD // We release the lock pthread_mutex_unlock(&mutex);