CP1832 Halfop
Joined: 09 Oct 2014 Posts: 68
|
Posted: Mon Feb 15, 2016 12:26 pm Post subject: Backup bot script |
|
|
I've got two identical bots running the same scripts with the same settings. I've created this simple script for the backup bot to join the mainchannel in case the main bot goes down for some reason and to leave the channel when the main bot joins the channel. For this script to work, both bots have to be in a channel together (I've added them both to a secondary channel that's unused). I'm checking the ident as the main bot is authed, since the auth might fail and change the bot's nick, I check the ident. | Code: | #**********#
# SETTINGS #
#**********#
# main bot ident
set mainbot "BOT"
# main channel
set mainchannel "#channel"
#************************#
# DO NOT EDIT UNDERNEATH #
#************************#
putlog "main-backup.tcl"
foreach bind [binds botjoin] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}
foreach bind [binds botpart] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}
bind join - * botjoin
bind part - * botpart
bind sign - * botpart
proc botjoin {nick uhost hand channel args} {
global mainbot mainchannel
set ident [string range [lindex [split $uhost @] 0] 1 end]
if {[string match -nocase $ident $mainbot]} {
putlog "Leaving $mainchannel"
channel remove $mainchannel
}
}
proc botpart {nick uhost hand channel args} {
global mainbot mainchannel
set ident [string range [lindex [split $uhost @] 0] 1 end]
if {[string match -nocase $ident $mainbot]} {
putlog "Joining $mainchannel"
channel add $mainchannel
}
} |
|
|