Reformat project

This commit is contained in:
2022-07-21 13:40:05 +01:00
parent 4ecb37b179
commit 2fecd98978
44 changed files with 363 additions and 236 deletions

View File

@@ -32,7 +32,7 @@ class AliasCommand:
failure("Must be a number, not %s" % spl[2])
return
num = int(spl[2])
if not num in main.alias.keys():
if num not in main.alias.keys():
failure("No such alias: %i" % num)
return
failed = False

View File

@@ -1,5 +1,5 @@
import main
from core.bot import deliverRelayCommands
from utils.deliver_relay_commands import deliverRelayCommands
class AllCommand:

View File

@@ -1,5 +1,5 @@
import main
from core.bot import deliverRelayCommands
from utils.deliver_relay_commands import deliverRelayCommands
class AllcCommand:

View File

@@ -1,4 +1,3 @@
import main
import modules.userinfo as userinfo

View File

@@ -1,5 +1,4 @@
import main
from core.bot import deliverRelayCommands
from utils.deliver_relay_commands import deliverRelayCommands
class CmdCommand:

View File

@@ -1,5 +1,5 @@
import main
from core.bot import deliverRelayCommands
from utils.deliver_relay_commands import deliverRelayCommands
class DisableCommand:
@@ -19,13 +19,13 @@ class DisableCommand:
name = spl[1] + spl[2]
if not spl[1] in main.IRCPool.keys():
info("Note - instance not running, proceeding anyway")
if not relayNum in main.network[spl[1]].relays.keys():
if relayNum not in main.network[spl[1]].relays.keys():
failure("No such relay: %s in network %s" % (spl[2], spl[1]))
return
main.network[spl[1]].relays[relayNum]["enabled"] = False
user = main.alias[relayNum]["nick"]
network = spl[1]
relay = main.network[spl[1]].relays[relayNum]
# relay = main.network[spl[1]].relays[relayNum]
commands = {"status": ["Disconnect"]}
deliverRelayCommands(relayNum, commands, user=user + "/" + network)
main.saveConf("network")

View File

@@ -17,7 +17,7 @@ class EmailCommand:
if "@" in domain:
failure("Not a domain: %s" % domain)
return
if not domain in main.irc["_"]["domains"]:
if domain not in main.irc["_"]["domains"]:
main.irc["_"]["domains"].append(domain)
success("Successfully added domain %s to default config" % domain)
main.saveConf("irc")
@@ -41,7 +41,7 @@ class EmailCommand:
else:
num = int(spl[2])
if spl[1] == "add":
if not num in main.alias.keys():
if num not in main.alias.keys():
failure("No such alias: %i" % num)
return
if not spl[3] in main.alias[num]["emails"]:
@@ -53,7 +53,7 @@ class EmailCommand:
failure("Email already exists in alias %i: %s" % (num, spl[3]))
return
elif spl[1] == "del":
if not num in main.alias.keys():
if num not in main.alias.keys():
failure("No such alias: %i" % num)
return
if spl[3] in main.alias[num]["emails"]:

View File

@@ -1,5 +1,5 @@
import main
from core.bot import deliverRelayCommands
from utils.deliver_relay_commands import deliverRelayCommands
class EnableCommand:

View File

@@ -1,6 +1,3 @@
import main
class ExecCommand:
def __init__(self, *args):
self.exec(*args)

View File

@@ -9,7 +9,7 @@ class ListCommand:
if authed:
if length == 1:
for i in main.network.keys():
if not 1 in main.network[i].relays.keys():
if 1 not in main.network[i].relays.keys():
info("Network has no first instance: %s" % i)
continue
if not i + "1" in main.IRCPool.keys():
@@ -22,10 +22,10 @@ class ListCommand:
if not spl[1] in main.network.keys():
failure("No such network: %s" % spl[1])
return
if not 1 in main.network[spl[1]].relays.keys():
if 1 not in main.network[spl[1]].relays.keys():
failure("Network has no first instance")
return
if not spl[1] + "1" in main.IRCPool.keys():
if spl[1] + "1" not in main.IRCPool.keys():
failure("No IRC instance: %s - 1" % spl[1])
return
main.IRCPool[spl[1] + "1"].list()

View File

@@ -1,4 +1,3 @@
import main
from utils.loaders.single_loader import loadSingle
@@ -10,7 +9,7 @@ class LoadmodCommand:
if authed:
if length == 2:
rtrn = loadSingle(spl[1])
if rtrn == True:
if rtrn is True:
success("Loaded module: %s" % spl[1])
return
elif rtrn == "RELOAD":

View File

@@ -1,6 +1,3 @@
import main
class LogoutCommand:
def __init__(self, *args):
self.logout(*args)

View File

@@ -1,5 +1,4 @@
import main
from yaml import dump
class ModCommand:
@@ -16,8 +15,8 @@ class ModCommand:
try:
setattr(main.network[spl[1]], spl[2], spl[3])
except e:
failure("Something went wrong.")
except Exception as e:
failure(f"Something went wrong: {e}")
return
main.saveConf("network")

View File

@@ -12,7 +12,7 @@ class MsgCommand:
failure("Network does not exist: %s" % spl[1])
return
if not int(spl[2]) in main.network[spl[1]].relays.keys():
failure("Relay % does not exist on network %" % (spl[2], spl[1]))
failure("Relay %s does not exist on network %s" % (spl[2], spl[1]))
return
if not spl[1] + spl[2] in main.IRCPool.keys():
failure("Name has no instance: %s" % spl[1])

View File

@@ -8,9 +8,7 @@ class RecheckauthCommand:
def recheckauth(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
if authed:
if length == 1:
results = []
for i in main.IRCPool.keys():
num = main.IRCPool[i].num
net = main.IRCPool[i].net
main.IRCPool[i].authenticated = False
main.IRCPool[i].regPing()
@@ -20,9 +18,8 @@ class RecheckauthCommand:
if not spl[1] in main.network.keys():
failure("No such network: %s" % spl[1])
return
results = []
for i in main.IRCPool.keys():
num = main.IRCPool[i].num
# num = main.IRCPool[i].num
net = main.IRCPool[i].net
if not net == spl[1]:
continue

View File

@@ -26,7 +26,7 @@ class StatsCommand:
stats.append("User records: %s" % numWhoEntries)
stats.append("Events/min: %s" % main.lastMinuteSample)
counterEvents = count.getEvents()
if counterEvents == None:
if counterEvents is None:
stats.append("No counters records")
else:
stats.append("Counters:")
@@ -43,7 +43,7 @@ class StatsCommand:
numNodes = 0
for i in main.IRCPool.keys():
if "".join([x for x in i if not x in digits]) == spl[1]:
if "".join([x for x in i if x not in digits]) == spl[1]:
numChannels += len(main.IRCPool[i].channels)
found = True
numNodes += 1
@@ -54,7 +54,7 @@ class StatsCommand:
stats.append("User records: %s" % numWhoEntries)
stats.append("Endpoints: %s" % numNodes)
counterEvents = count.getEvents(spl[1])
if counterEvents == None:
if counterEvents is None:
stats.append("No counters records")
else:
stats.append("Counters:")

View File

@@ -1,4 +1,3 @@
import main
import modules.userinfo as userinfo

View File

@@ -1,4 +1,3 @@
import main
import modules.userinfo as userinfo