+2005-06-28 Clinton Ebadi <clinton@unknownlamer.org>
+
+ * bobot++.texinfo (Low Level Message Functions): Documented
+ bot:send-ctcp-reply
+
+ * source/Parser.C (parseCTCP): Converted to use Commands::CTCPReply
+
+ * source/Interp.C (interp_init_helper): Bound bot:send-ctcp-reply
+ in scheme
+
+ * bobot++.texinfo (Low Level Message Functions):
+ s/bot:send-CTCP/bot:send-ctcp/
+
+ * source/Interp.C (interp_init_helper): Renamed bot:send-CTCP to
+ bot:send-ctcp
+
+ * source/ScriptCommands.H: Uncommended sendCTCPReply prototype
+
+ * source/ScriptCommands.C (sendCTCP): Convert to use Commands::CTCP
+ (sendCTCPReply): Added
+
+ * source/Parser.C (parseJoin): Convert to use Commands::CTCP
+
+ * source/Commands.C (CTCP): Implemented
+ (CTCPReply): Implemented
+ (Action): Convert to use Commands::CTCP
+
+ * source/Commands.H: Added CTCP (bot, target, command, message)
+ Added CTCPReply (bot, target, command, message)
+
2005-06-27 Clinton Ebadi <clinton@unknownlamer.org>
* examples/bot.conf (maxnicklength): Update example config
to the bobot++ functions
* bot:msg and bot:say may both send to channels and users (instead
of bot:msg for users and bot:say for channels)
+ * Renamed bot:send-CTCP to bot:send-ctcp
+ * Added bot:send-ctcp-reply to send a ctcp-reply
+ Debugging
* The debugging evaluator is now enabled when --debug is passed to the bot
- Documentation
(IRC Client Protocol) and CTCP spec. These functions all return
`*unspecified*' always, so don't use the return value for anything.
- -- Function: bot:send-CTCP to command message
+ -- Function: bot:send-ctcp to command message
`to' is the target of your CTCP message, `command' is the CTCP
command, and `message' is the message (or arguments) of the
command. Make sure to `bot:ctcp-quote' the message!
(line 123)
* bot:say: High Level Message Functions.
(line 7)
-* bot:send-CTCP: Low Level Message Functions.
+* bot:send-ctcp: Low Level Message Functions.
(line 13)
* bot:sent-to-me?: Misc Scripting Stuff.
(line 198)
@code{*unspecified*} always, so don't use the return value for
anything.
-@defun bot:send-CTCP to command message
+@defun bot:send-ctcp to command message
@code{to} is the target of your CTCP message, @code{command} is the
CTCP command, and @code{message} is the message (or arguments) of the
command. Make sure to @code{bot:ctcp-quote} the message!
@end defun
+@defun bot:send-ctcp-reply to command message
+@code{to} is the target of your CTCP reply, @code{command} is the
+CTCP command, and @code{message} is the message (or arguments) of the
+command. Make sure to @code{bot:ctcp-quote} the message!
+
+This is used to reply to a ctcp that the bot has received.
+@end defun
+
@node Misc Scripting Stuff, , Sending Messages, Scripting
@section Misc. Scripting Stuff
if (message.length() == 0)
return InvalidParameters;
- QUEUE->sendCTCP (channel, "ACTION", message);
+ Commands::CTCP (bot, channel, "ACTION", message);
return Ok;
}
return Ok;
}
+Message
+Commands::CTCP (Bot *bot, std::string target, std::string command,
+ std::string message)
+{
+ CHECK_CONNECTION;
+
+ if (target == "")
+ {
+ return EmptyAddressee;
+ }
+
+ if (command == "")
+ {
+ return InvalidParameters;
+ }
+
+ if (message == "")
+ {
+ return EmptyMessage;
+ }
+
+ if (Utils::channel_p (target) && !CHANNEL (target))
+ {
+ return NotOnChannel (target);
+ }
+
+
+ // Send multi-line messages as seperate privmsgs
+ StringTokenizer st_message (message);
+
+ while (st_message.more_tokens_p ('\n'))
+ {
+ QUEUE->sendCTCP (target, command, st_message.next_token ('\n'));
+ }
+
+ return Ok;
+}
+
+Message
+Commands::CTCPReply (Bot *bot, std::string target, std::string command,
+ std::string message)
+{
+ CHECK_CONNECTION;
+
+ if (target == "")
+ {
+ return EmptyAddressee;
+ }
+
+ if (command == "")
+ {
+ return InvalidParameters;
+ }
+
+ if (message == "")
+ {
+ return EmptyMessage;
+ }
+
+ // CTCP-REPLY cannot go to a channel
+ if (Utils::channel_p (target))
+ {
+ return NotToChannel;
+ }
+
+
+ // Send multi-line messages as seperate privmsgs
+ StringTokenizer st_message (message);
+
+ while (st_message.more_tokens_p ('\n'))
+ {
+ QUEUE->sendCTCPReply (target, command, st_message.next_token ('\n'));
+ }
+
+ return Ok;
+}
+
+
Message
Commands::Cycle(Bot *bot, String channel)
{
static Message AddServer(Bot *, String, String);
static Message Ban(Bot *, String, String);
static Message ChangeLevel(Bot *, String, String, int);
+ static Message CTCP (Bot*, std::string, std::string, std::string);
+ static Message CTCPReply (Bot*, std::string, std::string, std::string);
static Message Cycle(Bot *, String);
static Message Deban(Bot *, String, String);
static Message DelServer(Bot *, int);
(SCMFunc)ScriptCommands::sendDCCChatMessage);
// "Low Level" Message functuions
- scm_c_define_gsubr ("bot:send-CTCP", 3, 0, 0,
+ scm_c_define_gsubr ("bot:send-ctcp", 3, 0, 0,
(SCMFunc)ScriptCommands::sendCTCP);
+ scm_c_define_gsubr ("bot:send-ctcp-reply", 3, 0, 0,
+ (SCMFunc)ScriptCommands::sendCTCPReply);
}
#undef bot_new_procedure
#define AlreadyInShitlist(m, mc) (Message(-22, (m) + " is already in shitlist on channel(s) " + (mc)))
#define EmptyMessage (Message(-23, "Can not send an empty message"))
#define EmptyAddressee (Message(-24, "Can not send to nobody"))
-#define NotToChannel (Message(-25, "Can not send to a channel. Use \"say\" instead."))
+#define NotToChannel (Message(-25, "Can not send to a channel."))
#define NotConnected (Message(-26, "Not connected."))
#endif
{
// This is a part of the antispoof code
ch->getUser (n)->userkey = Utils::get_key ();
- cnx->queue->sendCTCP (n, "PING",
- ch->getUser (n)->userkey + " " + c);
+ Commands::CTCP (cnx->bot, n, "PING",
+ ch->getUser (n)->userkey + " " + c);
}
}
SCM_UNDEFINED));
#endif
if (command == "PING")
- cnx->queue->sendCTCPReply (nick, "PING", rest);
+ {
+ Commands::CTCPReply (cnx->bot, nick, "PING", rest);
+ }
else if (command == "VERSION")
{
- cnx->queue->sendCTCPReply (nick, "VERSION", cnx->bot->versionString);
+ Commands::CTCPReply (cnx->bot, nick, "VERSION",
+ cnx->bot->versionString);
}
else if (command == "CLOCK")
{
time_t diff = time (NULL) - cnx->bot->startTime;
- cnx->queue->sendCTCPReply (nick, "CLOCK",
- String ("elapsed time: ") +
- String ((long) (diff / 86400)) +
- "d" +
- String ((long) (diff % 86400) /
- 3600) + "h" +
- String ((long) (diff % 3600) / 60) +
- "m" + String ((long) (diff % 60)) + "s");
+ Commands::CTCPReply (cnx->bot, nick, "CLOCK",
+ String ("elapsed time: ") +
+ String ((long) (diff / 86400)) +
+ "d" +
+ String ((long) (diff % 86400) /
+ 3600) + "h" +
+ String ((long) (diff % 3600) / 60) +
+ "m" + String ((long) (diff % 60)) + "s");
}
else if (command == "COMMAND")
- cnx->queue->sendCTCPReply (nick,
- "COMMAND", String (cnx->bot->commandChar));
+ {
+ Commands::CTCPReply (cnx->bot, nick,
+ "COMMAND", String (cnx->bot->commandChar));
+ }
else if (command == "LAG")
- cnx->queue->sendCTCPReply (nick, "LAG",
- String ((long) cnx->lag) + " second(s)");
+ {
+ Commands::CTCPReply (cnx->bot, nick, "LAG",
+ String ((long) cnx->lag) + " second(s)");
+ }
else if (command == "DCC")
{
StringTokenizer st2 (rest);
VERIFY_STRING(command);
VERIFY_STRING(message);
- IQUEUE->sendCTCP (Utils::scm2str (to), Utils::scm2str (command),
- Utils::scm2str (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)
{
static SCM sendDCCChatMessage (SCM, SCM);
// Message sending
- static SCM sendCTCP(SCM, SCM, SCM);
+ static SCM sendCTCP(SCM, SCM, SCM);
+ static SCM sendCTCPReply(SCM, SCM, SCM);
/*
- SCM sendCTCPReply(SCM, SCM, SCM);
SCM sendChannelMode(SCM);
SCM sendChannelMode(SCM, SCM, SCM);
SCM sendInvite(SCM, SCM);