How to get IRC chat user nickname

I am now using the IRC API.

The script was written in PHP.

The information I receive is : comcool!comcool.sso.twitch.TV PRIVG # *****:bot
It is information that

How can I get a nickname from the user?

Nick is the part part leading up to the exclamation point. In your example it’s “comcool”. Most IRC libraries will parse it out for you. If you are not using a library you’ll have to parse it manually.

-> comcool is my id TT

Like @george pointed out, the nick of a user is the text leading up to the exclamation point. To give a little more detail on the structure, turn to the RFC 1459 spec.

The nick is located within the prefix, if one exists. The general structure being:


When a prefix is present, the <server_or_nick>is always included, where as both the <user> and <host> are optional and may not be present. If <user> is included it will be prefixed by !, and if <host> is included it will be prefixed with @. In the case of Twitch and ingesting chat messages, I’ve always seen the full prefix included in the message.

On a side note, is the data you posted the exact data that was ingested? Because the prefix, command, and parameters look malformed.

thanks. but my log is “:userId! PRIVMSG #channel : message”

i don’t know fix it…

i get log php script in fgets($this->socket).

Hm, Twitch must have updated their prefix format. Regardless, the information you want is the data between the colon and the exclamation point.

omg… my mistake…
I added this and the value comes in.

CAP REQ twitch.iv/commands Twitch

very very Thanks.
Thanks ur reply

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