Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. on encode_char(this_char)
  2.     set the ASCII_num to (the ASCII number this_char)
  3.     set the hex_list to {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}
  4.     set x to item ((ASCII_num div 16) + 1) of the hex_list
  5.     set y to item ((ASCII_num mod 16) + 1) of the hex_list
  6.     return ("%" & x & y) as string
  7. end encode_char
  8.  
  9. on encode_text(this_text, encode_URL_A, encode_URL_B)
  10.     set the standard_characters to "abcdefghijklmnopqrstuvwxyz0123456789"
  11.     set the URL_A_chars to "$+!'/?;&@=#%><{}[]\"~`^\\|*"
  12.     set the URL_B_chars to ".-_:"
  13.     set the acceptable_characters to the standard_characters
  14.     if encode_URL_A is false then set the acceptable_characters to the acceptable_characters & the URL_A_chars
  15.     if encode_URL_B is false then set the acceptable_characters to the acceptable_characters & the URL_B_chars
  16.     set the encoded_text to ""
  17.     repeat with this_char in this_text
  18.         if this_char is in the acceptable_characters then
  19.             set the encoded_text to (the encoded_text & this_char)
  20.         else
  21.             set the encoded_text to (the encoded_text & encode_char(this_char)) as string
  22.         end if
  23.     end repeat
  24.     return the encoded_text
  25. end encode_text
  26.  
  27. using terms from application "Messages"
  28.     on message received theMessage for theChat
  29.         set theURL to "http://MYSERVER.COM/mirror-quickstart-php/sendText.php?auth=superSecretCodew&message=" & encode_text(theMessage, false, false)
  30.         do shell script "curl " & quoted form of theURL
  31.     end message received
  32. end using terms from
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement