comparison libpurple/protocols/irc/msgs.c @ 22810:1fbc49b46e09

Fix IRC handling of PART without a part message on Undernet IRCds.
author Ethan Blanton <elb@pidgin.im>
date Sun, 04 May 2008 01:43:00 +0000
parents 8d3c68a8eed4
children f09acca60066
comparison
equal deleted inserted replaced
22809:7492fdcdbcea 22810:1fbc49b46e09
1013 1013
1014 void irc_msg_part(struct irc_conn *irc, const char *name, const char *from, char **args) 1014 void irc_msg_part(struct irc_conn *irc, const char *name, const char *from, char **args)
1015 { 1015 {
1016 PurpleConnection *gc = purple_account_get_connection(irc->account); 1016 PurpleConnection *gc = purple_account_get_connection(irc->account);
1017 PurpleConversation *convo; 1017 PurpleConversation *convo;
1018 char *nick, *msg; 1018 char *nick, *msg, *channel;
1019 1019
1020 if (!args || !args[0] || !gc) 1020 if (!args || !args[0] || !gc)
1021 return; 1021 return;
1022 1022
1023 convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[0], irc->account); 1023 /* Undernet likes to :-quote the channel name, for no good reason
1024 * that I can see. This catches that. */
1025 channel = (args[0][0] == ':') ? &args[0][1] : args[0];
1026
1027 convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, channel, irc->account);
1024 if (!convo) { 1028 if (!convo) {
1025 purple_debug(PURPLE_DEBUG_INFO, "irc", "Got a PART on %s, which doesn't exist -- probably closed\n", args[0]); 1029 purple_debug(PURPLE_DEBUG_INFO, "irc", "Got a PART on %s, which doesn't exist -- probably closed\n", channel);
1026 return; 1030 return;
1027 } 1031 }
1028 1032
1029 nick = irc_mask_nick(from); 1033 nick = irc_mask_nick(from);
1030 if (!purple_utf8_strcasecmp(nick, purple_connection_get_display_name(gc))) { 1034 if (!purple_utf8_strcasecmp(nick, purple_connection_get_display_name(gc))) {
1031 char *escaped = g_markup_escape_text(args[1], -1); 1035 char *escaped = g_markup_escape_text(args[1], -1);
1032 msg = g_strdup_printf(_("You have parted the channel%s%s"), 1036 msg = g_strdup_printf(_("You have parted the channel%s%s"),
1033 (args[1] && *args[1]) ? ": " : "", 1037 (args[1] && *args[1]) ? ": " : "",
1034 (escaped && *escaped) ? escaped : ""); 1038 (escaped && *escaped) ? escaped : "");
1035 g_free(escaped); 1039 g_free(escaped);
1036 purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[0], msg, PURPLE_MESSAGE_SYSTEM, time(NULL)); 1040 purple_conv_chat_write(PURPLE_CONV_CHAT(convo), channel, msg, PURPLE_MESSAGE_SYSTEM, time(NULL));
1037 g_free(msg); 1041 g_free(msg);
1038 serv_got_chat_left(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(convo))); 1042 serv_got_chat_left(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(convo)));
1039 } else { 1043 } else {
1040 msg = args[1] ? irc_mirc2txt(args[1]) : NULL; 1044 msg = args[1] ? irc_mirc2txt(args[1]) : NULL;
1041 purple_conv_chat_remove_user(PURPLE_CONV_CHAT(convo), nick, msg); 1045 purple_conv_chat_remove_user(PURPLE_CONV_CHAT(convo), nick, msg);