@kaufman-bot/first-meeting-server
Advanced tools
Comparing version 3.2.2 to 3.3.0
@@ -40,3 +40,3 @@ { | ||
], | ||
"version": "3.2.2", | ||
"version": "3.3.0", | ||
"peerDependencies": { | ||
@@ -43,0 +43,0 @@ "@nestjs/common": "9.2.0", |
@@ -29,6 +29,5 @@ "use strict"; | ||
const context = msg.context; | ||
const locale = this.botCommandsToolsService.getLocale(msg, 'en'); | ||
const text = msg.callbackQueryData || msg.text; | ||
const state = Object.assign(Object.assign({}, context), { status: 'EndMeeting', gender: text && | ||
this.botCommandsToolsService.checkCommands(this.commonService.prepareText(text, locale), [(0, class_validator_multi_lang_1.getText)('female'), (0, class_validator_multi_lang_1.getText)('fm'), (0, class_validator_multi_lang_1.getText)('f')], locale) | ||
this.botCommandsToolsService.checkCommands(this.commonService.prepareText(text, msg.locale), [(0, class_validator_multi_lang_1.getText)('female'), (0, class_validator_multi_lang_1.getText)('fm'), (0, class_validator_multi_lang_1.getText)('f')], msg.locale) | ||
? 'Female' | ||
@@ -44,3 +43,2 @@ : 'Male', messagesMetadata: { AskGenderRequest: msg } }); | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const locale = this.botCommandsToolsService.getLocale(msg, 'en'); | ||
const state = yield this.storage.getState(this.botCommandsToolsService.getChatId(msg)); | ||
@@ -55,3 +53,3 @@ if (!state) { | ||
(0, class_validator_multi_lang_1.getText)(`Nice to meet you, {{firstname}} {{vulcan}}`), | ||
]), locale, Object.assign(Object.assign({ vulcan: '🖖' }, state), { meetGender: this.commonService.mapGenderToMeetGender(state, locale), firstname: this.botCommandsToolsService.capitalizeFirstLetter(state.firstname, locale), lastname: this.botCommandsToolsService.capitalizeFirstLetter(state.lastname, locale) })), | ||
]), msg.locale, Object.assign(Object.assign({ vulcan: '🖖' }, state), { meetGender: this.commonService.mapGenderToMeetGender(state, msg.locale), firstname: this.botCommandsToolsService.capitalizeFirstLetter(state.firstname, msg.locale), lastname: this.botCommandsToolsService.capitalizeFirstLetter(state.lastname, msg.locale) })), | ||
message: msg, | ||
@@ -58,0 +56,0 @@ context: { status: 'EndMeeting' }, |
@@ -23,11 +23,10 @@ "use strict"; | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const locale = this.botCommandsToolsService.getLocale(msg, 'en'); | ||
const state = yield this.storage.getState(this.botCommandsToolsService.getChatId(msg)); | ||
const firstname = (msg.text && | ||
!msg.callbackQueryData && | ||
this.commonService.prepareText(msg.text, locale)) || | ||
this.commonService.prepareText(msg.text, msg.locale)) || | ||
'Unknown'; | ||
if ((_a = state === null || state === void 0 ? void 0 : state.messagesMetadata) === null || _a === void 0 ? void 0 : _a.AskFirstnameResponse) { | ||
yield ctx.api.editMessageText(state.messagesMetadata.AskFirstnameResponse.chat.id, state.messagesMetadata.AskFirstnameResponse.message_id, state.messagesMetadata.AskFirstnameResponse | ||
? `${state.messagesMetadata.AskFirstnameResponse.text} (${this.translatesService.translate((0, class_validator_multi_lang_1.getText)('Your answer'), locale)}: ${firstname})` | ||
? `${state.messagesMetadata.AskFirstnameResponse.text} (${this.translatesService.translate((0, class_validator_multi_lang_1.getText)('Your answer'), msg.locale)}: ${firstname})` | ||
: state.messagesMetadata.AskFirstnameResponse); | ||
@@ -39,7 +38,9 @@ } | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const locale = this.botCommandsToolsService.getLocale(msg, 'en'); | ||
const state = yield this.storage.getState(this.botCommandsToolsService.getChatId(msg)); | ||
return (this.commonService.checkSpyWords({ msg }) && | ||
return (this.botCommandsToolsService.checkSpyWords({ | ||
msg, | ||
spyWords: this.config.spyWords, | ||
}) && | ||
!state && | ||
this.botCommandsToolsService.checkCommands(msg.text, [core_server_1.BotCommandsEnum.start], locale)); | ||
this.botCommandsToolsService.checkCommands(msg.text, [core_server_1.BotCommandsEnum.start], msg.locale)); | ||
}); | ||
@@ -49,4 +50,3 @@ } | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const locale = this.botCommandsToolsService.getLocale(msg, 'en'); | ||
const text = this.getHelloText(locale); | ||
const text = this.getHelloText(msg.locale); | ||
yield this.storage.pathState({ | ||
@@ -75,4 +75,3 @@ userId: this.botCommandsToolsService.getChatId(msg), | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const locale = this.botCommandsToolsService.getLocale(msg, 'en'); | ||
const text = this.getHelloText(locale); | ||
const text = this.getHelloText(msg.locale); | ||
return { | ||
@@ -85,4 +84,6 @@ type: 'text', | ||
reply_markup: new grammy_1.InlineKeyboard() | ||
.text('➡️' + this.translatesService.translate((0, class_validator_multi_lang_1.getText)('Next'), locale), 'next') | ||
.text('❌' + this.translatesService.translate((0, class_validator_multi_lang_1.getText)('Cancel'), locale), 'exit'), | ||
.text('➡️' + | ||
this.translatesService.translate((0, class_validator_multi_lang_1.getText)('Next'), msg.locale), 'next') | ||
.text('❌' + | ||
this.translatesService.translate((0, class_validator_multi_lang_1.getText)('Cancel'), msg.locale), 'exit'), | ||
}, | ||
@@ -89,0 +90,0 @@ callback: (result) => tslib_1.__awaiter(this, void 0, void 0, function* () { |
@@ -23,9 +23,8 @@ "use strict"; | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const locale = this.botCommandsToolsService.getLocale(msg, 'en'); | ||
const state = yield this.storage.getState(this.botCommandsToolsService.getChatId(msg)); | ||
if ((_a = state === null || state === void 0 ? void 0 : state.messagesMetadata) === null || _a === void 0 ? void 0 : _a.AskGenderResponse) { | ||
yield ctx.api.editMessageText(state.messagesMetadata.AskGenderResponse.chat.id, state.messagesMetadata.AskGenderResponse.message_id, state.messagesMetadata.AskGenderResponse | ||
? `${state.messagesMetadata.AskGenderResponse.text} (${this.translatesService.translate((0, class_validator_multi_lang_1.getText)('Your answer'), locale)}: ${this.translatesService.translate( | ||
? `${state.messagesMetadata.AskGenderResponse.text} (${this.translatesService.translate((0, class_validator_multi_lang_1.getText)('Your answer'), msg.locale)}: ${this.translatesService.translate( | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
state.gender, locale)})` | ||
state.gender, msg.locale)})` | ||
: state.messagesMetadata.AskGenderResponse); | ||
@@ -54,5 +53,4 @@ } | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const locale = this.botCommandsToolsService.getLocale(msg, 'en'); | ||
const text = this.translatesService.translate((0, class_validator_multi_lang_1.getText)(`What is your gender?`), locale); | ||
const lastname = this.commonService.prepareText(msg.text || '', locale); | ||
const text = this.translatesService.translate((0, class_validator_multi_lang_1.getText)(`What is your gender?`), msg.locale); | ||
const lastname = this.commonService.prepareText(msg.text || '', msg.locale); | ||
return { | ||
@@ -65,5 +63,8 @@ type: 'text', | ||
reply_markup: new grammy_1.InlineKeyboard() | ||
.text('🚹' + this.translatesService.translate((0, class_validator_multi_lang_1.getText)('Male'), locale), 'male') | ||
.text('🚺' + this.translatesService.translate((0, class_validator_multi_lang_1.getText)('Female'), locale), 'female') | ||
.text('❌' + this.translatesService.translate((0, class_validator_multi_lang_1.getText)('Cancel'), locale), 'exit'), | ||
.text('🚹' + | ||
this.translatesService.translate((0, class_validator_multi_lang_1.getText)('Male'), msg.locale), 'male') | ||
.text('🚺' + | ||
this.translatesService.translate((0, class_validator_multi_lang_1.getText)('Female'), msg.locale), 'female') | ||
.text('❌' + | ||
this.translatesService.translate((0, class_validator_multi_lang_1.getText)('Cancel'), msg.locale), 'exit'), | ||
}, | ||
@@ -70,0 +71,0 @@ callback: (result) => tslib_1.__awaiter(this, void 0, void 0, function* () { |
@@ -23,11 +23,10 @@ "use strict"; | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const locale = this.botCommandsToolsService.getLocale(msg, 'en'); | ||
const state = yield this.storage.getState(this.botCommandsToolsService.getChatId(msg)); | ||
const lastname = (msg.text && | ||
!msg.callbackQueryData && | ||
this.commonService.prepareText(msg.text, locale)) || | ||
this.commonService.prepareText(msg.text, msg.locale)) || | ||
'Unknown'; | ||
if ((_a = state === null || state === void 0 ? void 0 : state.messagesMetadata) === null || _a === void 0 ? void 0 : _a.AskLastnameResponse) { | ||
yield ctx.api.editMessageText(state.messagesMetadata.AskLastnameResponse.chat.id, state.messagesMetadata.AskLastnameResponse.message_id, state.messagesMetadata.AskLastnameResponse | ||
? `${state.messagesMetadata.AskLastnameResponse.text} (${this.translatesService.translate((0, class_validator_multi_lang_1.getText)('Your answer'), locale)}: ${lastname})` | ||
? `${state.messagesMetadata.AskLastnameResponse.text} (${this.translatesService.translate((0, class_validator_multi_lang_1.getText)('Your answer'), msg.locale)}: ${lastname})` | ||
: state.messagesMetadata.AskLastnameResponse); | ||
@@ -56,7 +55,6 @@ } | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const locale = this.botCommandsToolsService.getLocale(msg, 'en'); | ||
const text = this.translatesService.translate((0, class_validator_multi_lang_1.getText)(`What is your last name?`), locale); | ||
const text = this.translatesService.translate((0, class_validator_multi_lang_1.getText)(`What is your last name?`), msg.locale); | ||
const firstname = (msg.text && | ||
!msg.callbackQueryData && | ||
this.commonService.prepareText(msg.text, locale)) || | ||
this.commonService.prepareText(msg.text, msg.locale)) || | ||
'Unknown'; | ||
@@ -70,4 +68,6 @@ return { | ||
reply_markup: new grammy_1.InlineKeyboard() | ||
.text('➡️' + this.translatesService.translate((0, class_validator_multi_lang_1.getText)('Next'), locale), 'next') | ||
.text('❌' + this.translatesService.translate((0, class_validator_multi_lang_1.getText)('Cancel'), locale), 'exit'), | ||
.text('➡️' + | ||
this.translatesService.translate((0, class_validator_multi_lang_1.getText)('Next'), msg.locale), 'next') | ||
.text('❌' + | ||
this.translatesService.translate((0, class_validator_multi_lang_1.getText)('Cancel'), msg.locale), 'exit'), | ||
}, | ||
@@ -74,0 +74,0 @@ callback: (result) => tslib_1.__awaiter(this, void 0, void 0, function* () { |
@@ -20,3 +20,2 @@ "use strict"; | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const locale = this.botCommandsToolsService.getLocale(msg, 'en'); | ||
return (this.commonService.isContextProcess({ msg }) && | ||
@@ -29,3 +28,3 @@ this.botCommandsToolsService.checkCommands(msg.text || msg.callbackQueryData, [ | ||
(0, class_validator_multi_lang_1.getText)('end'), | ||
], locale)); | ||
], msg.locale)); | ||
}); | ||
@@ -43,6 +42,5 @@ } | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const locale = this.botCommandsToolsService.getLocale(msg, 'en'); | ||
return { | ||
type: 'text', | ||
text: this.translatesService.translate((0, class_validator_multi_lang_1.getText)(`{{close}} Meeting canceled`), locale, { close: '❌' }), | ||
text: this.translatesService.translate((0, class_validator_multi_lang_1.getText)(`{{close}} Meeting canceled`), msg.locale, { close: '❌' }), | ||
message: msg, | ||
@@ -49,0 +47,0 @@ context: { status: 'EndMeeting' }, |
@@ -18,5 +18,2 @@ import { BotCommandsProviderActionMsg, BotCommandsToolsService } from '@kaufman-bot/core-server'; | ||
}): Promise<any>; | ||
checkSpyWords({ msg }: { | ||
msg: BotCommandsProviderActionMsg; | ||
}): string | undefined; | ||
} |
@@ -44,4 +44,3 @@ "use strict"; | ||
const context = msg.context; | ||
const locale = this.botCommandsToolsService.getLocale(msg, 'en'); | ||
return (this.botCommandsToolsService.checkCommands(msg.text, [this.config.name], locale) || Object.keys(context).length > 0); | ||
return (this.botCommandsToolsService.checkCommands(msg.text, [this.config.name], msg.locale) || Object.keys(context).length > 0); | ||
} | ||
@@ -54,6 +53,2 @@ isDisable({ msg }) { | ||
} | ||
checkSpyWords({ msg }) { | ||
const locale = this.botCommandsToolsService.getLocale(msg, 'en'); | ||
return this.config.spyWords.find((spyWord) => this.botCommandsToolsService.checkCommands(msg.text, [spyWord], locale)); | ||
} | ||
}; | ||
@@ -60,0 +55,0 @@ tslib_1.__decorate([ |
@@ -20,6 +20,5 @@ "use strict"; | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const locale = this.botCommandsToolsService.getLocale(msg, 'en'); | ||
const state = yield this.storage.getState(this.botCommandsToolsService.getChatId(msg)); | ||
return ((state === null || state === void 0 ? void 0 : state.status) === 'EndMeeting' && | ||
this.botCommandsToolsService.checkCommands(msg.text, [(0, class_validator_multi_lang_1.getText)('hi'), (0, class_validator_multi_lang_1.getText)('hello'), (0, class_validator_multi_lang_1.getText)('hey')], locale)); | ||
this.botCommandsToolsService.checkCommands(msg.text, [(0, class_validator_multi_lang_1.getText)('hi'), (0, class_validator_multi_lang_1.getText)('hello'), (0, class_validator_multi_lang_1.getText)('hey')], msg.locale)); | ||
}); | ||
@@ -29,3 +28,2 @@ } | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const locale = this.botCommandsToolsService.getLocale(msg, 'en'); | ||
const state = yield this.storage.getState(this.botCommandsToolsService.getChatId(msg)); | ||
@@ -43,3 +41,3 @@ if (!state) { | ||
(0, class_validator_multi_lang_1.getText)(`Hi {{firstname}} {{vulcan}}`), | ||
]), locale, Object.assign(Object.assign({ vulcan: '🖖', handsplayed: '🖐', wink: '😉' }, state), { meetGender: this.commonService.mapGenderToMeetGender(state, locale), firstname: this.botCommandsToolsService.capitalizeFirstLetter(state.firstname, locale), lastname: this.botCommandsToolsService.capitalizeFirstLetter(state.lastname, locale) })) | ||
]), msg.locale, Object.assign(Object.assign({ vulcan: '🖖', handsplayed: '🖐', wink: '😉' }, state), { meetGender: this.commonService.mapGenderToMeetGender(state, msg.locale), firstname: this.botCommandsToolsService.capitalizeFirstLetter(state.firstname, msg.locale), lastname: this.botCommandsToolsService.capitalizeFirstLetter(state.lastname, msg.locale) })) | ||
.split(' ') | ||
@@ -46,0 +44,0 @@ .join(' ') |
import { BotCommandsProviderActionMsg, BotCommandsProviderActionResultType, BotCommandsToolsService } from '@kaufman-bot/core-server'; | ||
import { CommonService } from './common.service'; | ||
export declare class HelpStepService { | ||
private readonly commonService; | ||
private readonly botCommandsToolsService; | ||
private readonly config; | ||
constructor(commonService: CommonService, botCommandsToolsService: BotCommandsToolsService); | ||
constructor(botCommandsToolsService: BotCommandsToolsService); | ||
is({ msg }: { | ||
@@ -9,0 +7,0 @@ msg: BotCommandsProviderActionMsg; |
@@ -9,6 +9,4 @@ "use strict"; | ||
const first_meeting_config_1 = require("../../first-meeting-config/first-meeting.config"); | ||
const common_service_1 = require("./common.service"); | ||
let HelpStepService = class HelpStepService { | ||
constructor(commonService, botCommandsToolsService) { | ||
this.commonService = commonService; | ||
constructor(botCommandsToolsService) { | ||
this.botCommandsToolsService = botCommandsToolsService; | ||
@@ -18,5 +16,7 @@ } | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const locale = this.botCommandsToolsService.getLocale(msg, 'en'); | ||
return (this.commonService.checkSpyWords({ msg }) && | ||
this.botCommandsToolsService.checkCommands(msg.text, [core_server_1.BotCommandsEnum.help], locale)); | ||
return (this.botCommandsToolsService.checkSpyWords({ | ||
msg, | ||
spyWords: this.config.spyWords, | ||
}) && | ||
this.botCommandsToolsService.checkCommands(msg.text, [core_server_1.BotCommandsEnum.help], msg.locale)); | ||
}); | ||
@@ -26,3 +26,2 @@ } | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const locale = this.botCommandsToolsService.getLocale(msg, 'en'); | ||
return { | ||
@@ -32,3 +31,3 @@ type: 'markdown', | ||
markdown: this.botCommandsToolsService.generateHelpMessage(msg, { | ||
locale, | ||
locale: msg.locale, | ||
name: this.config.title, | ||
@@ -49,6 +48,5 @@ descriptions: this.config.descriptions, | ||
(0, common_1.Injectable)(), | ||
tslib_1.__metadata("design:paramtypes", [common_service_1.CommonService, | ||
core_server_1.BotCommandsToolsService]) | ||
tslib_1.__metadata("design:paramtypes", [core_server_1.BotCommandsToolsService]) | ||
], HelpStepService); | ||
exports.HelpStepService = HelpStepService; | ||
//# sourceMappingURL=help-step.service.js.map |
import { BotCommandsProviderActionMsg, BotCommandsProviderActionResultType, BotCommandsToolsService } from '@kaufman-bot/core-server'; | ||
import { TranslatesService } from 'nestjs-translates'; | ||
import { CommonService } from './common.service'; | ||
export declare class ResetStepService { | ||
private readonly commonService; | ||
private readonly botCommandsToolsService; | ||
private readonly translatesService; | ||
private readonly storage; | ||
constructor(commonService: CommonService, botCommandsToolsService: BotCommandsToolsService, translatesService: TranslatesService); | ||
private readonly config; | ||
constructor(botCommandsToolsService: BotCommandsToolsService, translatesService: TranslatesService); | ||
is({ msg }: { | ||
@@ -11,0 +10,0 @@ msg: BotCommandsProviderActionMsg; |
@@ -10,7 +10,6 @@ "use strict"; | ||
const nestjs_translates_1 = require("nestjs-translates"); | ||
const first_meeting_config_1 = require("../../first-meeting-config/first-meeting.config"); | ||
const first_meeting_storage_1 = require("../first-meeting.storage"); | ||
const common_service_1 = require("./common.service"); | ||
let ResetStepService = class ResetStepService { | ||
constructor(commonService, botCommandsToolsService, translatesService) { | ||
this.commonService = commonService; | ||
constructor(botCommandsToolsService, translatesService) { | ||
this.botCommandsToolsService = botCommandsToolsService; | ||
@@ -21,5 +20,7 @@ this.translatesService = translatesService; | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const locale = this.botCommandsToolsService.getLocale(msg, 'en'); | ||
return (this.commonService.checkSpyWords({ msg }) && | ||
this.botCommandsToolsService.checkCommands(msg.text, [core_server_1.BotCommandsEnum.reset], locale)); | ||
return (this.botCommandsToolsService.checkSpyWords({ | ||
msg, | ||
spyWords: this.config.spyWords, | ||
}) && | ||
this.botCommandsToolsService.checkCommands(msg.text, [core_server_1.BotCommandsEnum.reset], msg.locale)); | ||
}); | ||
@@ -34,3 +35,2 @@ } | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const locale = this.botCommandsToolsService.getLocale(msg, 'en'); | ||
return { | ||
@@ -41,3 +41,3 @@ type: 'text', | ||
(0, class_validator_multi_lang_1.getText)('I forgot about your existence {{worried}}'), | ||
]), locale, { | ||
]), msg.locale, { | ||
unamused: '😒', | ||
@@ -55,6 +55,9 @@ worried: '😟', | ||
], ResetStepService.prototype, "storage", void 0); | ||
tslib_1.__decorate([ | ||
(0, nestjs_custom_injector_1.CustomInject)(first_meeting_config_1.FIRST_MEETING_CONFIG), | ||
tslib_1.__metadata("design:type", Object) | ||
], ResetStepService.prototype, "config", void 0); | ||
ResetStepService = tslib_1.__decorate([ | ||
(0, common_1.Injectable)(), | ||
tslib_1.__metadata("design:paramtypes", [common_service_1.CommonService, | ||
core_server_1.BotCommandsToolsService, | ||
tslib_1.__metadata("design:paramtypes", [core_server_1.BotCommandsToolsService, | ||
nestjs_translates_1.TranslatesService]) | ||
@@ -61,0 +64,0 @@ ], ResetStepService); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
95858
1235