feat: refactor and new features (#7)

* feat: refactor and new features

+ Refactored the codebase
+ OCR support in bots
+ Server sends training data every minute
+ Not using collectors for Discord feedback buttons anymore
+ Fixed grammar mistakes
+ Configs are now seperated
+ Tokens are no longer in configs
- Like feedback doesn't work for Discord yet

* feat: remove feedback button once voted

* feat: role blacklist

* feat: thread name check

* feat: error handler for training

* fix: bot crashing when a webhook msg is sent

* refactor: remove debugging lines

* feat: allow fixing mistake at votes in discord bot
This commit is contained in:
reis
2023-06-23 21:29:00 +03:00
committed by GitHub
parent f5214a6ace
commit 8b9f45dc22
60 changed files with 1962 additions and 1591 deletions

View File

@@ -0,0 +1,26 @@
export default {
name: 'callback_query',
once: false,
async execute(bot, helper, cb) {
const admins = await bot.getChatAdministrators(cb.message.chat.id);
const isAdmin = admins.find((admin) => admin.user.id === cb.from.id);
if (!isAdmin)
return 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
});
helper.sendTrainData(
cb.message.reply_to_message.text.toLowerCase(),
cb.data.replace('label_', '').toUpperCase()
);
bot.sendMessage(cb.message.chat.id, 'Sent training data to server.', {
message_thread_id: cb.message.message_thread_id,
reply_to_message_id: cb.message.message_id
});
bot.deleteMessage(cb.message.chat.id, cb.message.message_id);
}
};

View File

@@ -0,0 +1,15 @@
export default {
name: 'message',
once: false,
async execute(bot, helper, msg) {
if (msg.photo) {
const fileLink = await bot.getFileLink(msg.photo.at(-1).file_id);
helper.scanImage(fileLink, `${msg.chat.id}/${msg.message_thread_id}/${msg.message_id}`)
}
if (!msg.text) return;
helper.scanText(
msg.text.toLowerCase(),
`${msg.chat.id}/${msg.message_thread_id}/${msg.message_id}`
);
}
};