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 

Only bot can set channel mode lock (Dalnet network)
Goto page Previous  1, 2
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
Sydneybabe
Op


Joined: 27 Apr 2007
Posts: 106
Location: Philippines

PostPosted: Sat Aug 20, 2011 7:59 am    Post subject: Reply with quote

Hello sir i try the script but still no luck.
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sat Aug 20, 2011 9:04 am    Post subject: Reply with quote

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:
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.
_________________
NML_375, idling at #eggdrop@IrcNET


Last edited by nml375 on Mon Mar 19, 2012 12:34 pm; edited 4 times in total
Back to top
View user's profile Send private message
Sydneybabe
Op


Joined: 27 Apr 2007
Posts: 106
Location: Philippines

PostPosted: Sat Aug 20, 2011 1:36 pm    Post subject: Reply with quote

I test the script this time sir but nothing happens:

Quote:
* User sets mode: +R


the bot did not -R the channel :s
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sat Aug 20, 2011 6:02 pm    Post subject: Reply with quote

What did you set lockModes to?
Also, did you get any error messages in your logs or dcc chat?
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Sydneybabe
Op


Joined: 27 Apr 2007
Posts: 106
Location: Philippines

PostPosted: Sun Aug 21, 2011 12:51 am    Post subject: Reply with quote

Hello sir with the help of speechles the error found on this part:
Quote:
bind mode - "MODE" raw:modeCheck

and now the script is working but opposite of what i requested:

Quote:
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.
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sun Aug 21, 2011 6:18 am    Post subject: Reply with quote

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, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Sydneybabe
Op


Joined: 27 Apr 2007
Posts: 106
Location: Philippines

PostPosted: Mon Aug 22, 2011 9:09 am    Post subject: Reply with quote

Hi sir there is an error on the script how to fix this:
Quote:
Unknown subcommand "modecontrol" to "namespace"

Thanks in advance.
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Mon Aug 22, 2011 12:39 pm    Post subject: Reply with quote

Minor typo, lost the "eval" subcommand during copy/paste. Post updated now
_________________
NML_375, idling at #eggdrop@IrcNET
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 -> Script Requests All times are GMT - 4 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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