Search code examples
phpirc

Checking if a nick is identified on IRC with PHP?


I'm not sure how to actually word the title.

I'm coding an IRC bot in PHP. This IRC server runs Anope services (NickServ, ChanServ, HostServ, etc).

I created a user access level system, so that some commands can only be accessed by users with the proper access level.

Each time the server sends data to the bot, the bot stores the line of data as $data, and then explode()'s it by " ", so that when a user says something, the first word they say is stored as $exData[3]

I created a function to check if the user is identified, and it works. The problem is, by the time the WHOIS finishes receiving data, the user issuing the command's username is no longer stored in $exData, instead, the last line of the WHOIS is stored in $exData.

I have no idea how I can fix this. Suggestions would be incredibly helpful, thank you.


Solution

  • Store it in a variable other than $exData so that when $exData is reused, the user's original message is still available to you.

    You can have as many variables as you need.