How to send message to chat in IRC server? Here is API server, and description how to connect to this server, but I don't know how to implement it in java.
At first I need to connect to his irc server with login and password. And then send message. I found PircBot to connect to IRC server, but can't connect... to this API
I tried run in Client for this library
java Client -server irc.twitch.tv:6667 -pass oauth:1vuwah03rawwpgs5u38y -nick nick -user nick -name nick -ssl
Exception in thread "main" java.lang.NoClassDefFoundError: org/schwering/irc/lib
/IRCConnection
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.schwering.irc.lib.IRCConnection
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
If you have a look at the PircBot documentation, you can see the bits you might need are:
to make the connection: http://www.jibble.org/javadocs/pircbot/org/jibble/pircbot/PircBot.html#connect(java.lang.String, int)
to send the password: http://www.jibble.org/javadocs/pircbot/org/jibble/pircbot/PircBot.html#sendRawLine(java.lang.String)
I'm going to hazard a guess as I've never connected to twitch, but I'd imagine your connection lines would look like:
bot.connect("irc.twitch.tv",6667);
bot.sendRawLine("PASS oauth:twitch_oauth_token");
bot.sendRawLine("NICK yournickname");
edit:
and to answer the question in the title:
Once connected to the server, PircBot has a sendMessage(String channel,String message)
method, which will, as you would expect, send a message to the channel.