Reformat code with pre-commit
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import main
|
||||
from core.bot import deliverRelayCommands
|
||||
|
||||
|
||||
class AdmallCommand:
|
||||
def __init__(self, *args):
|
||||
self.admall(*args)
|
||||
|
||||
@@ -2,6 +2,7 @@ import main
|
||||
from yaml import dump
|
||||
from modules import alias
|
||||
|
||||
|
||||
class AliasCommand:
|
||||
def __init__(self, *args):
|
||||
self.alias(*args)
|
||||
@@ -21,7 +22,7 @@ class AliasCommand:
|
||||
if len(main.alias.keys()) == 0:
|
||||
nextNum = 1
|
||||
else:
|
||||
nextNum = max(main.alias.keys())+1
|
||||
nextNum = max(main.alias.keys()) + 1
|
||||
main.alias[nextNum] = alias.generate_alias()
|
||||
success("Generated new alias: %i" % nextNum)
|
||||
main.saveConf("alias")
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import main
|
||||
from core.bot import deliverRelayCommands
|
||||
|
||||
|
||||
class AllCommand:
|
||||
def __init__(self, *args):
|
||||
self.all(*args)
|
||||
@@ -14,8 +15,8 @@ class AllCommand:
|
||||
net = main.network[i].relays[x]["net"]
|
||||
alias = main.alias[x]["nick"]
|
||||
commands = {spl[1]: [" ".join(spl[2:])]}
|
||||
success("Sending commands to relay %s as user %s" % (num, alias+"/"+net))
|
||||
deliverRelayCommands(num, commands, user=alias+"/"+net)
|
||||
success("Sending commands to relay %s as user %s" % (num, alias + "/" + net))
|
||||
deliverRelayCommands(num, commands, user=alias + "/" + net)
|
||||
return
|
||||
else:
|
||||
incUsage("all")
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import main
|
||||
from core.bot import deliverRelayCommands
|
||||
|
||||
|
||||
class AllcCommand:
|
||||
def __init__(self, *args):
|
||||
self.allc(*args)
|
||||
@@ -16,9 +17,11 @@ class AllcCommand:
|
||||
targets.append((i, x))
|
||||
elif spl[1] == "alias":
|
||||
for i in main.network.keys():
|
||||
[targets.append((i, x)) for x in main.alias.keys() if
|
||||
main.alias[x]["nick"] == spl[2] and
|
||||
x in main.network[i].aliases.keys()]
|
||||
[
|
||||
targets.append((i, x))
|
||||
for x in main.alias.keys()
|
||||
if main.alias[x]["nick"] == spl[2] and x in main.network[i].aliases.keys()
|
||||
]
|
||||
else:
|
||||
incUsage("allc")
|
||||
return
|
||||
@@ -30,8 +33,8 @@ class AllcCommand:
|
||||
num = i[1]
|
||||
alias = main.alias[num]["nick"]
|
||||
commands = {spl[3]: [" ".join(spl[4:])]}
|
||||
success("Sending commands to relay %i as user %s" % (num, alias+"/"+net))
|
||||
deliverRelayCommands(num, commands, user=alias+"/"+net)
|
||||
success("Sending commands to relay %i as user %s" % (num, alias + "/" + net))
|
||||
deliverRelayCommands(num, commands, user=alias + "/" + net)
|
||||
return
|
||||
else:
|
||||
incUsage("allc")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import main
|
||||
|
||||
|
||||
class AuthcheckCommand:
|
||||
def __init__(self, *args):
|
||||
self.authcheck(*args)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import main
|
||||
from modules import provision
|
||||
|
||||
|
||||
class AutoCommand:
|
||||
def __init__(self, *args):
|
||||
self.auto(*args)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import main
|
||||
from yaml import dump
|
||||
|
||||
|
||||
class BlacklistCommand:
|
||||
def __init__(self, *args):
|
||||
self.blacklist(*args)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import main
|
||||
import modules.userinfo as userinfo
|
||||
|
||||
|
||||
class ChansCommand:
|
||||
def __init__(self, *args):
|
||||
self.chans(*args)
|
||||
@@ -16,7 +17,7 @@ class ChansCommand:
|
||||
rtrn += "Matches from: %s" % i
|
||||
rtrn += "\n"
|
||||
for x in result[i]:
|
||||
rtrn += (x)
|
||||
rtrn += x
|
||||
rtrn += "\n"
|
||||
rtrn += "\n"
|
||||
info(rtrn)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import main
|
||||
from core.bot import deliverRelayCommands
|
||||
|
||||
|
||||
class CmdCommand:
|
||||
def __init__(self, *args):
|
||||
self.cmd(*args)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import main
|
||||
from modules import regproc
|
||||
|
||||
|
||||
class ConfirmCommand:
|
||||
def __init__(self, *args):
|
||||
self.confirm(*args)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import main
|
||||
from core.bot import deliverRelayCommands
|
||||
|
||||
|
||||
class DisableCommand:
|
||||
def __init__(self, *args):
|
||||
self.disable(*args)
|
||||
@@ -15,7 +16,7 @@ class DisableCommand:
|
||||
failure("Must be a number, not %s" % spl[2])
|
||||
return
|
||||
relayNum = int(spl[2])
|
||||
name = spl[1]+spl[2]
|
||||
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():
|
||||
@@ -26,7 +27,7 @@ class DisableCommand:
|
||||
network = spl[1]
|
||||
relay = main.network[spl[1]].relays[relayNum]
|
||||
commands = {"status": ["Disconnect"]}
|
||||
deliverRelayCommands(relayNum, commands, user=user+"/"+network)
|
||||
deliverRelayCommands(relayNum, commands, user=user + "/" + network)
|
||||
main.saveConf("network")
|
||||
if name in main.ReactorPool.keys():
|
||||
if name in main.FactoryPool.keys():
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import main
|
||||
from subprocess import run, PIPE
|
||||
|
||||
|
||||
class DistCommand:
|
||||
def __init__(self, *args):
|
||||
self.dist(*args)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import main
|
||||
from yaml import dump
|
||||
|
||||
|
||||
class EmailCommand:
|
||||
def __init__(self, *args):
|
||||
self.email(*args)
|
||||
@@ -21,7 +22,7 @@ class EmailCommand:
|
||||
else:
|
||||
failure("Domain already exists in default config: %s" % domain)
|
||||
return
|
||||
|
||||
|
||||
else:
|
||||
num = int(spl[2])
|
||||
if spl[1] == "add":
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import main
|
||||
from core.bot import deliverRelayCommands
|
||||
|
||||
|
||||
class EnableCommand:
|
||||
def __init__(self, *args):
|
||||
self.enable(*args)
|
||||
@@ -22,9 +23,9 @@ class EnableCommand:
|
||||
user = main.alias[int(spl[2])]["nick"]
|
||||
network = spl[1]
|
||||
commands = {"status": ["Connect"]}
|
||||
deliverRelayCommands(int(spl[2]), commands, user=user+"/"+network)
|
||||
deliverRelayCommands(int(spl[2]), commands, user=user + "/" + network)
|
||||
main.saveConf("network")
|
||||
if not spl[1]+spl[2] in main.IRCPool.keys():
|
||||
if not spl[1] + spl[2] in main.IRCPool.keys():
|
||||
main.network[spl[1]].start_bot(int(spl[2]))
|
||||
else:
|
||||
pass
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import main
|
||||
|
||||
|
||||
class ExecCommand:
|
||||
def __init__(self, *args):
|
||||
self.exec(*args)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import main
|
||||
|
||||
|
||||
class HelpCommand:
|
||||
def __init__(self, *args):
|
||||
self.help(*args)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import main
|
||||
import modules.chankeep
|
||||
|
||||
|
||||
class JoinCommand:
|
||||
def __init__(self, *args):
|
||||
self.join(*args)
|
||||
@@ -21,10 +22,10 @@ class JoinCommand:
|
||||
if not int(spl[2]) in main.network[spl[1]].relays.keys():
|
||||
failure("Relay %s does not exist on network %s" % (spl[2], spl[1]))
|
||||
return
|
||||
if not spl[1]+spl[2] in main.IRCPool.keys():
|
||||
if not spl[1] + spl[2] in main.IRCPool.keys():
|
||||
failure("Name has no instance: %s" % spl[1])
|
||||
return
|
||||
main.IRCPool[spl[1]+spl[2]].join(spl[3])
|
||||
main.IRCPool[spl[1] + spl[2]].join(spl[3])
|
||||
success("Joined %s" % spl[3])
|
||||
return
|
||||
elif length == 5:
|
||||
@@ -34,10 +35,10 @@ class JoinCommand:
|
||||
if not int(spl[2]) in main.network[spl[1]].relays.keys():
|
||||
failure("Relay % does not exist on network %", (spl[2], spl[1]))
|
||||
return
|
||||
if not spl[1]+spl[2] in main.IRCPool.keys():
|
||||
if not spl[1] + spl[2] in main.IRCPool.keys():
|
||||
failure("Name has no instance: %s" % spl[1])
|
||||
return
|
||||
main.IRCPool[spl[1]+spl[2]].join(spl[3], spl[4])
|
||||
main.IRCPool[spl[1] + spl[2]].join(spl[3], spl[4])
|
||||
success("Joined %s with key %s" % (spl[3], spl[4]))
|
||||
return
|
||||
else:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import main
|
||||
|
||||
|
||||
class ListCommand:
|
||||
def __init__(self, *args):
|
||||
self.list(*args)
|
||||
@@ -11,10 +12,10 @@ class ListCommand:
|
||||
if not 1 in main.network[i].relays.keys():
|
||||
info("Network has no first instance: %s" % i)
|
||||
continue
|
||||
if not i+"1" in main.IRCPool.keys():
|
||||
if not i + "1" in main.IRCPool.keys():
|
||||
info("No IRC instance: %s - 1" % i)
|
||||
continue
|
||||
main.IRCPool[i+"1"].list()
|
||||
main.IRCPool[i + "1"].list()
|
||||
success("Requested list with first instance of %s" % i)
|
||||
return
|
||||
elif length == 2:
|
||||
@@ -24,10 +25,10 @@ class ListCommand:
|
||||
if not 1 in main.network[spl[1]].relays.keys():
|
||||
failure("Network has no first instance")
|
||||
return
|
||||
if not spl[1]+"1" in main.IRCPool.keys():
|
||||
if not spl[1] + "1" in main.IRCPool.keys():
|
||||
failure("No IRC instance: %s - 1" % spl[1])
|
||||
return
|
||||
main.IRCPool[spl[1]+"1"].list()
|
||||
main.IRCPool[spl[1] + "1"].list()
|
||||
success("Requested list with first instance of %s" % spl[1])
|
||||
return
|
||||
else:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import main
|
||||
|
||||
|
||||
class LoadCommand:
|
||||
def __init__(self, *args):
|
||||
self.load(*args)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import main
|
||||
from utils.loaders.single_loader import loadSingle
|
||||
|
||||
|
||||
class LoadmodCommand:
|
||||
def __init__(self, *args):
|
||||
self.loadmod(*args)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import main
|
||||
|
||||
|
||||
class LogoutCommand:
|
||||
def __init__(self, *args):
|
||||
self.logout(*args)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import main
|
||||
from yaml import dump
|
||||
|
||||
|
||||
class ModCommand:
|
||||
# This could be greatly improved, but not really important right now
|
||||
def __init__(self, *args):
|
||||
@@ -23,7 +24,7 @@ class ModCommand:
|
||||
success("Successfully set key %s to %s on %s" % (spl[2], spl[3], spl[1]))
|
||||
return
|
||||
# Find a better way to do this
|
||||
#elif length == 6:
|
||||
# elif length == 6:
|
||||
# if not spl[1] in main.network.keys():
|
||||
# failure("Network does not exist: %s" % spl[1])
|
||||
# return
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import main
|
||||
|
||||
|
||||
class MsgCommand:
|
||||
def __init__(self, *args):
|
||||
self.msg(*args)
|
||||
@@ -13,12 +14,12 @@ class MsgCommand:
|
||||
if not int(spl[2]) in main.network[spl[1]].relays.keys():
|
||||
failure("Relay % does not exist on network %" % (spl[2], spl[1]))
|
||||
return
|
||||
if not spl[1]+spl[2] in main.IRCPool.keys():
|
||||
if not spl[1] + spl[2] in main.IRCPool.keys():
|
||||
failure("Name has no instance: %s" % spl[1])
|
||||
return
|
||||
if not spl[3] in main.IRCPool[spl[1]+spl[2]].channels:
|
||||
if not spl[3] in main.IRCPool[spl[1] + spl[2]].channels:
|
||||
info("Bot not on channel: %s" % spl[3])
|
||||
main.IRCPool[spl[1]+spl[2]].msg(spl[3], " ".join(spl[4:]))
|
||||
main.IRCPool[spl[1] + spl[2]].msg(spl[3], " ".join(spl[4:]))
|
||||
success("Sent %s to %s on relay %s on network %s" % (" ".join(spl[4:]), spl[3], spl[2], spl[1]))
|
||||
return
|
||||
else:
|
||||
|
||||
@@ -3,6 +3,7 @@ from yaml import dump
|
||||
from modules.network import Network
|
||||
from string import digits
|
||||
|
||||
|
||||
class NetworkCommand:
|
||||
def __init__(self, *args):
|
||||
self.network(*args)
|
||||
@@ -38,7 +39,7 @@ class NetworkCommand:
|
||||
elif length == 3:
|
||||
if spl[1] == "del":
|
||||
if spl[2] in main.network.keys():
|
||||
main.network[spl[2]].seppuku() # ;(
|
||||
main.network[spl[2]].seppuku() # ;(
|
||||
del main.network[spl[2]]
|
||||
success("Successfully removed network: %s" % spl[2])
|
||||
main.saveConf("network")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import main
|
||||
|
||||
|
||||
class PartCommand:
|
||||
def __init__(self, *args):
|
||||
self.part(*args)
|
||||
@@ -13,10 +14,10 @@ class PartCommand:
|
||||
if not int(spl[2]) in main.network[spl[1]].relays.keys():
|
||||
failure("Relay % does not exist on network %", (spl[2], spl[1]))
|
||||
return
|
||||
if not spl[1]+spl[2] in main.IRCPool.keys():
|
||||
failure("Name has no instance: %s" % spl[1]+spl[2])
|
||||
if not spl[1] + spl[2] in main.IRCPool.keys():
|
||||
failure("Name has no instance: %s" % spl[1] + spl[2])
|
||||
return
|
||||
main.IRCPool[spl[1]+spl[2]].part(spl[3])
|
||||
main.IRCPool[spl[1] + spl[2]].part(spl[3])
|
||||
success("Left %s" % spl[3])
|
||||
return
|
||||
else:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import main
|
||||
|
||||
|
||||
class PassCommand:
|
||||
def __init__(self, *args):
|
||||
self.password(*args)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import main
|
||||
|
||||
|
||||
class PendingCommand:
|
||||
def __init__(self, *args):
|
||||
self.pending(*args)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import main
|
||||
|
||||
|
||||
class RecheckauthCommand:
|
||||
def __init__(self, *args):
|
||||
self.recheckauth(*args)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import main
|
||||
from modules import regproc
|
||||
|
||||
|
||||
class RegCommand:
|
||||
def __init__(self, *args):
|
||||
self.reg(*args)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import main
|
||||
from yaml import dump
|
||||
|
||||
|
||||
class RelayCommand:
|
||||
def __init__(self, *args):
|
||||
self.relay(*args)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import main
|
||||
|
||||
|
||||
class SaveCommand:
|
||||
def __init__(self, *args):
|
||||
self.save(*args)
|
||||
|
||||
@@ -3,6 +3,7 @@ import modules.counters as count
|
||||
import modules.userinfo as userinfo
|
||||
from string import digits
|
||||
|
||||
|
||||
class StatsCommand:
|
||||
def __init__(self, *args):
|
||||
self.stats(*args)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import main
|
||||
|
||||
|
||||
class SwhoCommand:
|
||||
def __init__(self, *args):
|
||||
self.swho(*args)
|
||||
|
||||
@@ -2,6 +2,7 @@ import main
|
||||
from yaml import dump
|
||||
from uuid import uuid4
|
||||
|
||||
|
||||
class TokenCommand:
|
||||
def __init__(self, *args):
|
||||
self.token(*args)
|
||||
@@ -31,11 +32,12 @@ class TokenCommand:
|
||||
elif length == 4:
|
||||
if spl[1] == "add":
|
||||
if not spl[2] in main.tokens.keys():
|
||||
if spl[3] in ["relay"]: # more to come!
|
||||
main.tokens[spl[2]] = {"hello": str(uuid4()),
|
||||
"usage": spl[3],
|
||||
"counter": str(uuid4()),
|
||||
}
|
||||
if spl[3] in ["relay"]: # more to come!
|
||||
main.tokens[spl[2]] = {
|
||||
"hello": str(uuid4()),
|
||||
"usage": spl[3],
|
||||
"counter": str(uuid4()),
|
||||
}
|
||||
main.saveConf("tokens")
|
||||
success("Successfully created token %s:" % spl[2])
|
||||
info(dump(main.tokens[spl[2]]))
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import main
|
||||
import modules.userinfo as userinfo
|
||||
|
||||
|
||||
class UsersCommand:
|
||||
def __init__(self, *args):
|
||||
self.users(*args)
|
||||
@@ -16,7 +17,7 @@ class UsersCommand:
|
||||
rtrn += "Matches from: %s" % i
|
||||
rtrn += "\n"
|
||||
for x in result[i]:
|
||||
rtrn += (x)
|
||||
rtrn += x
|
||||
rtrn += "\n"
|
||||
rtrn += "\n"
|
||||
info(rtrn)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import main
|
||||
import modules.userinfo as userinfo
|
||||
|
||||
|
||||
class WhoCommand:
|
||||
def __init__(self, *args):
|
||||
self.who(*args)
|
||||
@@ -14,7 +15,7 @@ class WhoCommand:
|
||||
rtrn += "Matches from: %s" % i
|
||||
rtrn += "\n"
|
||||
for x in result[i]:
|
||||
rtrn += (x)
|
||||
rtrn += x
|
||||
rtrn += "\n"
|
||||
rtrn += "\n"
|
||||
info(rtrn)
|
||||
|
||||
Reference in New Issue
Block a user