This is one of those annoying talker scripts.
I wrote it becuase I got tired of seeing talkers with hundreds of if statments in them.... This one lets you add your own through a handy dialog... Hope you guys enjoy it. And let me know of any issuses.
There are no defaults with this one. However, this one allows you to maintain multiple lists.... Im looking for people to test it, give suggestions and let me know of any errors.
Thanks to Msmo from #mircscripting As he wrote most of my regex.
Please Note. If you have any on input events halting the input, this script will not work. You could take the input from here and combine it with yours. But I check if the input is halted in my on input event.
This must be loaded from a file. Not pasted into the scripts editor. The On start event doesnt trigger right otherwise.
This script as with all of mine is open to anyone for modifications. You dont have to ask, and I only ask that you include some sort of credit or a link back to this snippet.
; Thanks to Msmo and everyone else in #mircscripting for their help with my regex woes.
; He pretty much wrote all my regex for me, but at least I have a better understanding now.
;
; There is no need whatsoever to edit this script.
; Doing so will most likely break it.
; Everything you need to do is accessible through the dialog and popup menu.
;
on *:start: {
if (!isdir($+(",$scriptdir,data\"))) mkdir $+(",$scriptdir,data\")
hmake yoinx.talker.settings
if ($exists($+(",$scriptdir,data\,yoinx.talker.settings.hsh"))) hload yoinx.talker.settings $+(",$scriptdir,data\,yoinx.talker.settings.hsh")
if ($exists($+(",$scriptdir,data\,$hget(yoinx.talker.settings,current),.tlk,"))) {
hmake $+(yoinx.talker.,$hget(yoinx.talker.settings,current))
hload $+(yoinx.talker.,$hget(yoinx.talker.settings,current)) $+(",$scriptdir,data\,$hget(yoinx.talker.settings,current),.tlk,")
}
else {
$yoinx.talker.makedefaults
}
}
on *:exit: {
yoinx.talker.closesave
}
on *:unload: {
yoinx.talker.closesave
}
menu channel,query,status {
$+(YoinxTalker,$chr(40),$group(#yoinxtalker).status,$chr(41))
.$iif($group(#yoinxtalker).status == on, off,on):$iif($group(#yoinxtalker).status == on, .disable #yoinxtalker,.enable #yoinxtalker)
.$iif(!$dialog(yoinxtalker),Configure):talkerconfig
}
#yoinxtalker on
on *:input:*: {
if ($left($1,1) != $readini(mirc.ini,text,commandchar)) && (!$halted) {
if ($window($active).type == channel) || ($window($active).type == query) || ($window($active).type == chat) {
$iif($hget(yoinx.talker.settings,defaultcolor),tokenize 32 $v1 $+ $+ $1-)
msg $active $yoinx.talker.converttext($1-)
haltdef
}
}
elseif ($right($1,2-) == me ) && (!$halted) {
if ($window($active).type == channel) || ($window($active).type == query) || ($window($active).type == chat) {
describe $active $yoinx.talker.converttext($($2-,2))
haltdef
}
}
unset %rtext
}
#yoinxtalker end
;#########################
;
; Dialog Tables
;
;##########################
dialog Yoinxtalker {
title "YoinxTalker"
size -1 -1 450 384
option pixels
text "Acronym:", 100, 10 10 52 16
edit "Typed Text", 1, 80 6 100 20, autohs
text "Actual Text:", 101, 10 34 66 16
edit "Text Sent to Chat", 2, 80 30 364 20, autohs
button "Add", 10, 398 6 50 24
box "Current Substitutions:", 103, 8 64 436 252
list 3, 16 96 418 190, sort size extsel hsbar vsbar
text "Acronym: Actual Text", 104, 26 80 132 16
button "Edit Selected", 11, 20 288 74 24
button "Del Selected", 12, 358 288 74 24
button "Close", 13, 360 344 74 24, ok cancel
box "Default Color For All Text. Leave Blank for None.", 42, 8 320 252 52
edit "Enter Your Color", 40, 24 344 116 20
button "Save Color", 41, 160 344 74 24
menu "File", 4
item "Load", 51, 4, ok
item "Save", 6, 4, ok
menu "Talkers", 7
menu "Help", 70
item "How To Use This Dialog", 71, 70, ok
item "About", 8, 70, ok
}
dialog Error {
title "Error"
size -1 -1 262 92
option pixels
text "", 1, 8 8 244 48, center
button "OK", 2, 92 66 74 24, ok cancel
}
dialog yoinxtalkerabout {
title "About"
size -1 -1 204 144
option dbu
list 1, 4 4 198 122, size
button "Close", 2, 80 128 37 12, ok cancel
}
dialog yoinxtalkerhelp {
title "Help"
size -1 -1 252 196
option dbu
button "Close", 2, 100 180 37 12, ok cancel
list 1, 4 4 246 174, size
}
;#######################
;
; Dialog Events
;
;#######################
on *:dialog:yoinxtalkerhelp:init:0: {
loadbuf -eothelp $dname 1 $+(",$script,")
}
on *:dialog:yoinxtalkerabout:init:0: {
loadbuf -eotabout $dname 1 $+(",$script,")
}
on *:dialog:yoinxtalker:init:0: {
yoinx.talker.fillmenu
if ($hget(yoinx.talker.settings,DefaultColor)) did -ra yoinxtalker 40 $hget(yoinx.talker.settings,DefaultColor)
if (!$window(@Sampletext)) window -da @sampletext $dialog(yoinxtalker).x $calc($dialog(yoinxtalker).y - 50) 456 50
}
on *:dialog:yoinxtalker:close:0: {
hdel -w yoinx.talker.settings 5??
hsave -o $+(Yoinx.talker.,$hget(yoinx.talker.settings,current)) $+(",$scriptdir,data\,$hget(yoinx.talker.settings,current),.tlk,")
if ($window(@Sampletext)) window -c @sampletext
}
on *:dialog:yoinxtalker:edit:2: {
if ($window(@Sampletext)) {
if ($line(@Sampletext,1)) dline @sampletext 1
if ($did($dname,2).text) aline @sampletext $did(yoinxtalker,2).text
}
}
on *:dialog:yoinxtalker:menu:*: {
if ($did > 500) {
if ($did($dname,$did).text != $hget(yoinx.talker.settings,current)) {
hmake $+(yoinx.talker.,$did($did).text)
if ($exists($+(",$scriptdir,data\,$did($did).text,.tlk,"))) hload $+(yoinx.talker.,$did($did).text) $+(",$scriptdir,data\,$did($did).text,.tlk,")
else hsave -o $+(yoinx.talker.,$did($did).text) $+(",$scriptdir,data\,$did($did).text,.tlk,")
yoinx.talker.switchmenu $did($did).text
}
}
elseif ($did == 51) {
var %file = $$?="Name Your List."
var %file = $remove($replace(%file,$chr(32),__),/,\,*)
if ($exists($+(",$scriptdir,data\,%file,.tlk,"))) {
dialog -md error error
did -a error A file By that name already exists
halt
}
else {
hmake $+(yoinx.talker.,%file)
hsave -o $+(yoinx.talker.,%file) $+(",$scriptdir,data\,%file,.tlk,")
yoinx.talker.switchmenu %file new
}
}
elseif ($did == 52) {
var %file = $sfile($+(",$scriptdir,data\,*.tlk),Select A File:)
if (%file) {
if ($exists($+(",$scriptdir,data\,$nopath(%file),"))) {
dialog -md error error
did -a error A file already exists by the name $+(",$nopath(%file),")
halt
}
else {
.rename $+(",%file,") $+(",$scriptdir,data\,$nopath(%file),")
yoinx.talker.switchmenu $left($nopath(%file),-4) new
}
}
}
elseif ($did == 54) {
.remove $+(",$scriptdir,data\,$hget(yoinx.talker.settings,current),.tlk")
hfree $+(yoinx.talker.,$hget(yoinx.talker.settings,current))
hdel yoinx.talker.settings current
hdel -w yoinx.talker.settings 5*
dialog -x yoinxtalker yoinxtalker
.timer 1 0 talkerconfig
}
elseif ($did == 71) {
dialog -md yoinxtalkerhelp yoinxtalkerhelp
}
elseif ($did == 72) {
dialog -md yoinxtalkerabout yoinxtalkerabout
}
}
on *:dialog:yoinxtalker:sclick:10: {
if ($numtok($did(yoinxtalker,1).text,32) != 1) {
dialog -md error error
did -ra error 1 You Can Only Specify One Word As The Acronym
}
elseif ($did(yoinxtalker,2).text == $null) {
dialog -md error error
did -ra error 1 You Must Specify Something To Replace $+(",$did(yoinxtalker,1).text,") With.
}
elseif ($regex($did(yoinxtalker,1).text,/[[:cntrl:]]/g)) {
dialog -md error error
did -ra error 1 Your Acro cannot ccontain control codes. Color, Underline, Bold, or Reverse.
}
elseif ($hget($+(Yoinx.talker.,$hget(yoinx.talker.settings,current)),$did(yoinxtalker,1).text)) {
dialog -md error error
did -ra error 1 $+(",$did(yoinxtalker,1).text,") already exists in your list. Please edit/delete it first.
}
else {
hadd -m $+(Yoinx.talker.,$hget(yoinx.talker.settings,current)) $upper($did(yoinxtalker,1).text) $did(yoinxtalker,2).text
did -a yoinxtalker 3 $upper($+($did(yoinxtalker,1).text,:)) $did(yoinxtalker,2).text
did -r yoinxtalker 1
did -r yoinxtalker 2
did -z yoinxtalker 3
if ($window(@Sampletext)) {
if ($line(@Sampletext,1)) dline @sampletext 1
}
}
}
on *:dialog:yoinxtalker:sclick:11: {
if ($did(yoinxtalker,3).seltext == $null ) {
dialog -md error error
did -ra error 1 You Must Select At Least One Line to Edit.
}
elseif ($did(yoinxtalker,3,0).sel > 1 ) {
dialog -md error error
did -ra error 1 You Can Only Select One Line To Edit.
}
else {
did -ra yoinxtalker 1 $left($gettok($did(yoinxtalker,3).seltext,1,32),-1)
did -ra yoinxtalker 2 $hget($+(yoinx.talker.,$hget(yoinx.talker.settings,current)),$left($gettok($did(yoinxtalker,3).seltext,1,32),-1))
hdel $+(Yoinx.talker.,$hget(yoinx.talker.settings,current)) $left($gettok($did(yoinxtalker,3).seltext,1,32),-1)
did -d yoinxtalker 3 $did(yoinxtalker,3).sel
did -z yoinxtalker 3
if ($window(@Sampletext)) {
if ($line(@Sampletext,1)) dline @sampletext 1
aline @sampletext $did(yoinxtalker,2).text
}
}
}
on *:dialog:yoinxtalker:sclick:12: {
if ($did(yoinxtalker,3).seltext == $null ) {
dialog -md error error
did -ra error 1 You Must Select At Least One Line to Delete.
}
else {
while ($did(yoinxtalker,3,1).sel) {
hdel $+(Yoinx.talker.,$hget(yoinx.talker.settings,current)) $left($gettok($did(yoinxtalker,3).seltext,1,32),-1)
did -d yoinxtalker 3 $did(yoinxtalker,3,1).sel
did -z yoinxtalker 3
}
}
}
on *:dialog:yoinxtalker:sclick:41: {
if ($did(yoinxtalker,40).text) {
if ($regex($did(yoinxtalker,40).text,/(?:\cc(?:\d\d?(?:,\d\d?)?)?)/) != 1) {
dialog -md error error
did -ra error 1 You must enter a Color Code, If you want to enter anything. ONLY enter a color code though.
}
else {
hadd -m yoinx.talker.settings DefaultColor $did(yoinxtalker,40).text
}
}
else {
if ($hget(yoinx.talker.settings,defaultcolor)) hdel yoinx.talker.settings defaultcolor
}
}
;######################
;
; Aliases
;
;#######################
alias talkerconfig {
dialog -dm yoinxtalker yoinxtalker
}
alias yoinx.talker.converttext {
var %text = $1-
.echo -q $regex(color,%text,/(\cc(?:\d\d?(?:,\d\d?)?)?)/g))
.echo -q $regsub($strip($1-,burc),/[-!.() $+ $chr(44) $+ ']/g,,%rtext)
var %x = 1
var %hashtable = $+(yoinx.talker.,$hget(yoinx.talker.settings,current))
var %regex = $+(/,$chr(40),?:,$replace(%rtext,$chr(32),$chr(124)),$chr(41),/Si)
while (%x <= $hfind(%hashtable,%regex,0,r)) {
var %word = $hfind(%hashtable,%regex,%x,r)
.echo -q $regsub(%text,/(^|(?<!\w)(?:\cc(?:\d\d?(?:,\d\d?)?)?)++(?:\x02\x02?)\x31?|\x02|\x31|[[:punct:]]|\s) $+ %WORD $+ (?!\w)/ig,$+(\1,$hget(%hashtable,%word),$regml(color,1)),%text)
inc %x
}
return %text
}
alias yoinx.talker.closesave {
if ($hget(yoinx.talker.settings,current)) hsave -o $+(yoinx.talker.,$hget(yoinx.talker.settings,current)) $+(",$scriptdir,data\,$hget(yoinx.talker.settings,current),.tlk,")
hdel -w yoinx.talker.settings 5*
hsave -o yoinx.talker.settings $+(",$scriptdir,data\yoinx.talker.settings.hsh,")
}
alias yoinx.talker.makedefaults {
hmake yoinx.talker.default
hadd yoinx.talker.default LOL Laughing Out Loud
hadd yoinx.talker.default BBIAB Be Back In A Bit
hadd yoinx.talker.default BRB Be Right Back
hadd yoinx.talker.default BBIAM Be Back In A Minute
hadd yoinx.talker.default BTW By The Way
hadd yoinx.talker.default LMAO Laughing My Ass Off
hadd yoinx.talker.default RTFM Read The Fucking Manual
hadd yoinx.talker.default ROFLMAO Rolling On The Floor Laughing My Ass Off
hadd yoinx.talker.default ROFL Rolling On The Floor
hadd yoinx.talker.default BBIAW Be Back In A While
hadd -m yoinx.talker.settings current default
hsave -o yoinx.talker.default $+(",$scriptdir,data\,default.tlk,")
return
}
alias yoinx.talker.fillmenu {
if ($hget(yoinx.talker.settings,501)) {
hdel -w yoinx.talker.settings 5*
$yoinx.talker.clearmenu($1)
}
if (!$hget(yoinx.talker.settings,current)) || (!$exists($+(",$scriptdir,data\,$hget(yoinx.talker.settings,current),.tlk,"))) {
$yoinx.talker.makedefaults
}
var %x = 1
while (%x <= $findfile($+(",$scriptdir,data\,"),*.tlk,0)) {
did -a yoinxtalker 500 $calc(500 + %x) $left($nopath($findfile($+(",$scriptdir,data\,"),*.tlk,%x)),-4)
hadd -m yoinx.talker.settings $calc(500 + %x) $left($nopath($findfile($+(",$scriptdir,data\,"),*.tlk,%x)),-4)
inc %x
}
yoinx.talker.checkmenu
}
alias yoinx.talker.clearmenu {
if ($1 == new) {
var %x = 1
while (%x < $findfile($+(",$scriptdir,data\,"),*.tlk,0)) {
did -d yoinxtalker $calc(500 + %x)
inc %x
}
}
else {
var %x = 1
while (%x <= $findfile($+(",$scriptdir,data\,"),*.tlk,0)) {
did -d yoinxtalker $calc(500 + %x)
inc %x
}
}
return
}
alias yoinx.talker.checkmenu {
if (!$hget(yoinx.talker.settings,current)) || (!$exists($+(",$scriptdir,data\,$hget(yoinx.talker.settings,current),.tlk,"))) {
if ($hfind(yoinx.talker.settings,default,1).data != current ) {
did -c yoinxtalker $hfind(yoinx.talker.settings,default,1).data
}
else {
did -c yoinxtalker $hfind(yoinx.talker.settings,default,2).data
}
$yoinx.talker.makedefaults
}
else {
if ($hfind(yoinx.talker.settings,$hget(yoinx.talker.settings,current),1).data != current ) {
did -c yoinxtalker $hfind(yoinx.talker.settings,$hget(yoinx.talker.settings,current),1).data
}
else {
did -c yoinxtalker $hfind(yoinx.talker.settings,$hget(yoinx.talker.settings,current),2).data
}
}
yoinx.talker.filltext
}
alias yoinx.talker.switchmenu {
hsave -o $+(yoinx.talker.,$hget(yoinx.talker.settings,current)) $+(",$scriptdir,data\,$hget(yoinx.talker.settings,current),.tlk,")
hfree $+(yoinx.talker.,$hget(yoinx.talker.settings,current))
if ($hfind(yoinx.talker.settings,$hget(yoinx.talker.settings,current),1).data != current ) {
did -u yoinxtalker $hfind(yoinx.talker.settings,$hget(yoinx.talker.settings,current),1).data
}
else {
did -u yoinxtalker $hfind(yoinx.talker.settings,$hget(yoinx.talker.settings,current),2).data
}
hadd -m yoinx.talker.settings current $1
yoinx.talker.fillmenu $2
}
alias yoinx.talker.filltext {
did -r yoinxtalker 3
var %x = 1
while (%x <= $hget($+(yoinx.talker.,$hget(yoinx.talker.settings,current)),0).item) {
did -a yoinxtalker 3 $hget($+(yoinx.talker.,$hget(yoinx.talker.settings,current)),%x).item $+ : $hget($+(yoinx.talker.,$hget(yoinx.talker.settings,current)),%x).data
inc %x
}
did -z yoinxtalker 3
}
[help]
This Script will replace any occurance of you acro in anything you type
while it is turned on. Right Click the channel to turn it off.
You can have multiple acro/talker lists. They'll all show up under the
Talkers Menu. The current one is marked with a checkmark. And is the only
one that will perform replacements when you type. You can select a new
active one from the talkers menu.
New:
File > New - Enter a Name for the talker list.
Avoid Spaces and special characters. This list will be blank.
Also it will show up in the talkers menu.
Load:
You can load other people's lists by either placing them in
$+(",$scriptdir,data\,")
or, you can use the load function File > Load
Its pretty straight forward.
To Add New Acros:
In the Top Edit Box add the acronym.
In the Bottom Box, add the text with codes you want to have replace the acronym.
Then click add.
Note:
Ctrl+k For colors - These are automatically closed.
----These must have a second one at the end of the text. If not, they will
----carry on throughout the rest of your text when you type an acro.
----Otherwise, the first color code (if there is one) will be replaced after
----The substitution.
Ctrl+U Underline
Crtl+B Bold
[about]
This is my first attempt at an Acro/Talker Script.
Please Let me know if you enjoy it.
I tried to make it as dynamic as possible...
However, that means that there may be issues
that I did not come accross in my testing.
Please let me know of any errors, and what you
were doing when you got the error.
Email them to:
Yoinx@graffiti.net Subject: Acro/Talker Script Error
Thanks.
Hey im getting this error ive gotten it 3 times so far and i dont knowwhat i was doing when i got it
/did: \'yoinxtalker\' invalid id \'500\' (line 309, script4.mrc)
This is line 309
did -a yoinxtalker 500 $calc(500 + %x) $left($nopath($findfile($+(\",$scriptdir,data\,\"),*.tlk,%x)),-4)
I dont know what thats about but just letting you know.
Yeah, i noticed that... that was kinda weird. I know they work in mine that i have loaded now, so I reposted that code. Also, the on start event doesnt seem to trigger all the time when You paste in the scripts editor. Try loading it via a filename.mrc /load -rs filename.mrc
Also, what do you mean the dialog is too big. I can use it on a laptop running 800x600 with no problems, and it doesnt take up the entire thing.. Anything smaller would make it hard to read.
upon loading and just opeing the dialog threw your given popups in the channel i get this error
i used the help popup in the edit menu of the dialog it opened blank with this error
same with the about dialog
i used the add and load feature threw the menu itmes and came up with these errors
over all great idea a few bugs and much needed dialog designing much smaller if possiable
yeah, I didnt take offense. Like I said, If someone says they did the colors, i\'ll put them in. None of the coding was ripped. just the colors and designs for the default substituitons...
@Zachery...
on :input:: {
if ($left($1,1) != $readini(mirc.ini,text,commandchar)) && (!$halted) {
var %x = 1
while (%x <= $0) {
if ($hget(yoinx.talker,$($+($,%x),2))) {
if (%x == 1) {
var %text = $hget(yoinx.talker,$($+($,%x),2))
}
else {
var %text = $+(%text,$chr(32),$hget(yoinx.talker,$($+($,%x),2)),)
}
}
else {
if (%x == 1) {
var %text = $($+($,%x),2)
}
else {
var %text = $+(%text,$chr(32),$($+($,%x),2))
}
}
inc %x
}
msg $active %text
haltdef
}
}
replace the group with that, and it will do the replacements anywhere in your text.
because, the other script had no credit tags, it was only an don input event with a bunch of if\'s. I just didnt feel like doing all the colors and what not for some defaults...
the idea of this script wasnt to provide the colors and all that... But to make a talker to provide a user friendly way of making their own custom words. without scripting anything. Also. this talker uses 3 evaluations in an if/then/else. Most of the talkers Ive seen are a hundred or so lines of ifs.... which means, you check 100 if\'s if you type the word that is in the last if.
Quoting Yoinx \"; The defaults that get loaded are kinda girlie.
; I borrowed them from another script with no credits.
; If they are yours, let me know... I\'ll give you the credit for them.\"
@ Roninwarrior, the default words were the only ones borrowed, not the script which is made by Yoinx himself.