Skip to content

Commit

Permalink
Fix appservice bot's missing renderers.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gnuxie committed Sep 20, 2024
1 parent 0d34e39 commit c22a1ec
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/appservice/bot/AccessCommands.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
describeCommand,
tuple,
} from "@the-draupnir-project/interface-manager";
import { AppserviceBotInterfaceAdaptor } from "./AppserviceBotCommandDispatcher";
import { AppserviceBotInterfaceAdaptor } from "./AppserviceBotInterfaceAdaptor";

export const AppserviceAllowCommand = describeCommand({
parameters: tuple({
Expand Down
18 changes: 3 additions & 15 deletions src/appservice/bot/AppserviceBotCommandDispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,22 @@ import {
CommandPrefixExtractor,
JSInterfaceCommandDispatcher,
MatrixInterfaceCommandDispatcher,
StandardAdaptorContextToCommandContextTranslator,
StandardJSInterfaceCommandDispatcher,
StandardMatrixInterfaceAdaptor,
StandardMatrixInterfaceCommandDispatcher,
} from "@the-draupnir-project/interface-manager";
import {
MPSCommandDispatcherCallbacks,
MPSMatrixInterfaceAdaptorCallbacks,
MatrixEventContext,
invocationInformationFromMatrixEventcontext,
} from "../../commands/interface-manager/MPSMatrixInterfaceAdaptor";
import { AppserviceAdaptorContext } from "./AppserviceBotPrerequisite";
import { userLocalpart } from "@the-draupnir-project/matrix-basic-types";
import { AppserviceBotCommands } from "./AppserviceBotCommandTable";
import { AppserviceBotHelpCommand } from "./AppserviceBotHelp";

export const AppserviceAdaptorContextToCommandContextTranslator =
new StandardAdaptorContextToCommandContextTranslator<AppserviceAdaptorContext>();

export const AppserviceBotInterfaceAdaptor = new StandardMatrixInterfaceAdaptor<
AppserviceAdaptorContext,
MatrixEventContext
>(
import {
AppserviceBotInterfaceAdaptor,
AppserviceAdaptorContextToCommandContextTranslator,
invocationInformationFromMatrixEventcontext,
MPSMatrixInterfaceAdaptorCallbacks,
MPSCommandDispatcherCallbacks
);
} from "./AppserviceBotInterfaceAdaptor";

function makePrefixExtractor(
appserviceContext: AppserviceAdaptorContext
Expand Down
8 changes: 3 additions & 5 deletions src/appservice/bot/AppserviceBotHelp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ import {
describeCommand,
} from "@the-draupnir-project/interface-manager";
import { ActionResult, Ok, isError } from "matrix-protection-suite";
import {
MatrixAdaptorContext,
MPSMatrixInterfaceAdaptor,
} from "../../commands/interface-manager/MPSMatrixInterfaceAdaptor";
import { MatrixAdaptorContext } from "../../commands/interface-manager/MPSMatrixInterfaceAdaptor";
import { AppserviceBotCommands } from "./AppserviceBotCommandTable";
import { renderTableHelp } from "../../commands/interface-manager/MatrixHelpRenderer";
import { AppserviceBotInterfaceAdaptor } from "./AppserviceBotInterfaceAdaptor";

export const AppserviceBotHelpCommand = describeCommand({
rest: {
Expand All @@ -44,6 +42,6 @@ function renderAppserviceBotHelp(
return Ok(<root>{renderTableHelp(appserviceBotCommands.ok)}</root>);
}

MPSMatrixInterfaceAdaptor.describeRenderer(AppserviceBotHelpCommand, {
AppserviceBotInterfaceAdaptor.describeRenderer(AppserviceBotHelpCommand, {
JSXRenderer: renderAppserviceBotHelp,
});
33 changes: 33 additions & 0 deletions src/appservice/bot/AppserviceBotInterfaceAdaptor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-FileCopyrightText: 2024 Gnuxie <Gnuxie@protonmail.com>
//
// SPDX-License-Identifier: Apache-2.0
//
// SPDX-FileAttributionText: <text>
// This modified file incorporates work from Draupnir
// https://github.com/the-draupnir-project/Draupnir
// </text>

import {
StandardAdaptorContextToCommandContextTranslator,
StandardMatrixInterfaceAdaptor,
} from "@the-draupnir-project/interface-manager";
import {
MatrixEventContext,
invocationInformationFromMatrixEventcontext,
MPSMatrixInterfaceAdaptorCallbacks,
MPSCommandDispatcherCallbacks,
} from "../../commands/interface-manager/MPSMatrixInterfaceAdaptor";
import { AppserviceAdaptorContext } from "./AppserviceBotPrerequisite";

export const AppserviceAdaptorContextToCommandContextTranslator =
new StandardAdaptorContextToCommandContextTranslator<AppserviceAdaptorContext>();

export const AppserviceBotInterfaceAdaptor = new StandardMatrixInterfaceAdaptor<
AppserviceAdaptorContext,
MatrixEventContext
>(
AppserviceAdaptorContextToCommandContextTranslator,
invocationInformationFromMatrixEventcontext,
MPSMatrixInterfaceAdaptorCallbacks,
MPSCommandDispatcherCallbacks
);
2 changes: 1 addition & 1 deletion src/appservice/bot/ListCommand.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
MatrixUserIDPresentationType,
tuple,
} from "@the-draupnir-project/interface-manager";
import { AppserviceBotInterfaceAdaptor } from "./AppserviceBotCommandDispatcher";
import { AppserviceBotInterfaceAdaptor } from "./AppserviceBotInterfaceAdaptor";

export const AppserviceListUnstartedCommand = describeCommand({
summary: "List any Draupnir that failed to start.",
Expand Down

0 comments on commit c22a1ec

Please sign in to comment.