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.

Only bot can set channel mode lock (Dalnet network)

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
S
Sydneybabe
Op
Posts: 106
Joined: Fri Apr 27, 2007 3:31 am
Location: Philippines

Post by Sydneybabe »

Hello sir i try the script but still no luck.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

It seems I introduced a new bug in my last fix (should'nt have added -- to the lsearch commands, that part was working just fine as it was).
The following have been successfully simulated in tclsh, and should work.
It will allow bots and masters/owners to override the lock.

Code: Select all

namespace eval modecontrol {
  variable enforceModes ""  #Always keep these set
  variable restrictModes "" #Never permit these to be set

  proc raw:modeCheck {from key text} {
    variable enforceModes
    variable restrictModes

    set from [split $from "!"]
    set nick [lindex $from 0]
    set handle [nick2hand $nick]
    #Sanity check
    if {[isbotnick $nick] || [matchattr $handle "+mnb"]} {
      return 0
    }

    set items [split $text]
    set enforce [split $enforceModes ""]
    set restrict [split $restrictModes ""]
    set target [lindex $items 0]
    set add 1
    set act 0

    foreach mode [split [lindex $items 1] ""] {
      switch -- $mode {
        "+" {
          set add 1
        }
        "-" {
          set add 0
        }
        "I" -
        "e" -
        "b" {
          set items [lreplace $items 2 2]
        }
        "k" {
          if {$add} {
            set key [lindex $items 2]
            set items [lreplace $items 2 2]
          }
        }
        "l" {
          if {$add} {
            set limit [lindex $items 2]
            set items [lreplace $items 2 2]
          }
        }
        default {
          if {[lsearch $enforce $mode] >= 0 && !$add} {
            pushmode $target "+$mode"
            set act 1
          } elseif {[lsearch $restrict $mode] >= 0 && $add} {
            pushmode $target "-$mode"
            set act 1
          }
        }
      }
      #Uncomment this to bounce key and limits
      #if {[info exists key]} {
      #  pushmode $target -k $key
      #}
      #if {[info exists limit]} {
      #  pushmode $target -l
      #}
    }
    if {$act && [llength $from] > 1} {
      puthelp "NOTICE $nick :Please let me handle the channel mode settings."
    }
    return 0
  }

  bind raw - "MODE" [namespace current]::modeCheck
}
Edit: Fixed incorrect binding type
Edit: Placed code in separate namespace, separated enforced and restricted modes
Edit: Fixed missing "eval" subcommand for namespace
Edit: Incorrect lsearch order and pattern.
Last edited by nml375 on Mon Mar 19, 2012 12:34 pm, edited 4 times in total.
NML_375
S
Sydneybabe
Op
Posts: 106
Joined: Fri Apr 27, 2007 3:31 am
Location: Philippines

Post by Sydneybabe »

I test the script this time sir but nothing happens:
* User sets mode: +R

the bot did not -R the channel :s
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

What did you set lockModes to?
Also, did you get any error messages in your logs or dcc chat?
NML_375
S
Sydneybabe
Op
Posts: 106
Joined: Fri Apr 27, 2007 3:31 am
Location: Philippines

Post by Sydneybabe »

Hello sir with the help of speechles the error found on this part:
bind mode - "MODE" raw:modeCheck
and now the script is working but opposite of what i requested:
User sets mode +m
User sets mode -m
Eggdrop sets mode +m

User sets mode +M
User sets mode -M
Eggdrop sets mode +M
It keep the settings that offender set that not added to the masters, owners, and other bots.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Then I am either confused of the intended behaviour, or you've got some other script or feature enabled that is interfering.

The way the script was written, is to enforce the modes set in lockModes - that is, do not let people remove the modes set from the channel, and do not let people add other modes to the channel.

I've now updated the previous post in order to separate enforced and restricted modes. I've also moved the code to a separate namespace, so make sure you restart your eggdrop (not just .rehash) to make sure the old code does not persist.
NML_375
S
Sydneybabe
Op
Posts: 106
Joined: Fri Apr 27, 2007 3:31 am
Location: Philippines

Post by Sydneybabe »

Hi sir there is an error on the script how to fix this:
Unknown subcommand "modecontrol" to "namespace"
Thanks in advance.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Minor typo, lost the "eval" subcommand during copy/paste. Post updated now
NML_375
Post Reply