app/bot: add contact define name & phone
This commit is contained in:
parent
87ec038739
commit
db1dcbf581
@ -42,13 +42,16 @@ bot.command('addcontact', async (context) => {
|
||||
|
||||
bot.on(message('contact'), async (context) => {
|
||||
const customer = await getCustomer(context.from.id);
|
||||
|
||||
const isRegistration = !customer;
|
||||
|
||||
const { contact } = context.message;
|
||||
const name = (contact.first_name || '') + ' ' + (contact.last_name || '').trim();
|
||||
const phone = contact.phone_number;
|
||||
|
||||
if (isRegistration) {
|
||||
const response = await createUser({
|
||||
name: context.from.first_name,
|
||||
phone: context.message.contact.phone_number,
|
||||
name,
|
||||
phone,
|
||||
telegramId: context.from.id,
|
||||
}).catch((error) => {
|
||||
context.reply('Произошла ошибка.\n' + error);
|
||||
@ -68,10 +71,6 @@ bot.on(message('contact'), async (context) => {
|
||||
);
|
||||
}
|
||||
|
||||
const { contact } = context.message;
|
||||
const name = (contact.first_name || '') + ' ' + (contact.last_name || '').trim();
|
||||
const phone = contact.phone_number;
|
||||
|
||||
const response = await createClient({ name, phone }).catch((error) => {
|
||||
context.reply('Произошла ошибка.\n' + error);
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user