• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SendMessage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.pengrad.telegrambot.request.SendMessage的典型用法代码示例。如果您正苦于以下问题:Java SendMessage类的具体用法?Java SendMessage怎么用?Java SendMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: executarBot

import com.pengrad.telegrambot.request.SendMessage; //导入依赖的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: sendMessageToAll

import com.pengrad.telegrambot.request.SendMessage; //导入依赖的package包/类
@Override
public void sendMessageToAll(final List<IncomingMessage> incomingMessageList) {
    final Set<Prefs.UserPrefs> subscribers = PrefsController.instance.getPrefs().getEventListeners();
    es.submit(new Runnable() {
        @Override
        public void run() {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append(botService.getString(com.rai220.securityalarmbot.R.string.incoming_messages));
            for (IncomingMessage message : incomingMessageList) {
                stringBuilder.append(message.getPhone());
                if (!Strings.isNullOrEmpty(message.getName())) {
                    stringBuilder.append(" (").append(message.getName()).append(")");
                }
                stringBuilder.append(": \"").append(message.getMessage()).append("\"\n");
            }

            for (final Prefs.UserPrefs user : subscribers) {
                bot.execute(new SendMessage(user.lastChatId, stringBuilder.toString()));
            }
        }
    });
}
 
开发者ID:Rai220,项目名称:Telephoto,代码行数:23,代码来源:TelegramService.java


示例3: notifyToOthers

import com.pengrad.telegrambot.request.SendMessage; //导入依赖的package包/类
@Override
public void notifyToOthers(final int userId, final String message) {
    Prefs prefs = PrefsController.instance.getPrefs();
    final Prefs.UserPrefs userChange = prefs.getUser(userId);
    final Set<Prefs.UserPrefs> subscribers = prefs.getEventListeners();
    es.submit(new Runnable() {
        @Override
        public void run() {
            String userName = "null";
            if (userChange != null) {
                userName = userChange.isNick ? "@".concat(userChange.userName) : userChange.userName;
            }
            for (final Prefs.UserPrefs user : subscribers) {
                if (user.id != userId) {
                    bot.execute(new SendMessage(user.lastChatId, userName + " " + message));
                }
            }
        }
    });
}
 
开发者ID:Rai220,项目名称:Telephoto,代码行数:21,代码来源:TelegramService.java


示例4: sendLocation

import com.pengrad.telegrambot.request.SendMessage; //导入依赖的package包/类
@Override
public void sendLocation(final Long chatId, final Location location) {
    if (location != null) {
        es.submit(new Runnable() {
            @Override
            public void run() {
                float latitude = (float) location.getLatitude();
                float longitude = (float) location.getLongitude();
                DateTime date = new DateTime(location.getTime());
                if (date.isBefore(DateTime.now().minusMinutes(60))) {
                    bot.execute(new SendMessage(chatId, botService.getString(R.string.last_date_location) +
                            date.toString(Constants.DATE_TIME_PATTERN)));
                }
                bot.execute(new SendLocation(chatId, latitude, longitude));
            }
        });
    }
}
 
开发者ID:Rai220,项目名称:Telephoto,代码行数:19,代码来源:TelegramService.java


示例5: sendMessage

import com.pengrad.telegrambot.request.SendMessage; //导入依赖的package包/类
@Override
public void sendMessage(final Long id, final String message) {
    es.submit(new Runnable() {
        @Override
        public void run() {
            bot.execute(new SendMessage(id, message));
        }
    });
}
 
开发者ID:Rai220,项目名称:Telephoto,代码行数:10,代码来源:TelegramService.java


示例6: addUpdatesListener

import com.pengrad.telegrambot.request.SendMessage; //导入依赖的package包/类
private void addUpdatesListener(TelegramBot bot) {
  bot.setUpdatesListener(updates -> {
    for (Update update: updates) {
      Message message = update.message();
      Long chatId = message.chat().id();
      SendMessage msg = new SendMessage(chatId,
          "Hello! Your chat id is '" + chatId + "'.\n" +
              "If you want to receive notifications about Teamcity events " +
              "please add this chat id in your Teamcity settings");
      bot.execute(msg);
    }
    return UpdatesListener.CONFIRMED_UPDATES_ALL;
  });
}
 
开发者ID:dancing-elf,项目名称:teamcity-telegram-plugin,代码行数:15,代码来源:TelegramBotManager.java


示例7: main

import com.pengrad.telegrambot.request.SendMessage; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
    AqivnBot bot = new AqivnBot();
    bot.getWebPage("http://www.aqivn.org/en/")
            .map(bot::documentToAqiString)
            .subscribe(str -> {
                System.out.println(str);
                bot.bot.execute(new SendMessage(51314083, str));
            });


}
 
开发者ID:pengrad,项目名称:java-telegram-bot-api,代码行数:12,代码来源:AqivnBot.java


示例8: sendMessage

import com.pengrad.telegrambot.request.SendMessage; //导入依赖的package包/类
/**
 * Send message to client
 * @param chatId client identifier
 * @param message text to send
 */
public synchronized void sendMessage(long chatId, @NotNull String message) {
  if (bot != null) {
    bot.execute(new SendMessage(chatId, message));
  }
}
 
开发者ID:dancing-elf,项目名称:teamcity-telegram-plugin,代码行数:11,代码来源:TelegramBotManager.java


示例9: sendNotification

import com.pengrad.telegrambot.request.SendMessage; //导入依赖的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


示例10: onWebhookUpdate

import com.pengrad.telegrambot.request.SendMessage; //导入依赖的package包/类
@Override
void onWebhookUpdate(Update update) {
    bot.execute(new SendMessage(update.message().chat().id(), getAqi()).replyMarkup(simpleKeyboard()));
}
 
开发者ID:pengrad,项目名称:java-telegram-bot-api,代码行数:5,代码来源:AqivnBot.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CollectionStatistics类代码示例发布时间:2022-05-23
下一篇:
Java BooleanQuery类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap