PHP - IRC Bot 不发送消息帮助

发布于 2024-10-03 18:19:38 字数 1529 浏览 7 评论 0原文

目前我正在制作一个 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 数据来发送到通道的消息信息。

这是我收到的日志:

:irc.underworld.no 366 Rawr30517 #bots :/NAMES 列表结束。 :irc.underworld.no 411 Rawr30517 :否 给定的收件人 (PRIVMSG) : 0: 0PING :irc.underworld.no

我不知道哪个部分导致了这个:

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

如果有人可以帮助我,谢谢。我试图简单地向机器人发布消息,然后机器人将消息传递到主频道。

Currently I am making a IRC that sends a message onto the IRC main channel. Here is my code:

<?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>

My problem is the BOT is not sending any messages to the channel, as you see I used post + get data for the message info sent to the channel.

Here is the log what I recieve:

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

I do not know which part causes the this:

recipient given (PRIVMSG) : 0: 0PING

Thanks if anyone could help me. I am trying to simply post a message to the bot and the bot delivers the message to the main channel.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

多像笑话 2024-10-10 18:19:38

更改:

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

至:

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

Change:

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

To:

$msg = $_POST['msg'];
...
fwrite($ircSocket, "PRIVMSG " . $ircChannel . " :" . $msg . "\n");
东走西顾 2024-10-10 18:19:38
fwrite($ircSocket, "PRIVMSG " . $ircChannel . " " . $msg = $_GET['msg'] . "\n");

到:

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

To:

fwrite($ircSocket, "PRIVMSG " . $ircChannel . " " .$msg. "\n");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文