#--------------------------------------------------------------------- # autostatus.tcl # # reports to a partyline user every minute the status of the bot, # partyline information and channels information. # # to switch the autostatus on/off type .autostatus or .as # # v0: 07-Oct-2003 #--------------------------------------------------------------------- package require eggdrop 1.6.15 package require Tcl 8.0 bind time - * autostatus:bindtime bind dcc - autostatus autostatus:dcc bind dcc - as autostatus:dcc #--------------------------------------------------------------------- # toggle autostatus on or off #--------------------------------------------------------------------- proc autostatus:dcc { hand idx text } { set status [getuser $hand XTRA autostatus] if { $status == "ON" } { setuser $hand XTRA autostatus OFF autostatus:put $idx "autostatus switched OFF." } else { setuser $hand XTRA autostatus ON autostatus:put $idx "autostatus switched ON." autostatus:report $idx } } #--------------------------------------------------------------------- # binded to time #--------------------------------------------------------------------- proc autostatus:bindtime { args } { foreach connection [dcclist] { set type [lindex $connection 3] if { $type != "CHAT" } { continue } set hand [lindex $connection 1] if { [getuser $hand XTRA autostatus] != "ON" } { continue } set idx [lindex $connection 0] autostatus:report $idx } } #--------------------------------------------------------------------- # Call the respective procedures #--------------------------------------------------------------------- proc autostatus:report { idx } { autostatus:put $idx {#---------------------------------------} autostatus:report:server $idx autostatus:put $idx {} autostatus:report:whom $idx autostatus:put $idx {} autostatus:report:channels $idx autostatus:put $idx {} } #--------------------------------------------------------------------- # report the date, servername, botname, uptime and online time #--------------------------------------------------------------------- proc autostatus:report:server { idx } { global serveraddress global botname global uptime global server-online set fmt "%-10s %-s" set currenttime [unixtime] set myuptime [duration [expr $currenttime - $uptime] ] set myonline [duration [expr $currenttime - ${server-online}] ] autostatus:put $idx [format $fmt DATE [ctime $currenttime ]] autostatus:put $idx [format $fmt SERVER $serveraddress] autostatus:put $idx [format $fmt BOTNAME $botname] autostatus:put $idx [format $fmt UPTIME $myuptime] autostatus:put $idx [format $fmt CONNECTED $myonline] } #--------------------------------------------------------------------- # report the channels #--------------------------------------------------------------------- proc autostatus:report:channels { idx } { # format: channel boton botop users operators voices set fmt "%-15s %-5s %-5s %-5s %-5s %-5s %-5s" # print the header autostatus:put $idx [format $fmt CHANNEL ON BOT@ {#} {@} {+v} BANS] # iterate over the channels foreach channel [channels] { set chn [string range $channel 0 12] # if bot not on chan, report and continue with next channel if { ![botonchan $channel] } { autostatus:put $idx [format $fmt $chn\ no {n/a} {n/a} {n/a} {n/a} {n/a}] continue } # bot is on the channel, does it have @? if { [botisop $channel] } { set botopped yes } else { set botopped no } # number of users, operators and voices set chanusers [chanlist $channel] set countusers [llength $chanusers] set operators 0 set voices 0 foreach user $chanusers { if { [isop $user $channel] } { incr operators } if { [isvoice $user $channel] } { incr voices } } # count the bans set bancount [llength [chanbans $channel] ] # report status for the channel autostatus:put $idx [format $fmt $chn yes $botopped\ $countusers $operators $voices $bancount] } } #--------------------------------------------------------------------- # report users on the partyline #--------------------------------------------------------------------- proc autostatus:report:whom { idx } { global handlen # nickname, botname, idletime, hostname set format "%-${handlen}s %-${handlen}s %-5s %-5s %s" # print header autostatus:put $idx [format $format NICK BOT CHAN IDLE HOSTNAME] # display user information foreach user [whom *] { set nickname [lindex $user 0] set botname [lindex $user 1] set hostname [lindex $user 2] set idletime [lindex $user 4] set channame [lindex $user 6] autostatus:put $idx [format $format $nickname $botname\ $channame $idletime $hostname] } } #--------------------------------------------------------------------- # Alternative putdcc #--------------------------------------------------------------------- proc autostatus:put { idx text } { set time [strftime "%H:%M"] putdcc $idx "\[$time\] $text\r" } putlog "Loaded (version 0): Autostatus."