I'm doing $irc->quit('Quit...');
But it just quit without saying anything: BotNick has quit IRC (Client closed connection)
v. 0.5.0, running under webserver
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hhhm that could be a little bug... first upgrade to 0.5.1 for using the current version, then search in SmartIRC.php for "function quit" in there should be a line like this:
$this->disconnect(true);
change it to:
$this->disconnect(false);
and tell me if that helps...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
pk now paste the debug output, but sure to enable debugging with $irc->setDebug(SMARTIRC_DEBUG_ALL);
1-2 lines before the QUIT and 1-2 lines are the QUIT is enough...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
the === and !== are special operators that exists in PHP, because you can't control variable types. PHP does all type casts by itself which can be pain....
if (0 == NULL) this is TRUE
if (1 == NULL) this is FALSE
if ("foo" == 1) this is TRUE
if ("foo" == 0) this is FALSE
if ("foo" == TRUE) this is TRUE
if ("foo" == FALSE) this is FALSE
if (TRUE == 1) this is TRUE
if (FALSE == 1) this is FALSE
here can you see what the type casts feature does, it can be very useful or a real problem :)
with the === it also compares the _variable type_ and the value
so it will look like this:
if (0 === NULL) this is FALSE
if (1 === NULL) this is FALSE
if ("foo" === 1) this is FALSE
if ("foo" === 0) this is FALSE
if ("foo" === TRUE) this is FALSE
if ("foo" === FALSE) this is FALSE
if (TRUE === 1) this is FALSE
if (FALSE === 1) this is FALSE
the types are:
1 is integer
NULL is null
"foor" is string
TRUE/FALSE is boolean
the default value for $quitmessage is NULL,
if you pass quitmessage(0); because you want 0 as quitmessage and SmartIRC wouldn't use === then the quitmessage would not be used. This is because 0 == null would be TRUE, to avoid these default value problem and type casts, I always use === for default value checking...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm doing $irc->quit('Quit...');
But it just quit without saying anything: BotNick has quit IRC (Client closed connection)
v. 0.5.0, running under webserver
hhhm that could be a little bug... first upgrade to 0.5.1 for using the current version, then search in SmartIRC.php for "function quit" in there should be a line like this:
$this->disconnect(true);
change it to:
$this->disconnect(false);
and tell me if that helps...
Now it says: BotNick has quit IRC (Quit: BotNick)
v.0.5.1
pk now paste the debug output, but sure to enable debugging with $irc->setDebug(SMARTIRC_DEBUG_ALL);
1-2 lines before the QUIT and 1-2 lines are the QUIT is enough...
Here is this debug messages:
Jan 21 17:42:25 DEBUG_IRCMESSAGES: received: ":Odik!~no@213.59.246.88 PRIVMSG #Kozanostra :!exit"
Jan 21 17:42:25 DEBUG_MESSAGEHANDLER: calling internal method "net_smartirc_messagehandler->_privmsg" (by string)
Jan 21 17:42:25 DEBUG_ACTIONHANDLER: actionhandler match found for id: 0 type: 2 message: "!exit" regex: "^!exit$"
Jan 21 17:42:25 DEBUG_ACTIONHANDLER: calling method "gamebot->quit"
Jan 21 17:42:25 DEBUG_IRCMESSAGES: sent: "QUIT"
Jan 21 17:42:26 DEBUG_CONNECTION: disconnected
show me how you registered that !exit actionhandler...
$irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, "^!exit$", &$bot, "quit");
now paste your gamebot::quit() method...
or at least the $irc->quit() call...
Here it is:
function quit(&$irc) {
$irc->quit('Quit...');
}
So what to do with quit message?
search again in SmartIRC.php for "function quit"
comment the $this->discconec() completly out, and try again (quitting)...
Commenting it out got it working
Also, noticed a possible error in the code:
f ($quitmessage !== null) {
shouldnt that be
f ($quitmessage != null) {
Im not sure, havent ever seen !== used before, but that doesnt mean it cant.
the === and !== are special operators that exists in PHP, because you can't control variable types. PHP does all type casts by itself which can be pain....
if (0 == NULL) this is TRUE
if (1 == NULL) this is FALSE
if ("foo" == 1) this is TRUE
if ("foo" == 0) this is FALSE
if ("foo" == TRUE) this is TRUE
if ("foo" == FALSE) this is FALSE
if (TRUE == 1) this is TRUE
if (FALSE == 1) this is FALSE
here can you see what the type casts feature does, it can be very useful or a real problem :)
with the === it also compares the _variable type_ and the value
so it will look like this:
if (0 === NULL) this is FALSE
if (1 === NULL) this is FALSE
if ("foo" === 1) this is FALSE
if ("foo" === 0) this is FALSE
if ("foo" === TRUE) this is FALSE
if ("foo" === FALSE) this is FALSE
if (TRUE === 1) this is FALSE
if (FALSE === 1) this is FALSE
the types are:
1 is integer
NULL is null
"foor" is string
TRUE/FALSE is boolean
the default value for $quitmessage is NULL,
if you pass quitmessage(0); because you want 0 as quitmessage and SmartIRC wouldn't use === then the quitmessage would not be used. This is because 0 == null would be TRUE, to avoid these default value problem and type casts, I always use === for default value checking...