How to make the bot autoreconnect after x amount of time, with x amount of tries?

24 views
Skip to first unread message

Jonis Hjellestad

unread,
Mar 8, 2013, 4:10:34 AM3/8/13
to pirc...@googlegroups.com
Fairly new to programming, and events is kind of new to me, so I'm unsure of the approach.
MessageEvent was easy enough to understand, but trying to figure out the correct way to approach a reconnect.
So far I've done this:

    public void onDisconnect(DisconnectEvent event) throws Exception {
        int i = 0;
        while (!event.getBot().isConnected() && i < 20) {
            Thread.sleep(2500);
            event.getBot().reconnect();
            i++;
        }
    }

But I'm not sure if I need to use DisconnectedEvent or ReconnectEvent.

Any help would be greatly appreciated.

darkgob

unread,
Mar 8, 2013, 6:43:23 AM3/8/13
to pirc...@googlegroups.com
ReconnectEvent won't be dispatched until you've actually reconnected, so DisconnectEvent is what you want.


--
You received this message because you are subscribed to the Google Groups "pircbotx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pircbotx+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages