-
Notifications
You must be signed in to change notification settings - Fork 2
/
forcechan.py
47 lines (34 loc) · 1.19 KB
/
forcechan.py
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
import znc
network = "Snoonet"
channel = "##bnc"
part = "PART " + channel
class forcechan(znc.Module):
module_types = [znc.CModInfo.GlobalModule]
description = "Forces users to remain in the configured channel"
def OnLoad(self, args, message):
return True
def OnUserPart(self, chan, message):
if channel == chan:
return znc.HALTCORE
return znc.CONTINUE
def OnSendToIRC(self, line):
if part in str(line):
self.force_chan()
return znc.HALTCORE
return znc.CONTINUE
def force_chan(self):
users = znc.CZNC.Get().GetUserMap()
for user in users.items():
net = user[1].FindNetwork(network)
if net:
chan = net.FindChan(channel)
if not chan:
net.AddChan(channel, True)
def OnModCommand(self, command):
if self.GetUser().IsAdmin():
if command.split()[0] == "forcechan":
self.force_chan()
self.PutModule("All users on network " + network +
" forced into channel " + channel)
else:
self.PutModule("Access denied.")