[英]PHP - IRC Bot Not sending message Help
目前,我正在制作一個將消息發送到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:0 PING: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");
fwrite($ircSocket, "PRIVMSG " . $ircChannel . " " . $msg = $_GET['msg'] . "\n");
至:
fwrite($ircSocket, "PRIVMSG " . $ircChannel . " " .$msg. "\n");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.