Source code for pywikibot.specialbots._unlink

"""Special bot library containing BaseUnlinkBot.

Do not import classes directly from here but from specialbots.
# (C) Pywikibot team, 2003-2022
# Distributed under the terms of the MIT license.
from import (
from pywikibot.bot_choice import UnhandledAnswer
from pywikibot.editor import TextEditor
from pywikibot.textlib import replace_links

class EditReplacementError(ChoiceException, UnhandledAnswer):

    """The text should be edited and replacement should be restarted."""

    def __init__(self) -> None:
        super().__init__('edit', 'e')
        self.stop = True

[docs]class BaseUnlinkBot(ExistingPageBot, AutomaticTWSummaryBot): """A basic bot unlinking a given link from the current page.""" use_redirects = False def __init__(self, **kwargs) -> None: """Redirect all parameters and add namespace as an available option.""" self.available_options.update({ 'namespaces': [], # Which namespaces should be processed? # default to [] which means all namespaces will be processed }) super().__init__(**kwargs) def _create_callback(self): """Create a new callback instance for replace_links.""" return InteractiveUnlink(self)