feat(telegram-bot): initialize

This commit is contained in:
GramingFoxTeam
2022-11-16 16:18:19 +03:00
parent 1c27ccb17c
commit d98902a285
8 changed files with 2152 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
export default {
name: 'aiResponse',
once: false,
async execute(aiRes) {
const response = global.config.responses.find(
(res) => res.label === aiRes.predictions[0].label
);
if (!response) return;
if (Number(aiRes.predictions[0].score) >= response.threshold) {
const ids = aiRes.id.split('/');
global.bot.sendMessage(ids[0], response.text, { message_thread_id: ids[1], reply_to_message_id: ids[2] });
return;
}
}
};

View File

@@ -0,0 +1,18 @@
export default {
name: 'callback_query',
once: false,
async execute(cb) {
const admins = await global.bot.getChatAdministrators(cb.message.chat.id);
const isAdmin = admins.find(admin => admin.user.id === cb.message.from.id);
if (!isAdmin) return global.bot.sendMessage(cb.message.chat.id, 'You\'re not an admin.', {
message_thread_id: cb.message.message_thread_id, reply_to_message_id: cb.message.message_id
});;
global.helper.sendTrainData(cb.message.reply_to_message.text.toLowerCase(), cb.data.replace('label_', '').toUpperCase());
global.bot.sendMessage(cb.message.chat.id, 'Sent train data to server.', {
message_thread_id: cb.message.message_thread_id, reply_to_message_id: cb.message.message_id
});
}
}

View File

@@ -0,0 +1,7 @@
export default {
name: 'message',
once: false,
async execute(msg) {
global.helper.scanText(msg.text.toLowerCase(), `${msg.chat.id}/${msg.message_thread_id}/${msg.message_id}`);
}
}