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.

chanmodes lock

Help for those learning Tcl or writing their own scripts.
Post Reply
M
McMilan
Voice
Posts: 24
Joined: Fri Mar 13, 2009 3:24 pm

chanmodes lock

Post by McMilan »

Hi.

can someone tell me some chanmodes locker script? Because i am trying use normal chanmode of eggdrop, but it isn't sensitive to uppercase.

Regards,
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

I can't imagine you literally mean mode locked as in the IRC sense of the phrase (for example \cs set #channelname mlock +m).

The bot would require founder access. The command and response would probably differ for different networks anyway.

Usually a script would watch for mode changes from channel users or changes in channel numbers or a flood and correct the appropriate mode if not conforming to the script's preconfigured settings. This is the case with a topiclock or limit script.

The following script has limited functionality but has been tested and works fine. I don't know iof this is what you mean. You can set any single character mode (not requiring an additional argument) to be maintained + or - on any channel for which the bot has op status.

Code: Select all

# script to retain preconfigured channel modes
# checks current modes when the bot comes online and corrects them if required
# checks mode changes and reverses them if required

# script has limited functionality (will not deal with channel modes requuiring an additional argument +b, -b, +k, +l etc)
# modes configured below must not conflict with mlocked modes otherwise the script will attempt to fight channel services

# set here the channel modes not allowed to be set +mode
# maximum one line per channel
# channel name must be lower case
# modes must be a space delimited list
array set vRetainMode0 {
    "#eggtcl" {c R}
    "#atlantis" {M}
}

# set here the channel modes required to be set +mode
# maximum one line per channel
# channel name must be lower case
# modes must be a space delimited list
array set vRetainMode1 {
    "#eggtcl" {M}
}

bind JOIN - * pRetainModeJoin
bind MODE - * pRetainModeMode

proc pRetainModeJoin {nick uhost hand chan} {
    if {[isbotnick $nick]} {
        set channel [string tolower $chan]
        utimer 10 [list pRetainModeDelay $channel]
    }
    return 0
}

proc pRetainModeMode {nick uhost hand chan mode target} {
    global vRetainMode0 vRetainMode1
    set channel [string tolower $chan]
    switch -- [string index $mode 0] {
        - {
            if {[info exists vRetainMode1($channel)]} {
                if {[lsearch -exact $vRetainMode1($channel) [string index $mode 1]] != -1} {
                    pRetainModeSet 1 $channel [string index $mode 1]
                }
              
            }
        }
        + {
            if {[info exists vRetainMode0($channel)]} {
                if {[lsearch -exact $vRetainMode0($channel) [string index $mode 1]] != -1} {
                    pRetainModeSet 0 $channel [string index $mode 1]
                }
              
            }
        }
        default {}
    }
    return 0
}

proc pRetainModeDelay {chan} {
    global vRetainMode0 vRetainMode1
    if {[info exists vRetainMode0($chan)]} {
        foreach mode $vRetainMode0($chan) {
            if {[regexp -- [subst -nocommands -nobackslashes {\+[^\-]*$mode}] [getchanmode $chan]]} {
                pRetainModeSet 0 $chan $mode
            }
        }
    }
    if {[info exists vRetainMode1($chan)]} {
        foreach mode $vRetainMode1($chan) {
            if {![regexp -- [subst -nocommands -nobackslashes {\+[^\-]*$mode}] [getchanmode $chan]]} {
                pRetainModeSet 1 $chan $mode
            }
        }
    }
    return 0
}

proc pRetainModeSet {type chan mode} {
    if {[botisop $chan]} {
        switch -- $type {
            0 {pushmode $chan -$mode}
            1 {pushmode $chan +$mode}
            default {}
        }
        flushmode $chan
    }
    return 0
}

# eof
I must have had nothing to do
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

The native "chanmode" mode-locking feature in eggdrop is not limited to lowercase modes, but a limited set of rfc1459 modes + a few other psuedo-standard modes in major irc network softwares. As such, it's more restrictive than just lowercase.

You could patch your eggdrop to recognize other channel modes available on your network, although this would require some coding experience.
This would involve creating a macro definition for your custom channel mode, as well as modifying a few functions to take this new mode into account:
getchanmode() (mod/irc.mod/chan.c),
recheck_channel_modes() (mod/irc.mod/chan.c),
get324() (mod/irc.mod/chan.c),
set_mode_protect() (mod/channels.mod/channels.c),
get_mode_protect() (mod/channels.mod/channels.c)

Possible some other function as well, although those are the core functions for the chanmode channel setting.
I havn't checked arfer's script throughout, but it would seem it gets the job done as well.
NML_375
Post Reply