From 540a33437cf6bfc1c941cad7a1b56500a01c8091 Mon Sep 17 00:00:00 2001 From: Ankit Raj Mahapatra <54436840+Ankit404butfound@users.noreply.github.com> Date: Thu, 14 Jan 2021 09:41:00 +0530 Subject: [PATCH] Update app.py --- app.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 9d883cd..6b02bd3 100644 --- a/app.py +++ b/app.py @@ -13,6 +13,7 @@ import wikipedia import sqlite3 import pyjokes +import requests now = datetime.now().strftime("%H:%M") user_commands = [] @@ -217,6 +218,13 @@ def get_bot_response(): if "joke" in lst: return pyjokes.get_joke() + fact_cond = ["facts", "fact","intresting thing","surprise me"] + if any(cond in userText for cond in fact_cond): + data = requests.get("https://www.generatormix.com/random-facts-generator").content + soup = BeautifulSoup(data) + fact = soup.find("blockquote",attrs = {'class':"text-left"}) + return (fact.text) + else: try: @@ -228,4 +236,4 @@ def get_bot_response(): return "Sorry. I do not have the answer to your query, so I'm searching the web for the answer ." if __name__ == "__main__": - app.run() \ No newline at end of file + app.run()