Mercurial > pidgin
diff libpurple/protocols/irc/msgs.c @ 22655:ef4ac2a83e1c
Handle IRC ban lists in-channel. Channels which are not joined are
still sent to the debug window, but in a bit prettier format.
References #209
author | Ethan Blanton <elb@pidgin.im> |
---|---|
date | Sat, 12 Apr 2008 22:59:33 +0000 |
parents | bc9845b6f9c0 |
children | cd682b57b6e4 |
line wrap: on
line diff
--- a/libpurple/protocols/irc/msgs.c Sat Apr 12 21:26:43 2008 +0000 +++ b/libpurple/protocols/irc/msgs.c Sat Apr 12 22:59:33 2008 +0000 @@ -30,6 +30,7 @@ #include "irc.h" #include <stdio.h> +#include <stdlib.h> static char *irc_mask_nick(const char *mask); static char *irc_mask_userhost(const char *mask); @@ -191,6 +192,49 @@ purple_notify_error(gc, NULL, _("Bad mode"), args[1]); } +void irc_msg_ban(struct irc_conn *irc, const char *name, const char *from, char **args) +{ + PurpleConversation *convo; + + if (!args || !args[0] || !args[1]) + return; + + convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, + args[1], irc->account); + + if (!strcmp(name, "367")) { + char *msg = NULL; + /* Ban list entry */ + if (!args[2]) + return; + if (args[3] && args[4]) { + /* This is an extended syntax, not in RFC 1459 */ + int t1 = atoi(args[4]); + time_t t2 = time(NULL); + msg = g_strdup_printf(_("Ban on %s by %s, set %ld seconds ago"), + args[2], args[3], t2 - t1); + } else { + msg = g_strdup_printf(_("Ban on %s"), args[2]); + } + if (convo) { + purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", msg, + PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, + time(NULL)); + } else { + purple_debug_info("irc", "%s\n", msg); + } + g_free(msg); + } else if (!strcmp(name, "368")) { + if (!convo) + return; + /* End of ban list */ + purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", + _("End of ban list"), + PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, + time(NULL)); + } +} + void irc_msg_banned(struct irc_conn *irc, const char *name, const char *from, char **args) { PurpleConnection *gc = purple_account_get_connection(irc->account);