I am trying to use Smart IRC, to connect to my irc server and get the num of users in a certain channel. So that I can output this number on my site. I don't know of a better way to do this or whatever. But in example 2 which is supposed to do what I need when I run it it would connect to my server and all, but it outputs the topic rather then the number of users. But I notice that in the debug stuff, it does actually grab the number if you scroll down it is right next to the channel name, i will make it bold. My question is if someone can help me output what I need.
-------------------------example 2.--------------------
include_once('../SmartIRC.php');
$irc = &new Net_SmartIRC();
$irc->startBenchmark();
$irc->setDebug(SMARTIRC_DEBUG_ALL);
$irc->setUseSockets(TRUE);
$irc->setBenchmark(TRUE);
$irc->connect('myserver.net', 6667);
$irc->login('Net_SmartIRC', 'Net_SmartIRC Client '.SMARTIRC_VERSION.' (example2.php)', 0, 'Net_SmartIRC');
$irc->getList('#chatzone');
$resultar = $irc->listenFor(SMARTIRC_TYPE_LIST);
$irc->disconnect();
$irc->stopBenchmark();
if (is_array($resultar)) {
$resultex = explode(' ', $resultar[0]);
$count = $resultex[1];
?>
<B>On our IRC Channel #chatzone are <? echo $count; ?> Users</B>
<?
} else {
?>
<B>An error occured, please check the specified server and settings<B>
<?
}
?>
--------------------------------------------------------------------------------------
Below is what happens when I run example 2.
--------------------------------------------------------------------------
Oct 03 19:35:16 SmartIRC.php(1495) DEBUG_IRCMESSAGES: sent: "LIST #chatzone"
Oct 03 19:35:16 SmartIRC.php(1568) DEBUG_IRCMESSAGES: received: ":localhost. 321 Net_S808 Channel :Users Name"
Oct 03 19:35:16 SmartIRC.php(1628) DEBUG_MESSAGEPARSER: ircdata nick: "" ident: "ocalhost" host: "ocalhost." type: "8388608" from: "localhost." channel: "" message: "Users Name"
Oct 03 19:35:16 SmartIRC.php(1972) DEBUG_MESSAGEHANDLER: no method found for "321" (event_rpl_liststart)
<B>Oct 03 19:35:16 SmartIRC.php(1568) DEBUG_IRCMESSAGES: received: ":localhost. 322 Net_S808 #chatzone 6 :This is the topic"</B>
Oct 03 19:35:16 SmartIRC.php(1628) DEBUG_MESSAGEPARSER: ircdata nick: "" ident: "ocalhost" host: "ocalhost." type: "32768" from: "localhost." channel: "" message: "This is the topic"
Oct 03 19:35:16 SmartIRC.php(1972) DEBUG_MESSAGEHANDLER: no method found for "322" (event_rpl_list)
Oct 03 19:35:16 SmartIRC.php(1999) DEBUG_ACTIONHANDLER: actionhandler match found for id: 0 type: 32768 message: "This is the topic" regex: "/.*/"
Oct 03 19:35:16 SmartIRC.php(2005) DEBUG_ACTIONHANDLER: calling method "net_smartirc_listenfor->handler"
Oct 03 19:35:16 SmartIRC.php(2501) DEBUG_ACTIONHANDLER: listenfor handler called
Oct 03 19:35:16 SmartIRC.php(906) DEBUG_CONNECTION: disconnected
Oct 03 19:35:16 SmartIRC.php(1568) DEBUG_IRCMESSAGES: received: ":localhost. 323 Net_S808 :End of /LIST"
Oct 03 19:35:16 SmartIRC.php(1628) DEBUG_MESSAGEPARSER: ircdata nick: "" ident: "ocalhost" host: "ocalhost." type: "32768" from: "localhost." channel: "" message: "End of /LIST"
Oct 03 19:35:16 SmartIRC.php(1972) DEBUG_MESSAGEHANDLER: no method found for "323" (event_rpl_listend)
Oct 03 19:35:16 SmartIRC.php(1999) DEBUG_ACTIONHANDLER: actionhandler match found for id: 0 type: 32768 message: "End of /LIST" regex: "/.*/"
Oct 03 19:35:16 SmartIRC.php(2005) DEBUG_ACTIONHANDLER: calling method "net_smartirc_listenfor->handler"
Oct 03 19:35:16 SmartIRC.php(2501) DEBUG_ACTIONHANDLER: listenfor handler called
Oct 03 19:35:16 SmartIRC.php(692) benchmark stopped
Oct 03 19:35:16 SmartIRC.php(707) benchmark time: 0.356927990913
On our IRC Channel #chatzone are This Users
Smart IRC
Moderator: General Moderators
What does
give you as result?
Code: Select all
echo '<pre>';
print_r($resultex);
echo '</pre>';Sorry, i think I mean:
Code: Select all
if (is_array($resultar)) { // begin insert after this
echo '<pre>';
print_r(resultar);
echo '</pre>';re
Array
(
[0] => This is the topic
[1] => End of /LIST
)
I think the prob may be in the file irccommands.php, where it mentions getList(). I will post that part below.
--------------------------------------------------------------------------------
function getList($channelarray = null, $priority = SMARTIRC_MEDIUM)
{
if ($channelarray !== null) {
if (!is_array($channelarray)) {
$channelarray = array($channelarray);
}
$channellist = implode(',', $channelarray);
$this->_send('LIST '.$channellist, $priority);
} else {
$this->_send('LIST', $priority);
}
}
(
[0] => This is the topic
[1] => End of /LIST
)
I think the prob may be in the file irccommands.php, where it mentions getList(). I will post that part below.
--------------------------------------------------------------------------------
function getList($channelarray = null, $priority = SMARTIRC_MEDIUM)
{
if ($channelarray !== null) {
if (!is_array($channelarray)) {
$channelarray = array($channelarray);
}
$channellist = implode(',', $channelarray);
$this->_send('LIST '.$channellist, $priority);
} else {
$this->_send('LIST', $priority);
}
}
Hard to tell without seeing the entire piece of code, as I understand what it tries to do (fetch usercount from a /list)...
However, depending on the ircd, amount of users in channel, channelsettings there might be issues.
Sorry, cant help you more on this one.
Code: Select all
#evilwalrus 7 PHP CodingSorry, cant help you more on this one.