Manual:Pywikibot/Flow

From Linux Web Expert

Pywikibot includes basic support for Flow, the new discussion framework for Wikimedia wikis. This support will evolve over time as more features are added.

Examples

Determining if a page is a Flow board

import pwb  # only needed if you haven't installed the framework as side-package
import pywikibot
import pywikibot.flow
site = pywikibot.Site('mediawiki', 'mediawiki')
page = pywikibot.Page(site, 'Talk:Sandbox')
if page.is_flow_page():
    board = pywikibot.flow.Board(page)

Loading topic titles

import pwb  # only needed if you haven't installed the framework as side-package
import pywikibot
import pywikibot.flow
site = pywikibot.Site('mediawiki', 'mediawiki')
board = pywikibot.flow.Board(site, 'Talk:Sandbox')
topic_titles = []
for topic in board.topics():
    topic_titles.append(topic.root.get())

Creating new topics

import pwb  # only needed if you haven't installed the framework as side-package
import pywikibot
import pywikibot.flow
site = pywikibot.Site('mediawiki', 'mediawiki')
board = pywikibot.flow.Board(site, 'Talk:Sandbox')
title = 'New topic'
content = 'This is a new topic.'
topic = board.new_topic(title, content)

Replying to topics

import pwb  # only needed if you haven't installed the framework as side-package
import pywikibot
import pywikibot.flow
site = pywikibot.Site('mediawiki', 'mediawiki')
board = pywikibot.flow.Topic(site, 'Topic:whatever')
content = 'This is a new reply.'
reply = topic.reply(content)


<translate> If you need more help on setting up your Pywikibot visit the {{<tvar name="1">irc|pywikibot</tvar>|#pywikibot IRC channel}} or [[<tvar name="2">mail:pywikibot</tvar>|pywikibot@ mailing list]].</translate>