Mercurial > pidgin
changeset 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 | e970c0c8a48d |
children | def8f39f542a |
files | ChangeLog libpurple/protocols/irc/irc.h libpurple/protocols/irc/msgs.c libpurple/protocols/irc/parse.c |
diffstat | 4 files changed, 48 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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);
--- 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);
--- 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 */