-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtopic.tcl
More file actions
85 lines (71 loc) · 2 KB
/
Copy pathtopic.tcl
File metadata and controls
85 lines (71 loc) · 2 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# topic.tcl
#
# This script sets the topic in a channel with the !topic command.
# Additionally, it contains examples of setting a specific topic, e.g., if a
# stream is online/offline with the !on and !off commands.
#
# Usage:
# !topic topic set topic in channel to topic
# !on set preconfigured "on" topic in channel
# !off set preconfigured "off" topic in channel
#
# Enable for a channel with: .chanset #channel +topic
# Disable for a channel with: .chanset #channel -topic
#
# See https://github.com/hwipl/eggdrop-scripts for the latest version and
# additional information including the license (MIT).
# tested versions, might run on earlier versions
package require Tcl 8.6
package require eggdrop 1.8.4
namespace eval ::topic {
# channel flag for enabling/disabling
setudef flag topic
# topic for !on command
variable onTopic "Something is now online."
# topic for !off command
variable offTopic "Something is now offline."
}
proc ::topic::setOffTopic { nick host hand chan arg } {
variable offTopic
# check channel flag if enabled in this channel
if {![channel get $chan topic]} {
return 0
}
# set topic
putserv "TOPIC $chan :$offTopic"
return 1
}
proc ::topic::setOnTopic { nick host hand chan arg } {
variable onTopic
# check channel flag if enabled in this channel
if {![channel get $chan topic]} {
return 0
}
# set topic
putserv "TOPIC $chan :$onTopic"
return 1
}
proc ::topic::setTopic { nick host hand chan arg } {
# check channel flag if enabled in this channel
if {![channel get $chan topic]} {
return 0
}
# only allow ops to change topic
if {![isop $nick $chan]} {
return 0
}
# set topic
if {$arg == ""} {
return 0
}
putserv "TOPIC $chan :$arg"
return 1
}
namespace eval ::topic {
# bind pub o|o !off ::topic::setOffTopic
# bind pub o|o !on ::topic::setOnTopic
bind pub - !off ::topic::setOffTopic
bind pub - !on ::topic::setOnTopic
bind pub - !topic ::topic::setTopic
putlog "Loaded topic.tcl"
}