Changeset 60993 in webkit


Ignore:
Timestamp:
Jun 10, 2010 11:56:31 PM (14 years ago)
Author:
abarth@webkit.org
Message:

2010-06-10 Adam Barth <abarth@webkit.org>

Reviewed by Daniel Bates.

Make SheriffBot more chatty
https://bugs.webkit.org/show_bug.cgi?id=40463

People seem to like to talk to SheriffBot, so let's make him chat back.

  • Scripts/webkitpy/thirdparty/init.py:
  • Scripts/webkitpy/tool/bot/irc_command.py:
  • Scripts/webkitpy/tool/bot/irc_command_unittest.py: Added.
  • Scripts/webkitpy/tool/bot/sheriffircbot.py:
  • Scripts/webkitpy/tool/bot/sheriffircbot_unittest.py:
Location:
trunk/WebKitTools
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r60988 r60993  
     12010-06-10  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Daniel Bates.
     4
     5        Make SheriffBot more chatty
     6        https://bugs.webkit.org/show_bug.cgi?id=40463
     7
     8        People seem to like to talk to SheriffBot, so let's make him chat back.
     9
     10        * Scripts/webkitpy/thirdparty/__init__.py:
     11        * Scripts/webkitpy/tool/bot/irc_command.py:
     12        * Scripts/webkitpy/tool/bot/irc_command_unittest.py: Added.
     13        * Scripts/webkitpy/tool/bot/sheriffircbot.py:
     14        * Scripts/webkitpy/tool/bot/sheriffircbot_unittest.py:
     15
    1162010-06-10  Brian Weinstein  <bweinstein@apple.com>
    217
  • trunk/WebKitTools/Scripts/webkitpy/thirdparty/__init__.py

    r60876 r60993  
    7272installer.install(url="http://pypi.python.org/packages/source/p/pep8/pep8-0.5.0.tar.gz#md5=512a818af9979290cd619cce8e9c2e2b",
    7373                  url_subpath="pep8-0.5.0/pep8.py")
    74 
     74installer.install(url="http://www.adambarth.com/webkit/eliza",
     75                  target_name="eliza.py")
    7576
    7677rietveld_dir = os.path.join(autoinstalled_dir, "rietveld")
  • trunk/WebKitTools/Scripts/webkitpy/tool/bot/irc_command.py

    r57948 r60993  
    7676
    7777
     78class Help(IRCCommand):
     79    def execute(self, nick, args, tool, sheriff):
     80        return "%s: Available commands: %s" % (nick, ", ".join(commands.keys()))
     81
     82
    7883class Hi(IRCCommand):
    7984    def execute(self, nick, args, tool, sheriff):
     
    8186        quips.append('"Only you can prevent forest fires." -- Smokey the Bear')
    8287        return random.choice(quips)
     88
     89
     90class Eliza(IRCCommand):
     91    therapist = None
     92
     93    def __init__(self):
     94        if not self.therapist:
     95            import webkitpy.thirdparty.autoinstalled.eliza as eliza
     96            Eliza.therapist = eliza.eliza()
     97
     98    def execute(self, nick, args, tool, sheriff):
     99        return "%s: %s" % (nick, self.therapist.respond(" ".join(args)))
     100
     101
     102# FIXME: Lame.  We should have an auto-registering CommandCenter.
     103commands = {
     104    "last-green-revision": LastGreenRevision,
     105    "restart": Restart,
     106    "rollout": Rollout,
     107    "help": Help,
     108    "hi": Hi,
     109}
  • trunk/WebKitTools/Scripts/webkitpy/tool/bot/sheriffircbot.py

    r56977 r60993  
    5353
    5454class SheriffIRCBot(object):
    55     # FIXME: Lame.  We should have an auto-registering CommandCenter.
    56     commands = {
    57         "last-green-revision": irc_command.LastGreenRevision,
    58         "restart": irc_command.Restart,
    59         "rollout": irc_command.Rollout,
    60         "hi": irc_command.Hi,
    61     }
    62 
    6355    def __init__(self, tool, sheriff):
    6456        self._tool = tool
     
    7668        if not tokenized_request:
    7769            return
    78         command = self.commands.get(tokenized_request[0])
     70        command = irc_command.commands.get(tokenized_request[0])
     71        args = tokenized_request[1:]
    7972        if not command:
    80             self._tool.irc().post("%s: Available commands: %s" % (
    81                                   nick, ", ".join(self.commands.keys())))
    82             return
    83         response = command().execute(nick,
    84                                      tokenized_request[1:],
    85                                      self._tool,
    86                                      self._sheriff)
     73            # Give the peoples someone to talk with.
     74            command = irc_command.Eliza
     75            args = tokenized_request
     76        response = command().execute(nick, args, self._tool, self._sheriff)
    8777        if response:
    8878            self._tool.irc().post(response)
  • trunk/WebKitTools/Scripts/webkitpy/tool/bot/sheriffircbot_unittest.py

    r57948 r60993  
    5151        OutputCapture().assert_outputs(self, run, args=["hi"], expected_stderr=expected_stderr)
    5252
    53     def test_bogus(self):
    54         expected_stderr = "MOCK: irc.post: mock_nick: Available commands: rollout, hi, restart, last-green-revision\n"
    55         OutputCapture().assert_outputs(self, run, args=["bogus"], expected_stderr=expected_stderr)
     53    def test_help(self):
     54        expected_stderr = "MOCK: irc.post: mock_nick: Available commands: rollout, hi, help, restart, last-green-revision\n"
     55        OutputCapture().assert_outputs(self, run, args=["help"], expected_stderr=expected_stderr)
    5656
    5757    def test_lgr(self):
Note: See TracChangeset for help on using the changeset viewer.