2022-08-14 10:41:29 +00:00
|
|
|
import main
|
|
|
|
from utils.get import getRelay
|
|
|
|
|
2022-08-14 11:43:33 +00:00
|
|
|
|
2022-08-14 10:41:29 +00:00
|
|
|
class GetstrCommand:
|
|
|
|
def __init__(self, *args):
|
|
|
|
self.getstr(*args)
|
|
|
|
|
|
|
|
def getstr(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
|
|
|
if authed:
|
|
|
|
if length == 3:
|
|
|
|
net = spl[1]
|
|
|
|
num = spl[2]
|
2022-08-14 11:43:33 +00:00
|
|
|
if net not in main.network.keys():
|
2022-08-14 10:41:29 +00:00
|
|
|
failure("Network does not exist: %s" % net)
|
|
|
|
return
|
|
|
|
if not num.isdigit():
|
|
|
|
failure("Must be a number, not %s" % num)
|
|
|
|
return
|
|
|
|
num = int(num)
|
|
|
|
alias = main.alias[num]["nick"].lower()
|
|
|
|
host, port = getRelay(num)
|
|
|
|
password = main.config["Relay"]["Password"]
|
|
|
|
connstr = f"/connect -ssl {host} {port}"
|
|
|
|
authstr = f"/quote PASS {alias}/{net}:{password}"
|
|
|
|
obj.send(connstr)
|
|
|
|
obj.send(authstr)
|
|
|
|
|
|
|
|
else:
|
|
|
|
incUsage("getstr")
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
incUsage(None)
|