Closed zJudGenie closed 7 years ago
Do you mean when a user starts a new chat with your bot?
If so, just check if the message contains "/start"
No, on startup on startup you must send me a message
You mean when you run your bot (maybe .jar
), bot must send a message to a specific user that the bot has started?
Yes, you must send a message to a chat id specified in the code
Hope this useful when you get an update:
sendMessage(new SendMessage() .setChatId(update.getMessage().getChatId()) .setText("THIS IS MY TEXT") .setReplyToMessageId(update.getMessage().getMessageId())); <-(OPTIONAL)
No, you must send the message when you start the bot and as soon as it receives an update
@rubenlagus
Why don't you use the sample case? https://github.com/rubenlagus/TelegramBots/wiki/Getting-Started#build-our-first-bot
The bot works but I want to do, Which sends a message upon starting and not on receipt of a message or an update
can run in super group or just standard group @rubenlagus?
@CrazyminerMC just execute the "sendMessage" method when you want. No need to wait for an incoming update. In the sample case, you could add something like this to the Main.java:
ApiContextInitializer.init();
TelegramBotsApi botsApi = new TelegramBotsApi();
try {
MyAmazingBot mybot = MyAmazingBot();
botsApi.registerBot(mybot);
SendMessage message = new SendMessage()
.setChatId("XXXXXXX")
.setText("Hello World!");
mybot.sendMessage(message);
} catch (TelegramApiException e) {
e.printStackTrace();
}
Thank you so much, I wanted to do just that
Sorry for my bad english
I want to send message to user when he/she register on my website, like i do not want user to start chat first, i want bot to start chat first.
That's not possible. Users need to start a Chat first, for Spam reasons
But you can give them a link like https://telegram.me/BOT_USER_NAME?start=your_unique_id_of_user_in_your_application
That will open the Chat with your bot
Isn't there any API from Telegram to send message with or without bot?
You could use the normal API of Telegram for that, but that was not designed for bots.
Can this API send message to user? like i want to send message to user when he/she register on my site
On Tue, Dec 4, 2018 at 2:03 PM Clevero notifications@github.com wrote:
You could use the normal API of Telegram for that, but that was not designed for bots.
https://github.com/rubenlagus/TelegramApi
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rubenlagus/TelegramBots/issues/204#issuecomment-444014870, or mute the thread https://github.com/notifications/unsubscribe-auth/ApY34PFKLh8wWAgqGTG-PTxe016GN2lVks5u1jNygaJpZM4Md7zZ .
-- Regards
Devendra Singh| Tejora Private Limited | Cell: +919799990168| Office: +91-22-40780780
I do not want create telegram like application.
How to send message on bot enable ?
Sorry for my bad english