diff --git a/docs/changelog.md b/docs/changelog.md new file mode 100644 index 0000000..f118eb2 --- /dev/null +++ b/docs/changelog.md @@ -0,0 +1,3 @@ +# 0.1.3 + +- Add overwrite option to append_text in wiki interface \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index f30dcdb..a40e8ef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "wiki-postbot" -version = "0.1.2" +version = "0.1.3" description = "Add posts to the wiki!" authors = ["sneakers-the-rat "] license = "GPL-3.0" diff --git a/wiki_postbot/interfaces/mediawiki.py b/wiki_postbot/interfaces/mediawiki.py index f0d8b87..751acbf 100644 --- a/wiki_postbot/interfaces/mediawiki.py +++ b/wiki_postbot/interfaces/mediawiki.py @@ -86,7 +86,11 @@ class Wiki: self.logger.debug(content) return WikiPage.from_source(title=content['parse']['title'], source=content['parse']['wikitext']) - def insert_text(self, page, section, text): + def insert_text(self, page, section, text, overwrite:bool=False): + if overwrite: + operation_key = 'text' + else: + operation_key = 'appendtext' # TODO: Move finding section IDs into the page class! page_text = self.get_page(page) @@ -119,7 +123,7 @@ class Wiki: "action":"edit", "title":page, "section":str(matching_section), - "appendtext":text, + operation_key:text, "format":"json", "token":token } @@ -133,7 +137,7 @@ class Wiki: "title":page, "section":"new", "sectiontitle":section, - "appendtext":text, + operation_key:text, "format":"json", "token":token }