Add command to set display name for main bot in AS mode (#1103)
Docker Hub - Develop / docker-latest (push) Failing after 22s
GHCR - Development Branches / ghcr-publish (push) Failing after 23s
Tests / Build & Lint (push) Failing after 2m24s
Tests / Unit tests (push) Successful in 3m1s
Tests / Integration tests (push) Failing after 13s
Tests / Application Service Integration tests (push) Failing after 15s

This commit is contained in:
Catalan Lover
2026-04-28 13:51:04 +02:00
committed by GitHub
parent 56c904880f
commit ad4ce0706f
3 changed files with 49 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"draupnir": patch
---
Add set display name command to appservice main bot.
@@ -20,12 +20,14 @@ import {
} from "./ListCommand";
import { AppserviceProvisionForUserCommand } from "./ProvisionCommand";
import { AppserviceVersionCommand } from "./VersionCommand";
import { AppserviceDisplaynameCommand } from "./DisplaynameCommand";
AppserviceBotCommands.internCommand(AppserviceBotHelpCommand, ["admin", "help"])
.internCommand(AppserviceAllowCommand, ["admin", "allow"])
.internCommand(AppserviceRemoveCommand, ["admin", "remove"])
.internCommand(AppserviceProvisionForUserCommand, ["admin", "provision"])
.internCommand(AppserviceVersionCommand, ["admin", "version"])
.internCommand(AppserviceDisplaynameCommand, ["admin", "displayname"])
.internCommand(AppserviceRestartDraupnirCommand, ["admin", "restart"])
.internCommand(AppserviceListUnstartedCommand, [
"admin",
@@ -0,0 +1,42 @@
// SPDX-FileCopyrightText: 2026 Catalan Lover <catalanlover@protonmail.com>
//
// SPDX-License-Identifier: Apache-2.0
import { AppserviceAdaptorContext } from "./AppserviceBotPrerequisite";
import { ActionResult, isError, Ok } from "matrix-protection-suite";
import {
StringPresentationType,
describeCommand,
} from "@the-draupnir-project/interface-manager";
import { AppserviceBotInterfaceAdaptor } from "./AppserviceBotInterfaceAdaptor";
import { resultifyBotSDKRequestError } from "matrix-protection-suite-for-matrix-bot-sdk";
export const AppserviceDisplaynameCommand = describeCommand({
summary: "Sets the displayname of the main appservice admin bot.",
parameters: [],
rest: {
name: "displayname",
acceptor: StringPresentationType,
},
async executor(
context: AppserviceAdaptorContext,
_info,
_keywords,
displaynameParts
): Promise<ActionResult<void>> {
const displayname = displaynameParts.join(" ");
const setDisplaynameResult = await context.client
.setDisplayName(displayname)
.then((_) => Ok(undefined), resultifyBotSDKRequestError);
if (isError(setDisplaynameResult)) {
return setDisplaynameResult.elaborate(
`Failed to set appservice bot displayname to ${displayname}`
);
}
return setDisplaynameResult;
},
});
AppserviceBotInterfaceAdaptor.describeRenderer(AppserviceDisplaynameCommand, {
isAlwaysSupposedToUseDefaultRenderer: true,
});