-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautorehash.tcl
61 lines (55 loc) · 1.82 KB
/
autorehash.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Скрипт для авторехаша при изменении каких либо файлов скриптов
# Warning! Не использовать если не знаете точно что нужен!
encoding system utf-8
::ck::require config
namespace eval autorehash {
variable version 0.1
variable author "Chpock <[email protected]>"
variable detected
namespace import -force ::ck::*
namespace import -force ::ck::config::config
}
proc ::autorehash::init { } {
config register -id "delay" -type time -default 90 \
-desc "Delay for rehash after change of files detected." -access "n" -folder "autorehash"
config register -id "notify" -type str -default "n" \
-desc "Global flags of users for notify about autorehash." -access "n" -folder "autorehash"
etimer -interval 50 ::autorehash::run
catch { unset ::autorehash::detected }
}
proc ::autorehash::run { } {
if { [catch {set ::autorehash::detected} t] } {
foreacharray ::ck::loaded {
if { ![file exists $k] || [file mtime $k] != $v } {
debug -debug "Detected change file <%s> at <%s>, rehash delayed..." $k [clock seconds]
set ::autorehash::detected [clock seconds]
return
}
}
debug -debug "No changes."
return
}
if { [expr { [clock seconds] - $t }] < [config get "delay"] } {
debug -debug "delay prossed..."
return
}
set_ [list]
foreacharray ::ck::loaded {
if { ![file exists $k] || [file mtime $k] != $v } {
lappend_ [file tail $k]
}
}
set_ [join_ "\00314\002\002, \00304"]
if { [config get "notify"] ne "" } {
set n [list]
foreach c [channels] {
set n [concat $n [chanlist $c [config get "notify"]]]
}
if { [llength $n] } {
foreach n [luniq $n] {
putquick "NOTICE $n :\00310Auto-rehash due change of\00314:\0034 $_"
}
}
}
after idle rehash
}