Sending whispers with my IRC bot

Hi,

So I’ve been upgrading my java bot and need to implement whispers.

I was reading THIS post on how to do it and hooked my bot up to a private channel.

Problem is, I’m still not getting the whispers. Any ideas?

1452032436489 >>>JOIN #_twitchraidstwitch_1452031568810
1452032460262 >>>PRIVMSG #_twitchraidstwitch_1452031568810 :/w Murderouskirk Hi! Test msg.

^That’s from my logs. The whisper never pops up though. I also tried .w with no luck.

What server IP and port are you using? The one mentioned in that post (.120) is no longer a group chat server.

Also, where are you trying to receive the whispers? Via the bot or the website?

	ChatRaids bot = new ChatRaids();
	bot.setVerbose(true);
	bot.connect("irc.twitch.tv", 6667, "myAuth");
	bot.joinChannel("#twitchraidstwitch");
	bot.joinChannel("#_twitchraidstwitch_1452031568810");

	sendMessage("#_twitchraidstwitch_1452031568810", "/w Murderouskirk Hi "+host+"! Test msg.");

I’m trying to whisper users on the site, bot doesn’t need to receive any whispers. (thanks for the help btw)

I’ve got a thread open over at reddit too. From what I’m seeing over there I’m missing some output.

“CAP REQ :twitch.tv/commands”

How do I properly request this in java?

ChatRaids bot = new ChatRaids();
bot.setVerbose(true);
bot.connect("irc.twitch.tv", 6667, "oauth:XXXX");
bot.joinChannel("#twitchraidstwitch");
sendMessage("#twitchraidstwitch", "CAP REQ :twitch.tv/membership\r\n");
sendMessage("#twitchraidstwitch", "CAP REQ :twitch.tv/tags\r\n");
sendMessage("#twitchraidstwitch", "CAP REQ :twitch.tv/commands\r\n");

^ That just sends the message into chat and doesn’t work.

CAP requests are sent to the server as a RAW command. your sendMessage sends a PRIVMSG command to the server

You sent:

PRIVMSG #twitchraidstwitch :CAP REQ :twitch.tv/membership

Instead of

CAP REQ :twitch.tv/membership

In addition you need to connect to GROUP CHAT you are connecting to irc.twitch.tv in error

Thanks! the problem now is that I don’t understand how to do that in java using pircbot.

also Group Chat. Someone in the reddit thread gave me ‘199.9.253.119:6667’. Is that what I’m supposed to connect to instead of irc.twitch.tv when i setup?

