Skip to content

Commit

Permalink
Update: bot_name settings field
Browse files Browse the repository at this point in the history
  • Loading branch information
juzser committed Feb 17, 2023
1 parent b2785f8 commit 0f85830
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
7 changes: 7 additions & 0 deletions OeReminderApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export class OeReminderApp extends App {
public botUsername: string;
public botUser: IUser;

public botName: string;

public defaultChannelName: string;
public defaultChannel: IRoom;

Expand Down Expand Up @@ -114,6 +116,8 @@ export class OeReminderApp extends App {
}
this.botUser = await this.getAccessors().reader.getUserReader().getByUsername(this.botUsername) as IUser;

this.botName = await environment.getSettings().getValueById('bot_name');

this.defaultChannelName = await environment.getSettings().getValueById('default_channel');
this.defaultChannel = await this.getAccessors().reader.getRoomReader().getByName(this.defaultChannelName) as IRoom;

Expand All @@ -139,6 +143,9 @@ export class OeReminderApp extends App {
this.botUser = await read.getUserReader().getByUsername(this.botUsername) as IUser;
}
break;
case 'bot_name':
this.botName = setting.value;
break;
case 'default_channel':
this.defaultChannelName = setting.value;
if (this.defaultChannelName) {
Expand Down
4 changes: 3 additions & 1 deletion i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"remind_params": "reminder list, reminder create",
"remind_desc": "Create reminders for yourself and other users.",
"bot_username": "Reminder Bot",
"bot_username_desc": "The name of the bot that will be used to send reminders.",
"bot_username_desc": "The username of bot that will be used to send reminders.",
"bot_name": "Reminder message author",
"bot_name_desc": "The name display for the bot that will be used to send reminders.",
"default_channel": "Default Channel",
"default_channel_desc": "The channel to get member list and use as default channel option.",
"enable_remindto_channel": "Enable create reminder to channel",
Expand Down
4 changes: 2 additions & 2 deletions src/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export async function sendMessage({ app, modify, room, message, attachments, blo
const msg = modify.getCreator().startMessage()
.setGroupable(group || false)
.setSender(app.botUser)
.setUsernameAlias(AppConfig.alias)
.setUsernameAlias(app.botName)
.setAvatarUrl(avatar || AppConfig.avatar)
.setRoom(room);

Expand Down Expand Up @@ -75,7 +75,7 @@ export async function notifyUser({ app, message, user, room, modify, blocks, att
}): Promise<void> {
const msg = modify.getCreator().startMessage()
.setSender(app.botUser)
.setUsernameAlias(AppConfig.alias)
.setUsernameAlias(app.botName)
.setAvatarUrl(AppConfig.avatar)
.setText(message)
.setRoom(room);
Expand Down
9 changes: 9 additions & 0 deletions src/lib/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ export const settings: Array<ISetting> = [
i18nLabel: 'bot_username',
i18nDescription: 'bot_username_desc',
},
{
id: 'bot_name',
type: SettingType.STRING,
packageValue: 'Cukoo',
required: true,
public: false,
i18nLabel: 'bot_name',
i18nDescription: 'bot_name_desc',
},
{
id: 'default_channel',
type: SettingType.STRING,
Expand Down

0 comments on commit 0f85830

Please sign in to comment.