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.

Backup bot script

Support & discussion of released scripts, and announcements of new releases.
Post Reply
C
CP1832
Halfop
Posts: 68
Joined: Thu Oct 09, 2014 4:03 pm

Backup bot script

Post by CP1832 »

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: Select all

#**********#
# 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
	}
}
Post Reply