date.tcl 871 B

12345678910111213141516171819202122232425262728293031323334353637
  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. # tested versions, might run on earlier versions
  11. package require Tcl 8.6
  12. package require eggdrop 1.8.4
  13. namespace eval ::date {
  14. # channel flag for enabling/disabling
  15. setudef flag date
  16. }
  17. proc ::date::show_date { nick host hand chan arg } {
  18. # check channel flag if enabled in this channel
  19. if {![channel get $chan date]} {
  20. return 0
  21. }
  22. # get current date
  23. set date_format "%a %b %d %H:%M:%S %Z %Y"
  24. set date [clock format [clock seconds] -format $date_format]
  25. puthelp "PRIVMSG $chan :$date"
  26. return 1
  27. }
  28. namespace eval ::date {
  29. bind pub - !date ::date::show_date
  30. putlog "Loaded date.tcl"
  31. }