winkratice
winkratice

Reputation: 131

My Telegram Bot can't read message sended by another Telegram Bot


I have two Telegram bots, written in Java.
First bot send some message every 10 min. (It works).
Second bot must read this sended message, and store it to txt file...
But problem is that the second bot don't see this message...
He see messages only from USERS.
M - bot
YR - user
Chat image
Console result



Here says if

BotFather=>Bot=>Settings=>Group Privacy => Privacy mode disabled and >BotFather=>Bot=>Settings=>Allow Groups? => Groups are currently enabled

bots must see messages sent from one to another.
I did it, also bots was invited to new group with Administrator rights.
Here code example (second bot):

public class TelegramBot extends TelegramLongPollingBot {

public final String BOT_TOKEN = "****************************";
public final String BOT_NAME = "*****************";

@Override
public void onUpdateReceived(Update update) {
    long inChatID = 0;
    int inMessID = 0;
    String inText = "";
    try {  // from chanel
        inChatID = update.getChannelPost().getChatId();
        inText = update.getChannelPost().getText();
        inMessID = update.getChannelPost().getMessageId();
    } catch (Throwable t1) {};
    try {  // from chat
        inChatID = update.getMessage().getChatId();
        inText = update.getMessage().getText();
        inMessID = update.getMessage().getMessageId();
    } catch (Throwable t2) {};

    System.out.println(inChatID);
    System.out.println(inMessID);
    System.out.println(inText);
}

@Override
public String getBotUsername() {
    return BOT_NAME;
}

@Override
public String getBotToken() {
    return BOT_TOKEN;
}
}

If I send any message like user, i getting in console ChatID, MessID, Text...
But if first bot send some message, i got nothing. Help me with this issue.
Any suggestion where my mistake ?

Upvotes: 4

Views: 6285

Answers (1)

winkratice
winkratice

Reputation: 131

I solved this issue by adding this two bots to channel with administrator rights. It's don't works with GROUP CHAT. Now i can see message sended from another bots. But there is another problem: all messages sended by any bot in channel throws like channel message, with out Bot ID, Bot Name, etc... So, I just can read message text, and parse it.

Upvotes: 6

Related Questions