# HG changeset patch # User Ethan Blanton # Date 1208041173 0 # Node ID ef4ac2a83e1ca045f8f0a71b34b82ff278df14bb # Parent e970c0c8a48ddb1b94c0ce9ee7b89d90ba64ebf2 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 diff -r e970c0c8a48d -r ef4ac2a83e1c ChangeLog --- a/ChangeLog Sat Apr 12 21:26:43 2008 +0000 +++ b/ChangeLog Sat Apr 12 22:59:33 2008 +0000 @@ -4,6 +4,7 @@ libpurple: * In MySpaceIM, messages from spambots are discarded (Justin Williams) * Strip mIRC formatting codes from quit and part messages. + * IRC now displays ban lists in-channel for joined channels. Pidgin: * The typing notification in the conversation history can be disabled or diff -r e970c0c8a48d -r ef4ac2a83e1c libpurple/protocols/irc/irc.h --- a/libpurple/protocols/irc/irc.h Sat Apr 12 21:26:43 2008 +0000 +++ b/libpurple/protocols/irc/irc.h Sat Apr 12 22:59:33 2008 +0000 @@ -118,6 +118,7 @@ void irc_msg_away(struct irc_conn *irc, const char *name, const char *from, char **args); void irc_msg_badmode(struct irc_conn *irc, const char *name, const char *from, char **args); void irc_msg_badnick(struct irc_conn *irc, const char *name, const char *from, char **args); +void irc_msg_ban(struct irc_conn *irc, const char *name, const char *from, char **args); void irc_msg_banfull(struct irc_conn *irc, const char *name, const char *from, char **args); void irc_msg_banned(struct irc_conn *irc, const char *name, const char *from, char **args); void irc_msg_chanmode(struct irc_conn *irc, const char *name, const char *from, char **args); diff -r e970c0c8a48d -r ef4ac2a83e1c libpurple/protocols/irc/msgs.c --- 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 +#include 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); diff -r e970c0c8a48d -r ef4ac2a83e1c libpurple/protocols/irc/parse.c --- a/libpurple/protocols/irc/parse.c Sat Apr 12 21:26:43 2008 +0000 +++ b/libpurple/protocols/irc/parse.c Sat Apr 12 22:59:33 2008 +0000 @@ -75,6 +75,8 @@ { "333", "*", irc_msg_ignore }, /* Topic setter stuff */ { "353", "nvc:", irc_msg_names }, /* Names list */ { "366", "nc:", irc_msg_names }, /* End of names */ + { "367", "ncnnv", irc_msg_ban }, /* Ban list */ + { "368", "nc:", irc_msg_ban }, /* End of ban list */ { "372", "n:", irc_msg_motd }, /* MOTD */ { "375", "n:", irc_msg_motd }, /* Start MOTD */ { "376", "n:", irc_msg_motd }, /* End of MOTD */