2019-08-25 20:29:11 +00:00
|
|
|
import main
|
|
|
|
|
2022-07-21 12:39:41 +00:00
|
|
|
|
2019-08-25 20:29:11 +00:00
|
|
|
class SwhoCommand:
|
|
|
|
def __init__(self, *args):
|
|
|
|
self.swho(*args)
|
|
|
|
|
2022-09-05 06:20:30 +00:00
|
|
|
def swho(
|
|
|
|
self, addr, authed, data, obj, spl, success, failure, info, incUsage, length
|
|
|
|
):
|
2019-08-25 20:29:11 +00:00
|
|
|
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)
|