Skip to content

Commit

Permalink
Added autoreply_confirmation to config
Browse files Browse the repository at this point in the history
  • Loading branch information
2naive committed Nov 26, 2022
1 parent f7bc0b9 commit 6f4d09c
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion config/config-sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ anonymous_tickets: true # Include userid in tickets or not
anonymous_replies: true # Include staff member name in response
show_auto_replied: false # Send auto replied msgs to staff chat
show_user_ticket: false # Show ticket id to user
autoreply_confirmation: true # Reply with language.confirmationMessage on each incoming message

signal_enabled: false # Enable/disable signal
signal_number: '+12345689' # Your signal number / account
Expand All @@ -37,7 +38,7 @@ language:
/clear - *Staff* Closes all tickets
/ban - *Staff* Ban a user from the chat
/unban - *Staff* Unban a user"
contactMessage: "Thank you for contacting us. We will answer as soon as possible. "
confirmationMessage: "Thank you for contacting us. We will answer as soon as possible. "
blockedSpam: 'You sent quite a number of questions in the last while. Please calm down and wait until staff reviews them.'
ticket: 'Ticket'
closed: 'closed'
Expand Down
2 changes: 1 addition & 1 deletion src/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ function fileHandler(type: string, bot: TelegramAddon, ctx: Context) {
}
// Confirmation message
let message =
cache.config.language.contactMessage +
cache.config.language.confirmationMessage +
(cache.config.show_user_ticket ?
cache.config.language.yourTicketId +
' #T' +
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ function createBot() {
}
defaultBot = new TelegramAddon(cache.config.bot_token);
}
cache.config.autoreply_confirmation = cache.config.autoreply_confirmation === undefined ? true : cache.config.autoreply_confirmation
cache.config.language.confirmationMessage = cache.config.language.confirmationMessage || cache.config.language.contactMessage // left for backward compatibility

return defaultBot;
}
Expand Down
4 changes: 3 additions & 1 deletion src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ interface Language {
startCommandText: string;
faqCommandText: string;
helpCommandText: string;
contactMessage: string;
confirmationMessage: string;
contactMessage: string; // left for backward compatibility
blockedSpam: string;
ticket: string;
closed: string;
Expand Down Expand Up @@ -100,6 +101,7 @@ interface Config {
dev_mode: boolean;
show_user_ticket: boolean;
language: Language;
autoreply_confirmation: boolean;
autoreply: Autoreply[];
categories: Category[];
}
Expand Down
4 changes: 2 additions & 2 deletions src/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ function chat(ctx: Context, chat: { id: string }) {
chat.id,
ctx.session.groupCategory,
function(ticket: { id: string }) {
if (!isAutoReply) {
if (!isAutoReply && cache.config.autoreply_confirmation) {
middleware.msg(
chat.id,
cache.config.language.contactMessage + '\n' +
cache.config.language.confirmationMessage + '\n' +
(cache.config.show_user_ticket ?
cache.config.language.ticket +
' #T' +
Expand Down
2 changes: 1 addition & 1 deletion test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('Messages', function() {
botAssert.assertMsgWildcard(
'Hello, this is some test!',
expected,
lang.contactMessage,
lang.confirmationMessage,
);
});
});
Expand Down

0 comments on commit 6f4d09c

Please sign in to comment.