From 0b7a49e2b886552fe45523069f33fb82f3086f42 Mon Sep 17 00:00:00 2001 From: unknown_lamer Date: Sun, 18 Aug 2002 21:32:49 +0000 Subject: [PATCH] [project @ 2002-08-18 21:32:48 by unknown_lamer] You can now talk to the bot using bot:dcc-chat-send --- ChangeLog | 9 +++++++++ NEWS | 9 +++++++-- acinclude.m4 | 2 +- bobot++.info | 37 ++++++++++++++++++++++++++++--------- bobot++.texinfo | 34 +++++++++++++++++++++++++++++++++- source/Interp.C | 3 +++ source/ScriptCommands.C | 10 ++++++++++ source/ScriptCommands.H | 3 +++ 8 files changed, 94 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index e78405d..b032c2e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2002-08-18 Clinton Ebadi + + * bobot++.texinfo (Hook Types): Fixed a typo (I wrote + user!nick@host instead of the correct nick!user@host). + + * source/Interp.C (Startup): Register bot:DCC-chat-send + + * source/ScriptCommands.C (sendDCCChatMessage): Added method again + 2002-08-08 Clinton Ebadi * source/String.C (String): The std::string copy constructor now diff --git a/NEWS b/NEWS index 8743d91..0ddbeb3 100644 --- a/NEWS +++ b/NEWS @@ -17,8 +17,13 @@ Version 2.1.1: foom name for your hooks. - Logging now works again (oops, I didn't realize I broke it until I started to work on DCC). -- DCC CHAT now "works." You can connect to the bot and talk to to it, - but it doesn't do anything useful. +- DCC CHAT now "works." You can connect to the bot and talk to to it + and use Scheme hooks to talk to the user. +- New hooks: hooks/dcc/chat-begin and hooks/dcc/chat-message. These + are called when a new DCC Chat begin and when the user sends a + message. +- New Function: bot:dcc-chat-send TO MESSAGE, sends a MESSAGE to the + person at address TO - New hooks: hooks/send/... where ... is one of action, ctcp, public, or message. These are triggered when the bot does an ACTION, sends a CTCP (_not_ a ctcp-reply), sends a PRIVMSG to a diff --git a/acinclude.m4 b/acinclude.m4 index d95ef2e..8b52437 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1,4 +1,4 @@ -pr# +# # Copyright (c) 1998 Etienne Bernard # Copyright (c) 2002 Clinton Ebadi # diff --git a/bobot++.info b/bobot++.info index a9712c3..114707e 100644 --- a/bobot++.info +++ b/bobot++.info @@ -244,7 +244,7 @@ general format of a hook is: - FROM, TO, ACTION - FROM: this is the address of the person that performed - the action in the form `USER ! NICK @ HOST' (without the + the action in the form `NICK ! USER @ HOST' (without the spaces). - TO: This is the target of the action, which is either a @@ -362,6 +362,23 @@ general format of a hook is: - # of args - `arg1': desc + * `hooks/dcc/begin' + - This hook is triggered when a user begins a DCC CHAT with the + bot. + + - FROM + - FROM: This is the user's address in the form + `nick!user@host'. + + * `hooks/dcc/message' + - This hook is triggered when a user sends a message to the bot + through a DCC CHAT + + - FROM MESSAGE + - FROM: This is the user's address in the form + `nick!user@host'. + + - MESSAGE: This is the message the user sent to the bot.  File: bobot++.info, Node: Scheme User Levels, Next: Sending Messages, Prev: Hooks, Up: Scripting @@ -476,6 +493,8 @@ Variable Index * hooks/action: Hook Types. * hooks/ctcp: Hook Types. * hooks/ctcp-reply: Hook Types. +* hooks/dcc/begin: Hook Types. +* hooks/dcc/message: Hook Types. * hooks/disconnect: Hook Types. * hooks/flood: Hook Types. * hooks/invite: Hook Types. @@ -513,13 +532,13 @@ Node: Adding New Commands4585 Node: Hooks5852 Node: Creating a Hook6826 Node: Hook Types7965 -Node: Scheme User Levels10905 -Node: Sending Messages12034 -Node: High Level Message Functions12631 -Node: Low Level Message Functions12845 -Node: Misc Scripting Stuff13598 -Node: Concept Index14017 -Node: Function Index14199 -Node: Variable Index14460 +Node: Scheme User Levels11439 +Node: Sending Messages12568 +Node: High Level Message Functions13165 +Node: Low Level Message Functions13379 +Node: Misc Scripting Stuff14132 +Node: Concept Index14551 +Node: Function Index14733 +Node: Variable Index14994  End Tag Table diff --git a/bobot++.texinfo b/bobot++.texinfo index 1dae231..b37b725 100644 --- a/bobot++.texinfo +++ b/bobot++.texinfo @@ -269,7 +269,7 @@ This hook is triggered when someone performs an action. @itemize @minus @item @var{from}: this is the address of the person that performed the -action in the form @samp{@var{user} ! @var{nick} @@ @var{host}} +action in the form @samp{@var{nick} ! @var{user} @@ @var{host}} (without the spaces). @item @var{to}: This is the target of the action, which is either a channel @@ -533,6 +533,38 @@ Description of the hook @end itemize @end itemize +@item +@vindex hooks/dcc/begin +@code{hooks/dcc/begin} +@itemize @minus +@item +This hook is triggered when a user begins a DCC CHAT with the bot. +@item +@var{FROM} +@itemize @minus +@item +@var{FROM}: This is the user's address in the form +@samp{nick!user@@host}. +@end itemize +@end itemize + +@item +@vindex hooks/dcc/message +@code{hooks/dcc/message} +@itemize @minus +@item +This hook is triggered when a user sends a message to the bot through +a DCC CHAT +@item +@var{FROM} @var{MESSAGE} +@itemize @minus +@item +@var{FROM}: This is the user's address in the form +@samp{nick!user@@host}. +@item +@var{MESSAGE}: This is the message the user sent to the bot. +@end itemize +@end itemize @end itemize diff --git a/source/Interp.C b/source/Interp.C index 1e542af..c1514a6 100644 --- a/source/Interp.C +++ b/source/Interp.C @@ -161,6 +161,9 @@ Interp::Startup() bot_new_procedure ("bot:deltimer", (SCMFunc)ScriptCommands::DelTimer, 1, 0, 0); + scm_c_define_gsubr ("bot:DCC-chat-send", 2, 0, 0, + (SCMFunc)ScriptCommands::sendDCCChatMessage); + // "Low Level" Message functuions scm_c_define_gsubr ("bot:send-CTCP", 3, 0, 0, (SCMFunc)ScriptCommands::sendCTCP); diff --git a/source/ScriptCommands.C b/source/ScriptCommands.C index 266c969..be4053c 100644 --- a/source/ScriptCommands.C +++ b/source/ScriptCommands.C @@ -29,6 +29,7 @@ #include "ScriptCommands.H" #include "Interp.H" #include "DCCPerson.H" +#include "DCCManager.H" #include #define VERIFY_STRING(par) if (!SCM_STRINGP((par))) \ @@ -586,6 +587,15 @@ ScriptCommands::DelTimer(SCM timer) return SCM_BOOL (Interp::bot->botInterp->DelTimer(timer)); } +SCM +ScriptCommands::sendDCCChatMessage (SCM to, SCM message) +{ + + return SCM_BOOL (Interp::bot->dccConnections->sendMessage + (Utils::scm2String (to), + Utils::scm2String (message))); +} + // Message sending // FIXME: write these diff --git a/source/ScriptCommands.H b/source/ScriptCommands.H index d192182..afd7799 100644 --- a/source/ScriptCommands.H +++ b/source/ScriptCommands.H @@ -78,6 +78,9 @@ public: static SCM AddTimer(SCM, SCM); static SCM DelTimer(SCM); + // DCC CHAT + static SCM sendDCCChatMessage (SCM, SCM); + // Message sending static SCM sendCTCP(SCM, SCM, SCM); /* -- 2.20.1