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 

chanmodes lock

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
McMilan
Voice


Joined: 13 Mar 2009
Posts: 24

PostPosted: Sun Aug 09, 2009 4:36 am    Post subject: chanmodes lock Reply with quote

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,
Back to top
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Sun Aug 09, 2009 10:56 am    Post subject: Reply with quote

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:

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


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sun Aug 09, 2009 12:07 pm    Post subject: Reply with quote

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, 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 -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
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