monolith/commands/swho.py

41 lines
1.5 KiB
Python

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():
if spl[1] in i:
for x in main.IRCPool[i].channels:
main.IRCPool[i].who(x)
success("Sent WHO to all channels on all networks on %s" % spl[1])
return
elif length == 3:
if not spl[1] in main.network.keys():
failure("Network does not exist: %s" % spl[1])
return
matches = []
for i in main.IRCPool.keys():
if spl[1] in i:
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)