egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Uptime

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
Snorly
Voice


Joined: 17 Apr 2006
Posts: 25

PostPosted: Wed Jun 07, 2006 5:34 pm    Post subject: Uptime Reply with quote

I want to know if it is possible with this script to display uptime on local shell and in other shells. if it is please tell me how

Code:
# uptime.tcl v1.08 [11 November 2000]
# Copyright (C) 1999-2000 Teemu Hjelt <temex@iki.fi>
#
# Latest version can be found from http://www.iki.fi/temex/eggdrop/
#
# If you have any suggestions, questions or you want to report
# bugs, please feel free to send me email to temex@iki.fi
#
# This script shows the uptime of the bot's maschine.
#
# Current DCC Commands:
#    .utime [option]
#
# Current MSG Commands:
#    uptime/utime [option]
#
# Current Channel Commands:
#    uptime/utime [option]
#
# Tested on eggdrop1.4.4 with TCL 7.6
#
# Version history:
# v1.00 - The very first version!
# v1.01 - Added little cosmetic things.
# v1.02 - There were few 'return 0' strings too much.
# v1.03 - Fixed few bugs, removed few params from uptime command and 
#         modified .uptime to .utime because .uptime was already in use.
# v1.04 - Renamed the procs, fixed little bug in ut_douptime proc and added msg commands.
# v1.05 - Fixed few little bugs and typos.
# v1.06 - Little bug fixed in msg command.
# v1.07 - Some cosmetic changes.
# v1.08 - Changed few minor things.

### Settings ###

## [0/1] Enable Channel Command?
set ut_enablepublic 1

## [0/1] Enable MSG Command?
set ut_enablemsg 1

## [0/1] Enable DCC Command?
set ut_enabledcc 1

## What command prefix do you want to use for channel commands?
set ut_cmdpfix "!"

## What users can use the uptime command?
set ut_flag1 "-"

## What users can start/stop the timer and show uptime on the channel/partyline?
set ut_flag2 "o"

## Send the uptime via NOTICE or PRIVMSG?
set ut_method "PRIVMSG"

## [0/1] Enable timer which shows uptime on the channel(s) or on partyline?
set ut_enabletimer 1

## What is the interval for the timer (mins)?
set ut_interval 60

## [0/1] Show uptime on partyline?
set ut_showdcc 1

## [0/1] Show uptime on channel(s)?
set ut_showchannel 1

## On what channels do you want to show the uptime?
# Note: Set this to "" to show the uptime on all channels.
set ut_chans "#si-shell"

###### You don't need to edit below this ######

### Misc Things ###

set ut_ver "1.08"

### Bindings ###

## Channel Command
if {$ut_enablepublic} {
   bind pub - ${ut_cmdpfix}uptime pub:ut_uptime
   bind pub - ${ut_cmdpfix}utime pub:ut_uptime
}

## MSG Command
if {$ut_enablemsg} {
   bind msg - uptime msg:ut_uptime
   bind msg - utime msg:ut_uptime
}

## DCC Command
if {$ut_enabledcc} {
   bind dcc - utime dcc:ut_uptime
}

### Channel Command ###

proc pub:ut_uptime {nick uhost hand chan arg} {
global ut_cmdpfix ut_flag1 ut_flag2 ut_interval ut_showdcc ut_showchannel ut_method ut_ver
set option [string tolower [lindex [split $arg] 0]]
   if {[matchattr $hand $ut_flag2]} {
      if {($option != "") && ($option != "-p") && ($option != "-start") && ($option != "-stop")} {
         putserv "PRIVMSG $nick :uptime.tcl v$ut_ver commands:"
         putserv "PRIVMSG $nick :   ${ut_cmdpfix}uptime        - Shows uptime for you."
         putserv "PRIVMSG $nick :   ${ut_cmdpfix}uptime -p     - Shows uptime on $chan."
         putserv "PRIVMSG $nick :   ${ut_cmdpfix}uptime -start - Starts timer."
         putserv "PRIVMSG $nick :   ${ut_cmdpfix}uptime -stop  - Stops timer."
      } else {
         if {$option == ""} {
            putserv "$ut_method $nick :[ut_douptime]"
         } elseif {$option == "-p"} {
            putserv "$ut_method $chan :[ut_douptime]"
         } elseif {$option == "-start"} {
            ut_stoptimer
            ut_starttimer 
            putserv "NOTICE $nick :Timer started! Interval: $ut_interval mins"
         } elseif {$option == "-stop"} {
            ut_stoptimer
            putserv "NOTICE $nick :Timer stopped!"
         }
      }
   } elseif {[matchattr $hand $ut_flag1]} {
      putserv "$ut_method $nick :[ut_douptime]"
   }
return 1
}

### MSG Command ###

