Nick Unuchek Nick Unuchek - 2 years ago 158
Java Question

How to send message to chat in IRC server?

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

  1. How to connect to IRC server?

  2. How to send message to IRC server?

I tried run in Client for this library

java Client -server -pass oauth:1vuwah03rawwpgs5u38y -nick nick -user nick -name nick -ssl

Exception in thread "main" java.lang.NoClassDefFoundError: org/schwering/irc/lib
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$ Source)
at$ Source)
at Method)
at Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)

Answer Source

If you have a look at the PircBot documentation, you can see the bits you might need are:

to make the connection:, int)

to send the password:

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.sendRawLine("PASS oauth:twitch_oauth_token");
bot.sendRawLine("NICK yournickname");


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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download