initial commit
This commit is contained in:
commit
e8e678bc2b
23 changed files with 2339 additions and 0 deletions
42
bin/matrixoidc.dart
Normal file
42
bin/matrixoidc.dart
Normal file
|
@ -0,0 +1,42 @@
|
|||
import "dart:io";
|
||||
import "package:cli_tools/config.dart";
|
||||
import "package:nexusbot/controllers/settings_controller.dart";
|
||||
import "package:nexusbot/helpers/api_helper.dart";
|
||||
import "package:riverpod/riverpod.dart";
|
||||
import "package:shelf/shelf.dart";
|
||||
import "package:shelf/shelf_io.dart";
|
||||
import "package:shelf_router/shelf_router.dart";
|
||||
|
||||
void main(List<String> argsRaw) async {
|
||||
final parser = ConfigParser()
|
||||
..addOption("socket", abbr: "s", mandatory: true)
|
||||
..addOption("homeserver", abbr: "h", mandatory: true)
|
||||
..addOption("foundUri", abbr: "f", mandatory: true)
|
||||
..addOption("name", abbr: "n", mandatory: true)
|
||||
..addOption("adminRoom", abbr: "a", mandatory: true)
|
||||
..addOption("botPasswordFile", abbr: "b", mandatory: true)
|
||||
..addOption("smtpPasswordFile", abbr: "p", mandatory: true)
|
||||
..addOption("inviteTo", abbr: "i");
|
||||
|
||||
final container = ProviderContainer();
|
||||
container
|
||||
.read(SettingsController.provider.notifier)
|
||||
.set(parser.parse(argsRaw));
|
||||
|
||||
final apiHelper = container.read(ApiHelper.provider);
|
||||
|
||||
final handler = const Pipeline()
|
||||
.addMiddleware(logRequests())
|
||||
.addHandler((Router()..post("/", apiHelper.register)).call);
|
||||
|
||||
final settings = container.read(SettingsController.provider)!;
|
||||
final server = HttpServer.listenOn(
|
||||
await ServerSocket.bind(
|
||||
InternetAddress(settings.socket, type: InternetAddressType.unix),
|
||||
0,
|
||||
),
|
||||
);
|
||||
|
||||
serveRequests(server, handler);
|
||||
print("Bot listening at ${server.address.address}");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue