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.
Code: Select all
# 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