Begin work on API endpoint
This commit is contained in:
parent
80c016761f
commit
4a8605626a
|
@ -0,0 +1,12 @@
|
|||
from klein import Klein
|
||||
|
||||
|
||||
class API(object):
|
||||
"""
|
||||
Our API webapp.
|
||||
"""
|
||||
|
||||
app = Klein()
|
||||
@app.route("/test", methods=["GET"])
|
||||
def hello(self, request):
|
||||
return "Hello"
|
|
@ -34,7 +34,7 @@ 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!
|
||||
if spl[3] in ["relay", "api"]: # more to come!
|
||||
main.tokens[spl[2]] = {
|
||||
"hello": str(uuid4()),
|
||||
"usage": spl[3],
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
"alias": "alias [<add|del>] [<num>]",
|
||||
"auto": "auto [<network>]",
|
||||
"cmd": "cmd <relay> <user> <entity> <text ...>",
|
||||
"token": "token <add|del|list> [<key>] [<relay>]",
|
||||
"token": "token <add|del|list> [<key>] [relay|api]",
|
||||
"all": "all <entity> <text ...>",
|
||||
"allc": "allc <network|alias> <(network)|(alias)> <entity> <text ...>",
|
||||
"admall": "admall <entity> <text ...>",
|
||||
|
|
|
@ -452,6 +452,7 @@ class IRCBot(IRCClient):
|
|||
def got_list(self, listinfo):
|
||||
if len(listinfo) == 0: # probably ngircd not supporting LIST >0
|
||||
return
|
||||
if main.config["ChanKeep"]["Enabled"]:
|
||||
chankeep.initialList(self.net, self.num, listinfo, self.chanlimit)
|
||||
|
||||
def recheckList(self):
|
||||
|
|
10
threshold
10
threshold
|
@ -5,17 +5,23 @@ from signal import SIGINT, signal
|
|||
from sys import stderr, stdout
|
||||
|
||||
from twisted.internet import reactor
|
||||
|
||||
# Webapp stuff
|
||||
from twisted.internet.protocol import Factory
|
||||
from twisted.internet.ssl import DefaultOpenSSLContextFactory
|
||||
|
||||
import core.logstash
|
||||
import main
|
||||
import modules.counters
|
||||
from api.views import API
|
||||
from core.relay import RelayFactory
|
||||
from core.server import ServerFactory
|
||||
from utils.cleanup import handler
|
||||
from utils.loaders.command_loader import loadCommands
|
||||
from utils.logging.log import log
|
||||
|
||||
Factory.noisy = False
|
||||
|
||||
main.initMain()
|
||||
|
||||
if "--debug" in sys.argv: # yes really
|
||||
|
@ -84,4 +90,8 @@ if __name__ == "__main__":
|
|||
for net in main.network.keys():
|
||||
main.network[net].start_bots()
|
||||
modules.counters.setupCounterLoop()
|
||||
if main.config["API"]["Enabled"]:
|
||||
api = API()
|
||||
api.app.run(main.config["API"]["Address"], main.config["API"]["Port"])
|
||||
else:
|
||||
reactor.run()
|
||||
|
|
Loading…
Reference in New Issue