Mercurial > pidgin.yaz
comparison libpurple/protocols/irc/msgs.c @ 22638: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 |
comparison
equal
deleted
inserted
replaced
22637:e970c0c8a48d | 22638:ef4ac2a83e1c |
---|---|
28 #include "util.h" | 28 #include "util.h" |
29 #include "debug.h" | 29 #include "debug.h" |
30 #include "irc.h" | 30 #include "irc.h" |
31 | 31 |
32 #include <stdio.h> | 32 #include <stdio.h> |
33 #include <stdlib.h> | |
33 | 34 |
34 static char *irc_mask_nick(const char *mask); | 35 static char *irc_mask_nick(const char *mask); |
35 static char *irc_mask_userhost(const char *mask); | 36 static char *irc_mask_userhost(const char *mask); |
36 static void irc_chat_remove_buddy(PurpleConversation *convo, char *data[2]); | 37 static void irc_chat_remove_buddy(PurpleConversation *convo, char *data[2]); |
37 static void irc_buddy_status(char *name, struct irc_buddy *ib, struct irc_conn *irc); | 38 static void irc_buddy_status(char *name, struct irc_buddy *ib, struct irc_conn *irc); |
187 | 188 |
188 if (!args || !args[1] || !gc) | 189 if (!args || !args[1] || !gc) |
189 return; | 190 return; |
190 | 191 |
191 purple_notify_error(gc, NULL, _("Bad mode"), args[1]); | 192 purple_notify_error(gc, NULL, _("Bad mode"), args[1]); |
193 } | |
194 | |
195 void irc_msg_ban(struct irc_conn *irc, const char *name, const char *from, char **args) | |
196 { | |
197 PurpleConversation *convo; | |
198 | |
199 if (!args || !args[0] || !args[1]) | |
200 return; | |
201 | |
202 convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, | |
203 args[1], irc->account); | |
204 | |
205 if (!strcmp(name, "367")) { | |
206 char *msg = NULL; | |
207 /* Ban list entry */ | |
208 if (!args[2]) | |
209 return; | |
210 if (args[3] && args[4]) { | |
211 /* This is an extended syntax, not in RFC 1459 */ | |
212 int t1 = atoi(args[4]); | |
213 time_t t2 = time(NULL); | |
214 msg = g_strdup_printf(_("Ban on %s by %s, set %ld seconds ago"), | |
215 args[2], args[3], t2 - t1); | |
216 } else { | |
217 msg = g_strdup_printf(_("Ban on %s"), args[2]); | |
218 } | |
219 if (convo) { | |
220 purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", msg, | |
221 PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, | |
222 time(NULL)); | |
223 } else { | |
224 purple_debug_info("irc", "%s\n", msg); | |
225 } | |
226 g_free(msg); | |
227 } else if (!strcmp(name, "368")) { | |
228 if (!convo) | |
229 return; | |
230 /* End of ban list */ | |
231 purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", | |
232 _("End of ban list"), | |
233 PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, | |
234 time(NULL)); | |
235 } | |
192 } | 236 } |
193 | 237 |
194 void irc_msg_banned(struct irc_conn *irc, const char *name, const char *from, char **args) | 238 void irc_msg_banned(struct irc_conn *irc, const char *name, const char *from, char **args) |
195 { | 239 { |
196 PurpleConnection *gc = purple_account_get_connection(irc->account); | 240 PurpleConnection *gc = purple_account_get_connection(irc->account); |