当前位置: 首页>>代码示例>>Java>>正文


Java TelegramBot.execute方法代码示例

本文整理汇总了Java中com.pengrad.telegrambot.TelegramBot.execute方法的典型用法代码示例。如果您正苦于以下问题:Java TelegramBot.execute方法的具体用法?Java TelegramBot.execute怎么用?Java TelegramBot.execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.pengrad.telegrambot.TelegramBot的用法示例。


在下文中一共展示了TelegramBot.execute方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: executarBot

import com.pengrad.telegrambot.TelegramBot; //导入方法依赖的package包/类
/**
 * Executa a inicializa��o do bot e realiza o 'polling' de mensagens enviadas
 */
public void executarBot() {
	TelegramBot bot = TelegramBotAdapter.build(TOKEN_ACESSO);
	int m = 0;

	while (true) {
		List<Update> updates = bot.execute(new GetUpdates().limit(100).offset(m)).updates();

		for (Update update : updates) {
			m = update.updateId() + 1;
			String mensagemRetorno = "";
			if (update.message() != null) {
				bot.execute(new SendChatAction(update.message().chat().id(), ChatAction.typing.name()));
				try {
					mensagemRetorno = tratarMensagemBot(update);
				} catch (Exception e) {
					mensagemRetorno = "Desculpe, n�o entendi... digite /ajuda para obter a lista de comandos conhecidos.";
				}
				bot.execute(new SendMessage(update.message().chat().id(), mensagemRetorno.toString()));
			}

		}
	}
}
 
开发者ID:pedrohnog,项目名称:Trabalhos-FIAP,代码行数:27,代码来源:Bot.java

示例2: apply

import com.pengrad.telegrambot.TelegramBot; //导入方法依赖的package包/类
@Override
public void apply(final SendMessage sendMessage) {
	final ImageSendPayload imageSendPayload = sendMessage.getPayloadWithType(ImageSendPayload.class);

	final String title = imageSendPayload.getTitle();
	final String imageUrl = imageSendPayload.getImageUrl();
	final String recipient = sendMessage.getRecipient().getId();

	final SendPhoto sendPhotoTelegram = new SendPhoto(recipient, imageUrl);

	if (!Strings.isBlank(title)) {
		sendPhotoTelegram.caption(title);
	}

	LOG.info("sending image {} to recipient {}", sendPhotoTelegram, recipient);
	final TelegramBot client = provideTelegramBot(sendMessage);
	client.execute(sendPhotoTelegram);
}
 
开发者ID:nitroventures,项目名称:bot4j,代码行数:19,代码来源:ImageRuleImpl.java

示例3: apply

import com.pengrad.telegrambot.TelegramBot; //导入方法依赖的package包/类
@Override
public void apply(final SendMessage sendMessage) {
	final VideoSendPayload videoSendPayload = sendMessage.getPayloadWithType(VideoSendPayload.class);

	final String title = videoSendPayload.getTitle();
	final String videoUrl = videoSendPayload.getVideoUrl();
	final String recipient = sendMessage.getRecipient().getId();

	final SendVideo sendVideoTelegram = new SendVideo(recipient, videoUrl);

	if (!Strings.isBlank(title)) {
		sendVideoTelegram.caption(title);
	}

	LOG.info("sending video {} to recipient {}", sendVideoTelegram, recipient);
	final TelegramBot client = provideTelegramBot(sendMessage);
	client.execute(sendVideoTelegram);
}
 
开发者ID:nitroventures,项目名称:bot4j,代码行数:19,代码来源:VideoRuleImpl.java

示例4: init

import com.pengrad.telegrambot.TelegramBot; //导入方法依赖的package包/类
@Inject
protected void init() {
	final String webhookUrl = telegramConfigService.getWebhookUrl((ReceiveMessage) null);

	if (Strings.isBlank(webhookUrl)) {
	} else {
		final SetWebhook request = new SetWebhook().url(webhookUrl);
		final TelegramBot bot = provideTelegramBot();
		bot.execute(request);
	}
}
 
开发者ID:nitroventures,项目名称:bot4j,代码行数:12,代码来源:TelegramWebhookImpl.java

示例5: getFileUrl

import com.pengrad.telegrambot.TelegramBot; //导入方法依赖的package包/类
protected String getFileUrl(final ReceiveMessage receiveMessage, final String fileId) {
	final TelegramBot bot = provideTelegramBot(receiveMessage);

	final GetFile getFile = new GetFile(fileId);
	final GetFileResponse response = bot.execute(getFile);
	final File file = response.file();
	final String url = bot.getFullFilePath(file);

	return url;
}
 
开发者ID:nitroventures,项目名称:bot4j,代码行数:11,代码来源:TelegramReceivePayloadFactoryImpl.java

示例6: sendPhotoElement

