date.tcl 1001 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # date.tcl
  2. #
  3. # This script shows the current date and time with the !date command.
  4. #
  5. # Usage:
  6. # !date show the current date and time
  7. #
  8. # Enable for a channel with: .chanset #channel +date
  9. # Disable for a channel with: .chanset #channel -date
  10. #
  11. # See https://github.com/hwipl/eggdrop-scripts for the latest version and
  12. # additional information including the license (MIT).
  13. # tested versions, might run on earlier versions
  14. package require Tcl 8.6
  15. package require eggdrop 1.8.4
  16. namespace eval ::date {
  17. # channel flag for enabling/disabling
  18. setudef flag date
  19. }
  20. proc ::date::show_date { nick host hand chan arg } {
  21. # check channel flag if enabled in this channel
  22. if {![channel get $chan date]} {
  23. return 0
  24. }
  25. # get current date
  26. set date_format "%a %b %d %H:%M:%S %Z %Y"
  27. set date [clock format [clock seconds] -format $date_format]
  28. puthelp "PRIVMSG $chan :$date"
  29. return 1
  30. }
  31. namespace eval ::date {
  32. bind pub - !date ::date::show_date
  33. putlog "Loaded date.tcl"
  34. }