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 

A script for a bot support

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
neoclust
Halfop


Joined: 14 Aug 2009
Posts: 55

PostPosted: Tue Sep 08, 2009 12:54 pm    Post subject: A script for a bot support Reply with quote

I have a bot to support it's role is to replace Bot1 & bot2 when they disconnect or they are not @, and he must deop when he sees that one of the two bots oped,
If you can help me solve this theory, thank you.
Back to top
View user's profile Send private message
arfer
Master


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

PostPosted: Tue Sep 08, 2009 5:48 pm    Post subject: Reply with quote

I have done a limited amount of checking on the following script and it seems fine:-

Code:

# support.tcl

# if none of the preconfigured bots is op in a preconfigured channel then the bot ..
# .. that this script is loaded on will attempt to op itself in the channel ..
# .. through chanserv services (if it is not already op'd)

# if one or more of the preconfigured bots is op in a preconfigured channel then ..
# .. the bot that this script is loaded on will will attempt to deop itself in ..
# .. the channel through chanserv services (if it is not already deop'd)

# requires a restart (not rehash) due to use of init-server evnt bind

# reacts to join/part/quit/split/kick plus +o/-o mode changes and additionally has a ..
# .. preconfigured scheduled check for all the preconfigured channels

# for the op command to succeed, the bot that this script is loaded on must be on ..
# .. the channel access list

### ------------------------------------------------------------- ###
### ---------- CONFIGURATION ------------------------------------ ###

# set here a list of the channels to add support services to
set vSupportChannels {
    "#eggtcl"
    "#atlantis"
    "#tcl"
}

# set here a list of other bots that the script is supporting
set vSupportBots {
    "Baal"
    "McKay"
}

# set here the address of services to op or deop
set vSupportServices "chanserv@services.dal.net"

# set here the frequency of the additional checking in minutes
set vSupportTimerFrequency 2

### ------------------------------------------------------------- ###
### ---------- CODE --------------------------------------------- ###

set vSupportVersion 1.0

bind EVNT - init-server pSupportTimerStart

bind PART - * pSupportPartCode
bind SIGN - * pSupportSignCode
bind KICK - * pSupportKickCode
bind SPLT - * pSupportSpltCode
bind JOIN - * pSupportJoinCode

bind MODE - "#% +o" pSupportModeCode
bind MODE - "#% -o" pSupportModeCode

proc pSupportCheck {nick chan} {
    global vSupportBots vSupportChannels
    set botstolower [split [string tolower [join $vSupportBots]]]
    set chanstolower [split [string tolower [join $vSupportChannels]]]
    if {[lsearch -exact $botstolower [string tolower $nick]] != -1} {
        if {[lsearch -exact $chanstolower [string tolower $chan]] != -1} {
            return 1
        }
    }
    return 0
}

proc pSupportModeCode {nick uhost hand chan change target} {
    if {[pSupportCheck $target $chan]} {
        utimer 10 [list pSupportOpCode $chan]
    }
    return 0
}

proc pSupportJoinCode {nick uhost hand chan} {
    if {([pSupportCheck $nick $chan]) || ([isbotnick $nick])} {
        utimer 10 [list pSupportOpCode $chan]
    }
    return 0
}

proc pSupportSpltCode {nick uhost hand chan} {
    if {[pSupportCheck $nick $chan]} {
        utimer 10 [list pSupportOpCode $chan]
    }
    return 0
}

proc pSupportKickCode {nick uhost hand chan target reason} {
    if {[pSupportCheck $target $chan]} {
        utimer 10 [list pSupportOpCode $chan]
    }
    return 0
}

proc pSupportSignCode {nick uhost hand chan reason} {
    if {[pSupportCheck $nick $chan]} {
        utimer 10 [list pSupportOpCode $chan]
    }
    return 0
}

proc pSupportPartCode {nick uhost hand chan msg} {
    if {[pSupportCheck $nick $chan]} {
        utimer 10 [list pSupportOpCode $chan]
    }
    return 0
}

