Hiya,
I’m working on creating a Twitch chatbot within PHP and I’ve hit a hurdle with receiving any responses from the Twitch IRC.
As far as I am aware I am connecting successfully with the Twitch IRC server and sending some PASS/NICK commands. However, I’m receiving no data back from the IRC server, not even the MOTD that I should get after PASS/NICK commands.
I am developing this on my local environment using Docker. This app is also a fresh Laravel app.
Below is my workflow to initialise the PHP socket.
public function connect()
{
$tcpConnector = new TcpConnector($this->loop);
$dnsResolverFactory = new Factory();
$dns = $dnsResolverFactory->createCached('1.1.1.1', $this->loop);
$dnsConnector = new DnsConnector($tcpConnector, $dns);
$connectorPromise = $dnsConnector->connect(sprintf('%s:6667', $this->host));
$connectorPromise->then(function (ConnectionInterface $connection) {
$this->socket = $connection;
$this->isConnected = true;
Log::info("Connected to the following IRC Server : {$this->socket->getRemoteAddress()}");
$this->socket->on('data', function ($data) {
Log::info("[>] $data");
});
$this->chatSend('CAP REQ :twitch.tv/membership twitch.tv/tags');
$this->chatSend("PASS oauth:$this->oAuth");
$this->chatSend("NICK $this->nick");
}, function (\Exception $error) {
Log::info($error);
});
$this->loop->run();
}
Here is an example log of this connect function.
[2024-07-21 09:02:54] local.INFO: Connected to the following IRC Server : 34.212.92.60:6667
[2024-07-21 09:02:54] local.INFO: [<] CAP REQ :twitch.tv/membership twitch.tv/tags
(1)
[2024-07-21 09:02:54] local.INFO: [<] PASS oauth:2xik66orlt3a******************
(1)
[2024-07-21 09:02:54] local.INFO: [<] NICK bakersoftware
(1)
Any tips/advice would be helpful