use of jenkinsci.plugins.telegrambot.users.Subscribers in project telegram-notifications-plugin by jenkinsci.
the class StatusCommand method execute.
@Override
public void execute(AbsSender absSender, User user, Chat chat, String[] strings) {
Subscribers subscribers = Subscribers.getInstance();
String toSend;
Long id = chat.getId();
boolean isSubscribed = subscribers.isSubscribed(id);
if (isSubscribed) {
boolean isApproved = subscribers.isApproved(id);
if (GlobalConfiguration.getInstance().getApprovalType() == UserApprover.ApprovalType.ALL) {
toSend = botStrings.get("message.status.approved");
} else {
toSend = isApproved ? botStrings.get("message.status.approved") : botStrings.get("message.status.unapproved");
}
} else {
toSend = botStrings.get("message.status.unsubscribed");
}
SendMessage answer = new SendMessage();
answer.setChatId(chat.getId().toString());
answer.setText(toSend);
try {
absSender.execute(answer);
} catch (TelegramApiException e) {
BotLogger.error(LOG_TAG, e);
}
}
use of jenkinsci.plugins.telegrambot.users.Subscribers in project telegram-notifications-plugin by jenkinsci.
the class SubCommand method execute.
@Override
public void execute(AbsSender absSender, User user, Chat chat, String[] strings) {
Subscribers subscribers = Subscribers.getInstance();
String ans;
Long id = chat.getId();
String name = chat.isUserChat() ? user.getUserName() : chat.getTitle();
boolean isSubscribed = subscribers.isSubscribed(id);
if (!isSubscribed) {
subscribers.subscribe(name, id);
ans = botStrings.get("message.sub.success");
} else {
ans = botStrings.get("message.sub.alreadysub");
}
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 jenkinsci.plugins.telegrambot.users.Subscribers 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);
}
}
Aggregations