/usr/share/amsn/plugins/sayit/sayit.tcl is in amsn-data 0.98.9-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | #TODO:
#
# * have an option to have URL's replaced by "URL" for reading
# * incomming messages should be queued, now they play through eachother (linux only?)
namespace eval ::sayit {
variable config
variable configlist
proc InitPlugin { dir } {
if { $::tcl_platform(platform) == "windows" } {
if {[string equal $::version "0.94"]} {
load [file join $dir winutils.dll]
} else {
package require WinUtils
}
}
::plugins::RegisterPlugin sayit
::plugins::RegisterEvent sayit chat_msg_received newmessage
if { [::plugins::CheckRequirements "0.95"] } {
::plugins::RegisterEvent sayit ContactListColourBarDrawn draw
}
array set ::sayit::config {
voice {}
linpath {festival}
snd_server_lin {0}
showswitch {0}
sayiton {1}
notonfocus {1}
unfocusstring {$nickname writes $msg}
junkfilter {0}
}
set ::sayit::configlist [list \
[list str "Voice (Mac only)" voice] \
[list str "Path to festival (Linux)" linpath] \
[list bool "Sound server running (Linux)" snd_server_lin] \
[list bool "Don't say message for focussed windows" notonfocus] \
[list bool "Show switch in contactlist (need 0.95)" showswitch] \
[list str "String to say when unfocused" unfocusstring] \
[list bool "Filter out smileys" junkfilter] \
]
}
proc newmessage {event evpar} {
variable config
upvar 2 $evpar newvar
upvar 2 $newvar(msg) msg
upvar 2 $newvar(user) user
#Define the 3 variables, email, nickname and message
set email $user
set nickname [::abook::getDisplayNick $user]
if { ($email != [::config::getKey login]) && \
((!$config(notonfocus)) || ([focus] == "")) && \
((!$config(showswitch)) || $config(sayiton)) && \
($msg != "") \
} {
# junkfilter
#
# TODO:
# * Add extra filter level: remove '...' and similar junk.
if { ($config(junkfilter)) } {
foreach smiley [array names ::emotions] {
while { ([set hit [lsearch $msg $smiley]] != -1) } {
set msg [lreplace $msg $hit $hit]
}
}
}
if { (![string compare $msg ""]) } { return }
# if window unfocused, use special string
if { ([focus] == "") } {
set msg [subst $config(unfocusstring)]
}
if { $::tcl_platform(platform) == "windows" } {
after 0 [list WinSayit "$msg"]
} elseif { $::tcl_platform(os)== "Linux" } {
if {$config(snd_server_lin)==1} {
exec echo "(Parameter.set 'Audio_Method 'Audio_Command)(Parameter.set 'Audio_Command \"esdplay \$FILE\")(Parameter.set 'Audio_Required_Format 'snd)(SayText \"$msg\")" | festival
} else {
exec echo \"$msg\" | $config(linpath) --tts &
}
} else {
if {$config(voice)!=""} {
exec say -v $config(voice) $msg
} else {
exec say $msg
}
}
}
}
proc draw {event evPar} {
upvar 2 $evPar vars
variable config
if { $config(showswitch) } {
set imag $::pgBuddyTop.mystatus.xxxsayit
if { $config(sayiton) == 1} {
label $imag -image [::skin::loadPixmap bell] -bg [::skin::getKey contactlistbg]
} else {
label $imag -image [::skin::loadPixmap belloff] -bg [::skin::getKey contactlistbg]
}
$imag configure -cursor hand2 -borderwidth 0 -padx 0 -pady 0
$::pgBuddyTop.mystatus window create [$::pgBuddyTop.mystatus index "1.0 lineend"] -window $imag -padx 5 -pady 0
bind $imag <Button1-ButtonRelease> "::sayit::togglespeach"
}
}
proc togglespeach { } {
variable config
if { $config(sayiton) == 1 } {
set config(sayiton) 0
} else {
set config(sayiton) 1
}
::cmsn_draw_online
}
}
|