View previous topic :: View next topic |
Author |
Message |
WulfMan72 Voice
Joined: 12 Oct 2005 Posts: 23 Location: Massachusetts
|
Posted: Wed Oct 12, 2005 11:06 am Post subject: matching capped nicks |
|
|
I'm writing a script and I'd like to be able to have it analyze a nick on join and determine if it's Capitalized or not.
the other aspect is, that since IRC nicks can have special characters as their first character, I'd need to strip it of all special characters before checking for a capped up nick.
any help would be appreciated |
|
Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Wed Oct 12, 2005 1:05 pm Post subject: |
|
|
This should strip all characters other than [A-z]:
Code: | regsub -all -- {[^A-z]|\^} $string "" string |
and to check if the string is all in upper case:
Code: | string is upper $string |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
Back to top |
|
 |
WulfMan72 Voice
Joined: 12 Oct 2005 Posts: 23 Location: Massachusetts
|
Posted: Wed Oct 12, 2005 1:11 pm Post subject: |
|
|
ty Fz, what about just to check if the first letter of a nick is uppercase? is there a way to do that with an eggdrop? |
|
Back to top |
|
 |
greenbear Owner
Joined: 24 Sep 2001 Posts: 733 Location: Norway
|
Posted: Wed Oct 12, 2005 3:23 pm Post subject: |
|
|
Returns 1 if it starts with a capital letter or a number, 0 if doesnt.
Code: | proc firstup {var} {
set first [string range $var 0 0]
if {![string isupper $first] && ![string is digit $first]} {
return 0
} {
return 1
}
} |
|
|
Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Wed Oct 12, 2005 7:11 pm Post subject: |
|
|
This should do it as well:
Code: | regexp -- {^[A-Z]} $string |
returns 1 if the first letter of $string is a capital letter, 0 otherwise.
OR
Code: | string is upper [string index $string 0] |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
Back to top |
|
 |
WulfMan72 Voice
Joined: 12 Oct 2005 Posts: 23 Location: Massachusetts
|
Posted: Wed Oct 12, 2005 8:50 pm Post subject: |
|
|
Thanks guys, I really appreciate it  |
|
Back to top |
|
 |
WulfMan72 Voice
Joined: 12 Oct 2005 Posts: 23 Location: Massachusetts
|
Posted: Mon Oct 17, 2005 4:51 pm Post subject: |
|
|
ok, here's what I have for my script so far, I wanna add the lines from the above posts to have it check if the nick Starts with a capitol letter before it runs the proc.
Code: | bind join - * servjoin
proc servjoin {nick hand u@h chan} {
if { [validuser $nick] == 1 } {
user-set $nick XTRA status "AWS"
}
return 0
}
|
Code: | regsub -all -- {[^A-z]|\^} $string "" string
regexp -- {^[A-Z]} $string |
can anyone show me exactly how to set up those two lines so the code will only trigger if the nick of the person who triggers it is capped? |
|
Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Mon Oct 17, 2005 5:09 pm Post subject: |
|
|
You simply use them in an if-statement. for example:
Code: | if {[regexp -- {^[A-Z]} $string]} {
# do whatever...
} |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
Back to top |
|
 |
WulfMan72 Voice
Joined: 12 Oct 2005 Posts: 23 Location: Massachusetts
|
Posted: Mon Oct 17, 2005 5:20 pm Post subject: |
|
|
thanks again Fz, it's been giving me fits  |
|
Back to top |
|
 |
|