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 

strip ~ anywhere in the mask and replace with *

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
simo
Owner


Joined: 22 Mar 2015
Posts: 969

PostPosted: Wed Aug 10, 2022 10:46 am    Post subject: strip ~ anywhere in the mask and replace with * Reply with quote

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


Joined: 13 Jan 2002
Posts: 1057
Location: France

PostPosted: Wed Aug 10, 2022 10:52 am    Post subject: Reply with quote

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


Joined: 22 Mar 2015
Posts: 969

PostPosted: Wed Aug 10, 2022 11:05 am    Post subject: Reply with quote

thanks CrazyCat that seems to work
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help 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