Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-6600

IRC Bot should wait a bit before joining channels

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: ircbot-plugin
    • Labels:
      None
    • Environment:
      Hudson 1.359 on Linux inside Jetty, IRC Plugin v2.4
    • Similar Issues:

      Description

      We use an invite exclusion for the IRC bot based on a cloak that gets applied after the bot identifies to NickServ. The bot seems to try to identify, then join the channels before the network's services can apply the cloak, keeping the bot from joining the channel.

      It would be nice if the bot could wait for notification from services (I can't think of an IRC network agnostic way to do this), or at least sleep for a period of time after identifying to services.

        Attachments

          Issue Links

            Activity

            mwalling Mark Walling created issue -
            Hide
            mwalling Mark Walling added a comment -

            World's worst fix, but it works for now:

            Index: src/main/java/hudson/plugins/ircbot/v2/IRCConnection.java
            ===================================================================
            — src/main/java/hudson/plugins/ircbot/v2/IRCConnection.java (revision 31262)
            +++ src/main/java/hudson/plugins/ircbot/v2/IRCConnection.java (working copy)
            @@ -76,6 +76,9 @@
            final String nickServPassword = this.descriptor.getNickServPassword();
            if(Util.fixEmpty(nickServPassword) != null) {
            this.pircConnection.identify(nickServPassword);
            + try

            { + Thread.sleep(5000); + }

            catch (java.lang.InterruptedException e) {}
            }

            for (IMMessageTarget groupChatName : this.groupChats) {

            Show
            mwalling Mark Walling added a comment - World's worst fix, but it works for now: Index: src/main/java/hudson/plugins/ircbot/v2/IRCConnection.java =================================================================== — src/main/java/hudson/plugins/ircbot/v2/IRCConnection.java (revision 31262) +++ src/main/java/hudson/plugins/ircbot/v2/IRCConnection.java (working copy) @@ -76,6 +76,9 @@ final String nickServPassword = this.descriptor.getNickServPassword(); if(Util.fixEmpty(nickServPassword) != null) { this.pircConnection.identify(nickServPassword); + try { + Thread.sleep(5000); + } catch (java.lang.InterruptedException e) {} } for (IMMessageTarget groupChatName : this.groupChats) {
            kutzi kutzi made changes -
            Field Original Value New Value
            Link This issue depends on JENKINS-4346 [ JENKINS-4346 ]
            Hide
            kutzi kutzi added a comment -

            If that patch works for you then fine, but you probably won't be suprised that I won't apply the patch to trunk.

            For this to fix properly I'll probably have to fix JENKINS-4346 first.

            Show
            kutzi kutzi added a comment - If that patch works for you then fine, but you probably won't be suprised that I won't apply the patch to trunk. For this to fix properly I'll probably have to fix JENKINS-4346 first.
            Hide
            kutzi kutzi added a comment -

            As I'm pretty much a layman in IRC specifica:

            can you elaborate how this cloak works and especially which notification the bot would have to wait for?
            Is this a general IRC mechanism or something proprietary to your organisation?
            Can you think of a way how to include this without affecting other user which don't apply this cloak?

            Show
            kutzi kutzi added a comment - As I'm pretty much a layman in IRC specifica: can you elaborate how this cloak works and especially which notification the bot would have to wait for? Is this a general IRC mechanism or something proprietary to your organisation? Can you think of a way how to include this without affecting other user which don't apply this cloak?
            Hide
            mwalling Mark Walling added a comment -

            When the bot identifies to NickServ, services then applies a cloak to the bot (changing the hostname from my server to 'hudson.bot'). The bot then can join an invite only channel with an invite exemption (similar concept to a ban, but instead of keeping you from joining, it allows you to get in).

            I know OFTC and Freenode both do user cloaks, and I'm sure other networks do as well.

            I'm not sure what kind of events you can get back from the IRC framework, but maybe an option "Wait for mode before joining", which the user can set what mode that network sends (OFTC sends +R), or "Wait for notice" (which is already seen with .onNotice) which takes a string to match (most networks will NOTICE you when you identify; OFTC, Freenode, Foonetic I know do).

            This could also be useful for other channels, like on Freenode, that are +r (require users to be registered before they can join).

            Show
            mwalling Mark Walling added a comment - When the bot identifies to NickServ, services then applies a cloak to the bot (changing the hostname from my server to 'hudson.bot'). The bot then can join an invite only channel with an invite exemption (similar concept to a ban, but instead of keeping you from joining, it allows you to get in). I know OFTC and Freenode both do user cloaks, and I'm sure other networks do as well. I'm not sure what kind of events you can get back from the IRC framework, but maybe an option "Wait for mode before joining", which the user can set what mode that network sends (OFTC sends +R), or "Wait for notice" (which is already seen with .onNotice) which takes a string to match (most networks will NOTICE you when you identify; OFTC, Freenode, Foonetic I know do). This could also be useful for other channels, like on Freenode, that are +r (require users to be registered before they can join).
            Hide
            mwalling Mark Walling added a comment -

            I re-thought my approach to this. Now, instead of trying to handle how different networks handle things, if the bot can't join the channel on the first try, tough luck.

            Instead, the bot can be invited to the channel, and if it is in the IRCConnection.groupChats List, it will join that channel.

            The bot will still try to send messages to channels it is not in, but that doesn't seem to hurt anything.

            http://codereview.appspot.com/1911042/show

            Show
            mwalling Mark Walling added a comment - I re-thought my approach to this. Now, instead of trying to handle how different networks handle things, if the bot can't join the channel on the first try, tough luck. Instead, the bot can be invited to the channel, and if it is in the IRCConnection.groupChats List, it will join that channel. The bot will still try to send messages to channels it is not in, but that doesn't seem to hurt anything. http://codereview.appspot.com/1911042/show
            Hide
            rshelley rshelley added a comment -

            I have a similar issue where the IRC bot will try to connect to the server and (apparently) timeout:

            ----------
            Sep 2, 2010 8:50:23 AM hudson.plugins.ircbot.v2.IRCConnection connect
            INFO: connected to IRC
            Sep 2, 2010 8:50:23 AM hudson.plugins.ircbot.v2.IRCConnection getGroupChat
            INFO: Trying to join channel #welcome
            ----------
            (never reaches the "Joined channel..." log line)

            It seems to be happening at this line (it's nested, so I don't know which constructor is causing it):

            ----------
            // TODO: how to check that join was successful (channelJoined is called later -
            // how long should we possibly wait until we declare that join was unsuccessful?)
            this.bots.add(new Bot(new IRCChannel(channel.getName(), this.pircConnection),
            this.descriptor.getNick(), this.descriptor.getHost(),
            this.descriptor.getCommandPrefix(), this.authentication));
            ----------

            When I query my OperServ, however, I don't see my bot connected, so I can't invite it as suggested previously. I've tried inviting it anyway, and it won't let me (because it's not connected). Checking my IRC connection logs, I see connections from my users, but not from the Hudson IRC bot. I suppose it's possible that some exception is being thrown during connection but being handled silently.

            I've tried connecting with my Chan/NickServ bot offline, to see if maybe it was booting it, and that didn't help. I've tried turning off my NickServ Identify password to just let it join as an unregistered user (my internal IRC doesn't require a registered account).

            I can connect to the server as the Hudson IRC bot user with an IRC client, so I know the user and NickServ password are correct. One thing to note is that if I'm connected via a client to the Hudson IRC bot account, and the Hudson plugin tries to connect, it does report that the username is already in use, so I know that a basic connection is being made, but not much more. I'm not really sure what else to check.

            Show
            rshelley rshelley added a comment - I have a similar issue where the IRC bot will try to connect to the server and (apparently) timeout: ---------- Sep 2, 2010 8:50:23 AM hudson.plugins.ircbot.v2.IRCConnection connect INFO: connected to IRC Sep 2, 2010 8:50:23 AM hudson.plugins.ircbot.v2.IRCConnection getGroupChat INFO: Trying to join channel #welcome ---------- (never reaches the "Joined channel..." log line) It seems to be happening at this line (it's nested, so I don't know which constructor is causing it): ---------- // TODO: how to check that join was successful (channelJoined is called later - // how long should we possibly wait until we declare that join was unsuccessful?) this.bots.add(new Bot(new IRCChannel(channel.getName(), this.pircConnection), this.descriptor.getNick(), this.descriptor.getHost(), this.descriptor.getCommandPrefix(), this.authentication)); ---------- When I query my OperServ, however, I don't see my bot connected, so I can't invite it as suggested previously. I've tried inviting it anyway, and it won't let me (because it's not connected). Checking my IRC connection logs, I see connections from my users, but not from the Hudson IRC bot. I suppose it's possible that some exception is being thrown during connection but being handled silently. I've tried connecting with my Chan/NickServ bot offline, to see if maybe it was booting it, and that didn't help. I've tried turning off my NickServ Identify password to just let it join as an unregistered user (my internal IRC doesn't require a registered account). I can connect to the server as the Hudson IRC bot user with an IRC client, so I know the user and NickServ password are correct. One thing to note is that if I'm connected via a client to the Hudson IRC bot account, and the Hudson plugin tries to connect, it does report that the username is already in use, so I know that a basic connection is being made, but not much more. I'm not really sure what else to check.
            Hide
            kutzi kutzi added a comment -

            It'd be great if you could test these attached development versions, if they work like desired for you.

            Show
            kutzi kutzi added a comment - It'd be great if you could test these attached development versions, if they work like desired for you.
            kutzi kutzi made changes -
            Attachment instant-messaging.hpi [ 19881 ]
            Attachment ircbot.hpi [ 19882 ]
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in hudson
            User: : kutzi
            Path:
            trunk/hudson/plugins/ircbot/src/main/java/hudson/plugins/ircbot/v2/IRCConnection.java
            trunk/hudson/plugins/ircbot/src/main/java/hudson/plugins/ircbot/v2/PircConnection.java
            http://jenkins-ci.org/commit/36175
            Log:
            JENKINS-6600 ircbot may be invited to a channel

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in hudson User: : kutzi Path: trunk/hudson/plugins/ircbot/src/main/java/hudson/plugins/ircbot/v2/IRCConnection.java trunk/hudson/plugins/ircbot/src/main/java/hudson/plugins/ircbot/v2/PircConnection.java http://jenkins-ci.org/commit/36175 Log: JENKINS-6600 ircbot may be invited to a channel
            Hide
            rshelley rshelley added a comment -

            Having the same issue still, but I'm on 1.372 and will try upgrading to 1.382 (to help resolve other issues). Will follow-up after the upgrade.

            Show
            rshelley rshelley added a comment - Having the same issue still, but I'm on 1.372 and will try upgrading to 1.382 (to help resolve other issues). Will follow-up after the upgrade.
            Hide
            rshelley rshelley added a comment -

            Upgraded to 1.382 and same issue persists. I wonder if it could be a issue that Hudson and my IRC server run on the same box?

            Show
            rshelley rshelley added a comment - Upgraded to 1.382 and same issue persists. I wonder if it could be a issue that Hudson and my IRC server run on the same box?
            Hide
            kutzi kutzi added a comment -

            rshelley: a stack dump of your Hudson server when it's currently trying to connect to your IRC server could help.

            What's the type of your IRC server?

            Show
            kutzi kutzi added a comment - rshelley: a stack dump of your Hudson server when it's currently trying to connect to your IRC server could help. What's the type of your IRC server?
            Hide
            rshelley rshelley added a comment -

            Tomcat stdout
            http://hudson.pastebin.com/hfYTJSii

            Thread Dump
            http://hudson.pastebin.com/hVbyhpDY

            IRC Server: Unreal 3.2

            Show
            rshelley rshelley added a comment - Tomcat stdout http://hudson.pastebin.com/hfYTJSii Thread Dump http://hudson.pastebin.com/hVbyhpDY IRC Server: Unreal 3.2
            Hide
            kutzi kutzi added a comment -

            Attached an ircbot.hpi which logs all server responses.
            Maybe you want to try it.

            Show
            kutzi kutzi added a comment - Attached an ircbot.hpi which logs all server responses. Maybe you want to try it.
            kutzi kutzi made changes -
            Attachment ircbot.hpi [ 19910 ]
            kutzi kutzi made changes -
            Attachment ircbot.hpi [ 19882 ]
            Hide
            kutzi kutzi added a comment -

            Fixed in IRC plugin 2.7

            rshelley: I believe what you see, is a different issue. If it persists please open a new JIRA issue for it.

            Show
            kutzi kutzi added a comment - Fixed in IRC plugin 2.7 rshelley: I believe what you see, is a different issue. If it persists please open a new JIRA issue for it.
            kutzi kutzi made changes -
            Status Open [ 1 ] Resolved [ 5 ]
            Resolution Fixed [ 1 ]
            kutzi kutzi made changes -
            Link This issue is duplicated by JENKINS-8451 [ JENKINS-8451 ]
            rtyler R. Tyler Croy made changes -
            Workflow JNJira [ 136695 ] JNJira + In-Review [ 187264 ]

              People

              • Assignee:
                kutzi kutzi
                Reporter:
                mwalling Mark Walling
              • Votes:
                1 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: