Home > OS >  Save chatID and text sent to a telegram bot, in a database
Save chatID and text sent to a telegram bot, in a database

Time:01-21

I'm developing a springboot application where i register the bot via token and username, and i just write some code in the class extending the TelegramLongPollingBot

@Autowired
BotService botService;
        .
        .
        .
if (certain Condition is met )) {
//send the text i retrieved from the bot api which is called command and access the service class and use it to create a ticket
    botService.createTicket(command);

But what i'm always getting is: Cannot invoke "BotService.createTicket(String)" because "this.BotService is null" Not only a service class, anything i try to access from this class gives me a NullPointerException

A small note everything is working fine it's just i can't send the messages i receive from the bot api to my service class or any other thing called from inside this class.

I need to know how to call a class without getting a null pointer, and hence save my needed info in the database. Thank you!!

CodePudding user response:

the error was from the dependency where instead of getting the spring-boot-telegram dependency i got the normal org.telegram dependency.

  •  Tags:  
  • Related