I seem to be having trouble using the array that lists all joined channels. The first step in my attempt to use it was to enable channel syncing which I think is working. The code is here, I do it right before I connect:
Now, $channel is supposed to be an array with a LIST of channels that the bot is joined in. From the documentation:
-----
$channel (line 327)
Data type: array
Description:
Stores all channels in this array where we are joined, works only if channelsynching is activated.
Eg. for accessing a user, use it like this: (in this example the SmartIRC object is stored in $irc) $irc->channel['#test']->users['meebey']->nick;
-----
What I want to do is every channel I'm in so I can send a message to all of them. I'm not sure if this is the array I want or not. Is there any way to get all the channels I'm in out of this, or another array (what array that might be is beyond me, since I've looked through all the elements for "channel")?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
eerr using 1 is a problem, because I also check if its a boolean and 1 is an integer, so use $irc->setChannelSynching(true); instead...
about the $irc->channel: its an array with objects of the channels, do:
foreach( $irc->channel as $key => $value) {
$irc->message(SMARTIRC_TYPE_CHANNEL, $value->name, "I love SmartIRC!");
}
this would go through all channels and get the objects and stores them in $value, and "name" is the channel name, its an object attribute..
please tell me if it works for you...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here's a little log:
(15:36:30) WildBill: !join #test
(15:36:35) WildBill: !inchans
(15:36:35) WildBillBot: I am in the following channels: #purezc #test
(15:36:38) WildBill: !leave #test
(15:36:44) WildBill: W00T!
(15:36:53) Alucard: !inchans
(15:36:53) WildBillBot: I am in the following channels: #purezc
And here's my function, if you're wondering:
-----
function inchans(&$irc, &$data)
{
foreach($irc->channel as $key => $value) {
$inchans .= ' ' . $value->name;
}
$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, 'I am in the following channels:' . $inchans);
}
-----
Now to make some features that send messages to all the channels. =) Thanks again.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I seem to be having trouble using the array that lists all joined channels. The first step in my attempt to use it was to enable channel syncing which I think is working. The code is here, I do it right before I connect:
-----
$irc->setChannelSynching(1);
$irc->connect('irc.initialized.org', 6667);
-----
Now, $channel is supposed to be an array with a LIST of channels that the bot is joined in. From the documentation:
-----
$channel (line 327)
Data type: array
Description:
Stores all channels in this array where we are joined, works only if channelsynching is activated.
Eg. for accessing a user, use it like this: (in this example the SmartIRC object is stored in $irc) $irc->channel['#test']->users['meebey']->nick;
-----
What I want to do is every channel I'm in so I can send a message to all of them. I'm not sure if this is the array I want or not. Is there any way to get all the channels I'm in out of this, or another array (what array that might be is beyond me, since I've looked through all the elements for "channel")?
eerr using 1 is a problem, because I also check if its a boolean and 1 is an integer, so use $irc->setChannelSynching(true); instead...
about the $irc->channel: its an array with objects of the channels, do:
foreach( $irc->channel as $key => $value) {
$irc->message(SMARTIRC_TYPE_CHANNEL, $value->name, "I love SmartIRC!");
}
this would go through all channels and get the objects and stores them in $value, and "name" is the channel name, its an object attribute..
please tell me if it works for you...
Thank you very much, that works perfectly. :)
Here's a little log:
(15:36:30) WildBill: !join #test
(15:36:35) WildBill: !inchans
(15:36:35) WildBillBot: I am in the following channels: #purezc #test
(15:36:38) WildBill: !leave #test
(15:36:44) WildBill: W00T!
(15:36:53) Alucard: !inchans
(15:36:53) WildBillBot: I am in the following channels: #purezc
And here's my function, if you're wondering:
-----
function inchans(&$irc, &$data)
{
foreach($irc->channel as $key => $value) {
$inchans .= ' ' . $value->name;
}
$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, 'I am in the following channels:' . $inchans);
}
-----
Now to make some features that send messages to all the channels. =) Thanks again.