proc msg:ut_uptime {nick uhost hand arg} {
global ut_cmdpfix ut_flag1 ut_flag2 ut_interval ut_showdcc ut_showchannel ut_method ut_ver
set option [string tolower [lindex [split $arg] 0]]
   if {[matchattr $hand $ut_flag2]} {
      if {($option != "") && ($option != "-start") && ($option != "-stop")} {
         putserv "PRIVMSG $nick :uptime.tcl v$ut_ver commands:"
         putserv "PRIVMSG $nick :   uptime        - Shows uptime for you."
         putserv "PRIVMSG $nick :   uptime -start - Starts timer."
         putserv "PRIVMSG $nick :   uptime -stop  - Stops timer."
      } else {
         if {$option == ""} {
            putserv "$ut_method $nick :[ut_douptime]"
         } elseif {$option == "-start"} {
            ut_stoptimer
            ut_starttimer 
            putserv "NOTICE $nick :Timer started! Interval: $ut_interval mins"
         } elseif {$option == "-stop"} {
            ut_stoptimer
            putserv "NOTICE $nick :Timer stopped!"
         }
      }
   } elseif {[matchattr $hand $ut_flag1]} {
      putserv "$ut_method $nick :[ut_douptime]"
   }
return 1
}

### DCC Command ###

proc dcc:ut_uptime {hand idx arg} {
global ut_cmdpfix ut_flag1 ut_flag2 ut_interval ut_showdcc ut_showchannel ut_method ut_ver
set option [string tolower [lindex [split $arg] 0]]
   putcmdlog "#$hand# utime $arg"
   if {[matchattr $hand $ut_flag2]} {
      if {($option != "") && ($option != "-p") && ($option != "-start") && ($option != "-stop")} {
         putidx $idx "uptime.tcl v$ut_ver commands:"
         putidx $idx "   .utime        - Shows uptime for you."
         putidx $idx "   .utime -p     - Shows uptime on partyline."
         putidx $idx "   .utime -start - Starts timer."
         putidx $idx "   .utime -stop  - Stops timer."
      } else {
         if {$option == ""} {
            putidx $idx "[ut_douptime]"
         } elseif {$option == "-p"} {
            putlog "[ut_douptime]"
         } elseif {$option == "-start"} {
            ut_stoptimer
            ut_starttimer 
            putidx $idx "Timer started! Interval: $ut_interval mins."
         } elseif {$option == "-stop"} {
            ut_stoptimer 
            putidx $idx "Timer stopped!"
         }
      }
   } elseif {[matchattr $hand $ut_flag1]} {
      putidx $idx "[ut_douptime]"
   }
}

### Other Procs ###

proc ut_showuptime { } {
global botnick ut_chans ut_showchannel ut_showdcc ut_method
   if {$ut_showchannel} {
      foreach chan [channels] {
         if {($ut_chans != "") && ([lsearch -exact [split [string tolower $ut_chans]] [string tolower $chan]] == -1)} { continue }
         if {([validchan $chan]) && ([onchan $botnick $chan])} {
            putserv "$ut_method $chan :[ut_douptime]"
         }
      }
   }
   if {$ut_showdcc} {
      putlog "uptime: [ut_douptime]"
   }
   ut_starttimer
}

proc ut_douptime { } {
   if {[catch {exec uptime} uptime]} { set uptime "Uptime is unavailable." }
   if {[catch {exec uname -sr} machine]} { set machine [unames] }
   if {[catch {exec hostname} hostname]} {   set hostname [info hostname] }
   return "Uptime for $hostname ($machine): $uptime"
}

proc ut_starttimer { } {
global ut_interval
   if {![string match "*ut_showuptime*" [timers]]} {
      timer $ut_interval ut_showuptime
   }
}

proc ut_stoptimer { } {
   foreach timer [timers] {
      if {[string match "*ut_showuptime*" $timer]} {
         killtimer [lindex $timer 2]
      }
   }
}

### End ###

if {$ut_enabletimer} { ut_starttimer }

putlog "TCL loaded: uptime.tcl v$ut_ver by Sup <temex@iki.fi>"
Back to top
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Wed Jun 07, 2006 10:46 pm    Post subject: Reply with quote

If I understand you correctly:
Quote:
# This script shows the uptime of the bot's maschine.

_________________
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Back to top
View user's profile Send private message Visit poster's website
Snorly
Voice


Joined: 17 Apr 2006
Posts: 25

PostPosted: Thu Jun 08, 2006 12:51 am    Post subject: Reply with quote

yes Smile
and i want it to show for 2 more maschines Razz if it is possible
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Thu Jun 08, 2006 2:10 am    Post subject: Reply with quote

use rconsole

it shows the uptime of each host on your botnet (and allows you to control it remotely without having to log into each bot, too)
_________________
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber