adium-1.4 3213:ae7444303756: Special case '/say' to send raw tex...
commits at adium.im
commits at adium.im
Mon Nov 1 23:39:43 UTC 2010
details: http://hg.adium.im/adium-1.4/rev/ae7444303756
revision: 3213:ae7444303756
author: Evan Schoenberg
date: Mon Nov 01 18:39:31 2010 -0500
Special case '/say' to send raw text. Remaining problem is that '/say ' is still shown in the message on the sender's side; fixing this is far too nontrivial to interest me, and I believe that making it possible would require some deep architectural changes
diffs (60 lines):
diff -r eabab501cd00 -r ae7444303756 Plugins/Purple Service/ESIRCAccount.m
--- a/Plugins/Purple Service/ESIRCAccount.m Mon Nov 01 18:01:04 2010 -0500
+++ b/Plugins/Purple Service/ESIRCAccount.m Mon Nov 01 18:39:31 2010 -0500
@@ -166,20 +166,35 @@
{
NSString *encodedString = nil;
- BOOL didCommand = [self.purpleAdapter attemptPurpleCommandOnMessage:inContentMessage.message.string
+ NSString *messageString = inContentMessage.message.string;
+ BOOL didCommand = [self.purpleAdapter attemptPurpleCommandOnMessage:messageString
fromAccount:(AIAccount *)inContentMessage.source
inChat:inContentMessage.chat];
- NSRange meRange = [inContentMessage.message.string rangeOfString:@"/me " options:NSCaseInsensitiveSearch];
-
- if (!didCommand || meRange.location == 0) {
- if (meRange.location == 0) {
+ BOOL hasSlashMe = ([messageString rangeOfString:@"/me " options:(NSCaseInsensitiveSearch | NSAnchoredSearch)].location == 0);
+
+ /* /say is a special case; it's not actually a command, but an instruction to display the following text (even if
+ * that text would normally be a command itself).
+ */
+ BOOL hasSlashSay = ([messageString rangeOfString:@"/say " options:(NSCaseInsensitiveSearch | NSAnchoredSearch)].location == 0);
+
+ if (!didCommand || hasSlashMe) {
+ if (hasSlashMe) {
inContentMessage.sendContent = NO;
}
- /* If we're sending a message on an encryption chat (can this even happen on irc?), we can encode the HTML normally, as links will go through fine.
- * If we're sending a message normally, IRC will drop the title of any link, so we preprocess it to be in the form "title (link)"
+ /* If we're sending a message on an encrypted direct msg, we can encode the HTML normally, as links will go through fine.
+ * However, in all other cases, IRC will drop the title of any link, so we preprocess it to be in the form "title (link)"
*/
- encodedString = [AIHTMLDecoder encodeHTML:(inContentMessage.chat.isSecure ? inContentMessage.message : [inContentMessage.message attributedStringByConvertingLinksToURLStrings])
+ NSAttributedString *messageAttributedString = inContentMessage.message;
+
+ /* Remove the "/say" */
+ if (hasSlashSay)
+ messageAttributedString = [messageAttributedString attributedSubstringFromRange:NSMakeRange(@"/say ".length,
+ messageAttributedString.length - @"/say ".length)];
+
+ encodedString = [AIHTMLDecoder encodeHTML:(inContentMessage.chat.isSecure ?
+ messageAttributedString :
+ [messageAttributedString attributedStringByConvertingLinksToURLStrings])
headers:NO
fontTags:YES
includingColorTags:YES
@@ -196,9 +211,10 @@
allowJavascriptURLs:YES];
}
- if (!didCommand && [inContentMessage.message.string hasPrefix:@"/"]) {
+
+ if (!didCommand && !hasSlashSay && [messageString hasPrefix:@"/"]) {
// Try to send it to the server, if we don't know what it is; definitely don't display.
- [self sendRawCommand:[inContentMessage.message.string substringFromIndex:1]];
+ [self sendRawCommand:[messageString substringFromIndex:1]];
return nil;
} else {
return encodedString;
More information about the commits
mailing list