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.

strip ~ anywhere in the mask and replace with *

Help for those learning Tcl or writing their own scripts.
Post Reply
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

strip ~ anywhere in the mask and replace with *

Post by simo »

greetz gentz,

im using a small code to add users in eggdrop access list and am wondering how to replace ~ with * in a mask like nick!~ident@host
heres the code we use:

Code: Select all

bind pub m !adduser pub_adduser


proc pub_adduser {nick host handle channel testes} {
set who [lindex [split $testes] 0 ]
set who "[string trimleft $who "+@"]"

set accesschan [lindex [split $testes] 1 ]
 

if {[matchattr $who +n]} {  putserv "NOTICE $nick :You Cannot Change An Owner's Attributes." ; return 1 }

 if {$who eq ""} { putnow "notice $nick :Syntax is: !adduser \<nick\> \<channel\> or !adduser \<nick\>" ; return 0 }
 if {$accesschan eq ""} { set accesschan "$channel" }

  if {![onchan $who $accesschan]} {
  putserv "NOTICE $nick :$who isn't on $accesschan."
  return 1
}


			if {[set chost [getchanhost $who $accesschan]] ne ""} {
				switch -glob -- $chost {
					{*.irccloud.com} - {*.mibbit.com} - {*.kiwiirc.com} - {*2001*67c*2f08*} - {*192.184.8.*} - {*192.184.9.*} - {*192.184.9.*} - {*192.184.10.*} {
                         set accessmask "[string trimleft [lindex [split $chost @] 0] "~"]"
				       set what "*!*[string tolower [string range $accessmask 1 end]]@*"
					}
					{default} {
                           set what [maskhost $who!$chost 5]
					}
				}
}



  adduser $who 
 chattr $who |+o $accesschan
 setuser $who HOSTS $what
 putserv "NOTICE $nick :Added $who to User-Database."
 return 1
}
 
User avatar
CrazyCat
Revered One
Posts: 1216
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Use regsub:

Code: Select all

regsub -all -- ~ $chost \* chost
Test:

Code: Select all

% set chost nick!~ident@host
nick!~ident@host
% regsub -all -- ~ $chost \* chost
1
% puts $chost
nick!*ident@host
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

thanks CrazyCat that seems to work
Post Reply