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.

matching capped nicks

Old posts that have not been replied to for several years.
Locked
W
WulfMan72
Voice
Posts: 23
Joined: Wed Oct 12, 2005 11:02 am
Location: Massachusetts

matching capped nicks

Post by WulfMan72 »

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
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

This should strip all characters other than [A-z]:

Code: Select all

regsub -all -- {[^A-z]|\^} $string "" string
and to check if the string is all in upper case:

Code: Select all

string is upper $string
W
WulfMan72
Voice
Posts: 23
Joined: Wed Oct 12, 2005 11:02 am
Location: Massachusetts

Post by WulfMan72 »

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?
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

Returns 1 if it starts with a capital letter or a number, 0 if doesnt.

Code: Select all

proc firstup {var} {
 set first [string range $var 0 0]
 if {![string isupper $first] && ![string is digit $first]} {
  return 0
 } {
  return 1
 }
}
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

This should do it as well:

Code: Select all

regexp -- {^[A-Z]} $string
returns 1 if the first letter of $string is a capital letter, 0 otherwise.

OR

Code: Select all

string is upper [string index $string 0]
W
WulfMan72
Voice
Posts: 23
Joined: Wed Oct 12, 2005 11:02 am
Location: Massachusetts

Post by WulfMan72 »

Thanks guys, I really appreciate it :)
W
WulfMan72
Voice
Posts: 23
Joined: Wed Oct 12, 2005 11:02 am
Location: Massachusetts

Post by WulfMan72 »

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: Select all

bind join - * servjoin
proc servjoin {nick hand u@h chan} {
 if { [validuser $nick] == 1 } {
   user-set $nick XTRA status "AWS"
  }
  return 0
}

Code: Select all

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?
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

You simply use them in an if-statement. for example:

Code: Select all

if {[regexp -- {^[A-Z]} $string]} {
 # do whatever...
}
W
WulfMan72
Voice
Posts: 23
Joined: Wed Oct 12, 2005 11:02 am
Location: Massachusetts

Post by WulfMan72 »

thanks again Fz, it's been giving me fits :)
Locked