Prodding around the javadocs (http://www.jibble.org/javadocs/pircbot/index.html) I found:

sendRawLine(String line)
Sends a raw line to the IRC server as soon as possible, bypassing the outgoing message queue.

going to give that a try.

ok i think that worked, but I get ‘Unrecognized command: /w’

If I try to connect to a “group chat” server instead of irc.twitch.tv it can’t listen or write in my channels chat though…

You will need two separate connections, one to irc.twitch.tv and one to one of the group chat servers.

oof. they sure do make this simple. Funny how /host and everything else works just fine.

so if I try to connect my bot to both connections it tells me im already connected to another. How do i separate a bot into two connections using the same username? Do i create a new bot object with a different name?

public ChatRaids() {
	this.setName("twitchraidstwitch");
}

public static void main(String[] args) throws Exception {
	
	ChatRaids bot = new ChatRaids();
	bot.setVerbose(true);
        ChatRaids whisperBot = new ChatRaids();
	whisperBot .setVerbose(true);
	bot.connect("irc.twitch.tv", 6667, "oauth:0XXXXXXXXXXX");
	whisperBot .connect("199.9.253.119", 6667, "oauth:XXXXXXXXXXXXXXXX");
	bot.joinChannel("#twitchraidstwitch");

}

that doesn’t seem right… hmm…

my head hurts xD

That basic logic looks correct.

	ChatRaids bot = new ChatRaids();
	bot.setVerbose(true);
	ChatRaids wBot = new ChatRaids();
	wBot.setVerbose(true);
	bot.connect("irc.twitch.tv", 6667, "oauth:XXXXXXXXXXX");
	wBot.connect("199.9.253.119", 6667, "oauth:XXXXXXXXXXXXXX");
	bot.joinChannel("#twitchraidstwitch");
	wBot.joinChannel("#twitchraidstwitch");

	sendRawLine("CAP REQ :twitch.tv/membership\r\n");
	sendRawLine("CAP REQ :twitch.tv/tags\r\n");
	sendRawLine("CAP REQ :twitch.tv/commands\r\n");

        sendMessage("#twitchraidstwitch", "/w Murderouskirk Hi "+host+"! Test msg.");

still gets me

1452078840868 @msg-id=unrecognized_cmd :tmi.twitch.tv NOTICE #twitchraidstwitch :Unrecognized command: /w

I’m not sure how it would choose which bot to send from either…

:confused:

sendMessage is sending to the connection identified as bot not the connection identified as wbot.

Also wbot doesn’t need to join any channels

I’m not sure how to differentiate which bot to send with…

public class ChatRaids extends PircBot{

boolean initialize = true;

public ChatRaids() {
	this.setName("twitchraidstwitch");
}

public static void main(String[] args) throws Exception {
	
	ChatRaids bot = new ChatRaids();
	bot.setVerbose(true);
	ChatRaids wBot = new ChatRaids();
	wBot.setVerbose(true);
	bot.connect("irc.twitch.tv", 6667, "oauth:XXXXXXXXXXX");
	wBot.connect("199.9.253.119", 6667, "oauth:XXXXXXXXXXXX");
	bot.joinChannel("#twitchraidstwitch");	
}

public void capReq(){
	sendRawLine("CAP REQ :twitch.tv/membership\r\n");
	sendRawLine("CAP REQ :twitch.tv/tags\r\n");
	sendRawLine("CAP REQ :twitch.tv/commands\r\n");
}

public void onMessage(String channel, String sender, String login, String hostname, String message) {
	
	if(initialize){
		capReq();
                initialize=false;
                sendMessage("#twitchraidstwitch", "/w Murderouskirk Hi "+host+"! Test msg.");
        }
}

edit*

Looks like my commands break when I capReq(); too.

1452080991241 :murderouskirk!murderouskirk@murderouskirk.tmi.twitch.tv PRIVMSG #twitchraidstwitch :!rank
turns into something much longer and it fails to react accordingly.

Seems like I need to totally differentiate the wBot in order to accomplish this somehow… another class maybe?

Would it be more straightforward to just learn how to send a message?

also I can’t reply anymore today and my alt account gets flagged so…

I’m going to do some research. I think I just made a basic java rookie mistake by putting everything in one long class. I think I’m failing to differentiate my objects properly. Hopefully I can figure out how to separate this.

I appreciate the help everyone!

One thing to note is that Pircbot does not support tags unless you’ve added support for it already. It will likely throw and exception anytime a message is received with tags included.

I got it working!

I had to fix my basic java so make sure I had a seperate bot object, then I did this.

		WhisperBot wBot = new WhisperBot();
		wBot.setVerbose(true);
		wBot.connect("199.9.253.119", 6667, "oauth:MYAUTH");
		wBot.joinChannel("#199.9.253.119");
		wBot.sendRawLineViaQueue("CAP REQ :twitch.tv/commands"); 
		wBot.sendRawLineViaQueue("PRIVMSG #jtv :/w murderouskirk This is an example PM");

So I put the above in a static void in its own class, then call it from my main class and pass through my msg every time i need to whisper. It seems like it opens up a new bot object every time it’s called (which makes sense with how it’s coded) but it does the job since I’m only whispering users once each. Just for clarity sake if I whispered the same user a couple times it would look normal on their end, and when I send a message back it would show in console X times for each msg sent.

But that’s something I can sort out later just my cleaning up my basic code theory more.

I haven’t been able to process incoming whispers yet but I see them in console so I’m sure I can get it working later if I need it in the future.

Thanks for all the help guys, really appreciate it.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.