2005-06-23 Clinton Ebadi <clinton@unknownlamer.org>
+ * source/Commands.C (Notice): Commented out check/abort if target
+ is a channel (there doesn't seem to be a reason for this to not work)
+
+ * source/Interp.C (interp_init_helper): Register bot:notice with scheme
+
+ * bobot++.texinfo (High Level Message Functions): Document bot:notice
+
+ * source/Message.H: Added operator== to Message (tests for error
+ code equality)
+
+ * source/Commands.C: Removed message type macros
+
+ * source/Message.H: Moved message type macros to Message.H
+
+ * source/ScriptCommands.C (sendNotice): Implemented sendNotice
+
+ * source/ScriptCommands.H: Uncomment sendNotice
+
* source/Bot.C (waitForInput): Use %02d when formatting
Hooks::TIMER argument instead of %2d, and switch to snprintf to
enforce max length
=====================================================================
Version 2.1.8:
-- Added bot:protection/[none|ban|kick|deop] and bot:aop/[yes|no]
- constants to the Scheme scripting interface
+- Scripting
+ + Hooks
+ * Added bot:protection/[none|ban|kick|deop] and bot:aop/[yes|no]
+ constants to the Scheme scripting interface
+ * hooks/timer argument is now zero padded instead of space padded
+ (e.g. "11:01" instead of "11: 1")
+ * hooks/disconnect is now called when the bot is disconnected from the
+ server unintentionally (network connection timeout, server died,
+ etc.)
+ + Message Sending
+ * Implemented bot:notice
+
Version 2.1.7:
- Fixed a number of small bugs and corner cases
The same as if a user typed `/msg nick message' to their IRC
client.
+ -- Function: bot:notice target message
+ Sends MESSAGE as a NOTICE to TARGET. TARGET may be a user (nick)
+ or a channel. This returns `#t' if the message was sent
+ successfull, `#f' otherwise.
+
\1f
File: bobot++.info, Node: Low Level Message Functions, Prev: High Level Message Functions, Up: Sending Messages
(line 111)
* bot:nick: Misc Scripting Stuff.
(line 114)
+* bot:notice: High Level Message Functions.
+ (line 20)
* bot:op: Misc Scripting Stuff.
(line 117)
* bot:part: Misc Scripting Stuff.
Node: Scheme User Levels\7f25525
Node: Sending Messages\7f26659
Node: High Level Message Functions\7f27275
-Node: Low Level Message Functions\7f27898
-Node: Misc Scripting Stuff\7f28666
-Node: Concept Index\7f35242
-Node: Function Index\7f35461
-Node: Variable Index\7f45305
+Node: Low Level Message Functions\7f28104
+Node: Misc Scripting Stuff\7f28872
+Node: Concept Index\7f35448
+Node: Function Index\7f35667
+Node: Variable Index\7f45655
\1f
End Tag Table
The same as if a user typed @code{/msg nick message} to their IRC client.
@end defun
+@defun bot:notice target message
+Sends @var{message} as a NOTICE to @var{target}. @var{target} may be a
+user (nick) or a channel. This returns @code{#t} if the message was
+sent successfull, @code{#f} otherwise.
+@end defun
+
@node Low Level Message Functions, , High Level Message Functions, Sending Messages
@subsection ``Low Level'' Message Functions
#include "Commands.H"
#include "Utils.H"
-#define Ok (Message(0, ""))
-#define NotOnChannel(c) (Message(-1, String("I am not on channel ") + (c)))
-#define NotChannelOp(c) (Message(-2, String("I am not channel op on ") + (c)))
-#define UserNotFound(w, c) (Message(-3, (w) + " is not on channel " + (c)))
-#define UserNotOp(w, c) (Message(-4, (w) + " is not channel op on " + (c)))
-#define UserProtected(w, c) (Message(-5, (w) + " is protected on " + (c)))
-#define InvalidNick(n) (Message(-6, (n) + " is not a valid nickname"))
-#define InvalidChannel(c) (Message(-7, (c) + " is not a valid channel name"))
-#define MassOpNotAllowed (Message(-8, "Mass op is not allowed."))
-#define UserOnShitList(w) (Message(-9, String("User ") + w + " is on my shitlist"))
-#define CanNotChangeTopic(c) (Message(-10, String("I can not change topic on ") + (c)))
-#define TopicLocked(c) (Message(-11, String("Topic is locked on ") + (c)))
-#define InvalidPort(p) (Message(-12, String((long)(p)) + " is an invalid port number"))
-#define InvalidTime(t) (Message(-13, String((long)(t)) + " is an invalid time"))
-#define CanNotChangeServer (Message(-14, "I cannot change server without loosing op on one of my channels"))
-#define EmptyServerList (Message(-15, "Server list is empty"))
-#define InvalidServerNumber(n) (Message(-16, String((long)(n)) + " is an invalid server number"))
-#define InvalidParameters (Message(-17, "Invalid parameters"))
-#define NotFound(w) (Message(-18, String("I can not find ") + (w)));
-#define NotInUserlist(w) (Message(-19, (w) + " is not in my userlist"))
-#define NotInShitlist(w) (Message(-20, (w) + " is not in my shitlist"))
-#define AlreadyInUserlist(m, mc) (Message(-21, (m) + " is already in userlist on channel(s) " + (mc)))
-#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 NotConnected (Message(-26, "Not connected."))
#define CHECK_CONNECTION if (!bot->serverConnection) return NotConnected
if (who == "")
return EmptyAddressee;
- if (Utils::channel_p(who))
- return NotToChannel;
+ // if (Utils::channel_p(who))
+ // return NotToChannel;
if (message == "")
return EmptyMessage;
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,
Message(int c, String d) : code(c), description(d) { }
int getCode() const { return code; }
String getMessage() const { return description; }
+
+ bool operator== (Message m) { return getCode () == m.getCode (); }
};
+#define Ok (Message(0, ""))
+#define NotOnChannel(c) (Message(-1, String("I am not on channel ") + (c)))
+#define NotChannelOp(c) (Message(-2, String("I am not channel op on ") + (c)))
+#define UserNotFound(w, c) (Message(-3, (w) + " is not on channel " + (c)))
+#define UserNotOp(w, c) (Message(-4, (w) + " is not channel op on " + (c)))
+#define UserProtected(w, c) (Message(-5, (w) + " is protected on " + (c)))
+#define InvalidNick(n) (Message(-6, (n) + " is not a valid nickname"))
+#define InvalidChannel(c) (Message(-7, (c) + " is not a valid channel name"))
+#define MassOpNotAllowed (Message(-8, "Mass op is not allowed."))
+#define UserOnShitList(w) (Message(-9, String("User ") + w + " is on my shitlist"))
+#define CanNotChangeTopic(c) (Message(-10, String("I can not change topic on ") + (c)))
+#define TopicLocked(c) (Message(-11, String("Topic is locked on ") + (c)))
+#define InvalidPort(p) (Message(-12, String((long)(p)) + " is an invalid port number"))
+#define InvalidTime(t) (Message(-13, String((long)(t)) + " is an invalid time"))
+#define CanNotChangeServer (Message(-14, "I cannot change server without loosing op on one of my channels"))
+#define EmptyServerList (Message(-15, "Server list is empty"))
+#define InvalidServerNumber(n) (Message(-16, String((long)(n)) + " is an invalid server number"))
+#define InvalidParameters (Message(-17, "Invalid parameters"))
+#define NotFound(w) (Message(-18, String("I can not find ") + (w)));
+#define NotInUserlist(w) (Message(-19, (w) + " is not in my userlist"))
+#define NotInShitlist(w) (Message(-20, (w) + " is not in my shitlist"))
+#define AlreadyInUserlist(m, mc) (Message(-21, (m) + " is already in userlist on channel(s) " + (mc)))
+#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 NotConnected (Message(-26, "Not connected."))
+
#endif
#include "DCCPerson.H"
#include "DCCManager.H"
#include "Parser.H"
+#include "Commands.H"
+#include "Message.H"
#include <libguile.h>
#define VERIFY_STRING(par) if (!SCM_STRINGP((par))) \
Utils::scm2str (message));
return SCM_UNSPECIFIED;
}
+
+SCM
+ScriptCommands::sendNotice (SCM to, SCM message)
+{
+ VERIFY_STRING (to);
+ VERIFY_STRING (message);
+
+ if (Commands::Notice (Interp::bot,
+ Utils::scm2str (to),
+ Utils::scm2str (message))
+ == Ok)
+ {
+ return SCM_BOOL_T;
+ }
+ else
+ {
+ return SCM_BOOL_F;
+ }
+}
#endif
SCM sendJoin(SCM, SCM);
SCM sendKick(SCM, SCM, SCM);
SCM sendNick(SCM);
- SCM sendNotice(SCM, SCM);
+ */
+ static SCM sendNotice(SCM, SCM);
+ /*
SCM sendPart(SCM);
SCM sendPass(SCM);
SCM sendPing(SCM);