if (args.at(0) == "Dx" + std::to_string(constants::ENGAGEMENT_AMOUNT) || args.at(0) == "dx" + std::to_string(constants::ENGAGEMENT_AMOUNT))
{
//###irrelavant code for now
}
else
{
if (!tools::isAdmin(bot, message->from, message))
{
if (tools::isAdmin(bot, bot.getApi().getMe(), message))
{
std::cout << "Deleted message in group:\n" << message->from->username << ":\n" <<
message->text << '\n' << std::endl;
bot.getApi().deleteMessage(message->chat->id, message->messageId);
}
else
{
TgBot::Message::Ptr msg = bot.getApi().sendMessage(message->chat->id, "\xe2\x9d\x8cThe
bot does not have the permission to delete messages. Make him admin to solve the
problem!");
//to delete message after a while
cleanChat::add(msg->messageId);
}
}
This is the relevant code.
The intention is that it is only allowed to write messages in a group which start with "Dx10".
Following problem occurs. I happens from time to time that the application crashes. The programm can be started again if the code above is commented out.
I highly assume that the program crashes due to the function deleteMessage() which tries to delete a non-existent message.
The only reason for this is that a user deletes a message before the program does it.
Deleting non-existent messages lets the app crash.
My question:
Is there a possibility to check whether the message with the corresponding messageId is still existent?
This is the relevant code. The intention is that it is only allowed to write messages in a group which start with "Dx10".
Following problem occurs. I happens from time to time that the application crashes. The programm can be started again if the code above is commented out. I highly assume that the program crashes due to the function deleteMessage() which tries to delete a non-existent message. The only reason for this is that a user deletes a message before the program does it. Deleting non-existent messages lets the app crash.
My question: Is there a possibility to check whether the message with the corresponding messageId is still existent?