Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.1.14

Request #23746 time handlers: need to know online state
Submitted: 2018-05-01 19:04 UTC
From: glen Assigned: garrettw
Status: Closed Package: Net_SmartIRC (version 1.1.11)
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 37 - 12 = ?

 
 [2018-05-01 19:04 UTC] glen (Elan Ruusamäe)
Description: ------------ i have time handlers that take data from external system and submit to irc channel. how if bot gets disconnected, the time handlers are still fired. and there does not seem to be a way to obtain connection state $irc->_updatestate() exists, but it's protected, not accessible from outside. otherwise the $irc object is available from callback, so making $irc->getState or $irc->getLoggedIn public would solve my problem. as it's probably too breaking change to stop emitting timer events if disconnected, so that solution won't do much.

Comments

 [2018-05-01 19:09 UTC] glen (Elan Ruusamäe)
on second thought, i should be able to access $target via $irc->getChannel for channels, but doesn't work for users as users don't need to be in any channel to be online. but then again, i can just skip all actions if bot is not in any channels, which means it's likely disconnected. but still would like to hear more ideas or feedback to mine :)
 [2018-05-01 19:50 UTC] glen (Elan Ruusamäe)
some other idea was to listen to connect, disconnect events, and update local state somehow. but there are imho too many codes to follow, and still get it wrong with some other type of irc server (or irc server with bugs)
 [2018-05-02 17:41 UTC] glen (Elan Ruusamäe)
went with "get joined channels info" to detect if should process events https://github.com/eventum/irc-bot/pull/2
 [2018-05-09 00:40 UTC] garrettw (Garrett Whitehorn)
Time handlers are still fired if the bot gets disconnected because you yourself requested that feature in #20973. I'm adding a public method isConnected() which you can call to see if the bot is connected (returns boolean).
 [2018-05-09 00:48 UTC] garrettw (Garrett Whitehorn)
-Status: Open +Status: Closed -Assigned To: +Assigned To: garrettw
Thank you for your bug report. This issue has been fixed in the latest released version of the package, which you can download at http://pear.php.net/get/
 [2018-05-09 13:19 UTC] glen (Elan Ruusamäe)
the return type is not technically boolean. it's 0,1,2 integers via SMARTIRC_STATE_CONNECTED, SMARTIRC_STATE_CONNECTING, SMARTIRC_STATE_DISCONNECTED using the feature here: https://github.com/eventum/irc-bot/pull/10
 [2018-05-09 13:56 UTC] garrettw (Garrett Whitehorn)
Oops, sorry! Fixing that now.