end telegram bot and begin trying deepface
This commit is contained in:
parent
88024f4356
commit
c27375e5f4
2 changed files with 30 additions and 4 deletions
17
index.py
Normal file
17
index.py
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
import requests
|
||||||
|
from deepface import DeepFace
|
||||||
|
import os
|
||||||
|
# url_one="https://gas-kvas.com/grafic/uploads/posts/2023-09/1695805187_gas-kvas-com-p-kartinki-garri-potter-6.jpg"
|
||||||
|
# url_two="https://frazy.su/wp-content/uploads/2016/07/regnum_picture_1464862366254511_normal.jpg"
|
||||||
|
current_path = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
photos_path = os.path.join(current_path,"photos")
|
||||||
|
# response_one=requests.get(url_one)
|
||||||
|
# response_two=requests.get(url_two)
|
||||||
|
photo_1 = os.path.join(photos_path,"photo_one.jpeg")
|
||||||
|
photo_2 = os.path.join(photos_path,"photo_two.jpeg")
|
||||||
|
print(photo_1,photo_2)
|
||||||
|
# with open(photo_1,"wb") as f: f.write(response_one.content)
|
||||||
|
# with open(photo_2,"wb") as f: f.write(response_two.content)
|
||||||
|
|
||||||
|
result = DeepFace.verify("photo_one.jpg","photo_two.jpg")
|
||||||
|
print(result)
|
17
main.py
17
main.py
|
@ -62,6 +62,14 @@ class Database:
|
||||||
|
|
||||||
self.close(sql['connect'],sql['cursor'])
|
self.close(sql['connect'],sql['cursor'])
|
||||||
return sql["cursor"].lastrowid
|
return sql["cursor"].lastrowid
|
||||||
|
def check_application(self,id_application) -> int:
|
||||||
|
sql = self.connect_db()
|
||||||
|
sql["cursor"].execute("""
|
||||||
|
select message_id from messages where id = ?
|
||||||
|
""",(id_application,))
|
||||||
|
data_message = sql["cursor"].fetchone()
|
||||||
|
self.close(sql["connect"],sql["cursor"])
|
||||||
|
return data_message[0]
|
||||||
def close(self,connect,cursor):
|
def close(self,connect,cursor):
|
||||||
cursor.close()
|
cursor.close()
|
||||||
connect.close()
|
connect.close()
|
||||||
|
@ -95,11 +103,12 @@ class TelegramBot(Database):
|
||||||
reply_message = message.reply_to_message.text
|
reply_message = message.reply_to_message.text
|
||||||
id_application = re.search(r"Номер заявки: (\d+)",reply_message).group(1)
|
id_application = re.search(r"Номер заявки: (\d+)",reply_message).group(1)
|
||||||
id_user = re.search(r"ID пользователя: (\d+)",reply_message).group(1)
|
id_user = re.search(r"ID пользователя: (\d+)",reply_message).group(1)
|
||||||
message_text = reply_message.split("\n")
|
current_message = self.check_application(id_application)
|
||||||
print(id_application,id_user)
|
print(current_message)
|
||||||
self.bot.send_message(
|
self.bot.send_message(
|
||||||
id_user,
|
id_user,
|
||||||
f"Ответ от админа: {message.text}"
|
f"Ответ от админа: {message.text}",
|
||||||
|
reply_to_message_id=current_message
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
check = self.check_user(message.from_user.id)
|
check = self.check_user(message.from_user.id)
|
||||||
|
@ -119,5 +128,5 @@ ID пользователя: {message.from_user.id}
|
||||||
|
|
||||||
TelegramBot(
|
TelegramBot(
|
||||||
db_name="tg.db",
|
db_name="tg.db",
|
||||||
token=""
|
token="7037219892:AAGAiUsOL_Ia6lz3iZSyAN0PMlmZFDXbDL0"
|
||||||
)
|
)
|
Loading…
Reference in a new issue