PHP-IRC 函数
我一直在考虑并尝试让我的 IRC 机器人向频道上的 % 用户发送私人消息,但它不起作用。
这是我的脚本,当你看到它时你就会明白它:
<?php
/**
* Configuration.
* Pretty self-explanatory
*/
$ircServer = "//";
$ircPort = "6667";
$ircChannel = "#//";
set_time_limit(0);
$msg = $_POST['message'];
$pr = $_POST['percentage'];
$pr /= 100;
$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");
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;
}
shuffle($users);
$size = count($users);
$target = $size * $pr;
$target = $round($target);
for ($i = 0; $i <= $target; $i++) {
fwrite($ircSocket, "PRIVMSG " . $users[$i] . " :" . $msg . "\n");
}
?>
每当我尝试重新编码时,这里是错误: 解析错误:语法错误,意外的 $end in C:\xampp\htdocs\irc.php on line 55
我正在尝试创建一个百分比系统,它将 IRC 频道上的用户百分比随机播放到随机播放系统上的一组私人消息。
I have been figuring about and trying to make my IRC bot send private messages to % of users on the channel however it's not working.
Here is my script, you will understand it when you see it:
<?php
/**
* Configuration.
* Pretty self-explanatory
*/
$ircServer = "//";
$ircPort = "6667";
$ircChannel = "#//";
set_time_limit(0);
$msg = $_POST['message'];
$pr = $_POST['percentage'];
$pr /= 100;
$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");
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;
}
shuffle($users);
$size = count($users);
$target = $size * $pr;
$target = $round($target);
for ($i = 0; $i <= $target; $i++) {
fwrite($ircSocket, "PRIVMSG " . $users[$i] . " :" . $msg . "\n");
}
?>
Evertime I try re-coding it here is the error: Parse error: syntax error, unexpected $end in C:\xampp\htdocs\irc.php on line 55
I am trying to make a percentage system that will shuffle the % of users on the IRC channel to private message a set % on the shuffle system.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
意外的 $end
表示已到达文件末尾,并且所有块 ({}
) 均未关闭。是的,开括号比闭括号多;你忘记在某处关闭一个。根据缩进,我认为您打算在if
语句之后关闭内部while
循环:仅通过浏览代码,我没有发现任何明显的错误该方法,但我实际上没有尝试过
unexpected $end
means it reached the end of the file and all your blocks ({}
) weren't closed. It's right, you have more open braces than close braces; you forgot to close one somewhere. Based on the indenting, I think you meant to close your innerwhile
loop right after theif
statement:Just from skimming the code, I don't see anything obviously wrong with the approach, but I didn't actually try it
你忘记了“}”
如果($ircSocket){
you forget the '}' for
if ($ircSocket) {