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:
|
elif length == 4:
|
||||||
if spl[1] == "add":
|
if spl[1] == "add":
|
||||||
if not spl[2] in main.tokens.keys():
|
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]] = {
|
main.tokens[spl[2]] = {
|
||||||
"hello": str(uuid4()),
|
"hello": str(uuid4()),
|
||||||
"usage": spl[3],
|
"usage": spl[3],
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
"alias": "alias [<add|del>] [<num>]",
|
"alias": "alias [<add|del>] [<num>]",
|
||||||
"auto": "auto [<network>]",
|
"auto": "auto [<network>]",
|
||||||
"cmd": "cmd <relay> <user> <entity> <text ...>",
|
"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 ...>",
|
"all": "all <entity> <text ...>",
|
||||||
"allc": "allc <network|alias> <(network)|(alias)> <entity> <text ...>",
|
"allc": "allc <network|alias> <(network)|(alias)> <entity> <text ...>",
|
||||||
"admall": "admall <entity> <text ...>",
|
"admall": "admall <entity> <text ...>",
|
||||||
|
|
|
@ -452,6 +452,7 @@ class IRCBot(IRCClient):
|
||||||
def got_list(self, listinfo):
|
def got_list(self, listinfo):
|
||||||
if len(listinfo) == 0: # probably ngircd not supporting LIST >0
|
if len(listinfo) == 0: # probably ngircd not supporting LIST >0
|
||||||
return
|
return
|
||||||
|
if main.config["ChanKeep"]["Enabled"]:
|
||||||
chankeep.initialList(self.net, self.num, listinfo, self.chanlimit)
|
chankeep.initialList(self.net, self.num, listinfo, self.chanlimit)
|
||||||
|
|
||||||
def recheckList(self):
|
def recheckList(self):
|
||||||
|
|
10
threshold
10
threshold
|
@ -5,17 +5,23 @@ from signal import SIGINT, signal
|
||||||
from sys import stderr, stdout
|
from sys import stderr, stdout
|
||||||
|
|
||||||
from twisted.internet import reactor
|
from twisted.internet import reactor
|
||||||
|
|
||||||
|
# Webapp stuff
|
||||||
|
from twisted.internet.protocol import Factory
|
||||||
from twisted.internet.ssl import DefaultOpenSSLContextFactory
|
from twisted.internet.ssl import DefaultOpenSSLContextFactory
|
||||||
|
|
||||||
import core.logstash
|
import core.logstash
|
||||||
import main
|
import main
|
||||||
import modules.counters
|
import modules.counters
|
||||||
|
from api.views import API
|
||||||
from core.relay import RelayFactory
|
from core.relay import RelayFactory
|
||||||
from core.server import ServerFactory
|
from core.server import ServerFactory
|
||||||
from utils.cleanup import handler
|
from utils.cleanup import handler
|
||||||
from utils.loaders.command_loader import loadCommands
|
from utils.loaders.command_loader import loadCommands
|
||||||
from utils.logging.log import log
|
from utils.logging.log import log
|
||||||
|
|
||||||
|
Factory.noisy = False
|
||||||
|
|
||||||
main.initMain()
|
main.initMain()
|
||||||
|
|
||||||
if "--debug" in sys.argv: # yes really
|
if "--debug" in sys.argv: # yes really
|
||||||
|
@ -84,4 +90,8 @@ if __name__ == "__main__":
|
||||||
for net in main.network.keys():
|
for net in main.network.keys():
|
||||||
main.network[net].start_bots()
|
main.network[net].start_bots()
|
||||||
modules.counters.setupCounterLoop()
|
modules.counters.setupCounterLoop()
|
||||||
|
if main.config["API"]["Enabled"]:
|
||||||
|
api = API()
|
||||||
|
api.app.run(main.config["API"]["Address"], main.config["API"]["Port"])
|
||||||
|
else:
|
||||||
reactor.run()
|
reactor.run()
|
||||||
|
|
Loading…
Reference in New Issue