Advertisement
wollux

Custom Aliases

Sep 12th, 2011
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Cancel's CustomAlias Plugin for Colloquy VERSION 1.0.0
  2. --Jason T. Powell jtpowell@users.sourceforge.net
  3.  
  4. --PREFERENCES
  5. property service : true -- true/false:
  6.  
  7. on run
  8.     display dialog "Don't run me, move me to ~/Library/Application Support/Colloquy/PlugIns/ and type /reload plugins in Colloquy."
  9. end run
  10.  
  11. using terms from application "Colloquy-1"
  12.    
  13.     on load
  14.         --if we did something on load it would be here
  15.     end load
  16.    
  17.     on idle
  18.         --if we had an idling stuff it would go here
  19.         --return 500
  20.     end idle
  21.    
  22.     on unload
  23.         --stuff to do when we unload goes here
  24.     end unload
  25.    
  26.     on build contextual menu for item customAlias in view
  27.         --display dialog class of view
  28.         --check if item is a member or chat room
  29.         if class of customAlias is chat room panel or class of customAlias is Unicode text then
  30.             my buildCustomAliasMenu(view)
  31.         end if
  32.     end build contextual menu for item
  33.    
  34.     on handle clicked contextual menu item menuTitle for room
  35.         if menuTitle begins with "Enable Custom Aliases" then
  36.             set service to true
  37.         else if menuTitle begins with "Disable Custom Aliases" then
  38.             set service to false
  39.         else if menuTitle begins with "About Custom Aliases Plugin" then
  40.             my aboutCustomAliases()
  41.         end if
  42.     end handle clicked contextual menu item
  43.    
  44.    
  45.     on process user command c with arguments for view
  46.         if service is true then
  47.             set thePListPath to POSIX path of (path to home folder) & "Library/Application Support/Colloquy/PlugIns/CustomAliases"
  48.             try
  49.                 tell application "System Events"
  50.                     tell property list file thePListPath
  51.                         tell contents
  52.                             set customCommand to value of property list item c
  53.                         end tell
  54.                     end tell
  55.                 end tell
  56.                
  57.                 send raw command customCommand to connection of view
  58.                
  59.             end try
  60.         end if
  61.     end process user command
  62.    
  63. end using terms from
  64.  
  65. on buildCustomAliasMenu(view)
  66.     if service is false then
  67.         return {title:"Custom Aliases", submenu:{{title:"Enable Custom Aliases", enabled:true, context:view}, {title:"Disable Custom Aliases", enabled:false}, {title:"About Custom Aliases Plugin..."}}}
  68.     else if service is true then
  69.         return {title:"Custom Aliases", submenu:{{title:"Enable Custom Aliases", enabled:false}, {title:"Disable Custom Aliases", enabled:true, context:view}, {title:"About Custom Aliases Plugin..."}}}
  70.     end if
  71. end buildCustomAliasMenu
  72.  
  73. on aboutCustomAliases()
  74.     tell application "Finder" to open file ((path to application support folder from user domain as Unicode text) & "Colloquy:Plugins:CustomAlias.scpt")
  75.    
  76.     tell application "Safari"
  77.         activate
  78.         set the URL of document 1 to "http://cancelbot.sourceforge.net"
  79.     end tell
  80. end aboutCustomAliases
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement