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.

Reop-Mode

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
g
geek
Halfop
Posts: 47
Joined: Fri Oct 24, 2008 6:07 am

Reop-Mode

Post by geek »

hi,
I would like a script that implements the following feature: HERE


something like:
<nick> !reop
<bot> Channel Reop List:
<bot> *!xxx@bla.bla.org
<bot> *!yyy@vhost.net
<bot> *!*@4.3.2.1

<nick> !+reop *!*@2001:67c:0:0:0:0:0:2 *!*@1.2.3.4
<bot> MODE #channel +R *!*@2001:67c:0:0:0:0:0:2
<bot> MODE #channel +R *!*@1.2.3.4
<bot> User(s) added to Reop List

<nick> !-reop *!xxx@bla.bla.org *!*@1.2.3.4
<bot> MODE #channel -R *!xxx@bla.bla.org
<bot> MODE #channel -R *!*@1.2.3.4
<bot> User(s) removed from Reop List
can you help me?
w
willyw
Revered One
Posts: 1196
Joined: Thu Jan 15, 2009 12:55 am

Re: Reop-Mode

Post by willyw »

It appears that this server mode acts only if there are no ops in the channel.
( We can't duplicate that with an Eggdrop, as the bot itself must still be op'd, for it to be able to op anyone else. )

I'm wondering if we are going to re-invent the wheel here. :)
Is the built-in "+o" flag good enough?

You can add users to the bot. You can make their hostmask as tight as you wish, even including nick.
Give them the +o flag, globally or on a channel specific basis.

Then, at any time in the future, then can send a /msg to the bot, and have the bot re-op them. Of course, this assumes that the bot itself is still op'd.
Or, you could give them the +a flag too, and bot would auto-op them.

Maybe I'm missing something here....
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Not sure I get the reasoning.

Why would you not just use the IRCnet MODE commands directly??
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
g
geek
Halfop
Posts: 47
Joined: Fri Oct 24, 2008 6:07 am

Post by geek »

@willyw
and
@SpiKe^^


I know eggdrop features very well, built-in flags, etc.

ircnet is "old style", so no Services at all
if you only have a couple of eggdrops with op and you want to have all other users just with +v, it's not impossible for the channel to become opless

Reop-Mode was introduced for this reason

I could give "MODE R" commands manually, but I would like to do it without the op and with !trigger

so I asked for this script
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

k.
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

altho i agree with willyw eggdrop needs to be opped to set anymode i came up with this took this from a cleanbans thread from forum here i dont remember from wich thread tho:

try this if it does the job:

Code: Select all

# Re-Op-Mode.tcl #

set reop(max) 10

bind pub - !reop Reop:chan


proc Reop:chan {nick uhost hand chan text} {
  global reop
 
  if {![isop $nick $chan] && ![matchattr $hand o|o $chan]} { return 0 }

 
   if {![botisop $chan]} return
  
  set reop($chan) [list 0]
  
  set reopnick $nick
  
  bind raw - 344 cb:bind:raw
  bind raw - 345 cb:bind:raw

  putserv "MODE $chan R"
  return 0
}





proc cb:bind:raw {from key text} {
  global reop
  lassign [split $text] not chan mask

  if {![info exists reop($chan)]} {  return 0  }

  set masks [lassign $reop($chan) total]

  if {$key == 344} {
    lappend masks $mask  ;  incr total
  }

  set cnt [llength $masks]
  if {$total == 0} {
    puthelp "Notice $::reopnick :$chan ReOp list is empty"
  } elseif {$cnt == $reop(max) || ($cnt > 0 && $key==345)} {
    set mode [string repeat "R" $cnt]
    putserv "Notice $::reopnick [join $masks]"

    set reop($chan) [list $total]
  } else {
    set reop($chan) [linsert $masks 0 $total]
  }

  if {$key == 345} {
    unset reop($chan)
    unbind raw - 344 cb:bind:raw
    unbind raw - 345 cb:bind:raw
    puthelp "Notice $::reopnick :$total ReOp entries on $chan"
  }

  return 1
}




bind pub -|- !reopmode pub:reopmode

proc  pub:reopmode {nick uhost hand chan text} {
            if {![isop $nick $chan] && ![matchattr $hand o|o $chan]} { return 0 }

    		set reopmsk [list]



	foreach entries [split $text]  { lappend reopmsk $reopmask }

		if {[info exists entries]} { reopmodes $chan $entries }
}




 proc reopmodes {chan reoplist {max 3}} {
      set count [llength $reoplist]
      while {$count > 0} {
         if {$count> $max} {
            set mode [string repeat "R" $max]
            set masks [join [lrange $reoplist 0 [expr {$max - 1}]]]
            set reoplist [lrange $reoplist $max end]
            incr count -$max
            incr total $max
         } else {
            set mode [string repeat "R" $count]
            set masks [join $reoplist]
            incr total $count
            set count 0
         }
         puthelp "MODE $chan +$mode $masks"
      }
   }





i checked the servers max mode settings per line and it returned 3 mode settings per line wich is why i used 3 in the mode stacker reopmodes
the reason i didnt use pushmode is because i wasnt sure if channel mode +R nick!ident@host is recognized by built in pushmode modes
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i tested this and it seems to work well except it doesnt stack the reop access list in a single line as much as possible instead it sends each in seperate notice spamming the nick requesting the list

Code: Select all

# Re-Op-Mode.tcl #

set reop(max) 10

bind pub - !reoplist Reoplist:chan

proc Reoplist:chan {nick uhost hand chan text} {
  global reop reopnick 

  if {![isop $nick $chan] && ![matchattr $hand o|o $chan]} { return 0 }

    if {![botisop $chan]} return
  
  set reop($chan) [list 0]
  
  set reopnick $nick
  
  bind raw - 344 cb:bind:reop
  bind raw - 345 cb:bind:reop

  putserv "MODE $chan R"
  return 0
}


proc cb:bind:reop {from key text} {
  global reop reopnick
  set text [regsub -all -- {\s{2,}} [string trim [stripcodes * $text]] { }]
  set text [split $text]

   lassign [split $text] not chan mask

   if {![info exists reop($chan)]} {  return 0  }

  set masks [lassign $reop($chan) total]



  if {$key == 344} {
   lappend masks $mask  ;  incr total
  }

  set cnt [llength $masks]
  if {$total == 0} {
    puthelp "Notice $reopnick :$chan ReOp list is empty"
  } elseif {$cnt == $reop(max) || ($cnt > 0 && $key==344)} {

    puthelp "Notice $reopnick :[join $masks]"

    set reop($chan) [list $total]
  } else {
    set reop($chan) [linsert $masks 0 $total]
  }

  if {$key == 345} {
    unset reop($chan)
    unbind raw - 344 cb:bind:reop
    unbind raw - 345 cb:bind:reop
    puthelp "Notice $reopnick :$total ReOp entries on $chan"
  }

  return 1
}



 




bind pub -|- !addreop pub:addreopmode

proc  pub:addreopmode {nick uhost hand chan text} {
            if {![isop $nick $chan] && ![matchattr $hand o|o $chan]} { return 0 }

    		set reopmsk [list]

        	foreach entries [split $text]  { lappend reopmsk $entries }

		if {[info exists reopmsk]} { reopmodes $chan $reopmsk }
}




 proc reopmodes {chan reoplist {max 3}} {
      set count [llength $reoplist]
      while {$count > 0} {
         if {$count> $max} {
            set mode [string repeat "R" $max]
            set masks [join [lrange $reoplist 0 [expr {$max - 1}]]]
            set reoplist [lrange $reoplist $max end]
            incr count -$max
            incr total $max
         } else {
            set mode [string repeat "R" $count]
            set masks [join $reoplist]
            incr total $count
            set count 0
         }
         puthelp "MODE $chan +$mode $masks"
      }
   }


  
Last edited by simo on Sun Feb 27, 2022 10:19 pm, edited 4 times in total.
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

the output of:

/mode #channel R

is:
[02:36:20][IRCnet] -> irc.nlnog.net MODE #channel R
[02:36:20][IRCnet] <- :irc.nlnog.net 344 botnick #channel *!*@All4Masti-4n8.556.33.95.IP
[02:36:20][IRCnet] <- :irc.nlnog.net 344 botnick #channel *!*@All4Masti-y0k.138.69.30.IP
[02:36:20][IRCnet] <- :irc.nlnog.net 344 botnick #channel *!*@All4Masti-in6.676.89.60.IP
[02:36:20][IRCnet] <- :irc.nlnog.net 344 botnick #channel *!*@All4Masti-x0a.532.56.04.IP
[02:36:20][IRCnet] <- :irc.nlnog.net 344 botnick #channel *!*@All4Masti-u93.803.38.49.IP
[02:36:20][IRCnet] <- :irc.nlnog.net 345 botnick #channel :End of Channel Reop List
g
geek
Halfop
Posts: 47
Joined: Fri Oct 24, 2008 6:07 am

Post by geek »

thanks for your script simo

now I have to work, I'll test it this evening
g
geek
Halfop
Posts: 47
Joined: Fri Oct 24, 2008 6:07 am

Post by geek »

works very well

only a strange behavior:
I disable this script with # in .conf
I .rehash the eggdrop
!commands still work :shock:

in any case, thanks simo!

are you on ircnet too?
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

yes im on #nespresso
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

Code: Select all

# ReOp-Mode.tcl #

set reop(max) 10

bind pub - !reoplist Reoplist:chan


proc Reoplist:chan {nick uhost hand chan text} {
  global reop reopnick 

  if {![isop $nick $chan] && ![matchattr $hand o|o $chan]} { return 0 }

 
   if {![botisop $chan]} return
  
  set reop($chan) [list 0]
  
  set reopnick $nick
  

  bind raw - 344 cb:bind:reop
  bind raw - 345 cb:bind:reop

  putserv "MODE $chan R"
  return 0
}





proc cb:bind:reop {from key text} {
  global reop reopnick
  set text [regsub -all -- {\s{2,}} [string trim [stripcodes * $text]] { }]
  set text [split $text]

   lassign [split $text] not chan mask

   if {![info exists reop($chan)]} {  return 0  }

  set masks [lassign $reop($chan) total]



  if {$key == 344} {
   lappend masks $mask  ;  incr total
  }

  set cnt [llength $masks]
  if {$total == 0} {
    putnow "Notice $reopnick :$chan ReOp list is empty"
  } elseif {$cnt == $reop(max) || ($cnt > 0 && $key==344)} {

    putnow "Notice $reopnick :[join $masks]"

    set reop($chan) [list $total]
  } else {
    set reop($chan) [linsert $masks 0 $total]
  }

  if {$key == 345} {
    unset reop($chan)
    unbind raw - 344 cb:bind:reop
    unbind raw - 345 cb:bind:reop
    puthelp "Notice $reopnick :$total ReOp entries on $chan"
  }

  return 1
}





bind pubm - "#% !+reop*" pub:addreopmode
bind pubm - "#% !-reop*" pub:addreopmode


proc pub:addreopmode {nick host hand chan text} {
            if {![isop $nick $chan] && ![matchattr $hand o|o $chan]} { return 0 }
            set text [stripcodes * $text]
            set text [split $text]
       		set restmodes [lrange [split $text] 1 end]
             if {[string match -nocase "!+reop*" [stripcodes * $text]]} { 
           if {![isop $nick $chan] && ![matchattr $hand o|o $chan]} { return 0 }
          set reopmsk [list]
           foreach entries [split $restmodes]  { lappend reopmsk $entries }
		if {[info exists reopmsk]} { reopmodes $chan + $reopmsk }
}

             if {[string match -nocase "!-reop*" [stripcodes * $text]]} { 
			if {![isop $nick $chan] && ![matchattr $hand o|o $chan]} { return 0 }
          set reopmsk [list]
           foreach entries [split $restmodes]  { lappend reopmsk $entries }
      if {[info exists reopmsk]} { reopmodes  $chan - $reopmsk }
}

}

proc reopmodes {chan prefix reoplist {max 3}} {
      set count [llength $reoplist]
      while {$count > 0} {
         if {$count> $max} {
            set mode [string repeat "R" $max]
            set masks [join [lrange $reoplist 0 [expr {$max - 1}]]]
            set reoplist [lrange $reoplist $max end]
            incr count -$max
            incr total $max
         } else {
            set mode [string repeat "R" $count]
            set masks [join $reoplist]
            incr total $count
            set count 0
         }
         puthelp "MODE $chan $prefix$mode $masks"
      }
   }
i hope someone can fix the display of reop list in 1 line as much as possible to prevent the bot to get disconnected due to excess messages sent

its weird why this doesnt get all the entries to stack in stacks of 10 in a line

if {$key == 344} {
lappend masks $mask ; incr total
}
Post Reply