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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
class ModesPlugin < Plugin
def help(plugin, topic="")
return "'op [<user>] [<channel>]' => grant user> (if ommitted yourself) ops in <channel> (or in the current channel if no channel is specified). Use deop instead of op to remove the privilege."
end
def op(m, params)
channel = params[:channel]
user = params[:user]
do_mode(m, channel, user, "+o")
end
def opme(m, params)
params[:user] = m.sourcenick
op(m, params)
end
def deop(m, params)
channel = params[:channel]
user = params[:user]
do_mode(m, channel, user, "-o")
end
def deopme(m, params)
params[:user] = m.sourcenick
deop(m, params)
end
def hop(m, params)
channel = params[:channel]
user = params[:user]
do_mode(m, channel, user, "+h")
end
def hopme(m, params)
params[:user] = m.sourcenick
hop(m, params)
end
def dehop(m, params)
channel = params[:channel]
user = params[:user]
do_mode(m, channel, user, "-h")
end
def dehopme(m, params)
params[:user] = m.sourcenick
dehop(m, params)
end
def voice(m, params)
channel = params[:channel]
user = params[:user]
do_mode(m, channel, user, "+v")
end
def voiceme(m, params)
params[:user] = m.sourcenick
voice(m, params)
end
def devoice(m, params)
channel = params[:channel]
user = params[:user]
do_mode(m, channel, user, "-v")
end
def devoiceme(m, params)
params[:user] = m.sourcenick
devoice(m, params)
end
def do_mode(m, channel, user, mode)
unless channel
if m.private?
target = user.nil? ? "you" : user
m.reply "You should tell me where you want me to #{mode} #{target}."
return
else
channel = m.channel
end
else
channel = m.server.channel(channel)
unless channel.has_user?(@bot.nick)
m.reply "I am not in that channel"
return
end
end
unless user
user = m.sourcenick
end
m.okay unless channel == m.channel.to_s
@bot.mode(channel, mode, user)
end
end
plugin = ModesPlugin.new
plugin.map("op [:user] [:channel]")
plugin.map("opme [:channel]") # For backwards compatibility with 0.9.10
plugin.map("deop [:user] [:channel]")
plugin.map("deopme [:channel]") # For backwards compatibility with 0.9.10
plugin.map("hop [:user] [:channel]")
plugin.map("hopme [:channel]")
plugin.map("dehop [:user] [:channel]")
plugin.map("dehopme [:channel]")
plugin.map("voice [:user] [:channel]")
plugin.map("voiceme [:channel]")
plugin.map("devoice [:user] [:channel]")
plugin.map("devoiceme [:channel]")
plugin.default_auth("*",false)
|