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.

Add user flag if nick gets opped via ChanServ

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Add user flag if nick gets opped via ChanServ

Post by simo »

greetings folks,

Some of our chanops and admins on danet dont have a fixed IP/HOST to grant them user flag based on their IP/HOST
so i thought of a concept of adding their user with chattr -|+o $chan the moment they are opped via ChanServ or chattr -|+v if they are halfopped via Chanserv that way we confirm their adminship in channel regardless of their IP/HOST, and the moment they part channel or quit IRC to del their user , oh and i forgot to mention in the case of a random chanadmin opping a random user and chanserv deops them instant as they arent in admin access list of the channel to make sure the user isnt added.



This is what i have so far and im not sure where to go from here :

Code: Select all


bind MODE - * Access:Cmodes_Check

proc Access:Cmodes_Check {nick uhost hand chan mode target} {
          set hnick [nick2hand $target]
        if {[isbotnick $target] || ![string match -nocase {ChanServ} "$nick"] || [matchattr $hnick +n] || [matchattr $hnick +m]} { return 0 }

     set uhostarget "[getchanhost $target]"
     set site "[lindex [split $uhostarget "@"] 1]"

     if {[string match -nocase "*.irccloud.com" $site]} {  
                   set ident [string trimleft [lindex [split $uhostarget @] 0] "~"]
                   set xbmaskx [string map {sid id uid id} $ident]
                   set addmask  *!*$xbmaskx@*
                  }  else {
                    set addmask  "*!*@$site"
                  }

           
             switch $mode {
                "+o" { if {![validuser $hand]} { adduser $who ; chattr $target |+o $chan } }
                "+h" { if {![validuser $hand]} { adduser $who ; chattr $target |+v $chan }  }
}

 
bind part - * Part-Check-Access:Remove
proc Part-Check-Access:Remove {nick uhost hand chan text} {
   if {[isbotnick $target] || [matchattr $hand +n] || [matchattr $hand +m]} { return 0 }
   if {[validuser $hand] && [matchattr $hand -|o $chan] || [matchattr $hand -|v $chan]} { deluser $hand }
}


bind sign - * Quit-Check-Access:Remove
proc Quit-Check-Access:Remove {nick uhost hand chan reason} {
      if {[isbotnick $target] || [matchattr $hand +n] || [matchattr $hand +m]} { return 0 }
      if {[validuser $hand] && [matchattr $hand -|o $chan] || [matchattr $hand -|v $chan]} { deluser $hand }
}



Thanks in advance.
User avatar
CrazyCat
Revered One
Posts: 1304
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Re: Add user flag if nick gets opped via ChanServ

Post by CrazyCat »

Do you know that you can now use things based on account ?
https://docs.eggheads.org/using/accounts.html
https://docs.eggheads.org/using/tcl-com ... me-channel and also bind account:

Code: Select all

bind account <flags> <mask> <proc>

    procname <nick> <user> <hand> <chan> <account>

    Description: this bind will trigger when eggdrop detects a change in the authentication status of a user’s service account. The mask for the bind is in the format “#channel nick!user@hostname.com account” and accepts wildcards. account is either the account name the user is logging in to or “*” if the user is not logged in to an account.

    NOTE: the three required IRC components for account tracking are: the WHOX feature, the extended-join IRCv3 capability and the account-notify IRCv3 capability. if only some of the three feature are available, eggdrop provides best-effort account tracking but this bind could be triggered late or never on account changes. Please see doc/ACCOUNTS for additional information.
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Re: Add user flag if nick gets opped via ChanServ

Post by simo »

Thanks for your reply CrazyCat but since we use this on dalnet wich afaik doesnt use account based checks (IRCV3)
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Re: Add user flag if nick gets opped via ChanServ

Post by simo »

ive tested with this but it seems to randomly trigger on random channel mode setting :

Code: Select all



#bind MODE - * Access:Cmodes_Check


proc Access:Cmodes_Check {nick uhost hand chan mode target} {
          set hnick [nick2hand $target]
            if {[isbotnick $target] || ![string match -nocase {ChanServ} "$nick"] || [matchattr $hnick +n] || [matchattr $hnick +m]} { putlog "«owner/master ignored»" ; return 0 }

             switch $mode {
                "+o" { after [expr {2*1000*1}] [list Delayed-Access:Cmodes_Check $nick $uhost $hand $chan $mode $target] }
                "+h" { after [expr {2*1000*1}] [list Delayed-Access:Cmodes_Check $nick $uhost $hand $chan $mode $target]  }
  }                  

}


proc Delayed-Access:Cmodes_Check {nick uhost hand chan mode target} {
        set hnick [nick2hand $target]

        if {[isbotnick $target] || ![string match -nocase {ChanServ} "$nick"] || [matchattr $hnick +n] || [matchattr $hnick +m]} { return 0 }

         if {![isop $target] && ![ishalfop $target]} { return 0 } 

         set uhostarget "[getchanhost $target]"
         set site "[lindex [split $uhostarget "@"] 1]"

     if {[string match -nocase "*.irccloud.com" $site]} {  
                   set ident [string trimleft [lindex [split $uhostarget @] 0] "~"]
                   set xbmaskx [string map {sid id uid id} $ident]
                   set addmask  *!*$xbmaskx@*.irccloud.com
                  }  else {
                    set addmask  "*!*@$site"
                  }

           
             switch $mode {
                "+o" { if {![validuser $target]} { adduser $target ; chattr $target -|+o $chan ; setuser $target HOSTS $addmask } }
                "+h" { if {![validuser $target]} { adduser $target ; chattr $target -|+o $chan ; setuser $target HOSTS $addmask }  }
  }
}
             

   


bind part - * Part-Check-Access:Remove
proc Part-Check-Access:Remove {nick uhost hand chan text} {
   if {[isbotnick $nick] || [matchattr $hand +n] || [matchattr $hand +m]} { return 0 }
   if {[validuser $hand] && [matchattr $hand -|o $chan]} { deluser $hand }
}


bind sign - * Quit-Check-Access:Remove
proc Quit-Check-Access:Remove {nick uhost hand chan reason} {
      if {[isbotnick $nick] || [matchattr $hand +n] || [matchattr $hand +m]} { return 0 }
      if {[validuser $hand] && [matchattr $hand -|o $chan]} { deluser $hand }
}



Post Reply