Ver código fonte

Merge branch 'feature/fortunes' of kirkleon/rollbot3 into master

kirkleon 6 anos atrás
pai
commit
b0cc74b629
1 arquivos alterados com 10 adições e 0 exclusões
  1. 10 0
      src/plugins/querying.py

+ 10 - 0
src/plugins/querying.py

@@ -184,3 +184,13 @@ def riddle(bot, message, log):
         riddle[0],
         riddle[0],
         f"I'll post the response in about {get_config('riddle.sleep_time')} seconds!",
         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}"