View previous topic :: View next topic |
Author |
Message |
simo Owner
Joined: 22 Mar 2015 Posts: 969
|
Posted: Wed Aug 10, 2022 10:46 am Post subject: strip ~ anywhere in the mask and replace with * |
|
|
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: |
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
}
|
|
|
Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1057 Location: France
|
Posted: Wed Aug 10, 2022 10:52 am Post subject: |
|
|
Use regsub:
Code: | regsub -all -- ~ $chost \* chost |
Test:
Code: | % set chost nick!~ident@host
nick!~ident@host
% regsub -all -- ~ $chost \* chost
1
% puts $chost
nick!*ident@host |
_________________ https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community. |
|
Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 969
|
Posted: Wed Aug 10, 2022 11:05 am Post subject: |
|
|
thanks CrazyCat that seems to work |
|
Back to top |
|
 |
|