florestbotfunctions 1.3.2__tar.gz → 1.3.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,11 @@
1
+ Metadata-Version: 2.1
2
+ Name: florestbotfunctions
3
+ Version: 1.3.4
4
+ Summary: Функции бота Флореста в одной библиотеке.
5
+ Author: florestdev
6
+ Author-email: florestone4185@internet.ru
7
+ Project-URL: Social Resources, https://taplink.cc/florestone4185
8
+ Project-URL: My bot, https://t.me/postbotflorestbot
9
+ Requires-Python: >=3.10
10
+
11
+ Привет! Данная библиотека включает в себя функции из https://t.me/postbotflorestbot. Все функции, с удобным объяснением кода, только здесь. P.S. Это официальная библиотека от создателя бота - FlorestDev. Все функции предоставляются в ознакомительном порядке.
@@ -1,8 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  """Привет!\nВ этой библиотеке Вы увидете некоторые функции [бота Флореста](https://t.me/postbotflorestbot).\nМои социальные сети: [тык](https://taplink.cc/florestone4185)"""
3
3
 
4
- import pytubefix.exceptions
5
- import pytubefix.exceptions
6
4
  import tkinter as tk
7
5
  from tkinter import filedialog, messagebox, scrolledtext
8
6
  import os, re
@@ -685,7 +683,45 @@ class FunctionsObject:
685
683
  return None
686
684
  else:
687
685
  return None
686
+ def image_text_recognition(self, img: bytes, lang: str = 'ru'):
687
+ """Разбор текста на изображении, с помощью инструментов Google Cloud.\nimg: ваше изображение в bytes.\nlang: язык текста на изображении."""
688
+ import requests, base64
689
+ if not self.google_key:
690
+ return 'Для работы с данной функцией необходим Ваш Google Cloud API ключ. Проверьте, что в разделе Enabled APIs & Services есть Vision AI API.'
691
+ else:
692
+ image = base64.b64encode(img).decode("utf-8")
693
+
694
+ # Тело запроса
695
+ request_body = {
696
+ "requests": [
697
+ {
698
+ "image": {
699
+ "content": image
700
+ },
701
+ "features": [
702
+ {
703
+ "type": "LABEL_DETECTION",
704
+ "maxResults": 10
705
+ }
706
+ ],
707
+ "imageContext": {
708
+ "languageHints": lang
709
+ }
710
+ }
711
+ ]
712
+ }
688
713
 
714
+ # URL
715
+ url = f"https://vision.googleapis.com/v1/images:annotate?key={self.google_key}"
716
+
717
+ # Заголовки
718
+ headers = {
719
+ "Content-Type": "application/json"
720
+ }
721
+
722
+ # Запрос
723
+ response = requests.post(url, headers=headers, json=request_body, proxies=self.proxies)
724
+ return {"code":response.status_code, 'answer':response.json()}
689
725
 
690
726
  class CodeEditor:
691
727
  """Редактор кода, написанный на Python с графическим интерфейсом и подсветкой ключевых слов при написании кода на Python.\nmaster: объект класса "Tk", встроенной библиотеки tkinter."""
@@ -877,7 +913,7 @@ import os
877
913
  from bs4 import BeautifulSoup
878
914
  import aiosmtplib
879
915
 
