This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

string match spanish accents

Help for those learning Tcl or writing their own scripts.
Post Reply
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

string match spanish accents

Post by juanamores »

Code: Select all

bind pubm - * who_emit
proc who_emit {nick uhost hand chan text} {
global dj
if {($text eq "Quien esta emitiendo?") || ([string match "Quien está emitiendo?" $text]) {
putmsg $chan "Emite Dj $dj"
}}
Not match the second condition for the accent "á"
<user> Quien esta emitiendo?
<bot> Emite Dj Roger
<user> Quien está emitiendo?
Besides accents, you can be fixed to coincide with additional question marks?
ie:
Quien está emitiendo??
or
Quien está emitiendo?????
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Post by juanamores »

I have fixed thanks to SpiKe^^

Code: Select all

proc who_emit {nick uhost hand chan text} {
global radiocanal nombreradio counf
	if {$chan != "$radiocanal"} {return 0}
set who1 "Quien emite?"
set who2 "Quien está emitiendo?"
set who3 "Quien esta de dj?"
set whof "?"
if {(([lsearch -exact -ascii -nocase [lindex [split $text] 0 end] [lindex [split $who1] 0 end]] != -1) && ([llength [split $text]] == 2) \
&& ([string index $text end] == "$whof")) \
|| (([lsearch -exact -ascii -nocase [lindex [split $text] 0 end] [lindex [split $who2] 0 end]] != -1) && ([llength [split $text]] == 3) \
&& ([string index $text end] == "$whof")) \
|| (([lsearch -exact -ascii -nocase [lindex [split $text] 0 end] [lindex [split $who3] 0 end]] != -1) && ([llength [split $text]] == 4) && ([string index $text end] == "$whof")) } { 
	if {[file exists dj]} {
    set temp [open "dj" r]
    set dj [gets $temp]
	set dj [lindex $dj 0]
    close $temp
	}
putmsg $chan [encoding convertfrom utf-8 "Our current DJ is $dj"}
}
The code is not case sensitive:

Code: Select all

-nocase
I added a counter along the string, so I did not take as correct portions thereof:

Code: Select all

[llength [split $text]] ==
I also added that work if the text has a question mark at the end, not to take any text expression but leads that sign.

Code: Select all

set whof "?" 
To make the text matched with Spanish accents, I used:

Code: Select all

-ascii
In this example, the current DJ database is:

Code: Select all

[file exists dj]
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
Post Reply