missingnotice: Implement update_page()
This method updates the content of the configured or given wikipage with the generated lines Issue #64 (#64)
This commit is contained in:
@@ -30,7 +30,7 @@ import pywikibot
|
|||||||
import jogobot
|
import jogobot
|
||||||
|
|
||||||
|
|
||||||
class MissingNoticeBot():
|
class MissingNoticeBot(pywikibot.bot.Bot):
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -46,7 +46,8 @@ ON `cl_from` = `page_id`
|
|||||||
""".format(cat=jogobot.config["red.missingnotice"]["article_category"])
|
""".format(cat=jogobot.config["red.missingnotice"]["article_category"])
|
||||||
|
|
||||||
def __init__( self, genFactory, **kwargs ):
|
def __init__( self, genFactory, **kwargs ):
|
||||||
pass
|
|
||||||
|
super(type(self), self).__init__(**kwargs)
|
||||||
|
|
||||||
def run( self ):
|
def run( self ):
|
||||||
pass
|
pass
|
||||||
@@ -115,6 +116,34 @@ ON `cl_from` = `page_id`
|
|||||||
links=jogobot.config["red.missingnotice"]["link_sep"].join(
|
links=jogobot.config["red.missingnotice"]["link_sep"].join(
|
||||||
links[1] ) )
|
links[1] ) )
|
||||||
|
|
||||||
|
def update_page( self, wikipage=None):
|
||||||
|
"""
|
||||||
|
Handles the updating process of the wikipage
|
||||||
|
|
||||||
|
@param wikipage Wikipage to put text on, otherwise use configured page
|
||||||
|
@type wikipage str
|
||||||
|
"""
|
||||||
|
|
||||||
|
# if not given get wikipage from config
|
||||||
|
if not wikipage:
|
||||||
|
wikipage = jogobot.config["red.missingnotice"]["wikipage"]
|
||||||
|
|
||||||
|
# Create page object for wikipage
|
||||||
|
page = pywikibot.Page(pywikibot.Site(), wikipage)
|
||||||
|
|
||||||
|
# Define edit summary
|
||||||
|
summary = jogobot.config["red.missingnotice"]["edit_summary"]
|
||||||
|
|
||||||
|
# Make sure summary starts with "Bot:"
|
||||||
|
if not summary[:len("Bot:")] == "Bot:":
|
||||||
|
summary = "Bot: " + summary.strip()
|
||||||
|
|
||||||
|
# Concatenate new text
|
||||||
|
new_text = "\n".join(self.page_content)
|
||||||
|
|
||||||
|
# Save new text
|
||||||
|
self.userPut( page, page.text, new_text, summary=summary )
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_categorized_articles( cls ):
|
def get_categorized_articles( cls ):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user