proc pSupportTimerStart {type} {
    global vSupportTimerFrequency
    if {[string is integer -strict $vSupportTimerFrequency]} {
        if {$vSupportTimerFrequency > 0} {
            pSupportTimerSchedule
        }
    }
    return 0
}

proc pSupportTimerSchedule {} {
    global vSupportTimerFrequency
    foreach schedule [binds TIME] {
        if {[string equal pSupportTimerCode [join [lindex $schedule 4]]]} {
            set minute [join [lindex [lindex $schedule 2] 0]]
            set hour [join [lindex [lindex $schedule 2] 1]]
            unbind TIME - "$minute $hour * * *" pSupportTimerCode
        }
    }
    set minute [strftime %M [expr {[unixtime] + ($vSupportTimerFrequency * 60)}]]
    set hour [strftime %H [expr {[unixtime] + ($vSupportTimerFrequency * 60)}]]
    bind TIME - "$minute $hour * * *" pSupportTimerCode
    return 0
}

proc pSupportTimerCode {minute hour day month year} {
    global vSupportBots vSupportChannels
    if {([llength $vSupportBots] != 0) && ([llength $vSupportChannels] != 0)} {
        pSupportOpCode 0
    }
    return 0
}

proc pSupportOpCode {chan} {
    global botnick vSupportBots vSupportChannels vSupportServices
    switch -- $chan {
        0 {
            foreach channel $vSupportChannels {
                set oped 0
                if {[validchan $channel]} {
                    if {[botonchan $channel]} {
                        foreach bot $vSupportBots {
                            if {[onchan $bot $channel]} {
                                if {[isop $bot $channel]} {
                                    incr oped
                                }
                            }
                        }
                        switch -- $oped {
                            0 {
                                if {![botisop $channel]} {
                                    putserv "PRIVMSG $vSupportServices :OP $channel $botnick"
                                }
                            }
                            default {
                                if {[botisop $channel]} {
                                    putserv "PRIVMSG $vSupportServices :DEOP $channel $botnick"
                                }
                            }
                        }
                    }
                }
            }
            pSupportTimerSchedule
        }
        default {
            set oped 0
            if {[validchan $chan]} {
                if {[botonchan $chan]} {
                    foreach bot $vSupportBots {
                        if {[onchan $bot $chan]} {
                            if {[isop $bot $chan]} {
                                incr oped
                            }
                        }
                    }
                }
            }
            switch -- $oped {
                0 {
                    if {![botisop $chan]} {
                        putserv "PRIVMSG $vSupportServices :OP $chan $botnick"
                    }
                }
                default {
                    if {[botisop $chan]} {
                        putserv "PRIVMSG $vSupportServices :DEOP $chan $botnick"
                    }
                }
            }
        }
    }
    return 0
}

putlog "support.tcl version $vSupportVersion by arfer loaded"

# eof

_________________
I must have had nothing to do
Back to top
View user's profile Send private message
neoclust
Halfop


Joined: 14 Aug 2009
Posts: 55

PostPosted: Tue Sep 08, 2009 7:10 pm    Post subject: Reply with quote

Thanks a lot man good script, and if i want change the nick to host of bots it will be effective since their addresses are fixed, Ex *!*@blah.com i replace the $nick of uhost and setting
set vSupportBots {
"*!*@blah.com"
}
right ?
Back to top
View user's profile Send private message
arfer
Master


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

PostPosted: Tue Sep 08, 2009 7:17 pm    Post subject: Reply with quote

I don't think you can reliably do that with the script as it stands.

Some binds return the nick/uhost of the user they effect and can be used directly. Other binds return the nick/uhost that did the action and seperately return the target of the action (but not the uhost of the target).

Hence you see some of my bind procs use nick whilst others use target.
_________________
I must have had nothing to do
Back to top
View user's profile Send private message
neoclust
Halfop


Joined: 14 Aug 2009
Posts: 55

PostPosted: Tue Sep 08, 2009 7:31 pm    Post subject: Reply with quote

I use this script on Undernet where nicknames does not register it so there's that someone else takes, is why i referred to the host that the script is much more reliable, I could get rid of BIND kick and MODE as they use target
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
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