-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomset.etcl
executable file
·60 lines (56 loc) · 2.62 KB
/
comset.etcl
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
###
# Usage: /msg botnick comset [<channel>] <command> <value>
###
### COMSET:
bind msg - comset "msg_error msg_comset"
bind pub - $set(cmd)comset "pub_error pub_comset"
### CHANNEL:
proc pub_comset {nick uhost handle chan text} {
if {[validuser $handle]} {
all_comset c $nick $uhost $handle $chan $text
}
}
### QUERY:
proc msg_comset {nick uhost handle text} {
if {![validuser $handle]} {
return
} elseif {[lindex $text 0] == ""} {
notice $nick $handle "Invalid request: Wheres the channel name?"
} elseif {![string match #* [lindex $text 0]]} {
notice $nick $handle "Invalid request: [lindex $text 0] is not a channel"
} else {
all_comset m $nick $uhost $handle [lindex $text 0] [lrange $text 1 end]
}
}
### MAIN:
proc all_comset {type nick uhost handle chan text} {
global set botnick
chan_settings comget $type $nick $uhost $handle $chan $text
if {[level $handle $chan] == "0" || ![auth_check $nick $uhost $handle $chan] || [backup_check $chan]} {
return
} elseif {![validchan $chan]} {
notice $nick $handle "Invalid request: $chan is not a valid channel"
} elseif {[string tolower $type] == "c" && [changet $chan nochanmsg]} {
notice $nick $handle "$set(cmd)commands have been disabled for $chan"
} elseif {[level $handle $chan] < [comget $chan comset]} {
notice $nick $handle "Your level of [level $handle $chan] is less then the required [comget $chan comset] for this command"
} else {
set command [string tolower [lindex $text 0]]
set value [string tolower [lindex $text 1]]
if {$command == ""} {
notice $nick $handle "Invalid request: What command are you changing?"
} elseif {$value == ""} {
notice $nick $handle "Invalid request: What are you setting this to?"
} elseif {[readfile $set(data.dir)/[file_change $chan].com $command] == ""} {
notice $nick $handle "Invalid request: $command doesn't seem to be a valid command on $chan"
} elseif {[comget $chan $command] > [level $handle $chan]} {
notice $nick $handle "The current level of \002[comget $chan $command]\002 for \002$command\002 exceeds your level [level $handle $chan]"
} elseif {![isnum $value] || $value > "200" || $value < "0"} {
notice $nick $handle "Invalid request: The valid levels are between 0-200"
} else {
notice $nick $handle "Command level for '\002$command\002' on \002$chan\002 now set to '\002$value\002' from '\002[comget $chan $command]\002'"
writefile $set(data.dir)/[file_change $chan].com $command $value
}
}
putcmdlog "> !$handle! ($nick!$uhost) COMSET\[$type\] ($chan): $text"
}