<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -65,12 +65,11 @@ class Contact:
     'broadcast contact' (chat rooms, IRC channels as a whole).
     &quot;&quot;&quot;
 
-    def __init__(self, channel, showBlameList = False):
+    def __init__(self, channel):
         self.channel = channel
         self.notify_events = {}
         self.subscribed = 0
         self.add_notification_events(channel.notify_events)
-        self.showBlameList = showBlameList
 
     silly = {
         &quot;What happen ?&quot;: &quot;Somebody set up us the bomb.&quot;,
@@ -336,7 +335,7 @@ class Contact:
         if buildurl:
             r += &quot;  Build details are at %s&quot; % buildurl
 
-        if build.getResults() != SUCCESS and self.showBlameList:
+        if self.channel.showBlameList and build.getResults() != SUCCESS and len(build.changes) != 0:
             r += '  blamelist: ' + ', '.join([c.who for c in build.changes])
 
         self.send(r)
@@ -580,15 +579,13 @@ class Contact:
 class IRCContact(Contact):
     # this is the IRC-specific subclass of Contact
 
-    def __init__(self, channel, dest,
-                 noticeOnChannel = False, showBlameList = False):
-        Contact.__init__(self, channel, True)
+    def __init__(self, channel, dest):
+        Contact.__init__(self, channel)
         # when people send us public messages (&quot;buildbot: command&quot;),
         # self.dest is the name of the channel (&quot;#twisted&quot;). When they send
         # us private messages (/msg buildbot command), self.dest is their
         # username.
         self.dest = dest
-        self.noticeOnChannel = noticeOnChannel
 
     def onChannel(self):
         return self.dest[0] == '#'
@@ -601,10 +598,8 @@ class IRCContact(Contact):
     # userJoined(self, user, channel)
 
     def send(self, message):
-        if self.onChannel() and self.noticeOnChannel:
-            self.channel.notice(self.dest, message.encode(&quot;ascii&quot;, &quot;replace&quot;))
-        else:
-            self.channel.msg(self.dest, message.encode(&quot;ascii&quot;, &quot;replace&quot;))
+        self.channel.msgOrNotice(self.dest, message.encode(&quot;ascii&quot;, &quot;replace&quot;))
+
     def act(self, action):
         self.channel.me(self.dest, action.encode(&quot;ascii&quot;, &quot;replace&quot;))
 
@@ -703,15 +698,19 @@ class IrcStatusBot(irc.IRCClient):
         self.noticeOnChannel = noticeOnChannel
         self.showBlameList = showBlameList
 
+    def msgOrNotice(self, dest, message):
+        if self.noticeOnChannel and dest[0] == '#':
+            self.notice(dest, message)
+        else:
+            self.msg(dest, message)
+
     def addContact(self, name, contact):
         self.contacts[name] = contact
 
     def getContact(self, name):
         if name in self.contacts:
             return self.contacts[name]
-        new_contact = self.contactClass(self, name,
-                                        noticeOnChannel = self.noticeOnChannel,
-                                        showBlameList = self.showBlameList)
+        new_contact = self.contactClass(self, name)
         self.contacts[name] = new_contact
         return new_contact
 </diff>
      <filename>buildbot/status/words.py</filename>
    </modified>
    <modified>
      <diff>@@ -1323,7 +1323,7 @@ class ContactTester(unittest.TestCase):
         self.failUnlessEqual(irc.message, &quot;&quot;, &quot;No finish notification generated on exception with notify_events=['success']&quot;)
 
     def test_notification_failed(self):
-        irc = MyContact(showBlameList = True)
+        irc = MyContact()
 
         my_builder = MyBuilder(&quot;builder834&quot;)
         my_build = MyIrcBuild(my_builder, 862, builder.FAILURE)
@@ -1338,8 +1338,10 @@ class ContactTester(unittest.TestCase):
         self.failUnlessEqual(irc.message, &quot;&quot;, &quot;No started notification with notify_events=['failed']&quot;)
 
         irc.message = &quot;&quot;
+        irc.channel.showBlameList = True
         irc.buildFinished(my_builder.getName(), my_build, None)
         self.failUnlessEqual(irc.message, &quot;build #862 of builder834 is complete: Failure [step1 step2]  Build details are at http://myserver/mypath?build=765  blamelist: author1&quot;, &quot;Finish notification generated on failure with notify_events=['failed']&quot;)
+        irc.channel.showBlameList = False
 
         irc.message = &quot;&quot;
         my_build.results = builder.SUCCESS
@@ -1371,9 +1373,10 @@ class ContactTester(unittest.TestCase):
         self.failUnlessEqual(irc.message, &quot;build #862 of builder834 is complete: Exception [step1 step2]  Build details are at http://myserver/mypath?build=765&quot;, &quot;Finish notification generated on failure with notify_events=['exception']&quot;)
 
         irc.message = &quot;&quot;
-        irc.showBlameList = True
+        irc.channel.showBlameList = True
         irc.buildFinished(my_builder.getName(), my_build, None)
         self.failUnlessEqual(irc.message, &quot;build #862 of builder834 is complete: Exception [step1 step2]  Build details are at http://myserver/mypath?build=765  blamelist: author1&quot;, &quot;Finish notification generated on failure with notify_events=['exception']&quot;)
+        irc.channel.showBlameList = False
 
         irc.message = &quot;&quot;
         my_build.results = builder.SUCCESS
@@ -1403,12 +1406,6 @@ class ContactTester(unittest.TestCase):
         irc.buildFinished(my_builder.getName(), my_build, None)
         self.failUnlessEqual(irc.message, expected_msg, &quot;Finish notification generated on failure with notify_events=['successToFailure']&quot;)
 
-        if expected_msg != '' and new_result != builder.SUCCESS:
-            irc.message = ''
-            irc.showBlameList = True
-            irc.buildFinished(my_builder.getName(), my_build, None)
-            self.failUnlessEqual(irc.message, expected_msg + '  blamelist: author1', &quot;Finish notification generated on failure with notify_events=['successToFailure']&quot;)
-
     def test_notification_successToFailure(self):
         self.do_x_to_y_notification_test(notify=&quot;successToFailure&quot;, previous_result=builder.SUCCESS, new_result=builder.FAILURE,
                                          expected_msg=&quot;build #862 of builder834 is complete: Failure [step1 step2]  Build details are at http://myserver/mypath?build=765&quot; )
@@ -1620,12 +1617,13 @@ class MyChannel:
 
     def __init__(self, notify_events = {}):
         self.notify_events = notify_events
+        self.showBlameList = False
 
 class MyContact(words.Contact):
     message = &quot;&quot;
 
-    def __init__(self, channel = MyChannel(), showBlameList = False):
-        words.Contact.__init__(self, channel, showBlameList)
+    def __init__(self, channel = MyChannel()):
+        words.Contact.__init__(self, channel)
         self.message = &quot;&quot;
 
     def subscribe_to_build_events(self):
@@ -1637,41 +1635,39 @@ class MyContact(words.Contact):
     def send(self, msg):
         self.message += msg
 
-class MyIRCChannel(MyChannel):
-    def __init__(self):
-        self.called = []
+class MyIrcStatusBot(words.IrcStatusBot):
+    def msg(self, dest, message):
+        self.message = ['msg', dest, message]
 
-    def __getattr__(self, name):
-        def f(*args, **kwargs):
-            self.called += [name]
-            pass
-        return f
+    def notice(self, dest, message):
+        self.message = ['notice', dest, message]
+
+class IrcStatusBotTester(unittest.TestCase):
+    def testMsgOrNotice(self):
+        channel = MyIrcStatusBot('alice', 'pa55w0od', ['#here'],
+                                 builder.SUCCESS, None, {})
+        channel.msgOrNotice('bob', 'hello')
+        self.failUnlessEqual(channel.message, ['msg', 'bob', 'hello'])
+
+        channel.msgOrNotice('#here', 'hello')
+        self.failUnlessEqual(channel.message, ['msg', '#here', 'hello'])
+
+        channel.noticeOnChannel = True
+
+        channel.msgOrNotice('bob', 'hello')
+        self.failUnlessEqual(channel.message, ['msg', 'bob', 'hello'])
+
+        channel.msgOrNotice('#here', 'hello')
+        self.failUnlessEqual(channel.message, ['notice', '#here', 'hello'])
 
 class IRCContactTester(unittest.TestCase):
     def testOnChannel(self):
-        contact = words.IRCContact(MyIRCChannel(), 'alice')
+        contact = words.IRCContact(MyChannel(), 'alice')
         self.failUnlessEqual(contact.onChannel(), False)
 
-        contact = words.IRCContact(MyIRCChannel(), '#somewhere')
+        contact = words.IRCContact(MyChannel(), '#somewhere')
         self.failUnlessEqual(contact.onChannel(), True)
 
-    def testSendToUser(self):
-        ch = MyIRCChannel()
-        contact = words.IRCContact(ch, 'alice')
-        contact.send('hello')
-        self.failUnlessEqual(ch.called, ['msg'])
-
-    def testSendToChannel(self):
-        ch = MyIRCChannel()
-        contact = words.IRCContact(ch, '#somewhere', noticeOnChannel = True)
-        contact.send('hi')
-        self.failUnlessEqual(ch.called, ['notice'])
-
-        ch = MyIRCChannel()
-        contact = words.IRCContact(ch, '#somewhere')
-        contact.send('hi')
-        self.failUnlessEqual(ch.called, ['msg'])
-
 class StepStatistics(unittest.TestCase):
     def testStepStatistics(self):
         status = builder.BuildStatus(builder.BuilderStatus(&quot;test&quot;), 123)</diff>
      <filename>buildbot/test/test_status.py</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>c56bd20cb96a2e363f5f85aa9a935187abab680a</id>
    </parent>
  </parents>
  <author>
    <name>KATO Kazuyoshi</name>
    <email>kzys@8-p.info</email>
  </author>
  <url>http://github.com/kzys/buildbot/commit/95f7a0e4f86c9052236e195ead6346545db778fd</url>
  <id>95f7a0e4f86c9052236e195ead6346545db778fd</id>
  <committed-date>2009-10-21T05:59:44-07:00</committed-date>
  <authored-date>2009-10-21T05:59:44-07:00</authored-date>
  <message>Cleanup.</message>
  <tree>8fa6cd97d1412af6338b9e745e63e128fe157a25</tree>
  <committer>
    <name>KATO Kazuyoshi</name>
    <email>kzys@8-p.info</email>
  </committer>
</commit>
