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.

NTP Time TCL

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
V
VoodooServ
Voice
Posts: 7
Joined: Sun Oct 27, 2013 12:49 pm
Location: Bulgaria / Pleven
Contact:

NTP Time TCL

Post by VoodooServ »

Hi. Can write TCL script in command: !time ot !ntp bot telling time directly from a specific NTP server.

for example:
User: !ntp
Bot: NTP pool.ntp.org time: 09:45:63 GMT+2
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

Code: Select all

# Author: tomekk
# e-mail:  tomekk/@/tomekk/./org
# home page: http://tomekk.org/
#
# Version 0.1
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html

set server "pool.ntp.org"

###########################################################
bind pub - !ntp gimme_time

package require time

proc gimme_time { nick uhost hand chan arg } {
        global server

        set tok [time::getsntp $server]
        time::wait $tok

        if {[time::status $tok] eq "ok"} {
                set t [time::unixtime $tok]
                putquick "PRIVMSG $chan :NTP $server time: [clock format $t -format "%H:%M:%S"]"
        } else {
                putquick "PRIVMSG $chan :NTP [time::error $tok]"
        }

        time::cleanup $tok
}

putlog "ntp.tcl ver 0.1 by tomekk loaded"
check it.... its kinda old...
GMT calculation .. do it at your own
V
VoodooServ
Voice
Posts: 7
Joined: Sun Oct 27, 2013 12:49 pm
Location: Bulgaria / Pleven
Contact:

Post by VoodooServ »

Thanks for script.
How to config for GMT+2 ?
I can't find package time .

Code: Select all

can't find package time
while executing
"package require time"
     (file "scripts/ntp.tcl" line 12)
     invoked from within
 "source scripts/ntp.tcl"
     (file "eggdrop.conf" line 1396)
 * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

Time package is a part of TCLLIB.
For GMT add extra 2 hours to the current time (GMT +0)
V
VoodooServ
Voice
Posts: 7
Joined: Sun Oct 27, 2013 12:49 pm
Location: Bulgaria / Pleven
Contact:

Post by VoodooServ »

Now:

Code: Select all

NTP couldn't open socket: host is unreachable
Please test.

how to fix ?
Post Reply