How to recieve private Whispers using PircBot

Question: How do I recieve private Whispers using PircBot? I know how to send whispers using:
sendRawLineViaQueue(“PRIVMSG #jtv :/w [Username][Message]”);

But now I need to detect when the bot receives a whisper and be able to read the message.

To receive whispers, you need to request the commands capability via CAP REQ and listen to the WHISPER commands.

I don’t think pircbot has a way to register a message handler for custom commands (pircbotx might have it), but it should have a way for you to check raw messages for it yourself. Someone more familiar with pircbot can probably tell you more.

I Know about the commands capability request, but my question is how do i Listen to the WHISPER commands?

The raw message looks like this:

@badges=staff/1,turbo/1;color=#00CDFF;display-name=3ventic;emotes=25:0-4;message-id=90;thread-id=17089325_76480729;turbo=1;user-id=17089325;user-type=staff :3ventic! WHISPER notventic :Kappa

Try using onUnknown(String line) and parsing it yourself, otherwise you’ll need someone who knows pircbot. It might also be worth looking into pircbotx, which supports tags as well, as far as I know.

K will try. Thank you kind sir

quick question though, I need to change notventic correct? that is your name? and Kappa would be the message?

Yes, notventic is the receiving username (your account).

and what if the message is unknown? what if the message isnt Kappa?

Would I just be able to cut it short to @badges=staff/1,turbo/1;color=#00CDFF;display-name=3ventic;emotes=25:0-4;message-id=90;thread-id=17089325_76480729;turbo=1;user-id=17089325;user-type=staff :3ventic! WHISPER notventic :

Basically cutting it short right before the message ans checking if the line contains that?

The beginning might be different. Tags (from @ to :3ventic) won’t be there if you haven’t enabled tags via CAP REQ. 3ventic is the sending username, so it can be different. What you’re looking for is the WHISPER command.

Essentially @tags :sender_username! WHISPER receiver_username :message

oh ok

What kinds of tags would i need to use for a regular viewer or sub?

Is this reply “ CAP * ACK” that I get from just printing out the line in the onUnknown event stating that I have accessed the the CAP REQ commands?

This is shown after I send a rawMessage with the CAP REQ

Whispers don’t have channel context, so you can’t tell if someone’s a sub from the whisper. The CAP * ACK is the acknowledgement to your CAP REQ. (CAPability REQuest ACKnowledged, enabled.)

After some time yesterday I figured out that I the issue was I had two bots active and the requests were established by only one of them making the one trying to listen to the messages to recieve them. Thank You so much 3ventic.

You should check out this modded version of PircBot, which has built-in support with Twitch IRC commands, including whispers and IRCv3 tags. It’s worth giving a try if you’re finding an easier way to code your bot with basically the same IRC library :wink:

1 Like

You can also check out how I did the WHISPER parsing in my TwitchChat library if you want some inspiration:

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