Code: Select all
bind link - * detect:bot
bind bot - "!Transferftpinfo" ftp:transferinfo
bind bot - "!Transferuserinfo" user:transferinfo
bind link - * getchanjoin:transfert
bind pub - "test" chantest
bind bot - "jointime" procbot
bind join - * joinproc
#when a person joins, his getchanjoin is added into $mychanjoin(with nick and channel info also) from Bot1
proc joinproc {nick uhost hand chan} {
global mychanjoin
set channel #channel
set mychanjoin($nick,$channel) [getchanjoin $nick $channel]
}
#when Bot2 was online, and Bot1 came online (opposite as normal), then Bot2 will send his getchanjoins to Bot1, starting with "jointime". Bot1 will store those info's into variables
proc procbot {bot command text} {
global mychanjoin
set nick [lindex [split $text] 0]
set channel [lindex [split $text] 1]
set mychanjoin($nick,$channel) [lindex [split $text] 2]
}
#This is for testing. When i type in #channel : test1 a_nickname_online , then i should get the getchanjoin value from that nick
proc chantest {nick uhost hand chan arg} {
global mychanjoin
set channel #channel
set nick [lindex [split $arg] 0]
puthelp "PRIVMSG #channel : $mychanjoin($nick,$channel)"
}
#If Bot2 (that was not on #channel) and joins #channel, then Bot1 sends all the getchanjoins that he had, to Bot2 (so that Bot2, get all the getchanjoins too). Is same as "proc procbot", but then for Bot1
proc getchanjoin:transfert {botname via} {
if {[islinked "Bot2"]} {
global mychanjoin
set channel #channel
foreach user [chanlist #channel] {
putbot Bot2 "jointime $user $channel $mychanjoin($user,$channel)"
puthelp "PRIVMSG #channel1 : jointime $user $channel $mychanjoin($user,$channel)"
}
}
}
#If Bot2 wasn't online, and then comes online, then Bot1 will send all his info that is in "usersuptime_backup.txt" to Bot2 (those are send in privmsg beginning with !transferuserinfo or !transferftpinfo). Bot2 will detect those first words, and will write them down in a txt file.
proc detect:bot {botname via} {
if {[islinked "Bot2"]} {
timer 10 {
set file [open /usr/home/eggdrop/logs/usersuptime_backup.txt w+]
set buf [read $file]
foreach line [split $buf \n] {
set line [string trim $line " "]
if {$line == ""} {continue}
#putserv "PRIVMSG Bot1 :\001!Transferuserinfo $line"
putbot Bot1 !Transferuserinfo $line
}
set file [open /usr/home/eggdrop/logs/ftpsuptime_backup.txt w+]
set buf1 [read $file]
foreach line [split $buf1 \n] {
set line [string trim $line " "]
if {$line == ""} {continue}
#putserv "PRIVMSG Bot2 :\001!Transferftpinfo $line"
putbot Bot1 !Transferftpinfo $line
}
timer 60 { file delete /usr/home/eggdrop/logs/usersuptime_backup.txt
file delete /usr/home/eggdrop/logs/ftpsuptime_backup.txt }
}
}
}
#Bot1 will write down info coming from Bot2 starting with !tTransferftpinfo
proc ftp:transferinfo {botnick command arg} {
set file [open /home/eggdrop/logs/ftpsuptime.txt a+]
puts $file "$arg"
close $file
}
#Bot1 will write down info coming from Bot2 starting with !Transferuserinfo
proc user:transferinfo {botnick command arg} {
set file [open /home/eggdrop/logs/usersuptime.txt a+]
puts $file "$arg"
close $file
}
Code: Select all
bind join - * joinproc
proc joinproc {nick uhost hand chan} {
if {[string equal -nocase $nick "bot1"] || [string match -nocase "*@blabla.com" $uhost]} {
foreach nick [chanlist #channel] {
putbot bot2 [list accept $nick [getchanjoin $nick #channel]]
puthelp "PRIVMSG #controlchan : [list accept $nick [getchanjoin $nick #channel]]"
}
}
}
Code: Select all
bind bot - "accept" procbot
proc procbot {bot command text} {
global mychanjoin
set nick [lindex [split $text] 0]
set jointime [lindex [split $text] 1]
set [getchanjoin $nick #channel] jointime
}
Code: Select all
bind pub - "test1" chantest
proc chantest {nick uhost hand chan arg} {
global mychanjoin
set channel #channel
set nick [lindex [split $arg] 0]
puthelp "PRIVMSG #controlchan : [getchanjoin $nick #channel]"
}
Code: Select all
bind pub - "test" chantest
proc chantest {nick uhost hand chan arg} {
global mychanjoin
set channel #channel
set nick [lindex [split $arg] 0]
puthelp "PRIVMSG #controlchan : [getchanjoin $nick #channel]"
}
I think the point of this code was to use the var mychanjoin, not [getchanjoin].Buffy_25 wrote:
bot2:Code: Select all
bind bot - "accept" procbot proc procbot {bot command text} { global mychanjoin set nick [lindex [split $text] 0] set jointime [lindex [split $text] 1] set [getchanjoin $nick #channel] jointime }
You are right, set [getchanjoin ...] blah does not modify the getchanjoin. You have to store it in your own variable and use that instead.
So it seems that getchanjoin hasn't been transferred to bot2
I don't know if this is a correct statement : set [getchanjoin $nick #flightsim] jointime (i think we can't modify a getchanjoin...or am i wrong?). But i don't know what else i can try to get that getchanjoin from bot1 to bot2
I hope with this information you can help me a bit more.
Thnx in advance.
Best regards,
Buffy