Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
Undo last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexDyakonov committed Aug 18, 2024
1 parent 71f2279 commit faf9a39
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 70 deletions.
57 changes: 0 additions & 57 deletions routes/commands.js

This file was deleted.

72 changes: 59 additions & 13 deletions routes/dashBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@ router.use(
const { devlog, handleError } = require('./common.js');

const { sendMessage, getUserProfilePicture } = require('./methods.js');
const {
handleReportMessage,
handleStartCommand,
handleHelpCommand,
handleReportCommand,
handleUnknownCommand,
} = require('./commands.js');

setTimeout(function () {
axios
Expand Down Expand Up @@ -92,20 +85,73 @@ router.post(`/hook`, (req, res) => {
if (currentSession.reportMode) {
currentSession.reportMode = false;

if (reportChatId === undefined) {
if (report_chat_id === undefined) {
console.log("`report_chat_id` is undefined. Check envs to turn on reports.");
} else {
handleReportMessage(message, chat_id, reportChatId, token);
let reportTime = new Date().toLocaleString();

sendMessage(
{
chat_id: reportChatId,
text: `⚠️ <b>Репорт от пользователя:</b>\n\n<b>Имя:</b> ${message.from.first_name} ${message.from.last_name || ''}\n<b>Юзернейм:</b> @${message.from.username || 'нет юзернейма'}\n<b>Chat ID:</b> ${chat_id}\n<b>Время обращения:</b> ${reportTime}\n\n<b>Сообщение:</b>\n${text}`,
parse_mode: 'HTML',
},
'sendMessage',
token
);

sendMessage(
{
chat_id: chat_id,
text: 'Ваш репорт был успешно отправлен администрации.',
},
'sendMessage',
token
);
}
} else if (text === '/start') {
handleStartCommand(chat_id, message, token);
let fullName = message.from.first_name;
if (message.from.last_name) {
fullName += ` ${message.from.last_name}`;
}

sendMessage(
{
chat_id: chat_id,
text: `Добро пожаловать, <b>${fullName}</b>!\n\nИспользуйте DishDash, чтобы легко и быстро выбрать место для встречи в компании. Упомяните бота в чате и введите <code>@dishdash_bot start</code> для создания лобби.\n\nБот <a href='https://dishdash.ru'>DishDash</a> разработан командой <a href='https://t.me/+4l8DChDSxMQxNWUy'>\"Шампиньоны\"</a>.`,
parse_mode: 'HTML',
},
'sendMessage',
token
);
} else if (text === '/help') {
handleHelpCommand(chat_id, token);
sendMessage(
{
chat_id: chat_id,
text: 'Доступные команды:\n/start - Запуск бота\n/help - Справка\n/report - сообщить о баге/проблеме',
},
'sendMessage',
token
);
} else if (text === '/report') {
currentSession.reportMode = true;
handleReportCommand(chat_id, token);
sendMessage(
{
chat_id: chat_id,
text: 'Теперь отправьте сообщение, которое вы хотите сообщить администрации.',
},
'sendMessage',
token
);
} else {
handleUnknownCommand(chat_id, token);
sendMessage(
{
chat_id: chat_id,
text: 'Извините, я не понимаю эту команду.',
},
'sendMessage',
token
);
}
}
}
Expand Down

0 comments on commit faf9a39

Please sign in to comment.