<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- MuClient version 4.01 -->

<!-- Plugin "TTS_jFW" generated by Plugin Wizard -->

<!--
Features to add: 
reading of chat.
Ability to make certain strings interrupt?
-->

<muclient>
<plugin
   name="TTS_jFW"
   author="Olivier BERT"
   id="d56716d986c08af57cb69f34"
   language="VBscript"
   purpose="Enables Your primary TTS system to become JFW"
   requires="4.01"
   version="1.0"
   >
<description trim="y">
<![CDATA[
This Plugin lets you use JFW (or JAWS) as your primary text-to-speech system with MUSHclient.  it has one command, TTS, which you can type in a world to toggle reading of new text.
The plugin currently reads inbound text from your connected world, and tab-completion.  It will work even if you are outside of the MUSHclient window.
]]>
</description>

</plugin>



<!--  Aliases  -->

<aliases>
  <alias
   script="TTSToggle"
   match="tts"
   enabled="y"
   group="TTS"
   omit_from_command_history="y"
   omit_from_log="y"
   omit_from_output="y"
   sequence="100"
  >
  </alias>
</aliases>

<!--  Script  -->


<script>
<![CDATA[
'setup some variables - the tts object, and the toggle for reading.
dim TTSObject
dim TTSReadNew
'first decide whether or not to read incoming text, with an alias.
sub TTSToggle (name, line, x)
if TTSReadNew = 1 then
TTSReadNew = 0
TTSObject.SayString "Lecture de la fenêtre désactivée.", 0
else
TTSReadNew = 1
TTSObject.SayString "Lecture de la fenêtre activée.",0
end if
end sub
'when the plugIn is first installed, initiate the tts.
sub OnPluginInstall
set TTSObject = CreateObject("ScreenReaderAPI.Interface")
TTSObject.SayString "Le plug-in MushClient pour JAWS est prêt.",0
TTSReadNew = 1

end sub
'this event fires when new text is drawn from the mud.
'sub OnPluginScreendraw (t, log, line)
'if (t = 0 or t = 1 or t = 2)  and TTSReadNew = 1 then
'TTSObject.SayString line, 0
'end if
'end sub

sub OnPluginPacketReceived (line)
dim nline
Dim re
Dim Match, Matches
set re = new regexp
re.Global = true
re.IgnoreCase = true
if TTSReadNew = 1 then
re.Pattern = "ÿù|ÿû|ÿü|\x00\r|\xff\xfb\x01\x00|\xff\xfa\x56\xff\xf0|x00|\r"
nline = re.Replace(line, "")
re.Pattern = "\x1b\[[0-9;]*[ ]*[a-zA-Z]"
nline = re.Replace(nline, "")
re.Pattern = "\!\!SOUND\([A-Za-z0-9./]+.*\)"
nline = re.Replace(nline, "")
re.Pattern = ".*\n?"
set Matches = re.Execute(nline)
For Each Match in Matches
TTSObject.SayString Match, 0
next
end if
end sub

'this event is called when a broadcastPlugin event occurs.
sub OnPluginBroadcast (msg, id, name, text)
if msg = 887 then
TTSObject.SayString text,0
elseIf msg = 8874 then
TTSObject.SayString text,1
end if
end sub

'this event is called when the user presses tab and a completion is called.
sub onPluginTabComplete(s)
TTSObject.SayString s, 0
end sub
]]>
</script>


<!--  Plugin help  -->

<aliases>
  <alias
   script="OnHelp"
   match="TTS_jFW:help"
   enabled="y"
  >
  </alias>
</aliases>

<script>
<![CDATA[
Sub OnHelp (sName, sLine, wildcards)
  world.Note world.GetPluginInfo (world.GetPluginID, 3)
End Sub
]]>
</script> 

</muclient>
