Skip to content

Commit

Permalink
Mjölnir-for-all: Nicer display name
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoric authored and David Teller committed Jan 10, 2023
1 parent fa5fbee commit d83127e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/appservice/MjolnirManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ export class MjolnirManager {
intentListener,
);
await managedMjolnir.start();
if (this.config.displayName) {
await client.setDisplayName(this.config.displayName);
if (this.config.bot.displayName) {
await client.setDisplayName(this.config.bot.displayName);
}
this.perMjolnirId.set(mjolnirUserId, managedMjolnir);
this.perOwnerId.set(requestingUserId, managedMjolnir);
Expand Down
13 changes: 9 additions & 4 deletions src/appservice/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,21 @@ export interface IConfig {
address: string;
}
},
/** a display name */
displayName?: string,
bot: {
/** a display name */
displayName?: string,
},
}

export function read(configPath: string): IConfig {
const content = fs.readFileSync(configPath, "utf8");
const parsed = load(content);
const config = (parsed as object) as IConfig;
if (!config.displayName) {
config.displayName = "Moderation Bot";
if (!config.bot) {
config.bot = {};
}
if (!config.bot.displayName) {
config.bot.displayName = "Moderation Bot";
}
return config;
}

0 comments on commit d83127e

Please sign in to comment.