PHP-IRC Bot不发送消息帮助

目前,我正在制作一个将消息发送到IRC主频道的IRC.这是我的代码:

<?php


$ircServer = "xxxx";
$ircPort = "6667";
$ircChannel = "#bots";

set_time_limit(0);

$msg = $_GET['msg'];

$ircSocket = fsockopen($ircServer, $ircPort, $eN, $eS);

if ($ircSocket)
{

    fwrite($ircSocket, "USER Lost rawr.test lol :code\n");
    fwrite($ircSocket, "NICK Rawr" . rand() . "\n");
    fwrite($ircSocket, "JOIN " . $ircChannel . "\n");
    fwrite($ircSocket, "PRIVMSG " . $channel . " :" . $msg = $_GET['msg'] . "\n");

    while(1)
    {
        while($data = fgets($ircSocket, 128))
        {
            echo nl2br($data);
            flush();

            // Separate all data
            $exData = explode(' ', $data);

            // Send PONG back to the server
            if($exData[0] == "PING")
            {
                fwrite($ircSocket, "PONG ".$exData[1]."\n");
            }
}
    echo $eS . ": " . $eN;
}
}
?>

<html><body>
<h4>IRC Bot Tester</h4>
<form action="irc.php" method="post"> 
Command: <input type="text" name="msg" />
<input type="submit" />
</form>
</body></html>

我的问题是BOT没有向该频道发送任何消息,如您所见,我使用post get data作为发送至该频道的消息信息.

这是我收到的日志:

:irc.underworld.no 366 Rawr30517 #bots
:End of /NAMES list.
:irc.underworld.no 411 Rawr30517 :No
recipient given (PRIVMSG) : 0: 0PING
:irc.underworld.no

我不知道是什么原因造成的:

给定的收件人(PRIVMSG):0:0 PING

谢谢任何人能帮助我.我试图将消息简单地发布到机器人,然后机器人将消息传递到主渠道.

解决方法:

更改:

$msg = $_GET['msg'];
...
fwrite($ircSocket, "PRIVMSG " . $channel . " :" . $msg = $_GET['msg'] . "\n");

至:

$msg = $_POST['msg'];
...
fwrite($ircSocket, "PRIVMSG " . $ircChannel . " :" . $msg . "\n");
上一篇:IRC服务器搭建——ngircd


下一篇:python-使用扭曲检查IRC通道中的用户是否“发声”或“ op”