Closed aekramer closed 4 years ago
Try including telegrambots-4.6-with-dependencies.jar https://repo1.maven.org/maven2/org/telegram/telegrambots/4.6/
I made the same mistake as above at first. The *-with-dependencies.jar worked but I got following warning message on running:
[java] SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
[java] SLF4J: Defaulting to no-operation (NOP) logger implementation
[java] SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
I followed the link and added slf4j-simple-1.7.19.jar to my classpath.
But then I got:
[java] Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
Solution to remove the warning I copied the folder '/org/slf4j/impl/' containing the StaticLoggerBinder into 'telegrambots-4.6-with-dependencies.jar'. Now the warning is gone.
@OysterSandwich The warning is telling you that there is not logger implementation. What you need is an implementation of slf4j in your classpath. Either use log4j2 or logback for that
The all dependencies one didn't work for me, I finally managed to get it to work using the default jar I had before, extract it so I have the source code files instead, then investigate (based on errors in each file) what libraries were missing. I had to manually import ALL of these (downloaded latest versions from mvn repo for most, had to use some older versions or special combinations to make it work): https://imgur.com/uWPFqVT
Using the jar-with-dependencies as mentioned from here, you don't need to get any external libraries.
If you need to implement slf4j, please follow SLF4J docs: http://www.slf4j.org/manual.html
I can't seem to get this library to work, I included the telegrambots-4.6.jar like I usually do created a script according to:
` public class MyAmazingBot extends TelegramLongPollingBot { @Override public void onUpdateReceived(Update update) { // TODO }
}`
(Sorry there seems to be an issue with code tags on github.. can't get this thing to show properly but its a straight up copy from https://github.com/rubenlagus/TelegramBots/wiki/Getting-Started)
Imported:
import org.telegram.telegrambots.bots.TelegramLongPollingBot;
And at that point "MyAmazingBot" gives the error: "The hierarchy of the type MyAmazingBot is inconsistent" and "Update" can not be resolved to a type (no suggested import).
I also tried importing the source directly, at which point I receive massive errors in the imported files, for example when going into
org.telegram.telegrambots.bots.TelegramLongPollingBot
The first 3 imports will show:
The import org.telegram.telegrambots.meta cannot be resolved