Mjölnir-for-all: Nicer display name

This commit is contained in:
David Teller 2023-01-06 14:24:16 +01:00 committed by David Teller
parent fa5fbee229
commit d83127ea8c
2 changed files with 11 additions and 6 deletions

View File

@ -65,8 +65,8 @@ export class MjolnirManager {
intentListener, intentListener,
); );
await managedMjolnir.start(); await managedMjolnir.start();
if (this.config.displayName) { if (this.config.bot.displayName) {
await client.setDisplayName(this.config.displayName); await client.setDisplayName(this.config.bot.displayName);
} }
this.perMjolnirId.set(mjolnirUserId, managedMjolnir); this.perMjolnirId.set(mjolnirUserId, managedMjolnir);
this.perOwnerId.set(requestingUserId, managedMjolnir); this.perOwnerId.set(requestingUserId, managedMjolnir);

View File

@ -75,16 +75,21 @@ export interface IConfig {
address: string; address: string;
} }
}, },
/** a display name */ bot: {
displayName?: string, /** a display name */
displayName?: string,
},
} }
export function read(configPath: string): IConfig { export function read(configPath: string): IConfig {
const content = fs.readFileSync(configPath, "utf8"); const content = fs.readFileSync(configPath, "utf8");
const parsed = load(content); const parsed = load(content);
const config = (parsed as object) as IConfig; const config = (parsed as object) as IConfig;
if (!config.displayName) { if (!config.bot) {
config.displayName = "Moderation Bot"; config.bot = {};
}
if (!config.bot.displayName) {
config.bot.displayName = "Moderation Bot";
} }
return config; return config;
} }