/* Arexx script for StrICQ triggered by the notify event that will use
the Amiga's narrator.device to inform you who sent you the last msg.

$VER:release v0.1 june-10th-1998 by Eric Giroux (eric_giroux@videotron.ca)

PLay16 by Thomans Wenzel (http://linux.rz.fh-hannover.de/~wenzel/programming.html)
and translator.library are required.

Simply put that script in StrICQ's "settings/prefs/stricq/message notify command"
"rx notify_stricq.rexx %ld"

Put contacts.prefs in the same drawer as notify_stricq.rexx and modify
it to reflect your contact list.  The first argument is the UIN and
the second, after the comma, is the name you want the translator to
speak.

Change the TALKTO variable to your first name.
Change the SAY_COMMAND variable to reflect the path on your system.
Change the SAMPLE variable to the sample you want to hear as general notification.
Change the PLAYER variable to reflect the one you use.
*/

talkto="Eric"
say_command="sys:utilities/say"
sample="term:sound/incoming.iff"
player="c:play16"
say_command=center(say_command,length(say_command)+2,'"')

found="0"
port=address()

curdir=pragma('d')
if right(curdir,1) ~= ":" then prefs=curdir"/Contacts.prefs"
 else prefs=curdir"Contacts.prefs"

if ~show('L','rexxsupport.library') then
  if addlib('rexxsupport.library',0,-30,0)=0 then exit

if ~exists('libs:translator.library') then exit

options results

parse upper arg UIN

if UIN="" then exit

if exists(sample)=1 & exists(player)=1 then address command player ' <>nil: ' sample

if exists(prefs)=1 then do
  if open(notify_prefs_file,prefs,r) = "0" then exit
  nlines="1"
  do while ~eof(notify_prefs_file)
   nick.nlines=readln(notify_prefs_file)
   if nick.nlines="" then iterate
    else do
     if index(nick.nlines,UIN) >= 1 then do
      if exists(compress(SAY_COMMAND,'"'))=1 then
       address command say_command d2c(34) talkto ',,,you have a message from,' spoken_nick(nick.nlines) ',on  I see cue.' d2c(34)
      found=found+1
     end
     nlines=nlines+1
    end
  if found="1" then leave
  end
 nick.0=nlines-1
 close(notify_prefs_file)
end


exit

spoken_nick:
 parse arg new_nick
    new_nick=substr(new_nick,lastpos(',',new_nick)+1)
return new_nick

PubScreen:
 If show('p', port) = 1 then do
  address value port
  INFO SCREEN
  PubScreen = result
 end
  else
 PubScreen = 'Workbench'
return pubscreen
