Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to listen for not bot messages — account messages. #1179

Open
dynoChris opened this issue Jan 8, 2023 · 2 comments
Open

How to listen for not bot messages — account messages. #1179

dynoChris opened this issue Jan 8, 2023 · 2 comments

Comments

@dynoChris
Copy link

dynoChris commented Jan 8, 2023

Hi! I made my first Telegram bot. It's able to listen for new messages in the Telegram bot (BotFarther), code below, but I need to listen for new messages on my Telegram account! Not bot! How to do it help me please!

package org.example;

import org.telegram.telegrambots.bots.TelegramLongPollingBot;
import org.telegram.telegrambots.meta.TelegramBotsApi;
import org.telegram.telegrambots.meta.api.objects.Update;
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
import org.telegram.telegrambots.updatesreceivers.DefaultBotSession;

public class Main {
    public static void main(String[] args) {
        try {
            TelegramBotsApi telegramBotsApi = new TelegramBotsApi(DefaultBotSession.class);
            MyBot bot = new MyBot();
            telegramBotsApi.registerBot(bot);

        } catch (TelegramApiException e) {
            e.printStackTrace();
        }
    }
}

class MyBot extends TelegramLongPollingBot {
    @Override
    public void onUpdateReceived(Update update) {
        System.out.println("Hello World");
    }

    @Override
    public String getBotUsername() {
        return "BOT_USERNAME";
    }

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

}
@zortan3301
Copy link

Telegram prohibits using personal accounts as bots, you can only create a bot through BotFather

@samosxin
Copy link

you need telegram TD lib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants