rubenlagus / TelegramBots

Java library to create bots using Telegram Bots API
https://telegram.me/JavaBotsApi
MIT License
4.77k stars 1.22k forks source link

Deleting messages #555

Closed hamhub7 closed 5 years ago

hamhub7 commented 5 years ago

I am trying to delete a message using my bot in a direct message, and I get this error: org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException: Error deleting message: [400] Bad Request: message can't be deleted at org.telegram.telegrambots.meta.api.methods.updatingmessages.DeleteMessage.deserializeResponse(DeleteMessage.java:95) at org.telegram.telegrambots.meta.api.methods.updatingmessages.DeleteMessage.deserializeResponse(DeleteMessage.java:26) at org.telegram.telegrambots.bots.DefaultAbsSender.sendApiMethod(DefaultAbsSender.java:717) at org.telegram.telegrambots.meta.bots.AbsSender.execute(AbsSender.java:47) at hamhub7.seversonbot.Bot.onUpdateReceived(Bot.java:170) at java.util.ArrayList.forEach(Unknown Source) at org.telegram.telegrambots.meta.generics.LongPollingBot.onUpdatesReceived(LongPollingBot.java:27) at org.telegram.telegrambots.updatesreceivers.DefaultBotSession$HandlerThread.run(DefaultBotSession.java:305) Dec 01, 2018 12:00:06 AM org.telegram.telegrambots.meta.logging.BotLogger severe SEVERE: BOTSESSION java.lang.NullPointerException at hamhub7.seversonbot.Bot.onUpdateReceived(Bot.java:23) at java.util.ArrayList.forEach(Unknown Source) at org.telegram.telegrambots.meta.generics.LongPollingBot.onUpdatesReceived(LongPollingBot.java:27) at org.telegram.telegrambots.updatesreceivers.DefaultBotSession$HandlerThread.run(DefaultBotSession.java:305)

It seems like the bot does not have enough permissions, but I am not sure how to add them. Can I have the bot automatically request permissions? Can I add them through @BotFather? Where do I go from here?

hamhub7 commented 5 years ago

Upon further inspection, I found that disabling the "All memebers are admin" in my group then checking my bot allows it to delete the message. I want to know now if that is possible in dms, and if that process can be automated

Chase22 commented 5 years ago

You can't delete messages of ther other user in DMs Also, for your bot to be able to delete messages in groups, your bot has to be admin in that group. I think the "all members are admin" does not allow all members to delete messages from every user.

Chase22 commented 5 years ago

Is this question answered? @hamhub7

Clevero commented 5 years ago

I think this issue can be closed since no activity @rubenlagus