Introduction
Introduction Statistics Contact Development Disclaimer Help
wikipediagame: add giveup command - annna - Annna the nice friendly bot.
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6…
Log
Files
Refs
Tags
README
---
commit c66c8287325a231220ec51624fbb4a0f39eb414c
parent 4d565ad505a663f9c39318daeb7a2c5ed403ef5c
Author: Anders Damsgaard <[email protected]>
Date: Sun, 23 Apr 2023 10:22:42 +0200
wikipediagame: add giveup command
Signed-off-by: Annna Robert-Houdin <[email protected]>
Diffstat:
M annna-message-wikigame | 2 +-
M wikipediagame | 23 ++++++++++++++++-------
2 files changed, 17 insertions(+), 8 deletions(-)
---
diff --git a/annna-message-wikigame b/annna-message-wikigame
@@ -14,7 +14,7 @@ text="$4"
saytext=""
case "${text}" in
-init|summary|hint|more)
+init|summary|hint|more|giveup)
saytext="$(wikipediagame "${text}")"
;;
"init "*)
diff --git a/wikipediagame b/wikipediagame
@@ -23,6 +23,16 @@ def concealtitle(s, title):
s = s.replace(titlepart, "*" * len(titlepart))
return s
+def geturi(wpage):
+ wuri = wpage.url
+ return wuri.replace("https://en.wikipedia.org/wiki", "gopher://gopherpedia…
+
+def endgame(hintpath, titlepath):
+ if os.path.exists(hintpath):
+ os.remove(hintpath)
+ if os.path.exists(titlepath):
+ os.remove(titlepath)
+
def main(args):
try:
opts, largs = getopt.getopt(args[1:], "h")
@@ -135,17 +145,16 @@ def main(args):
trytext = largs[1]
if title.strip().lower() == trytext.strip().lower():
wpage = w.page(title)
- wuri = wpage.url
- uri = wuri.replace("https://en.wikipedia.org/wiki", "gopher://goph…
- print("Congrats! You have found the right title! :: %s" % (uri))
- if os.path.exists(hintpath):
- os.remove(hintpath)
- if os.path.exists(titlepath):
- os.remove(titlepath)
+ print("Congrats! You have found the right title! :: %s" % (geturi(…
+ endgame(hintpath, titlepath)
else:
print("Sorry, wrong guess. (%.0f%% correct)" % \
(SequenceMatcher(None, title.strip().lower(), …
+ if cmd == "giveup":
+ print("The correct title was: %s" % (geturi(wpage)))
+ endgame(hintpath, titlepath)
+
return 0
if __name__ == "__main__":
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.