880
- class FunctionsObject:
916
+ class AsyncFunctionsObject:
881
917
  def __init__(self, proxies: dict = {}, html_headers: dict = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36', 'Accept-Language': 'ru-RU'}, google_api_key: str = "", gigachat_key: str = "", gigachat_id: str = "", username_mail: str = "", mail_passwd: str = "", speech_to_text_key: str = None, vk_token: str = None):
882
918
  """Initialize the FunctionsObject with configuration parameters."""
883
919
  print(f'Объект класса был успешно запущен.')
@@ -1451,4 +1487,44 @@ class FunctionsObject:
1451
1487
  return {"text": text, "post_id": post_id, "owner_id": owner_id, "link": link, 'views': views, 'reposts': reposts, 'likes': likes}
1452
1488
  except:
1453
1489
  return None
1454
- return None
1490
+ return None
1491
+ async def image_text_recognition(self, img: bytes, lang: str = 'ru'):
1492
+ """Разбор текста на изображении, с помощью инструментов Google Cloud.\nimg: ваше изображение в bytes.\nlang: язык текста на изображении."""
1493
+ import base64
1494
+ if not self.google_key:
1495
+ return 'Для работы с данной функцией необходим Ваш Google Cloud API ключ. Проверьте, что в разделе Enabled APIs & Services есть Vision AI API.'
1496
+ else:
1497
+ image = base64.b64encode(img).decode("utf-8")
1498
+
1499
+ # Тело запроса
1500
+ request_body = {
1501
+ "requests": [
1502
+ {
1503
+ "image": {
1504
+ "content": image
1505
+ },
1506
+ "features": [
1507
+ {
1508
+ "type": "LABEL_DETECTION",
1509
+ "maxResults": 10
1510
+ }
1511
+ ],
1512
+ "imageContext": {
1513
+ "languageHints": lang
1514
+ }
1515
+ }
1516
+ ]
1517
+ }
1518
+
1519
+ # URL
1520
+ url = f"https://vision.googleapis.com/v1/images:annotate?key={self.google_key}"
1521
+
1522
+ # Заголовки
1523
+ headers = {
1524
+ "Content-Type": "application/json"
1525
+ }
1526
+
1527
+ # Асинхронный запрос
1528
+ async with aiohttp.ClientSession() as session:
1529
+ async with session.post(url, json=request_body, headers=headers, proxy=self.proxies.get('https') if self.proxies else None) as response:
1530
+ return {"code": response.status, "answer": await response.json()}
@@ -0,0 +1,11 @@
1
+ Metadata-Version: 2.1
2
+ Name: florestbotfunctions
3
+ Version: 1.3.4
4
+ Summary: Функции бота Флореста в одной библиотеке.
5
+ Author: florestdev
6
+ Author-email: florestone4185@internet.ru
7
+ Project-URL: Social Resources, https://taplink.cc/florestone4185
8
+ Project-URL: My bot, https://t.me/postbotflorestbot
9
+ Requires-Python: >=3.10
10
+
11
+ Привет! Данная библиотека включает в себя функции из https://t.me/postbotflorestbot. Все функции, с удобным объяснением кода, только здесь. P.S. Это официальная библиотека от создателя бота - FlorestDev. Все функции предоставляются в ознакомительном порядке.
@@ -5,4 +5,4 @@ def get_libraries():
5
5
  file = open(pathlib.Path(sys.argv[0]).parent.resolve() / 'libraries.txt', 'r')
6
6
  return file.readlines()
7
7
 
8
- setup(name='florestbotfunctions', version='1.3.2', description='Функции бота Флореста в одной библиотеке.', long_description='Привет! Данная библиотека включает в себя функции из https://t.me/postbotflorestbot. Все функции, с удобным объяснением кода, только здесь. P.S. Это официальная библиотека от создателя бота - FlorestDev. Все функции предоставляются в ознакомительном порядке.', author='florestdev', author_email='florestone4185@internet.ru', packages=find_packages(), python_requires='>=3.8.9', project_urls={"Social Resources": 'https://taplink.cc/florestone4185', 'My bot':"https://t.me/postbotflorestbot"}, install_requires=get_libraries())
8
+ setup(name='florestbotfunctions', version='1.3.4', description='Функции бота Флореста в одной библиотеке.', long_description='Привет! Данная библиотека включает в себя функции из https://t.me/postbotflorestbot. Все функции, с удобным объяснением кода, только здесь. P.S. Это официальная библиотека от создателя бота - FlorestDev. Все функции предоставляются в ознакомительном порядке.', author='florestdev', author_email='florestone4185@internet.ru', packages=find_packages(), python_requires='>=3.10', project_urls={"Social Resources": 'https://taplink.cc/florestone4185', 'My bot':"https://t.me/postbotflorestbot"}, install_requires=get_libraries())
@@ -1,13 +0,0 @@
1
- Metadata-Version: 1.2
2
- Name: florestbotfunctions
3
- Version: 1.3.2
4
- Summary: Функции бота Флореста в одной библиотеке.
5
- Home-page: UNKNOWN
6
- Author: florestdev
7
- Author-email: florestone4185@internet.ru
8
- License: UNKNOWN
9
- Project-URL: Social Resources, https://taplink.cc/florestone4185
10
- Project-URL: My bot, https://t.me/postbotflorestbot
11
- Description: Привет! Данная библиотека включает в себя функции из https://t.me/postbotflorestbot. Все функции, с удобным объяснением кода, только здесь. P.S. Это официальная библиотека от создателя бота - FlorestDev. Все функции предоставляются в ознакомительном порядке.
12
- Platform: UNKNOWN
13
- Requires-Python: >=3.8.9
@@ -1,13 +0,0 @@
1
- Metadata-Version: 1.2
2
- Name: florestbotfunctions
3
- Version: 1.3.2
4
- Summary: Функции бота Флореста в одной библиотеке.
5
- Home-page: UNKNOWN
6
- Author: florestdev
7
- Author-email: florestone4185@internet.ru
8
- License: UNKNOWN
9
- Project-URL: Social Resources, https://taplink.cc/florestone4185
10
- Project-URL: My bot, https://t.me/postbotflorestbot
11
- Description: Привет! Данная библиотека включает в себя функции из https://t.me/postbotflorestbot. Все функции, с удобным объяснением кода, только здесь. P.S. Это официальная библиотека от создателя бота - FlorestDev. Все функции предоставляются в ознакомительном порядке.
12
- Platform: UNKNOWN
13
- Requires-Python: >=3.8.9