adium 2429:4211a3be19a2: Create a new plugin - AIAnnoyingIRCMess...
commits at adium.im
commits at adium.im
Sun May 31 18:41:32 UTC 2009
details: http://hg.adium.im/adium/rev/4211a3be19a2
revision: 2429:4211a3be19a2
author: Zachary West <zacw at adium.im>
date: Sun May 31 14:41:17 2009 -0400
Create a new plugin - AIAnnoyingIRCMessagesHiderPlugin - which hides, well, annoying messages.
Consider yourself smited, freenode-connect. No, DALnet I don't care that the MOTD was last updated in 2006. Useful knowledge thank you.
diffs (186 lines):
diff -r 6cedea6c669d -r 4211a3be19a2 Adium.xcodeproj/project.pbxproj
--- a/Adium.xcodeproj/project.pbxproj Sun May 31 14:16:36 2009 -0400
+++ b/Adium.xcodeproj/project.pbxproj Sun May 31 14:41:17 2009 -0400
@@ -142,6 +142,8 @@
11879C0B0F6FF4C400CACFB1 /* AITwitterAccountOAuthSetup.m in Sources */ = {isa = PBXBuildFile; fileRef = 11879C0A0F6FF4C400CACFB1 /* AITwitterAccountOAuthSetup.m */; };
11879DF80F6FFC0B00CACFB1 /* OAuthConsumer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 11879DF70F6FFC0B00CACFB1 /* OAuthConsumer.framework */; };
11879E0A0F6FFC1000CACFB1 /* OAuthConsumer.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 11879DF70F6FFC0B00CACFB1 /* OAuthConsumer.framework */; };
+ 1192E6D90FD3056F003CAEF5 /* AIAnnoyingIRCMessagesHiderPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 1192E6B10FD30307003CAEF5 /* AIAnnoyingIRCMessagesHiderPlugin.h */; };
+ 1192E6DA0FD30578003CAEF5 /* AIAnnoyingIRCMessagesHiderPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 1192E6B20FD30307003CAEF5 /* AIAnnoyingIRCMessagesHiderPlugin.m */; };
11945F400F7935A2002A54B3 /* Ignore.png in Resources */ = {isa = PBXBuildFile; fileRef = 11945F3F0F7935A2002A54B3 /* Ignore.png */; };
1197F6710FCF8D180032F19B /* AITwitterStatusFollowup.m in Sources */ = {isa = PBXBuildFile; fileRef = 1197F6700FCF8D180032F19B /* AITwitterStatusFollowup.m */; };
11A2F10A0FC8FC1A00C3F05C /* AIMessageAlertsAdvancedPreferences.nib in Resources */ = {isa = PBXBuildFile; fileRef = 11A2F1090FC8FC1A00C3F05C /* AIMessageAlertsAdvancedPreferences.nib */; };
@@ -1882,6 +1884,8 @@
11879C090F6FF4C400CACFB1 /* AITwitterAccountOAuthSetup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AITwitterAccountOAuthSetup.h; path = "Plugins/Twitter Plugin/AITwitterAccountOAuthSetup.h"; sourceTree = "<group>"; };
11879C0A0F6FF4C400CACFB1 /* AITwitterAccountOAuthSetup.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AITwitterAccountOAuthSetup.m; path = "Plugins/Twitter Plugin/AITwitterAccountOAuthSetup.m"; sourceTree = "<group>"; };
11879DF70F6FFC0B00CACFB1 /* OAuthConsumer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OAuthConsumer.framework; path = Frameworks/OAuthConsumer.framework; sourceTree = "<group>"; };
+ 1192E6B10FD30307003CAEF5 /* AIAnnoyingIRCMessagesHiderPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AIAnnoyingIRCMessagesHiderPlugin.h; path = "Plugins/Purple Service/AIAnnoyingIRCMessagesHiderPlugin.h"; sourceTree = "<group>"; };
+ 1192E6B20FD30307003CAEF5 /* AIAnnoyingIRCMessagesHiderPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AIAnnoyingIRCMessagesHiderPlugin.m; path = "Plugins/Purple Service/AIAnnoyingIRCMessagesHiderPlugin.m"; sourceTree = "<group>"; };
11945F3F0F7935A2002A54B3 /* Ignore.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Ignore.png; path = "Frameworks/Adium Framework/Resources/Ignore.png"; sourceTree = "<group>"; };
1197F66F0FCF8D180032F19B /* AITwitterStatusFollowup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AITwitterStatusFollowup.h; path = "Plugins/Twitter Plugin/AITwitterStatusFollowup.h"; sourceTree = "<group>"; };
1197F6700FCF8D180032F19B /* AITwitterStatusFollowup.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AITwitterStatusFollowup.m; path = "Plugins/Twitter Plugin/AITwitterStatusFollowup.m"; sourceTree = "<group>"; };
@@ -5972,6 +5976,8 @@
34B3241D09B9FF6900029361 /* IRC */ = {
isa = PBXGroup;
children = (
+ 1192E6B10FD30307003CAEF5 /* AIAnnoyingIRCMessagesHiderPlugin.h */,
+ 1192E6B20FD30307003CAEF5 /* AIAnnoyingIRCMessagesHiderPlugin.m */,
1150A9950FBE48D600E0BD31 /* ESIRCAccountView.nib */,
1139FFA80F85260E0081A418 /* AIIRCChannelLinker.h */,
1139FFA90F85260E0081A418 /* AIIRCChannelLinker.m */,
@@ -8841,6 +8847,7 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
+ 1192E6D90FD3056F003CAEF5 /* AIAnnoyingIRCMessagesHiderPlugin.h in Headers */,
6332879B0A769BF3004D0F2B /* AIPurpleLiveJournalAccount.h in Headers */,
6332879C0A769BF3004D0F2B /* AILiveJournalService.h in Headers */,
3485DB1809EBCE6500232CC4 /* SLPurpleCocoaAdapter.h in Headers */,
@@ -10005,6 +10012,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ 1192E6DA0FD30578003CAEF5 /* AIAnnoyingIRCMessagesHiderPlugin.m in Sources */,
117009A70F7E7D720078D6AB /* AIIRCServicesPasswordPlugin.m in Sources */,
3485DB1909EBCE6500232CC4 /* SLPurpleCocoaAdapter.m in Sources */,
3485DB1B09EBCE6500232CC4 /* adiumPurpleBlist.m in Sources */,
diff -r 6cedea6c669d -r 4211a3be19a2 Plugins/Purple Service/AIAnnoyingIRCMessagesHiderPlugin.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Plugins/Purple Service/AIAnnoyingIRCMessagesHiderPlugin.h Sun May 31 14:41:17 2009 -0400
@@ -0,0 +1,13 @@
+//
+// AIAnnoyingIRCMessagesHiderPlugin.h
+// Adium
+//
+// Created by Zachary West on 2009-05-31.
+// Copyright 2009 Adium. All rights reserved.
+//
+
+ at interface AIAnnoyingIRCMessagesHiderPlugin : AIPlugin {
+
+}
+
+ at end
diff -r 6cedea6c669d -r 4211a3be19a2 Plugins/Purple Service/AIAnnoyingIRCMessagesHiderPlugin.m
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Plugins/Purple Service/AIAnnoyingIRCMessagesHiderPlugin.m Sun May 31 14:41:17 2009 -0400
@@ -0,0 +1,71 @@
+//
+// AIAnnoyingIRCMessagesHiderPlugin.m
+// Adium
+//
+// Created by Zachary West on 2009-05-31.
+// Copyright 2009 Adium. All rights reserved.
+//
+
+#import "AIAnnoyingIRCMessagesHiderPlugin.h"
+#import <Adium/AIContentControllerProtocol.h>
+#import <Adium/AIContentObject.h>
+
+#import <AIUtilities/AIStringAdditions.h>
+#import <Adium/AIContentObject.h>
+#import <Adium/AIContentMessage.h>
+#import <Adium/AIListObject.h>
+
+ at implementation AIAnnoyingIRCMessagesHiderPlugin
+- (void)installPlugin
+{
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(willReceiveContent:)
+ name:Content_WillReceiveContent
+ object:nil];
+}
+
+- (void)uninstallPlugin
+{
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+}
+
+#pragma mark Content handling
+- (void)willReceiveContent:(NSNotification *)notification
+{
+ AIContentObject *contentObject = [[notification userInfo] objectForKey:@"Object"];
+ BOOL hidden;
+
+ if (![contentObject isKindOfClass:[AIContentMessage class]]) {
+ return;
+ }
+
+ NSArray *serverMessages = [NSArray arrayWithObjects:
+ @"highest connection count",
+ @"your host is",
+ @"exempt from DNS blacklists",
+ @"motd was last changed",
+ @"please read the motd",
+ @"if you see",
+ @"please disregard them, as they are",
+ @"for more information please visit",
+ nil];
+
+ if ([contentObject.source.UID rangeOfString:@"."].location != NSNotFound) {
+ for (NSString *message in serverMessages) {
+ if ([contentObject.message.string rangeOfString:message options:NSCaseInsensitiveSearch].location != NSNotFound) {
+ hidden = YES;
+ break;
+ }
+ }
+ } else if ([contentObject.source.UID isEqualToString:@"freenode-connect"]) {
+ hidden = YES;
+ }
+
+ // We use our own "did we hide?" variable, in case something else somewhere has caused this to not display.
+ if (hidden) {
+ AILogWithSignature(@"Hiding %@", contentObject);
+ contentObject.displayContent = NO;
+ }
+}
+
+ at end
diff -r 6cedea6c669d -r 4211a3be19a2 Plugins/Purple Service/CBPurpleServicePlugin.h
--- a/Plugins/Purple Service/CBPurpleServicePlugin.h Sun May 31 14:16:36 2009 -0400
+++ b/Plugins/Purple Service/CBPurpleServicePlugin.h Sun May 31 14:41:17 2009 -0400
@@ -15,11 +15,12 @@
*/
- at class AMPurpleTuneTooltip, AIIRCServicesPasswordPlugin;
+ at class AMPurpleTuneTooltip, AIIRCServicesPasswordPlugin, AIAnnoyingIRCMessagesHiderPlugin;
@interface CBPurpleServicePlugin : AIPlugin{
AMPurpleTuneTooltip *tunetooltip;
AIIRCServicesPasswordPlugin *ircPasswordPlugin;
+ AIAnnoyingIRCMessagesHiderPlugin *messageHiderPlugin;
}
@end
diff -r 6cedea6c669d -r 4211a3be19a2 Plugins/Purple Service/CBPurpleServicePlugin.m
--- a/Plugins/Purple Service/CBPurpleServicePlugin.m Sun May 31 14:16:36 2009 -0400
+++ b/Plugins/Purple Service/CBPurpleServicePlugin.m Sun May 31 14:41:17 2009 -0400
@@ -22,6 +22,7 @@
#import <AdiumLibpurple/SLPurpleCocoaAdapter.h>
#import "AMPurpleTuneTooltip.h"
#import "AIIRCServicesPasswordPlugin.h"
+#import "AIAnnoyingIRCMessagesHiderPlugin.h"
@implementation CBPurpleServicePlugin
@@ -66,6 +67,9 @@
ircPasswordPlugin = [[AIIRCServicesPasswordPlugin alloc] init];
[ircPasswordPlugin installPlugin];
+
+ messageHiderPlugin = [[AIAnnoyingIRCMessagesHiderPlugin alloc] init];
+ [messageHiderPlugin installPlugin];
}
- (void)uninstallPlugin
@@ -76,6 +80,9 @@
[ircPasswordPlugin uninstallPlugin];
[ircPasswordPlugin release];
+
+ [messageHiderPlugin uninstallPlugin];
+ [messageHiderPlugin release];
}
@end
More information about the commits
mailing list