Spaces:
Runtime error
Runtime error
siteaichatgpt
commited on
Commit
•
c569761
1
Parent(s):
8ea7765
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import requests
|
|
2 |
import streamlit as st
|
3 |
import shutil
|
4 |
import random
|
|
|
5 |
import requests
|
6 |
from PIL import Image, ImageDraw, ImageFont
|
7 |
from io import BytesIO
|
@@ -14,11 +15,18 @@ import time
|
|
14 |
from time import strftime
|
15 |
import datetime
|
16 |
import khayyam
|
|
|
|
|
17 |
from IPython.display import HTML
|
18 |
from bs4 import BeautifulSoup
|
19 |
import base64
|
20 |
import os
|
|
|
|
|
|
|
|
|
21 |
conn = sqlite3.connect('chatbot_data.db')
|
|
|
22 |
def main():
|
23 |
st.title("انیمه کردن تصاویر")
|
24 |
image_link = st.text_input("لطفاً لینک عکس را وارد کنید:")
|
@@ -38,6 +46,21 @@ cursor.execute('''
|
|
38 |
)
|
39 |
|
40 |
''')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
def fetch_estekhare():
|
42 |
url = "http://api-free.ir/api/es.php"
|
43 |
response = requests.get(url)
|
@@ -512,17 +535,15 @@ if inp:
|
|
512 |
st.error("خطا در دریافت اطلاعات استخاره")
|
513 |
elif inp =="time" or inp =="تایم":
|
514 |
current_time = time.strftime("%H:%M:%S")
|
515 |
-
|
516 |
-
|
517 |
-
m=now.strftime("%Y-%m-%d")
|
518 |
-
st.text_area("Chatbot's Response", value=f"تایم کنونی :{m}" , height=400)
|
519 |
elif inp =="تاریخ":
|
520 |
tariq =khayyam.JalaliDatetime.today().strftime("%A %D %B %Y")
|
521 |
st.text_area("Chatbot's Response", value=f"تاریخ شما:\n{tariq}" , height=400)
|
522 |
|
523 |
-
elif inp.startswith("
|
524 |
|
525 |
-
url = inp.replace("
|
526 |
response = requests.get(url)
|
527 |
if response.status_code == 200:
|
528 |
st.text("در حال دریافت قالب وبسایت...")
|
@@ -559,6 +580,20 @@ if inp:
|
|
559 |
|
560 |
else:
|
561 |
st.error(f"خطا: {response.status_code}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
562 |
|
563 |
|
564 |
|
@@ -606,7 +641,7 @@ if inp:
|
|
606 |
st.text_area("Chatbot's Response", value=chat , height=400)
|
607 |
insert_chatbot_response(inp, chat)
|
608 |
|
609 |
-
a=logging.info(f"
|
610 |
with open(LOG_FILE, 'r') as file:
|
611 |
print(file.read())
|
612 |
|
|
|
2 |
import streamlit as st
|
3 |
import shutil
|
4 |
import random
|
5 |
+
import gtts
|
6 |
import requests
|
7 |
from PIL import Image, ImageDraw, ImageFont
|
8 |
from io import BytesIO
|
|
|
15 |
from time import strftime
|
16 |
import datetime
|
17 |
import khayyam
|
18 |
+
import datetime
|
19 |
+
import time
|
20 |
from IPython.display import HTML
|
21 |
from bs4 import BeautifulSoup
|
22 |
import base64
|
23 |
import os
|
24 |
+
import phonenumbers
|
25 |
+
import phonenumbers
|
26 |
+
from phonenumbers import geocoder, carrier
|
27 |
+
|
28 |
conn = sqlite3.connect('chatbot_data.db')
|
29 |
+
|
30 |
def main():
|
31 |
st.title("انیمه کردن تصاویر")
|
32 |
image_link = st.text_input("لطفاً لینک عکس را وارد کنید:")
|
|
|
46 |
)
|
47 |
|
48 |
''')
|
49 |
+
def get_phone_number_info(phone_number):
|
50 |
+
try:
|
51 |
+
|
52 |
+
parsed_phone_number = phonenumbers.parse(phone_number, "IR")
|
53 |
+
|
54 |
+
# دریافت اطلاعات مربوط به موقعیت جغرافیایی
|
55 |
+
location = geocoder.description_for_number(parsed_phone_number, "fa")
|
56 |
+
|
57 |
+
# دریافت اطلاعات مربوط به اپراتور
|
58 |
+
operator = carrier.name_for_number(parsed_phone_number, "fa")
|
59 |
+
|
60 |
+
# بازگشت اطلاعات به ترتیب مطلوب
|
61 |
+
return (phone_number, parsed_phone_number.country_code, parsed_phone_number.national_number, location, operator)
|
62 |
+
except phonenumbers.NumberParseException as e:
|
63 |
+
return (phone_number, None, None, None, None)
|
64 |
def fetch_estekhare():
|
65 |
url = "http://api-free.ir/api/es.php"
|
66 |
response = requests.get(url)
|
|
|
535 |
st.error("خطا در دریافت اطلاعات استخاره")
|
536 |
elif inp =="time" or inp =="تایم":
|
537 |
current_time = time.strftime("%H:%M:%S")
|
538 |
+
|
539 |
+
st.text_area("Chatbot's Response", value=f"تایم کنونی :{ current_time}" , height=400)
|
|
|
|
|
540 |
elif inp =="تاریخ":
|
541 |
tariq =khayyam.JalaliDatetime.today().strftime("%A %D %B %Y")
|
542 |
st.text_area("Chatbot's Response", value=f"تاریخ شما:\n{tariq}" , height=400)
|
543 |
|
544 |
+
elif inp.startswith("سورس"):
|
545 |
|
546 |
+
url = inp.replace("سورس", "")
|
547 |
response = requests.get(url)
|
548 |
if response.status_code == 200:
|
549 |
st.text("در حال دریافت قالب وبسایت...")
|
|
|
580 |
|
581 |
else:
|
582 |
st.error(f"خطا: {response.status_code}")
|
583 |
+
elif inp.startswith("info:"):
|
584 |
+
st.text("منتظربمانید برای به دست اوردن اطلاعات شماره")
|
585 |
+
phone_number =inp.replace("info:","")
|
586 |
+
phone_number_info = get_phone_number_info(phone_number)
|
587 |
+
st.write("شماره موبایل:", phone_number_info[0])
|
588 |
+
st.write("کد کشور:", phone_number_info[1])
|
589 |
+
st.write("شماره ملی:", phone_number_info[2])
|
590 |
+
st.write("موقعیت جغرافیایی:", phone_number_info[3])
|
591 |
+
st.write("اپراتور:", phone_number_info[4])
|
592 |
+
|
593 |
+
|
594 |
+
|
595 |
+
|
596 |
+
|
597 |
|
598 |
|
599 |
|
|
|
641 |
st.text_area("Chatbot's Response", value=chat , height=400)
|
642 |
insert_chatbot_response(inp, chat)
|
643 |
|
644 |
+
a=logging.info(f"User input: {inp}, Chatbot response: {chat}")
|
645 |
with open(LOG_FILE, 'r') as file:
|
646 |
print(file.read())
|
647 |
|