2019-08-25 20:29:11 +00:00
|
|
|
import main
|
|
|
|
|
|
|
|
class SwhoCommand:
|
|
|
|
def __init__(self, *args):
|
|
|
|
self.swho(*args)
|
|
|
|
|
|
|
|
def swho(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
|
|
|
if authed:
|
|
|
|
if length == 2:
|
|
|
|
if not spl[1] in main.network.keys():
|
|
|
|
failure("Network does not exist: %s" % spl[1])
|
|
|
|
return
|
|
|
|
for i in main.IRCPool.keys():
|
2019-09-28 18:46:10 +00:00
|
|
|
if spl[1] == main.IRCPool[i].net:
|
2019-08-25 20:29:11 +00:00
|
|
|
for x in main.IRCPool[i].channels:
|
|
|
|
main.IRCPool[i].who(x)
|
2019-09-28 18:46:10 +00:00
|
|
|
success("Sent WHO to all channels on all networks for %s" % spl[1])
|
2019-08-25 20:29:11 +00:00
|
|
|
return
|
|
|
|
elif length == 3:
|
|
|
|
if not spl[1] in main.network.keys():
|
|
|
|
failure("Network does not exist: %s" % spl[1])
|
|
|
|
return
|
|
|
|
matches = []
|
2019-09-28 18:46:10 +00:00
|
|
|
|
|
|
|
# This loop gets all networks where the core network matches spl[1]
|
|
|
|
# where there is also a currently joined channel matching spl[2]
|
2019-08-25 20:29:11 +00:00
|
|
|
for i in main.IRCPool.keys():
|
2019-09-28 18:46:10 +00:00
|
|
|
if spl[1] == main.IRCPool[i].net:
|
2019-08-25 20:29:11 +00:00
|
|
|
for x in main.IRCPool[i].channels:
|
|
|
|
if x == spl[2]:
|
|
|
|
main.IRCPool[i].who(x)
|
|
|
|
matches.append(i)
|
|
|
|
if matches == []:
|
|
|
|
failure("No matches found for channel %s" % spl[2])
|
|
|
|
return
|
|
|
|
success("Sent WHO to %s on: %s" % (spl[2], ", ".join(matches)))
|
|
|
|
return
|
|
|
|
|
|
|
|
else:
|
|
|
|
incUsage("swho")
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
incUsage(None)
|