A Python robot that edits Wikipedia and interacts with people over IRC https://en.wikipedia.org/wiki/User:EarwigBot
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.3 KiB

  1. #! /usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # Copyright (C) 2009-2012 by Ben Kurtovic <ben.kurtovic@verizon.net>
  5. #
  6. # Permission is hereby granted, free of charge, to any person obtaining a copy
  7. # of this software and associated documentation files (the "Software"), to deal
  8. # in the Software without restriction, including without limitation the rights
  9. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. # copies of the Software, and to permit persons to whom the Software is
  11. # furnished to do so, subject to the following conditions:
  12. #
  13. # The above copyright notice and this permission notice shall be included in
  14. # all copies or substantial portions of the Software.
  15. #
  16. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  22. # SOFTWARE.
  23. import argparse
  24. from os import path
  25. from earwigbot import __version__
  26. from earwigbot.bot import Bot
  27. __all__ = ["BotUtility", "main"]
  28. class BotUtility(object):
  29. """
  30. This is a command-line utility for EarwigBot that enables you to easily
  31. start the bot without writing generally unnecessary three-line bootstrap
  32. scripts. It supports starting the bot from any directory, as well as
  33. starting individual tasks instead of the entire bot.
  34. """
  35. def version(self):
  36. return "EarwigBot v{0}".format(__version__)
  37. def run(self, root_dir):
  38. bot = Bot(root_dir)
  39. print self.version()
  40. #try:
  41. # bot.run()
  42. #finally:
  43. # bot.stop()
  44. def main(self):
  45. parser = argparse.ArgumentParser(description=BotUtility.__doc__)
  46. parser.add_argument("-v", "--version", action="version",
  47. version=self.version())
  48. parser.add_argument("root_dir", metavar="path", nargs="?", default=path.curdir)
  49. args = parser.parse_args()
  50. root_dir = path.abspath(args.root_dir)
  51. self.run(root_dir)
  52. main = BotUtility().main
  53. if __name__ == "__main__":
  54. main()