douzhiji2020 2010-11-19 17:08
浏览 14
已采纳

PHP - IRC Bot不发送消息帮助

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
");
    fwrite($ircSocket, "NICK Rawr" . rand() . "
");
    fwrite($ircSocket, "JOIN " . $ircChannel . "
");
    fwrite($ircSocket, "PRIVMSG " . $channel . " :" . $msg = $_GET['msg'] . "
");

    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]."
");
            }
}
    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.

  • 写回答

2条回答 默认 最新

  • douzhang5295 2010-11-19 17:11
    关注

    Change:

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

    To:

    $msg = $_POST['msg'];
    ...
    fwrite($ircSocket, "PRIVMSG " . $ircChannel . " :" . $msg . "
    ");
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 请问如何在openpcdet上对KITTI数据集的测试集进行结果评估?
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路
  • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错