From 24df2de5e60adef3efe432d5e63536c7826b54c8 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Fri, 12 May 2023 09:16:06 -0300 Subject: Add bloatware --- game/wiki.rpy | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 game/wiki.rpy diff --git a/game/wiki.rpy b/game/wiki.rpy new file mode 100644 index 0000000..2f8b2be --- /dev/null +++ b/game/wiki.rpy @@ -0,0 +1,72 @@ +################################################################################# +# This file is part of Mana Launcher. +# Copyright (C) 2023 Jesusalva +# +# Distributed under the MIT license. +################################################################################# +init python: + if mwclient is not None: + wiki=mwclient.Site('wiki.themanaworld.org', path='/') + else: + wiki=None + + def wiki_get(game, page): + if wiki is None: + return "" + page = wiki.pages['%s:%s' % (game, page)] + if page.exists: + return page.text(expandtemplates=False) # expandtemplates=True cache=False + return "" + + def wiki_links(page): + ls=[] + for ln in list(page.links()): + # ln.name takes the namespace in account + # ln.base_name is ln.name but split by "/" + # ln.page_title has no namespace and base_title is split by "/" + # Red links are excluded by the if clause + if ln.exists: + ls.append([str(ln.page_title), str(ln.name)]) + return ls + + def wiki_sub(s, nl=" "): + parsed="" + if s.startswith('https://'): + parsed+="{a=%s}%s{/a}" % (s, _("External Link")) + elif s.startswith('[[') and s.startswith(']]'): + # We don't have a code for this... + parsed+=s + elif s.startswith('{{') and s.startswith('}}'): + return "" + else: + parsed+=s + parsed+=nl + return parsed + + def wiki_parse(raw): + raw=raw.replace('
', '\n').replace('
', '\n') + fin="" + part="" + for s in raw.split('\n'): + part+=wiki_sub(s, "\n") + for s in part.split(' '): + fin+=wiki_sub(s, " ") + # TODO: Add a see-also section with the inner links + return fin + + def load_wiki(server=99): + global statusmsg + print("Loading wiki for server %d" % server) + # persistent.serverlist[server]["Help"] + game="Classic" + page="Walkthrough" + + #data=wiki_get(game, page) + print("Wiki loaded, parsing") + statusmsg = "Boo boo boo" #wiki_parse(data) + print("Done!") + renpy.restart_interaction() + print("Forcefully restarted, returning now.") + return None + + -- cgit v1.2.3-60-g2f50