Skip to content

lloistborn/yoeker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yoeker

@YoekerBot As i called her Yoekie, a client for telegram-bot written on Java using Springboot 2.2.2 and Netty server.

Yoekie is listening to new message using onUpdateReceived(Update update) and convert the message into reactive-data-stream-context to make it posible handling message reactively.

Here is sample how it is done by Yoekie

  @Override
  public void onUpdateReceived(Update update) {

    Mono.just(update)
        .filter(Update::hasMessage)
        .filter(upd -> upd.getMessage().hasText())
        .flatMap(upd -> {
          String messageText = upd.getMessage().getText();
          long chatId = upd.getMessage().getChatId();

          return Mono.fromCallable(() ->
              execute(new SendMessage().setChatId(chatId).setText(messageText)))
              .doOnNext(data -> LOGGER.info("Sent message \"{}\" to {}", messageText, chatId))
              .doOnError(throwable -> LOGGER.error("Failed to send message \"{}\" to {} due to error: {}",
                  messageText, chatId, throwable.getMessage()));
        })
        .subscribe();
  }

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages