Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ichat-convert: support sender IDs that are emails prefixed with "e:"

  • Loading branch information...
commit 01f4aefd0e657bff39531e9b6120de6da3ca1a40 1 parent f3001b1
@mislav authored
Showing with 12 additions and 2 deletions.
  1. +12 −2 bin/ichat-convert
View
14 bin/ichat-convert
@@ -1,7 +1,9 @@
#!/usr/bin/env macruby -wKU
framework 'Foundation'
+$VERBOSE = nil
framework 'AppKit' # for decoding classes such as NSMutableParagraphStyle
+$VERBOSE = true
framework 'AddressBook'
# based on Logorrhea from Spiny Software
@@ -101,6 +103,10 @@ class ABAddressBook
def find_chat_buddy(id)
search_properties(%w[Email AIMInstant JabberInstant URLs], for:id).first
end
+
+ def find_by_email(email)
+ search_properties(%w[Email], for:email).first
+ end
end
# adding a method to String for some reason doesn't work for all strings
@@ -140,7 +146,11 @@ if $0 == __FILE__
ab = ABAddressBook.sharedAddressBook
lambda { |id|
- buddy = ab.find_chat_buddy(id)
+ if id =~ /^e:(.+)/ and $1.include? '@'
+ buddy = ab.find_by_email($1)
+ else
+ buddy = ab.find_chat_buddy(id)
+ end
buddy ? (buddy.nickname || buddy.first_name) : id.split('@').first
}
end
@@ -162,4 +172,4 @@ if $0 == __FILE__
previous_msg = msg
end
-end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.