소스 검색

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

kirkleon 6 년 전
부모
커밋
b0cc74b629
1개의 변경된 파일10개의 추가작업 그리고 0개의 파일을 삭제
  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}"