3
# * have an option to have URL's replaced by "URL" for reading
4
# * incomming messages should be queued, now they play through eachother (linux only?)
6
namespace eval ::sayit {
10
proc InitPlugin { dir } {
11
if { $::tcl_platform(platform) == "windows" } {
12
if {[string equal $::version "0.94"]} {
13
load [file join $dir winutils.dll]
15
package require WinUtils
19
::plugins::RegisterPlugin sayit
20
::plugins::RegisterEvent sayit chat_msg_received newmessage
21
if { [::plugins::CheckRequirements "0.95"] } {
22
::plugins::RegisterEvent sayit ContactListColourBarDrawn draw
26
array set ::sayit::config {
33
unfocusstring {$nickname writes $msg}
37
set ::sayit::configlist [list \
38
[list str "Voice (Mac only)" voice] \
39
[list str "Path to festival (Linux)" linpath] \
40
[list bool "Sound server running (Linux)" snd_server_lin] \
41
[list bool "Don't say message for focussed windows" notonfocus] \
42
[list bool "Show switch in contactlist (need 0.95)" showswitch] \
43
[list str "String to say when unfocused" unfocusstring] \
44
[list bool "Filter out smileys" junkfilter] \
48
proc newmessage {event evpar} {
51
upvar 2 $newvar(msg) msg
52
upvar 2 $newvar(user) user
54
#Define the 3 variables, email, nickname and message
56
set nickname [::abook::getDisplayNick $user]
58
if { ($email != [::config::getKey login]) && \
59
((!$config(notonfocus)) || ([focus] == "")) && \
60
((!$config(showswitch)) || $config(sayiton)) && \
66
# * Add extra filter level: remove '...' and similar junk.
68
if { ($config(junkfilter)) } {
69
foreach smiley [array names ::emotions] {
70
while { ([set hit [lsearch $msg $smiley]] != -1) } {
71
set msg [lreplace $msg $hit $hit]
75
if { (![string compare $msg ""]) } { return }
77
# if window unfocused, use special string
78
if { ([focus] == "") } {
79
set msg [subst $config(unfocusstring)]
82
if { $::tcl_platform(platform) == "windows" } {
83
after 0 [list WinSayit "$msg"]
84
} elseif { $::tcl_platform(os)== "Linux" } {
85
if {$config(snd_server_lin)==1} {
86
exec echo "(Parameter.set 'Audio_Method 'Audio_Command)(Parameter.set 'Audio_Command \"esdplay \$FILE\")(Parameter.set 'Audio_Required_Format 'snd)(SayText \"$msg\")" | festival
88
exec echo \"$msg\" | $config(linpath) --tts &
91
if {$config(voice)!=""} {
92
exec say -v $config(voice) $msg
100
proc draw {event evPar} {
103
if { $config(showswitch) } {
104
set imag $::pgBuddyTop.mystatus.xxxsayit
105
if { $config(sayiton) == 1} {
106
label $imag -image [::skin::loadPixmap bell] -bg [::skin::getKey contactlistbg]
108
label $imag -image [::skin::loadPixmap belloff] -bg [::skin::getKey contactlistbg]
110
$imag configure -cursor hand2 -borderwidth 0 -padx 0 -pady 0
111
$::pgBuddyTop.mystatus window create [$::pgBuddyTop.mystatus index "1.0 lineend"] -window $imag -padx 5 -pady 0
113
bind $imag <Button1-ButtonRelease> "::sayit::togglespeach"
117
proc togglespeach { } {
119
if { $config(sayiton) == 1 } {
120
set config(sayiton) 0
122
set config(sayiton) 1