我有一個php腳本加入這個IRC服務器上的頻道:irc.worldnet.net 感謝服務器響應我可以說我成功加入了頻道,在用戶列表中。但是,此命令:發送私人訊息給IRC機器人
MSG bot_nickname hello my friend !
發出'msg:unknown command'響應。 的時候我發這條線:
PRIVMSG bot_nickname : hello my friend !
有沒有從機器人的反應(我沒有任何反正錯誤消息)。 我發送的命令有問題嗎?
這裏是我使用的PHP代碼:
<?php
$channel_sent = false;
$channel_joined = false;
$msg_sent = false;
set_time_limit(0);
ini_set('display_errors', 'on');
$config = array(
'server' => 'irc.worldnet.net',
'port' => 6667,
'nick' => 'cesame'.rand(),
'channel' => '#nc-irc-challs'
);
$server = array();
$server['SOCKET'] = @fsockopen($config['server'], $config['port'], $errno, $errstr, 2);
if($server['SOCKET'])
{
SendCommand("PASS NOPASS\n\r");
SendCommand("NICK " . $config['nick'] . "\n\r");
SendCommand("USER " . $config['nick'] . " USING PHP IRC\n\r");
SendCommand("JOIN " . $config['channel'] . "\n\r");
while(!feof($server['SOCKET'])) {
ReadServer();
flush();
sleep(1);
}
}
function ReadServer(){
global $server;
global $config;
global $channel_joined;
global $channel_sent;
global $msg_sent;
$server['READ_BUFFER'] = fgets($server['SOCKET'], 1024);
echo "[RECEIVE] ".$server['READ_BUFFER']."<br>\n\r";
if(substr($server['READ_BUFFER'], 0, 6) == "PING :") {
SendCommand("PONG :".substr($server['READ_BUFFER'], 6)."\n\r");
}
if(strpos($server['READ_BUFFER'], "#nc-irc-challs :End of /NAMES list")){
$channel_joined = true;
}
if(trim($server['READ_BUFFER']) == "" && $channel_joined &&!$msg_sent) {
SendCommand('PRIVMSG Daneel : .challenge_caesar start' . "\n\r");
$msg_sent = true;
}
}
function SendCommand ($cmd)
{
global $server; //Extends our $server array to this function
@fwrite($server['SOCKET'], $cmd, strlen($cmd)); //sends the command to the server
echo "[SEND] $cmd <br>"; //displays it on the screen
}
?>
所以我跟着你的建議。這是我得到的日誌:
[RECEIVE] :[email protected] JOIN :#nc-irc-challs
[RECEIVE] :Vidar.IRC.Worldnet.Net 332 cesame1582 #nc-irc-challs :NewbieContest -- http://www.newbiecontest.org/ (channel officiel : #newbiecontest) -- Rappel : aucune épreuve ne peut se résoudre en bruteforce.
[RECEIVE] :Vidar.IRC.Worldnet.Net 333 cesame1582 #nc-irc-challs zours 1195848644
[RECEIVE] :Vidar.IRC.Worldnet.Net 353 cesame1582 = #nc-irc-challs :cesame1582 \o_ @Eole +Daneel
[RECEIVE] :Vidar.IRC.Worldnet.Net 366 cesame1582 #nc-irc-challs :End of /NAMES list.
[SEND] PRIVMSG Daneel : .challenge_caesar start
[RECEIVE] :[email protected] NOTICE cesame1582 :[Logon News - Apr 07 2004] Use irc.worldnet.net to join our network, thanks | Dorenavant, utilisez irc.worldnet.net pour joindre notre reseau, merci.
[RECEIVE] :[email protected] NOTICE cesame1582 :[Logon News - Jan 07 2007] If you see a connection on port 23, 1080, 3128 or 8080 from 194.117.194.78 this is NOT an attack! It's our insecure proxy detector.
[RECEIVE] :[email protected] NOTICE cesame1582 :[Logon News - Feb 07 2007] Vous pouvez utiliser le port 7000 pour une connexion en SSL. You can use port 7000 with a secure SSL connection.
[RECEIVE] :[email protected] NOTICE cesame1582 :[Logon News - Oct 14 2009] Salons officiels du reseau Worldnet : #worldnet - #help pour de l'aide sur IRC et l'informatique en general. - ##opers pour les problemes réseau spécifiques à Worldnet.
[RECEIVE] :[email protected] NOTICE cesame1582 :[Random News - Apr 24 2004] Pour avoir de l'aide sur les commandes des services, visitez http://help.irc.worldnet.net
[RECEIVE] :[email protected] NOTICE cesame1582 :Your nick isn't registered.
[RECEIVE]
[RECEIVE] PING :Vidar.IRC.Worldnet.Net
[SEND] PONG :Vidar.IRC.Worldnet.Net
[RECEIVE]
[RECEIVE] PING :Vidar.IRC.Worldnet.Net
[SEND] PONG :Vidar.IRC.Worldnet.Net
您期待什麼迴應?我在這裏沒有看到任何會讓你的機器人迴應這個消息的東西。 –
this line: SendCommand('PRIVMSG Daneel:.challenge_caesar start'。「\ n \ r」); 我想發送到機器人「Daneel」「.challenge_caesar start」作爲私人消息 請參閱SendCommand函數的最底部。感謝您的幫助:) – user1079988
好的,爲什麼服務器會向您發送一個空字符串?它有時會發生,但並不意味着機器人閒置。相反,只要知道機器人已加入該頻道,就應該立即發送該命令(在NAMES列表的結尾處)。 –