use of org.telegram.telegrambots.api.methods.send.SendMessage in project telegram-notifications-plugin by jenkinsci.
the class UnsubCommand method execute.
@Override
public void execute(AbsSender absSender, User user, Chat chat, String[] strings) {
Subscribers subscribers = Subscribers.getInstance();
String ans;
Long id = chat.getId();
boolean isSubscribed = subscribers.isSubscribed(id);
if (isSubscribed) {
subscribers.unsubscribe(id);
ans = botStrings.get("message.unsub.success");
} else {
ans = botStrings.get("message.unsub.alreadyunsub");
}
SendMessage answer = new SendMessage();
answer.setChatId(chat.getId().toString());
answer.setText(ans);
try {
absSender.execute(answer);
} catch (TelegramApiException e) {
BotLogger.error(LOG_TAG, e);
}
}
use of org.telegram.telegrambots.api.methods.send.SendMessage in project webofneeds by researchstudio-sat.
the class TelegramMessageGenerator method getErrorMessage.
public SendMessage getErrorMessage(Long chatId) {
SendMessage sendMessage = new SendMessage();
sendMessage.setChatId(chatId);
sendMessage.setText("could not create need wrong syntax");
return sendMessage;
}
use of org.telegram.telegrambots.api.methods.send.SendMessage in project webofneeds by researchstudio-sat.
the class TelegramMessageGenerator method getConnectMessage.
public SendMessage getConnectMessage(Long chatId, URI remoteNeedUri, URI yourNeedUri) {
Dataset remoteNeedRDF = eventListenerContext.getLinkedDataSource().getDataForResource(remoteNeedUri);
DefaultNeedModelWrapper needModelWrapper = new DefaultNeedModelWrapper(remoteNeedRDF);
String title = needModelWrapper.getSomeTitleFromIsOrAll("en", "de");
String description = needModelWrapper.getSomeDescription(NeedContentPropertyType.ALL, "en", "de");
SendMessage sendMessage = new SendMessage();
sendMessage.setChatId(chatId);
String text = "<b>Someone wants to connect with you!\n\n</b><a href='" + remoteNeedUri + "'>" + title + "\n\n</a>";
if (description != null) {
text = text + "<em>" + description + "</em>";
}
sendMessage.setText(text);
sendMessage.setReplyMarkup(getConnectionActionKeyboard("Accept", "Deny"));
sendMessage.enableHtml(true);
return sendMessage;
}
use of org.telegram.telegrambots.api.methods.send.SendMessage in project telegram-notifications-plugin by jenkinsci.
the class TelegramBot method sendMessage.
public void sendMessage(Long chatId, String message) {
SendMessage sendMessageRequest = new SendMessage();
sendMessageRequest.setChatId(chatId.toString());
sendMessageRequest.setText(message);
sendMessageRequest.enableMarkdown(true);
try {
execute(sendMessageRequest);
} catch (TelegramApiException e) {
LOGGER.log(Level.SEVERE, String.format("TelegramBot: Error while sending message: %s%n%s", chatId, message), e);
}
}
use of org.telegram.telegrambots.api.methods.send.SendMessage in project telegram-notifications-plugin by jenkinsci.
the class HelpCommand method execute.
@Override
public void execute(AbsSender absSender, User user, Chat chat, String[] strings) {
SendMessage answer = new SendMessage();
answer.setChatId(chat.getId().toString());
answer.setText(botStrings.get("message.help"));
try {
absSender.execute(answer);
} catch (TelegramApiException e) {
BotLogger.error(LOG_TAG, e);
}
}
Aggregations