Advertisement
tduva

mIRC Chatty Addressbook Edit

Aug 9th, 2015
910
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 2.79 KB | None | 0 0
  1.  
  2. ; Add a user to the "voice" Addressbook category
  3. alias givevoice {
  4.   var %name = $$1
  5.   ab.write add %name voice
  6. }
  7.  
  8. ; Remove a user from the "voice" Addressbook category
  9. alias removevoice {
  10.   var %name = $$1
  11.   ab.write remove %name voice
  12. }
  13.  
  14. /*
  15. Chatty provides a way to execute Addressbook commands that
  16. are added to the addressbookImport.txt file in the settings
  17. directory.
  18.  
  19. The following script is a simple way to add lines to the
  20. addressbookImport.txt file.
  21.  
  22. It is recommended to not write to the file too often, so
  23. nothing gets lost (it is only read by Chatty a few seconds
  24. after a change is deteced). For that purpose lines written
  25. with ab.write are added to a cache, that is then written at
  26. once into the file. A timer is started on start to check if
  27. the cache contains anything every 10 seconds.
  28.  
  29. You need to enable the auto-import in Chatty (restart Chatty
  30. for the setting change to take effect):
  31. /set abAutoImport on
  32.  
  33. Chatty help on the Addressbook import via file:
  34. http://chatty.github.io/help/help-addressbook.html#file
  35. */
  36.  
  37. /*
  38. ### Setting (must be changed)
  39.  
  40. The file to export to for Chatty. You need to change
  41. this path to whatever Chatty outputs for the /dir command. The
  42. file must be called addressbookImport.txt for Chatty to detect it.
  43.  
  44. If /dir returns "C:\Users\john\.chatty\" then you need to
  45. change this to:
  46. C:\Users\john\.chatty\addressbookImport.txt
  47. */
  48. alias ab.exportFile {
  49.   return H:\coding\java\netbeans\Chatty\main\working_directory\addressbookImport.txt
  50. }
  51.  
  52. /*
  53. ### Setting
  54.  
  55. Name of the hashtable to store the ab cache in. You can
  56. keep this as it is.
  57. */
  58. alias ab.cache {
  59.   return writeToAbCache
  60. }
  61.  
  62. /*
  63. ### Function: Write to Addressbook
  64.  
  65. Adds a line to the adderssbook import file. To be used by scripts
  66. to edit the Addressbook. Check the Chatty help for commands that
  67. are available to edit the Addressbook.
  68.  
  69. Since this is written to a cache, it can take over 10 seconds for
  70. changes to occur in the Addressbook.
  71. */
  72. alias ab.write {
  73.   var %command = $$1-
  74.   hadd -m $ab.cache $calc($hget($ab.cache, 0).item + 1) %command
  75. }
  76.  
  77.  
  78. ;#### Internal things you usually don't need to change
  79.  
  80. on *:start:{
  81.   ab.startCacheTimer
  82. }
  83.  
  84. alias ab.startCacheTimer {
  85.   .timerWriteCacheToAb 0 10 ab.writeCache
  86. }
  87.  
  88. /*
  89. Writes the current cache to the Addressbook import file and clears
  90. the cache afterwards.
  91. */
  92. alias -l ab.writeCache {
  93.   ;echo -a writeCacheToAb
  94.   if ($hget($ab.cache, 0).item == 0) {
  95.     ; Cache empty, do nothing
  96.     return
  97.   }
  98.   ; Clear file
  99.   write -c $ab.exportFile
  100.   var %i = 1
  101.   while (%i <= $hget($ab.cache, 0).item) {
  102.     var %command = $hget($ab.cache, %i)
  103.     if (%command != $null) {
  104.       ; Append command to file
  105.       write -a $ab.exportFile %command
  106.       ;echo -a %command
  107.     }
  108.     inc %i
  109.   }
  110.   hfree $ab.cache
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement