egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

matching capped nicks

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive
View previous topic :: View next topic  
Author Message
WulfMan72
Voice


Joined: 12 Oct 2005
Posts: 23
Location: Massachusetts

PostPosted: Wed Oct 12, 2005 11:06 am    Post subject: matching capped nicks Reply with quote

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
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Wed Oct 12, 2005 1:05 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
WulfMan72
Voice


Joined: 12 Oct 2005
Posts: 23
Location: Massachusetts

PostPosted: Wed Oct 12, 2005 1:11 pm    Post subject: Reply with quote

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
View user's profile Send private message
greenbear
Owner


Joined: 24 Sep 2001
Posts: 733
Location: Norway

PostPosted: Wed Oct 12, 2005 3:23 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Wed Oct 12, 2005 7:11 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
WulfMan72
Voice


Joined: 12 Oct 2005
Posts: 23
Location: Massachusetts

PostPosted: Wed Oct 12, 2005 8:50 pm    Post subject: Reply with quote

Thanks guys, I really appreciate it Smile
Back to top
View user's profile Send private message
WulfMan72
Voice


Joined: 12 Oct 2005
Posts: 23
Location: Massachusetts

PostPosted: Mon Oct 17, 2005 4:51 pm    Post subject: Reply with quote

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
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Mon Oct 17, 2005 5:09 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
WulfMan72
Voice


Joined: 12 Oct 2005
Posts: 23
Location: Massachusetts

PostPosted: Mon Oct 17, 2005 5:20 pm    Post subject: Reply with quote

thanks again Fz, it's been giving me fits Smile
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber