# HG changeset patch # User Vladislav Guberinic # Date 1216672409 0 # Node ID dc359ea9eb9a24e9191c3dd3fa352d932bd5af71 # Parent a270bd4b5298b55cd6337f01b1d2d2a5b2b42e26 /ctcp command for IRC committer: Ethan Blanton diff -r a270bd4b5298 -r dc359ea9eb9a COPYRIGHT --- a/COPYRIGHT Mon Jul 21 07:46:23 2008 +0000 +++ b/COPYRIGHT Mon Jul 21 20:33:29 2008 +0000 @@ -157,6 +157,7 @@ Konrad Gräfe Miah Gregory David Grohmann +Vladislav Guberinić Gideon N. Guillen Christian Hammond Erick Hamness diff -r a270bd4b5298 -r dc359ea9eb9a ChangeLog --- a/ChangeLog Mon Jul 21 07:46:23 2008 +0000 +++ b/ChangeLog Mon Jul 21 20:33:29 2008 +0000 @@ -10,6 +10,9 @@ 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 diff -r a270bd4b5298 -r dc359ea9eb9a libpurple/protocols/irc/cmds.c --- a/libpurple/protocols/irc/cmds.c Mon Jul 21 07:46:23 2008 +0000 +++ b/libpurple/protocols/irc/cmds.c Mon Jul 21 20:33:29 2008 +0000 @@ -68,6 +68,39 @@ 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); diff -r a270bd4b5298 -r dc359ea9eb9a libpurple/protocols/irc/irc.h --- a/libpurple/protocols/irc/irc.h Mon Jul 21 07:46:23 2008 +0000 +++ b/libpurple/protocols/irc/irc.h Mon Jul 21 20:33:29 2008 +0000 @@ -164,6 +164,7 @@ 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); diff -r a270bd4b5298 -r dc359ea9eb9a libpurple/protocols/irc/parse.c --- a/libpurple/protocols/irc/parse.c Mon Jul 21 07:46:23 2008 +0000 +++ b/libpurple/protocols/irc/parse.c Mon Jul 21 20:33:29 2008 +0000 @@ -123,6 +123,7 @@ } _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 : sends ctcp msg to nick.") }, { "chanserv", ":", irc_cmd_service, N_("chanserv: Send a command to chanserv") }, { "deop", ":", irc_cmd_op, N_("deop <nick1> [nick2] ...: Remove channel operator status from someone. You must be a channel operator to do this.") }, { "devoice", ":", irc_cmd_op, N_("devoice <nick1> [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.") },