-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PreBW.tcl
65 lines (58 loc) · 1.99 KB
/
PreBW.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
62
63
64
65
################################################################################
# slv-prebw v1.0 20190609 for ngBot/dZSbot
################################################################################
namespace eval ::ngBot::plugin::PreBW {
variable ns [namespace current]
## Config Settings ###############################
##
## Choose one of two settings: the first when using ngBot, the second when using dZSbot
variable np [namespace qualifiers [namespace parent]]
#variable np ""
##
variable bashScript "$::ngBot::glroot/bin/slv-prebw.sh"
variable scriptName ${ns}::LogEvent
variable events [list "PRE"]
## If you use a different PRE event/announce you can add it above
## Example: [list "PRE" "PREMP3" "ISOPRE"]
#bind evnt -|- prerehash ${ns}::DeInit
if {[string equal "" $np]} {
bind evnt -|- prerehash ${ns}::deinit
}
proc init {} {
variable np
variable events
variable scriptName
variable ${np}::precommand
putlog "\[ngBot\] PreBW :: Loaded successfully."
foreach event $events {
lappend precommand($event) $scriptName
}
return
}
proc deinit {} {
variable ns
variable np
variable events
variable scriptName
variable ${np}::precommand
foreach event $events {
if {[info exists precommand($event)] && [set pos [lsearch -exact $precommand($event) $scriptName]] != -1} {
set precommand($event) [lreplace $precommand($event) $pos $pos]
}
}
namespace delete $ns
#catch {unbind evnt -|- prerehash ${ns}::deinit}
return
}
proc LogEvent {event section logData} {
variable bashScript
variable events
if {[lsearch $events $event] != -1} {
exec $bashScript [lindex $logData 0] &
}
return 1
}
}
if {[string equal "" $::ngBot::plugin::PreBW::np]} {
::ngBot::plugin::PreBW::init
}