Hello, I tried this class, because I was looking for something, which can show MOTD and whois information on my webpage.
I used the following code:
$irc = &new Net_SmartIRC();
$irc->connect('server.name.de', 6667);
$irc->login('minick', 'minich', 0, 'minick');
$result = $irc->getMotd();
$irc->disconnect();
but the $result is an empty array.
If I log on to this server using a standard client (let's say BitchX), then I got the MOTD.
I also tried the following:
$irc->whois("nickname");
$result = $irc->listenFor(SMARTIRC_TYPE_WHOIS);
and it is just hanging on IRC, doing nothing, then quits with timeout.
How can I get back data from MOTD and whois?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
the firstone doesn't work because after he logs on you try to get the MOTD which is not received yet, there you need to make an actionhandler waiting for SMARTIRC_TYPE_MOTD, then you have to check if its the end of the MOTD; if so, then disconnect...
This one doesnt work with listenFor() because listenFor() waits till the event happens _once_ directly after it happend, he will disconnect... So listenFor() can be only used for things where you just need 1 answer back, sometimes 2 or 3 get passed because of socket buffers (data received that is already in the buffer and gets further processed)
I should add there some features for waiting for 2 or 3 events, or a new parameter for how often the event should occur before the connection is closed..
the second thing... hhmm... that should work... I have to check that one.. maybe its a bug...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ok, I made som progress, but it's not perfect yet. :-)
I created an ActionHandler, as you said, but how can I check that I'm at the end of MOTD? I checked $data, and it always contains data from MOTD from first line to the last, but then it stays connected to IRC, and I cannot disconnect.
class mybot
{
function motd(&$irc, &$data)
{
// ? How can I check end of MOTD numeric ?
}
}
I think you know much more than it is written to the help or to the example files ;-) If this works, I will post you the script, you can put it as the next example file.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ops. my previous message was lost somehow. Anyway, here it is again: I read your comments about sockets in a different thread, and I tried it. After I commented out setSockets, both worked! :-)
$irc->getMotd(); and whois also. :-)
However I would like to get answer to my previous question: how can I check for a specified numeric response from the irc szerver?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Its still kinda strange with the sockets, what PHP version do you have? maybe there is some bug in it or in my socket handling...
what you did with sending whois and getting motd and then listenFor() for WHOIS is a great hack! :) that way you get both for sure... the whois _has_ to come after the MOTD... nice idea ;)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello, I tried this class, because I was looking for something, which can show MOTD and whois information on my webpage.
I used the following code:
$irc = &new Net_SmartIRC();
$irc->connect('server.name.de', 6667);
$irc->login('minick', 'minich', 0, 'minick');
$result = $irc->getMotd();
$irc->disconnect();
but the $result is an empty array.
If I log on to this server using a standard client (let's say BitchX), then I got the MOTD.
I also tried the following:
$irc->whois("nickname");
$result = $irc->listenFor(SMARTIRC_TYPE_WHOIS);
and it is just hanging on IRC, doing nothing, then quits with timeout.
How can I get back data from MOTD and whois?
the firstone doesn't work because after he logs on you try to get the MOTD which is not received yet, there you need to make an actionhandler waiting for SMARTIRC_TYPE_MOTD, then you have to check if its the end of the MOTD; if so, then disconnect...
This one doesnt work with listenFor() because listenFor() waits till the event happens _once_ directly after it happend, he will disconnect... So listenFor() can be only used for things where you just need 1 answer back, sometimes 2 or 3 get passed because of socket buffers (data received that is already in the buffer and gets further processed)
I should add there some features for waiting for 2 or 3 events, or a new parameter for how often the event should occur before the connection is closed..
the second thing... hhmm... that should work... I have to check that one.. maybe its a bug...
Ok, I made som progress, but it's not perfect yet. :-)
I created an ActionHandler, as you said, but how can I check that I'm at the end of MOTD? I checked $data, and it always contains data from MOTD from first line to the last, but then it stays connected to IRC, and I cannot disconnect.
class mybot
{
function motd(&$irc, &$data)
{
// ? How can I check end of MOTD numeric ?
}
}
$irc->registerActionhandler(SMARTIRC_TYPE_MOTD, '.*', $bot, 'motd');
I think you know much more than it is written to the help or to the example files ;-) If this works, I will post you the script, you can put it as the next example file.
I read your answer about sockets in a different thread. It was the problem. :-} I also commented out useSockets, and both is working! :-)
$irc = &new Net_SmartIRC();
//$irc->setUseSockets(TRUE);
$irc->connect('server.name.de', 6667);
$irc->login('minick', 'minich', 0, 'minick');
$irc->whois("minick");
$result = $irc->listenFor(SMARTIRC_TYPE_WHOIS);
$result_motd = $irc->getMotd();
$irc->disconnect();
print("<p>");
print_r($result);
print("<p>");
print_r($result_motd);
print("<p>");
However I'm still want answer for my previous question: how can I check what numeric replies did I get?
Ops. my previous message was lost somehow. Anyway, here it is again: I read your comments about sockets in a different thread, and I tried it. After I commented out setSockets, both worked! :-)
$irc->getMotd(); and whois also. :-)
However I would like to get answer to my previous question: how can I check for a specified numeric response from the irc szerver?
The numeric code should be in $data->rawmessageex[0]
About the previous message, I got it and its posted...
URL: https://sourceforge.net/forum/message.php?msg_id=1933334
Its still kinda strange with the sockets, what PHP version do you have? maybe there is some bug in it or in my socket handling...
what you did with sending whois and getting motd and then listenFor() for WHOIS is a great hack! :) that way you get both for sure... the whois _has_ to come after the MOTD... nice idea ;)
Yes, I also see now both of my messages. Maybe something is wrong with my provider's cache. :-}
I tried it in two versions of PHP, the first is 4.2.1 (Apache+Debian) and the other is 4.1.2 (Apache+Redhat).