monolith/commands/reg.py

36 lines
1.3 KiB
Python
Raw Normal View History

import main
from modules import regproc
class RegCommand:
def __init__(self, *args):
self.reg(*args)
def reg(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
if authed:
2020-11-01 03:37:29 +00:00
if length == 2:
if not spl[1] in main.network.keys():
failure("No such network: %s" % spl[1])
return
2020-11-01 18:50:17 +00:00
for i in main.network[spl[1]].relays.keys():
2020-11-01 03:37:29 +00:00
regproc.registerAccount(spl[1], int(spl[2]))
success("Requested registration for all relays on %s" % spl[1])
return
elif length == 3:
if not spl[1] in main.network.keys():
failure("No such network: %s" % spl[1])
return
if not spl[2].isdigit():
failure("Must be a number, not %s" % spl[2])
return
if not int(spl[2]) in main.network[spl[1]].relays.keys():
failure("No such relay on %s: %s" % (spl[2], spl[1]))
return
regproc.registerAccount(spl[1], int(spl[2]))
success("Requested registration on %s - %s" % (spl[1], spl[2]))
return
else:
incUsage("reg")
return
else:
incUsage(None)