pidgin: 8a1c165f: /ctcp command for IRC

elb at pidgin.im elb at pidgin.im
Mon Jul 21 16:40:50 EDT 2008


-----------------------------------------------------------------
Revision: 8a1c165f0ab459826e0911c2dbdc1f20f47c7815
Ancestor: 9932219978c2a9b1f5c6ebadd9986b0f30e4c8af
Author: neosisani at gmail.com
Date: 2008-07-21T20:33:29
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/8a1c165f0ab459826e0911c2dbdc1f20f47c7815

Modified files:
        COPYRIGHT ChangeLog libpurple/protocols/irc/cmds.c
        libpurple/protocols/irc/irc.h
        libpurple/protocols/irc/parse.c

ChangeLog: 

/ctcp command for IRC

-------------- next part --------------
============================================================
--- COPYRIGHT	70fc3e1c1bd26b4f2a8d0123b2e769619c83dee4
+++ COPYRIGHT	f1dc7439fadc0ffb211137c165b72cc4bb7ae805
@@ -157,6 +157,7 @@ David Grohmann
 Konrad Gräfe
 Miah Gregory
 David Grohmann
+Vladislav Guberinić
 Gideon N. Guillen
 Christian Hammond
 Erick Hamness
============================================================
--- ChangeLog	d5474df1882a1143bf334995a57937068532f10b
+++ ChangeLog	dc61c0d07ba9d758b05c31428028d0a6fb6c6afa
@@ -10,6 +10,9 @@ version 2.5.0 (??/??/2008):
 	  we don't install our SSL CA certs, so it's important that the
 	  libpurple package depend on the CA certificates.
 
+	IRC:
+	* /ctcp command (Vladislav Guberinić)
+
 	MSN:
 	* Update MSN support to protocol 15 (Elliott Sales de Andrade, Jorge
 	  Villaseñor, Mike Ruprecht, Carlos Silva, Ma Yuan, Daniel Ljungborg
============================================================
--- libpurple/protocols/irc/cmds.c	5a474ed951b98282d4d7564fc984cba00c852681
+++ libpurple/protocols/irc/cmds.c	ef5eea3673719c8516c5c98bba301240c48f9023
@@ -68,6 +68,39 @@ int irc_cmd_away(struct irc_conn *irc, c
 	return 0;
 }
 
+int irc_cmd_ctcp(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
+{
+	/* we have defined args as args[0] is target and args[1] is ctcp command */
+        char *buf;
+	GString *string;
+	
+	/* check if we have args */
+	if (!args || !args[0] || !args[1])
+		return 0;
+
+	/* TODO:strip newlines or send each line as separate ctcp or something
+	 * actually, this shouldn't be done here but somewhere else since irc should support escaping newlines
+	 * utf8 could pose additional problems here since it allows some of weird chars (NULL) to be part of bigger chars */ 
+
+	string = g_string_new(args[1]);
+	g_string_prepend_c (string,'\001');
+	g_string_append_c (string,'\001');
+	buf = irc_format(irc, "vn:", "PRIVMSG", args[0], string->str);
+	g_string_free(string,TRUE);
+
+	/* check if line is small enough to send
+	 * XXX: strlen will prolly not work for UTF-8 */
+	if (strlen(buf) >= 512)
+		return 0;
+
+	irc_send(irc, buf);
+	g_free(buf);
+	
+
+	return 1;
+	
+}
+
 int irc_cmd_ctcp_action(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
 {
 	PurpleConnection *gc = purple_account_get_connection(irc->account);
============================================================
--- libpurple/protocols/irc/irc.h	725eea8187529e6af90e5e25cd948a9f2e91facf
+++ libpurple/protocols/irc/irc.h	f10942383ebaf18501bdd3d60917ee05cbd4fb6f
@@ -164,6 +164,7 @@ int irc_cmd_away(struct irc_conn *irc, c
 
 int irc_cmd_default(struct irc_conn *irc, const char *cmd, const char *target, const char **args);
 int irc_cmd_away(struct irc_conn *irc, const char *cmd, const char *target, const char **args);
+int irc_cmd_ctcp(struct irc_conn *irc, const char *cmd, const char *target, const char **args);
 int irc_cmd_ctcp_action(struct irc_conn *irc, const char *cmd, const char *target, const char **args);
 int irc_cmd_ctcp_version(struct irc_conn *irc, const char *cmd, const char *target, const char **args);
 int irc_cmd_invite(struct irc_conn *irc, const char *cmd, const char *target, const char **args);
============================================================
--- libpurple/protocols/irc/parse.c	1294e0e7cf82d5c3a2e7dbea2f89c499e88dcc13
+++ libpurple/protocols/irc/parse.c	4d3663539911d5b6e9e14d203a091c8e37ed73c1
@@ -123,6 +123,7 @@ static struct _irc_user_cmd {
 } _irc_cmds[] = {
 	{ "action", ":", irc_cmd_ctcp_action, N_("action <action to perform>:  Perform an action.") },
 	{ "away", ":", irc_cmd_away, N_("away [message]:  Set an away message, or use no message to return from being away.") },
+	{ "ctcp", "t:", irc_cmd_ctcp, N_("ctcp <nick> <msg>: sends ctcp msg to nick.") },
 	{ "chanserv", ":", irc_cmd_service, N_("chanserv: Send a command to chanserv") },
 	{ "deop", ":", irc_cmd_op, N_("deop &lt;nick1&gt; [nick2] ...:  Remove channel operator status from someone. You must be a channel operator to do this.") },
 	{ "devoice", ":", irc_cmd_op, N_("devoice &lt;nick1&gt; [nick2] ...:  Remove channel voice status from someone, preventing them from speaking if the channel is moderated (+m). You must be a channel operator to do this.") },


More information about the Commits mailing list