{"id":15017696,"url":"https://github.com/earwig/earwigbot","last_synced_at":"2025-04-07T05:10:03.369Z","repository":{"id":57424943,"uuid":"1592604","full_name":"earwig/earwigbot","owner":"earwig","description":"A Python bot that edits Wikipedia and interacts over IRC","archived":false,"fork":false,"pushed_at":"2024-11-04T04:09:07.000Z","size":2513,"stargazers_count":42,"open_issues_count":3,"forks_count":14,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-03-31T04:05:43.872Z","etag":null,"topics":["irc-bot","mediawiki","python","wikipedia"],"latest_commit_sha":null,"homepage":"https://en.wikipedia.org/wiki/User:EarwigBot","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/earwig.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-04-09T19:57:26.000Z","updated_at":"2025-03-26T22:32:07.000Z","dependencies_parsed_at":"2024-07-23T02:44:11.979Z","dependency_job_id":"15a3448a-a728-40fa-8c81-fd8d1cf87be0","html_url":"https://github.com/earwig/earwigbot","commit_stats":{"total_commits":1113,"total_committers":11,"mean_commits":"101.18181818181819","dds":"0.28391734052111406","last_synced_commit":"f5a6ff0b3270c3178ed68bfd8b4570943188ae8b"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/earwig%2Fearwigbot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/earwig%2Fearwigbot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/earwig%2Fearwigbot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/earwig%2Fearwigbot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/earwig","download_url":"https://codeload.github.com/earwig/earwigbot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247595334,"owners_count":20963943,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["irc-bot","mediawiki","python","wikipedia"],"created_at":"2024-09-24T19:50:52.305Z","updated_at":"2025-04-07T05:10:03.342Z","avatar_url":"https://github.com/earwig.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"EarwigBot\n=========\n\nEarwigBot_ is a Python bot that edits Wikipedia_ and interacts over IRC_.\nThis README provides a basic overview of how to install and setup the bot;\nmore detailed information is located in the ``docs/`` directory\n(`available online_`).\n\nHistory\n-------\n\nDevelopment began, based on `Pywikibot`_, in early 2009. Approval for its\nfirst task, a `copyright violation detector`_, was carried out in May, and the\nbot has been running consistently ever since. It currently handles\n`several ongoing tasks`_ ranging from statistics generation to category\ncleanup, and on-demand tasks such as WikiProject template tagging. Since it\nstarted running, the bot has made over 300,000 edits.\n\nThe current version of its codebase began development in April 2011, moving\naway from Pywikibot to a custom framework.\n\nInstallation\n------------\n\nThis package contains the core ``earwigbot``, abstracted to be usable and\ncustomizable by anyone running a bot on a MediaWiki site. Since it is modular,\nthe IRC components can be disabled if desired. IRC commands and bot tasks\nspecific to `my instance of EarwigBot`_ that I don't feel the average user\nwill need are available from the repository `earwigbot-plugins`_.\n\nLatest release\n~~~~~~~~~~~~~~\n\nEarwigBot is available from the `Python Package Index`_, so you can install\nthe latest release with:\n\n    pip install earwigbot\n\nThere are a few sets of optional dependencies:\n\n- ``crypto``: Allows encrypting bot passwords and secrets in the config\n- ``sql``: Allows interfacing with MediaWiki databases (e.g. on Toolforge_)\n- ``copyvios``: Includes parsing libraries for checking copyright violations\n- ``dev``: Installs development dependencies (e.g. test runners)\n\nFor example, to install all non-dev dependencies:\n\n    pip install 'earwigbot[crypto,sql,copyvios]'\n\nErrors while pip is installing dependencies may be due to missing header\nfiles. For example, on Ubuntu, see `this StackOverflow post`_.\n\nDevelopment version\n~~~~~~~~~~~~~~~~~~~\n\nYou can install the development version of the bot::\n\n    git clone https://github.com/earwig/earwigbot.git\n    cd earwigbot\n    python3 -m venv venv\n    . venv/bin/activate\n    pip install -e '.[crypto,sql,copyvios,dev]'\n\nTo run the bot's unit tests, run ``pytest`` (requires the ``dev``\ndependencies). Coverage is currently rather incomplete.\n\nSetup\n-----\n\nThe bot stores its data in a \"working directory\", including its config file\nand databases. This is also the location where you will place custom IRC\ncommands and bot tasks, which will be explained later. It doesn't matter where\nthis directory is, as long as the bot can write to it.\n\nStart the bot with ``earwigbot path/to/working/dir``, or just ``earwigbot`` if\nthe working directory is the current directory. It will notice that no\n``config.yml`` file exists and take you through the setup process.\n\nThere is currently no way to edit the ``config.yml`` file from within the bot\nafter it has been created, but you should be able to make any necessary\nchanges yourself.\n\nAfter setup, the bot will start. This means it will connect to the IRC servers\nit has been configured for, schedule bot tasks to run at specific times, and\nthen wait for instructions (as commands on IRC). For a list of commands, say\n\"``!help``\" (commands are messages prefixed with an exclamation mark).\n\nYou can stop the bot at any time with Control+C, same as you stop a normal\nPython program, and it will try to exit safely. You can also use the\n\"``!quit``\" command on IRC.\n\nCustomizing\n-----------\n\nThe bot's working directory contains a ``commands`` subdirectory and a\n``tasks`` subdirectory. Custom IRC commands can be placed in the former,\nwhereas custom wiki bot tasks go into the latter. Developing custom modules is\nexplained below, and in more detail through the bot's documentation_ or in the\n``docs/`` dir.\n\nNote that custom commands will override built-in commands and tasks with the\nsame name.\n\n``Bot`` and ``BotConfig``\n~~~~~~~~~~~~~~~~~~~~~~~~~\n\n`earwigbot.bot.Bot`_ is EarwigBot's main class. You don't have to instantiate\nthis yourself, but it's good to be familiar with its attributes and methods,\nbecause it is the main way to communicate with other parts of the bot. A\n``Bot`` object is accessible as an attribute of commands and tasks (i.e.,\n``self.bot``).\n\n`earwigbot.config.BotConfig`_ stores configuration information for the bot.\nIts docstring explains what each attribute is used for, but essentially each\n\"node\" (one of ``config.components``, ``wiki``, ``irc``, ``commands``,\n``tasks``, and ``metadata``) maps to a section of the bot's ``config.yml``\nfile. For example, if ``config.yml`` includes something like::\n\n    irc:\n        frontend:\n            nick: MyAwesomeBot\n            channels:\n                - \"##earwigbot\"\n                - \"#channel\"\n                - \"#other-channel\"\n\nthen ``config.irc[\"frontend\"][\"nick\"]`` will be ``\"MyAwesomeBot\"`` and\n``config.irc[\"frontend\"][\"channels\"]`` will be ``[\"##earwigbot\", \"#channel\",\n\"#other-channel\"]``.\n\nCustom IRC commands\n~~~~~~~~~~~~~~~~~~~\n\nCustom commands are subclasses of `earwigbot.commands.Command`_ that override\n``Command``'s ``process()`` (and optionally ``check()``, ``setup()``, or\n``unload()``) methods.\n\nThe bot has a wide selection of built-in commands and plugins to act as sample\ncode and/or to give ideas. Start with test_, and then check out chanops_ and\nafc_status_ for some more complicated scripts.\n\nCustom bot tasks\n~~~~~~~~~~~~~~~~\n\nCustom tasks are subclasses of `earwigbot.tasks.Task`_ that override\n``Task``'s ``run()`` (and optionally ``setup()`` or ``unload()``) methods.\n\nSee the built-in wikiproject_tagger_ task for a relatively straightforward\ntask, or the afc_statistics_ plugin for a more complicated one.\n\nThe Wiki Toolset\n----------------\n\nEarwigBot's answer to the Pywikibot_ is the Wiki Toolset (``earwigbot.wiki``),\nwhich you will mainly access through ``bot.wiki``.\n\n``bot.wiki`` provides three methods for the management of Sites:\n``get_site()``, ``add_site()``, and ``remove_site()``. Sites are objects that\nsimply represent a MediaWiki site. A single instance of EarwigBot (i.e. a\nsingle *working directory*) is expected to relate to a single site or group of\nsites using the same login info (like all WMF wikis with CentralAuth).\n\nLoad your default site (the one that you picked during setup) with\n``site = bot.wiki.get_site()``.\n\nNot all aspects of the toolset are covered in the docs. Explore `its code and\ndocstrings`_ to learn how to use it in a more hands-on fashion. For reference,\n``bot.wiki`` is an instance of ``earwigbot.wiki.SitesDB`` tied to the\n``sites.db`` file in the bot's working directory.\n\n.. _EarwigBot:                      https://en.wikipedia.org/wiki/User:EarwigBot\n.. _Wikipedia:                      https://en.wikipedia.org/\n.. _IRC:                            https://en.wikipedia.org/wiki/Internet_Relay_Chat\n.. _available online:               https://pythonhosted.org/earwigbot/\n.. _Pywikibot:                      https://www.mediawiki.org/wiki/Manual:Pywikibot\n.. _copyright violation detector:   https://en.wikipedia.org/wiki/Wikipedia:Bots/Requests_for_approval/EarwigBot_1\n.. _several ongoing tasks:          https://en.wikipedia.org/wiki/User:EarwigBot#Tasks\n.. _my instance of EarwigBot:       https://en.wikipedia.org/wiki/User:EarwigBot\n.. _earwigbot-plugins:              https://github.com/earwig/earwigbot-plugins\n.. _Python Package Index:           https://pypi.python.org/pypi/earwigbot\n.. _Toolforge:                      https://wikitech.wikimedia.org/wiki/Portal:Toolforge\n.. _this StackOverflow post:        https://stackoverflow.com/questions/6504810/how-to-install-lxml-on-ubuntu/6504860#6504860\n.. _documentation:                  https://pythonhosted.org/earwigbot/\n.. _earwigbot.bot.Bot:              https://github.com/earwig/earwigbot/blob/main/earwigbot/bot.py\n.. _earwigbot.config.BotConfig:     https://github.com/earwig/earwigbot/blob/main/earwigbot/config.py\n.. _earwigbot.commands.Command:     https://github.com/earwig/earwigbot/blob/main/earwigbot/commands/__init__.py\n.. _test:                           https://github.com/earwig/earwigbot/blob/main/earwigbot/commands/test.py\n.. _chanops:                        https://github.com/earwig/earwigbot/blob/main/earwigbot/commands/chanops.py\n.. _afc_status:                     https://github.com/earwig/earwigbot-plugins/blob/main/commands/afc_status.py\n.. _earwigbot.tasks.Task:           https://github.com/earwig/earwigbot/blob/main/earwigbot/tasks/__init__.py\n.. _wikiproject_tagger:             https://github.com/earwig/earwigbot/blob/main/earwigbot/tasks/wikiproject_tagger.py\n.. _afc_statistics:                 https://github.com/earwig/earwigbot-plugins/blob/main/tasks/afc_statistics.py\n.. _its code and docstrings:        https://github.com/earwig/earwigbot/tree/main/earwigbot/wiki\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fearwig%2Fearwigbot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fearwig%2Fearwigbot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fearwig%2Fearwigbot/lists"}