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

IRC Bot should wait a bit before joining channels

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • ircbot-plugin
    • None
    • Hudson 1.359 on Linux inside Jetty, IRC Plugin v2.4

      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.

          [JENKINS-6600] IRC Bot should wait a bit before joining channels

          Mark Walling created issue -

          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) {

          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 made changes -
          Link New: This issue depends on JENKINS-4346 [ JENKINS-4346 ]

          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.

          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.

          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?

          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?

          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).

          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).

          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

          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

          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.

          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.

          kutzi added a comment -

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

          kutzi added a comment - It'd be great if you could test these attached development versions, if they work like desired for you.
          kutzi made changes -
          Attachment New: instant-messaging.hpi [ 19881 ]
          Attachment New: ircbot.hpi [ 19882 ]

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

              Created:
              Updated:
              Resolved: