; Add a user to the "voice" Addressbook category
alias givevoice {
var %name = $$1
ab.write add %name voice
}
; Remove a user from the "voice" Addressbook category
alias removevoice {
var %name = $$1
ab.write remove %name voice
}
/*
Chatty provides a way to execute Addressbook commands that
are added to the addressbookImport.txt file in the settings
directory.
The following script is a simple way to add lines to the
addressbookImport.txt file.
It is recommended to not write to the file too often, so
nothing gets lost (it is only read by Chatty a few seconds
after a change is deteced). For that purpose lines written
with ab.write are added to a cache, that is then written at
once into the file. A timer is started on start to check if
the cache contains anything every 10 seconds.
You need to enable the auto-import in Chatty (restart Chatty
for the setting change to take effect):
/set abAutoImport on
Chatty help on the Addressbook import via file:
http://chatty.github.io/help/help-addressbook.html#file
*/
/*
### Setting (must be changed)
The file to export to for Chatty. You need to change
this path to whatever Chatty outputs for the /dir command. The
file must be called addressbookImport.txt for Chatty to detect it.
If /dir returns "C:\Users\john\.chatty\" then you need to
change this to:
C:\Users\john\.chatty\addressbookImport.txt
*/
alias ab.exportFile {
return H:\coding\java\netbeans\Chatty\main\working_directory\addressbookImport.txt
}
/*
### Setting
Name of the hashtable to store the ab cache in. You can
keep this as it is.
*/
alias ab.cache {
return writeToAbCache
}
/*
### Function: Write to Addressbook
Adds a line to the adderssbook import file. To be used by scripts
to edit the Addressbook. Check the Chatty help for commands that
are available to edit the Addressbook.
Since this is written to a cache, it can take over 10 seconds for
changes to occur in the Addressbook.
*/
alias ab.write {
var %command = $$1-
hadd -m $ab.cache $calc($hget($ab.cache, 0).item + 1) %command
}
;#### Internal things you usually don't need to change
on *:start:{
ab.startCacheTimer
}
alias ab.startCacheTimer {
.timerWriteCacheToAb 0 10 ab.writeCache
}
/*
Writes the current cache to the Addressbook import file and clears
the cache afterwards.
*/
alias -l ab.writeCache {
;echo -a writeCacheToAb
if ($hget($ab.cache, 0).item == 0) {
; Cache empty, do nothing
return
}
; Clear file
write -c $ab.exportFile
var %i = 1
while (%i <= $hget($ab.cache, 0).item) {
var %command = $hget($ab.cache, %i)
if (%command != $null) {
; Append command to file
write -a $ab.exportFile %command
;echo -a %command
}
inc %i
}
hfree $ab.cache
}
Comments
0 B
|👍
/👎
0 B
|👍
/👎
0 B
|👍
/👎
0 B
|👍
/👎
0 B
|👍
/👎
0 B
|👍
/👎
0 B
|👍
/👎
0 B
|👍
/👎
0 B
|👍
/👎