import com.pengrad.telegrambot.TelegramBot; //导入方法依赖的package包/类
protected void sendPhotoElement(final SendMessage sendMessage, final String recipient,
		final ListSendElement listSendElement) {
	final SendPhoto sendPhotoTelegram = new SendPhoto(recipient, listSendElement.getImageUrl());
	final String title = listSendElement.getTitle();

	if (!Strings.isBlank(title)) {
		sendPhotoTelegram.caption(title);
	}

	LOG.info("sending image {} to recipient {}", sendPhotoTelegram, recipient);
	final TelegramBot client = provideTelegramBot(sendMessage);
	client.execute(sendPhotoTelegram);
}
 
开发者ID:nitroventures,项目名称:bot4j,代码行数:14,代码来源:ListRuleImpl.java

示例7: requestDescription

import com.pengrad.telegrambot.TelegramBot; //导入方法依赖的package包/类
@Nullable
public BotInfo requestDescription(@NotNull TelegramSettings settings) {
  TelegramBot bot = createBot(settings);
  GetMeResponse response = bot.execute(new GetMe());
  User user = response.user();
  if (user == null) {
    return null;
  }
  return new BotInfo(user.firstName(), user.username());
}
 
开发者ID:dancing-elf,项目名称:teamcity-telegram-plugin,代码行数:11,代码来源:TelegramBotManager.java

示例8: apply

import com.pengrad.telegrambot.TelegramBot; //导入方法依赖的package包/类
@Override
public void apply(final SendMessage sendMessage) {
	final BaseRequest message = (BaseRequest) sendMessage.getNativePayload(TelegramPlatformEnum.TELEGRAM);
	final TelegramBot client = provideTelegramBot(sendMessage);
	client.execute(message);
}
 
开发者ID:nitroventures,项目名称:bot4j,代码行数:7,代码来源:NativeRuleImpl.java

示例9: execute

import com.pengrad.telegrambot.TelegramBot; //导入方法依赖的package包/类
protected void execute(final SendMessage sendMessage, final com.pengrad.telegrambot.request.SendMessage message,
		final String recipient) {
	LOG.info("sending to {} message {}", recipient, message);
	final TelegramBot client = provideTelegramBot(sendMessage);
	client.execute(message);
}
 
开发者ID:nitroventures,项目名称:bot4j,代码行数:7,代码来源:AbstractTelegramSendRuleImpl.java

示例10: sendNotification

import com.pengrad.telegrambot.TelegramBot; //导入方法依赖的package包/类
public void sendNotification(@NotNull Notification notification) {

        final StringBuilder message = new StringBuilder();
        String imContent = notification.getIMContent();

        if (!StringUtils.isEmpty(imContent) && resultsSummary != null) {
            if (resultsSummary.isSuccessful()) {
                message.append("\uD83D\uDE00 \uD83D\uDC4C ");
            } else {
                message.append("\uD83D\uDE31 \uD83D\uDE45\u200D♂️ ");
            }
            message.append(imContent).append(resultsSummary.getReasonSummary()).append("\n");

            List<String> authorsNames = resultsSummary.getUniqueAuthors().stream().map(Author::getFullName).collect(Collectors.toList());
            if (!authorsNames.isEmpty()) {
                message.append(" Responsible Users: ")
                        .append(String.join(", ", authorsNames))
                        .append("\n");
            }

            List<VariableSubstitution> variables = resultsSummary.getManuallyOverriddenVariables();
            if (!variables.isEmpty()) {
                message.append("Variables: \n");
                for (VariableSubstitution variable : variables) {
                    message.append(variable.getKey())
                            .append(": ")
                            .append(variable.getKey().contains("password") ? "******" :variable.getValue())
                            .append(" \n");
                }
            }

            List<String> labels = resultsSummary.getLabelNames();
            if (!labels.isEmpty()) {
                message.append("Labels: ")
                        .append(String.join(", ", labels))
                        .append("\n");
            }

            Set<LinkedJiraIssue> jiraIssues = resultsSummary.getRelatedJiraIssues();
            if (!jiraIssues.isEmpty()) {
                message.append("Issues: \n");
                for (LinkedJiraIssue issue : jiraIssues) {

                    if (issue.getJiraIssueDetails() == null) {
                        message.append(issue.getIssueKey());
                    } else {
                        message.append("<a href=\"")
                                .append(issue.getJiraIssueDetails().getDisplayUrl())
                                .append("\">")
                                .append(issue.getIssueKey())
                                .append("</a>")
                                .append(" - ")
                                .append(issue.getJiraIssueDetails().getSummary());
                    }
                    message.append("\n");
                }
            }
        }

        try {
            TelegramBot bot = TelegramBotAdapter.build(botToken);
            SendMessage request = new SendMessage(chatId, message.toString())
                    .parseMode(ParseMode.HTML);
            BaseResponse response = bot.execute(request);
            if (!response.isOk()) {
                log.error("Error using telegram API. error code: " + response.errorCode() + " message: " + response.description());
            } else {
                log.info("Success Telegram API message response: " + response.description() + " toString: " + response.toString());
            }
        } catch (RuntimeException e) {
            log.error("Error using telegram API: " + e.getMessage(), e);
        }
    }
 
开发者ID:leonoff,项目名称:bamboo-telegram-plugin,代码行数:74,代码来源:TelegramNotificationTransport.java


注:本文中的com.pengrad.telegrambot.TelegramBot.execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。