本文整理汇总了Java中org.telegram.telegrambots.bots.TelegramLongPollingBot类的典型用法代码示例。如果您正苦于以下问题:Java TelegramLongPollingBot类的具体用法?Java TelegramLongPollingBot怎么用?Java TelegramLongPollingBot使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TelegramLongPollingBot类属于org.telegram.telegrambots.bots包,在下文中一共展示了TelegramLongPollingBot类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.telegram.telegrambots.bots.TelegramLongPollingBot; //导入依赖的package包/类
public static void main(String[] args) throws TelegramApiException {
TelegramBotsApi telegramBotsApi = new TelegramBotsApi();
try {
telegramBotsApi.registerBot(new TelegramLongPollingBot() {
@Override
public String getBotToken() {
return "232561070:AAFxh2DgKa3N21xluXZg565lMAnjh_MmdbQ";
}
@Override
public String getBotUsername() {
return "EsearchBot";
}
@Override
public void onUpdateReceived(Update update) {
logger.info(update.toString());
}
});
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
示例2: run
import org.telegram.telegrambots.bots.TelegramLongPollingBot; //导入依赖的package包/类
public void run(Update update, TelegramLongPollingBot bot) {
SendMessage sm = new SendMessage();
sm.setChatId(update.getMessage().getChatId());
sm.setParseMode(ParseMode.HTML);
String finalMessage = new String("<b>Verificador de Qualis - CAPES</b>\n");
finalMessage = finalMessage.concat("\nUtilize os seguintes comandos para consulta\n");
finalMessage = finalMessage.concat("\n<b>/conferencia</b> <i>sigla_conferencia</i> OU <i>nome_conferencia</i>");
finalMessage = finalMessage.concat("\n<b>/periodico</b> <i>issn_periodico</i> OU <i>nome_periodico</i>");
sm.setText(finalMessage);
try {
bot.sendMessage(sm);
} catch (TelegramApiException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例3: testOnUpdateReceived
import org.telegram.telegrambots.bots.TelegramLongPollingBot; //导入依赖的package包/类
@Test
public void testOnUpdateReceived() throws Exception {
TelegramLongPollingBot bot = Mockito.mock(TelegramLongPollingBot.class);
Mockito.doCallRealMethod().when(bot).onUpdatesReceived(any());
Update update1 = new Update();
Update update2 = new Update();
bot.onUpdatesReceived(asList(update1, update2));
Mockito.verify(bot).onUpdateReceived(update1);
Mockito.verify(bot).onUpdateReceived(update2);
}
示例4: registerBot
import org.telegram.telegrambots.bots.TelegramLongPollingBot; //导入依赖的package包/类
/**
* Register a bot. The Bot Session is started immediately, and may be disconnected by calling close.
* @param bot
*/
public BotSession registerBot(TelegramLongPollingBot bot) throws TelegramApiException {
setWebhook(bot.getBotToken());
return new BotSession(bot.getBotToken(), bot);
}
示例5: run
import org.telegram.telegrambots.bots.TelegramLongPollingBot; //导入依赖的package包/类
public void run(Update update, TelegramLongPollingBot bot);