Kirk Trombley 6 years ago
parent
commit
e65f00bb24
1 changed files with 10 additions and 0 deletions
  1. 10 0
      src/plugins/querying.py

+ 10 - 0
src/plugins/querying.py

@@ -184,3 +184,13 @@ def riddle(bot, message, log):
         riddle[0],
         f"I'll post the response in about {get_config('riddle.sleep_time')} seconds!",
     ))
+
+
+@as_plugin
+def fortune():
+    sesh = HTMLSession()
+    r = sesh.get("http://www.fortunecookiemessage.com/")
+    quote = r.html.xpath("//div[contains(@class, 'quote')]/a")[0].text
+    learn, lotto = [x.split(":", 1)[-1].strip() for x in r.html.xpath("//div[contains(@class, 'bottom-message')]")[0].text.split("\n")[:2]]
+
+    return f"'{quote}'\nLucky Numbers: {lotto}\nLearn Chinese: {learn}"