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

Create Book #1358

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Create Book #1358

wants to merge 1 commit into from

Conversation

ApataTEAM
Copy link

import org.telegram.telegrambots.bots.TelegramLongPollingBot;
import org.telegram.telegrambots.meta.api.methods.send.SendVideo;
import org.telegram.telegrambots.meta.api.objects.Message;
import org.telegram.telegrambots.meta.api.objects.Update;
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;

public class MyTelegramBot extends TelegramLongPollingBot {

@Override
public void onUpdateReceived(Update update) {
    Message message = update.getMessage();
    if (message != null && message.hasText()) {
        String text = message.getText();
        switch (text) {
            case "/start":
                sendTextMessage(message.getChatId().toString(), "Привет! Это пример телеграм бота.");
                break;
            case "/bagtutor":
                sendVideo(message.getChatId().toString(), "https://drive.google.com/file/d/1z8iLiKp0lXf4WDC_KQ5WNDhAL7FHK07-/view?usp=drivesdk");
                break;
            case "/poisk.laik":
                sendTextMessage(message.getChatId().toString(), "Текст для команды /poisk.laik");
                break;
        }
    }
}

private void sendTextMessage(String chatId, String text) {
    try {
        execute(new org.telegram.telegrambots.meta.api.methods.send.SendMessage(chatId, text));
    } catch (TelegramApiException e) {
        e.printStackTrace();
    }
}

private void sendVideo(String chatId, String videoUrl) {
    SendVideo sendVideo = new SendVideo();
    sendVideo.setChatId(chatId);
    sendVideo.setVideo(videoUrl);
    try {
        execute(sendVideo);
    } catch (TelegramApiException e) {
        e.printStackTrace();
    }
}

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

@Override
public String getBotToken() {
    return "6991957347:AAHaCw_nv4aDnOj3MQSsJES1Q0VezrpS4V8";
}

}
Fixes #

@rubenlagus
Copy link
Owner

Not sure what's this for

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

Successfully merging this pull request may close these issues.

None yet

2 participants