florestbotfunctions 1.0.0__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.
- florestbotfunctions-1.0.0/PKG-INFO +25 -0
- florestbotfunctions-1.0.0/florestbotfunctions/__init__.py +214 -0
- florestbotfunctions-1.0.0/florestbotfunctions.egg-info/PKG-INFO +25 -0
- florestbotfunctions-1.0.0/florestbotfunctions.egg-info/SOURCES.txt +8 -0
- florestbotfunctions-1.0.0/florestbotfunctions.egg-info/dependency_links.txt +1 -0
- florestbotfunctions-1.0.0/florestbotfunctions.egg-info/requires.txt +10 -0
- florestbotfunctions-1.0.0/florestbotfunctions.egg-info/top_level.txt +1 -0
- florestbotfunctions-1.0.0/setup.cfg +4 -0
- florestbotfunctions-1.0.0/setup.py +4 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: florestbotfunctions
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Функции бота Флореста в одной библиотеке.
|
|
5
|
+
Home-page: https://taplink.cc/florestone4185
|
|
6
|
+
Author: florestdev
|
|
7
|
+
Author-email: florestone4185@internet.ru
|
|
8
|
+
Project-URL: Social Resources, https://taplink.cc/florestone4185
|
|
9
|
+
Project-URL: My bot, https://t.me/postbotflorestbot
|
|
10
|
+
Requires-Python: >=3.8.9
|
|
11
|
+
Requires-Dist: MukeshAPI
|
|
12
|
+
Requires-Dist: g4f
|
|
13
|
+
Requires-Dist: curl_cffi
|
|
14
|
+
Requires-Dist: requests
|
|
15
|
+
Requires-Dist: pytubefix
|
|
16
|
+
Requires-Dist: google-api-python-client
|
|
17
|
+
Requires-Dist: bs4
|
|
18
|
+
Requires-Dist: pillow
|
|
19
|
+
Requires-Dist: gtts
|
|
20
|
+
Requires-Dist: qrcode
|
|
21
|
+
|
|
22
|
+
Привет! Данная библиотека включает в себя функции из https://t.me/postbotflorestbot.
|
|
23
|
+
Все функции, с удобным объяснением кода, только здесь.
|
|
24
|
+
P.S. Это официальная библиотека от создателя бота - FlorestDev.
|
|
25
|
+
Все функции предоставляются в ознакомительном порядке.
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""Привет!\nВ этой библиотеке Вы увидете некоторые функции [бота Флореста](https://t.me/postbotflorestbot).\nМои социальные сети: [тык](https://taplink.cc/florestone4185)"""
|
|
3
|
+
|
|
4
|
+
class FunctionsObject:
|
|
5
|
+
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 = "", ):
|
|
6
|
+
"""Привет. Именно в данном классе находятся ВСЕ функции бота. Давай я объясню смысл параметров?\nproxies: прокси, которые используются при HTTPS запросах к сайтам.\nhtml_headers: заголовки HTTPS запросов.\ngoogle_api_key: апи ключ гугла. Получить его можно [здесь](https://console.google.com/)"""
|
|
7
|
+
print(f'Объект класса был успешно запущен.')
|
|
8
|
+
self.proxies = proxies
|
|
9
|
+
self.headers = html_headers
|
|
10
|
+
self.google_key = google_api_key
|
|
11
|
+
def generate_image(self, prompt: str) -> bytes:
|
|
12
|
+
from MukeshAPI import api
|
|
13
|
+
"""Данная функция генерирует говно-картинки с помощью пиратской нейросети.\nprompt: запрос, по которому надо сгенерировать изображение."""
|
|
14
|
+
return api.ai_image(prompt)
|
|
15
|
+
def ai(self, prompt: str) -> str:
|
|
16
|
+
"""Обычный чат-гпт. Бесплатный.\nprompt: что тебе нужно от нейросетки."""
|
|
17
|
+
from g4f.client import Client
|
|
18
|
+
from g4f.Provider import Liaobots
|
|
19
|
+
|
|
20
|
+
return Client().chat.completions.create([{"role":"user", "content":prompt}], 'gpt-3.5-turbo', Liaobots).choices[0].message.content
|
|
21
|
+
def deanon(self, ip: str) -> list:
|
|
22
|
+
"""Деанончик по IP.\nВы сами принимаете на себя ответственность за использование данной функции.\nip: дай айпи, тварюка."""
|
|
23
|
+
import requests
|
|
24
|
+
r = requests.get(f'http://ip-api.com/json/{ip}?lang=ru', proxies=self.proxies, headers=self.headers).json()
|
|
25
|
+
results = []
|
|
26
|
+
for key, value in r.items():
|
|
27
|
+
results.append(f'{key.title()}: {value}')
|
|
28
|
+
return results
|
|
29
|
+
def download_video(self, url: str):
|
|
30
|
+
"""Данная функция качает видео с YouTube с помощью URL.\nurl: ссылка на видео."""
|
|
31
|
+
from pytubefix import YouTube
|
|
32
|
+
|
|
33
|
+
yt_obj = YouTube(url, proxies=self.proxies)
|
|
34
|
+
|
|
35
|
+
if yt_obj.age_restricted:
|
|
36
|
+
return 'На видео наложены возрастные ограничения.'
|
|
37
|
+
else:
|
|
38
|
+
import io
|
|
39
|
+
|
|
40
|
+
buffer = io.BytesIO()
|
|
41
|
+
|
|
42
|
+
yt_obj.streams.get_lowest_resolution().stream_to_buffer(buffer)
|
|
43
|
+
|
|
44
|
+
return buffer.getvalue()
|
|
45
|
+
def search_videos(self, query: str):
|
|
46
|
+
"""Функция для поиска видео по запросу и дальнейшего его закачивания.\nquery: запрос, по которому надо искать видео."""
|
|
47
|
+
from pytubefix import Search
|
|
48
|
+
|
|
49
|
+
search = Search(query, proxies=self.proxies)
|
|
50
|
+
videos = search.videos
|
|
51
|
+
|
|
52
|
+
if len(videos) == 0:
|
|
53
|
+
return 'Видео по запросу не существует.'
|
|
54
|
+
else:
|
|
55
|
+
video = videos[0]
|
|
56
|
+
if video.age_restricted:
|
|
57
|
+
return 'На видео, которое мы нашли первым присутствуют возрастные ограничение. Его скачивание невозможно.'
|
|
58
|
+
else:
|
|
59
|
+
import io
|
|
60
|
+
|
|
61
|
+
buffer = io.BytesIO()
|
|
62
|
+
|
|
63
|
+
video.streams.get_lowest_resolution().stream_to_buffer(buffer)
|
|
64
|
+
|
|
65
|
+
return buffer.getvalue()
|
|
66
|
+
def create_demotivator(self, top_text: str, bottom_text: str, photo: bytes, font: str):
|
|
67
|
+
"""Создайте демотиватор с помощью данной фичи!\ntop_text: верхний текст.\nbottom_text: нижний текст.\nphoto: ваша фотография в bytes.\nfont: ваш шрифт. Пример: `times.ttf`."""
|
|
68
|
+
import io
|
|
69
|
+
image = io.BytesIO(photo)
|
|
70
|
+
from PIL import Image, ImageOps, ImageDraw, ImageFont
|
|
71
|
+
img = Image.new('RGB', (1280, 1024), color='black')
|
|
72
|
+
img_border = Image.new('RGB', (1060, 720), color='#000000')
|
|
73
|
+
border = ImageOps.expand(img_border, border=2, fill='#ffffff')
|
|
74
|
+
user_img = Image.open(image).convert("RGBA").resize((1050, 710))
|
|
75
|
+
(width, height) = user_img.size
|
|
76
|
+
img.paste(border, (111, 96))
|
|
77
|
+
img.paste(user_img, (118, 103))
|
|
78
|
+
drawer = ImageDraw.Draw(img)
|
|
79
|
+
font_1 = ImageFont.truetype(font=font, size=80, encoding='UTF-8')
|
|
80
|
+
text_width = font_1.getlength(top_text)
|
|
81
|
+
|
|
82
|
+
while text_width >= (width + 250) - 20:
|
|
83
|
+
font_1 = ImageFont.truetype(font=font, size=80, encoding='UTF-8')
|
|
84
|
+
text_width = font_1.getlength(top_text)
|
|
85
|
+
top_size -= 1
|
|
86
|
+
|
|
87
|
+
font_2 = ImageFont.truetype(font=font, size=60, encoding='UTF-8')
|
|
88
|
+
text_width = font_2.getlength(bottom_text)
|
|
89
|
+
|
|
90
|
+
while text_width >= (width + 250) - 20:
|
|
91
|
+
font_2 = ImageFont.truetype(font=font, size=60, encoding='UTF-8')
|
|
92
|
+
text_width = font_2.getlength(bottom_text)
|
|
93
|
+
bottom_size -= 1
|
|
94
|
+
|
|
95
|
+
size_1 = drawer.textlength(top_text, font=font_1)
|
|
96
|
+
size_2 = drawer.textlength(bottom_text, font=font_2)
|
|
97
|
+
|
|
98
|
+
drawer.text(((1280 - size_1) / 2, 840), top_text, fill='white', font=font_1)
|
|
99
|
+
drawer.text(((1280 - size_2) / 2, 930), bottom_text, fill='white', font=font_2)
|
|
100
|
+
|
|
101
|
+
result_here = io.BytesIO()
|
|
102
|
+
|
|
103
|
+
img.save(result_here, 'JPEG')
|
|
104
|
+
|
|
105
|
+
del drawer
|
|
106
|
+
|
|
107
|
+
return result_here.getvalue()
|
|
108
|
+
def photo_make_black(self, photo: bytes):
|
|
109
|
+
"""Сделать фото черно-белым.\nphoto: фото в `bytes`."""
|
|
110
|
+
import io
|
|
111
|
+
from PIL import Image
|
|
112
|
+
your_photo = io.BytesIO(photo)
|
|
113
|
+
|
|
114
|
+
image = Image.open(your_photo)
|
|
115
|
+
new_image = image.convert('L')
|
|
116
|
+
buffer = io.BytesIO()
|
|
117
|
+
new_image.save(buffer, 'JPEG')
|
|
118
|
+
return buffer.getvalue()
|
|
119
|
+
def check_weather(self, city: str):
|
|
120
|
+
"""Проверить погоду в каком-либо городе.\ncity: город, или населенный пункт."""
|
|
121
|
+
import requests
|
|
122
|
+
from bs4 import BeautifulSoup
|
|
123
|
+
|
|
124
|
+
r = requests.get(f'https://www.google.ru/search?q=погода+в+{city}', proxies=self.proxies, headers=self.headers)
|
|
125
|
+
if r.status_code != 200:
|
|
126
|
+
return 'Ошибка. Не получилось получить доступ к Google.'
|
|
127
|
+
else:
|
|
128
|
+
try:
|
|
129
|
+
soup = BeautifulSoup(r.text, 'html.parser')
|
|
130
|
+
temperature = soup.select("#wob_tm")[0].getText()
|
|
131
|
+
title = soup.select("#wob_dc")[0].getText()
|
|
132
|
+
humidity = soup.select("#wob_hm")[0].getText()
|
|
133
|
+
time = soup.select("#wob_dts")[0].getText()
|
|
134
|
+
wind = soup.select("#wob_ws")[0].getText()
|
|
135
|
+
veroyatnost = soup.select("#wob_pp")[0].getText()
|
|
136
|
+
return {"temp":temperature, "opisanie":title, 'humidity':humidity, 'time':time, 'wind':wind, 'veroyatnost':veroyatnost}
|
|
137
|
+
except:
|
|
138
|
+
return "Не был найден населенный пункт."
|
|
139
|
+
def create_qr(self, content: str):
|
|
140
|
+
"""Создать QR код.\ncontent: что будет нести в себе qr. ссылка, текст..."""
|
|
141
|
+
import qrcode
|
|
142
|
+
import io
|
|
143
|
+
|
|
144
|
+
buffer = io.BytesIO()
|
|
145
|
+
qr = qrcode.make(content)
|
|
146
|
+
qr.save(buffer, scale=10)
|
|
147
|
+
return buffer.getvalue()
|
|
148
|
+
def get_charts(self):
|
|
149
|
+
"""Узнать чарты Я.Музыки."""
|
|
150
|
+
import requests
|
|
151
|
+
headers = {
|
|
152
|
+
'Accept': 'application/json, text/javascript, */*; q=0.01',
|
|
153
|
+
'Accept-Language': 'ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7,fi;q=0.6,nb;q=0.5,is;q=0.4,pt;q=0.3,ro;q=0.2,it;q=0.1,de;q=0.1',
|
|
154
|
+
'Connection': 'keep-alive',
|
|
155
|
+
'Referer': 'https://music.yandex.ru/chart',
|
|
156
|
+
'Sec-Fetch-Dest': 'empty',
|
|
157
|
+
'Sec-Fetch-Mode': 'cors',
|
|
158
|
+
'Sec-Fetch-Site': 'same-origin',
|
|
159
|
+
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36',
|
|
160
|
+
'X-Current-UID': '403036463',
|
|
161
|
+
'X-Requested-With': 'XMLHttpRequest',
|
|
162
|
+
'X-Retpath-Y': 'https://music.yandex.ru/chart',
|
|
163
|
+
'sec-ch-ua': '"Not?A_Brand";v="8", "Chromium";v="108", "Google Chrome";v="108"',
|
|
164
|
+
'sec-ch-ua-mobile': '?0',
|
|
165
|
+
'sec-ch-ua-platform': '"Linux"',
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
params = {
|
|
169
|
+
'what': 'chart',
|
|
170
|
+
'lang': 'ru',
|
|
171
|
+
'external-domain': 'music.yandex.ru',
|
|
172
|
+
'overembed': 'false',
|
|
173
|
+
'ncrnd': '0.23800355071570123',
|
|
174
|
+
}
|
|
175
|
+
result = []
|
|
176
|
+
response = requests.get('https://music.yandex.ru/handlers/main.jsx', params=params, headers=headers, proxies=self.proxies)
|
|
177
|
+
chart = response.json()['chartPositions']
|
|
178
|
+
for track in chart[:10]:
|
|
179
|
+
position = track['track']['chart']['position']
|
|
180
|
+
title = track['track']['title']
|
|
181
|
+
author = track['track']['artists'][0]['name']
|
|
182
|
+
result.append(f"№{position}: {author} - {title}")
|
|
183
|
+
return f'Чарты Яндекс Музыки на данный момент🔥\n🥇{result[0]}\n🥈{result[1]}\n🥉{result[2]}\n{result[3]}\n{result[4]}\n{result[5]}\n{result[6]}\n{result[7]}\n{result[8]}\n{result[9]}'
|
|
184
|
+
def generate_password(self, symbols: int = 15):
|
|
185
|
+
"""Сгенерировать пароль.\nsymbols: количество символов в пароле."""
|
|
186
|
+
import string
|
|
187
|
+
import random
|
|
188
|
+
|
|
189
|
+
symbols_ascii = list(string.ascii_letters + string.digits)
|
|
190
|
+
|
|
191
|
+
random.shuffle(symbols_ascii)
|
|
192
|
+
|
|
193
|
+
return ''.join(symbols_ascii[:symbols])
|
|
194
|
+
def text_to_speech(self, text: str, lang: str = 'ru'):
|
|
195
|
+
"""Из текста в речь на Python.\ntext: текст для озвучки.\nlang: язык для озвучки. По умолчанию, **русский**."""
|
|
196
|
+
import gtts
|
|
197
|
+
import io
|
|
198
|
+
|
|
199
|
+
buffer = io.BytesIO()
|
|
200
|
+
engine = gtts.gTTS(text, lang=lang)
|
|
201
|
+
engine.write_to_fp(buffer)
|
|
202
|
+
return buffer.getvalue()
|
|
203
|
+
def information_about_yt_channel(self, url: str):
|
|
204
|
+
"""Узнать информацию о YouTube канале на Python.\nurl: ссылка на канал."""
|
|
205
|
+
if not self.google_key:
|
|
206
|
+
return 'Для использования данной функции нужно указать параметр `google_key` в конструктор класса.'
|
|
207
|
+
else:
|
|
208
|
+
from googleapiclient.discovery import build
|
|
209
|
+
from pytubefix import Channel
|
|
210
|
+
channel = Channel(url, proxies=self.proxies).channel_id
|
|
211
|
+
youtube = build('youtube', 'v3', developerKey=self.google_key)
|
|
212
|
+
request = youtube.channels().list(part='snippet,statistics', id=channel.channel_id)
|
|
213
|
+
response = request.execute()
|
|
214
|
+
return {"url_of_ava":response["items"][0]["snippet"]["thumbnails"]["high"]["url"], "channel_name":response["items"][0]["snippet"]["title"], 'channel_nickname':response["items"][0]["snippet"]["customUrl"], 'country':response["items"][0]["snippet"]["country"], 'total_views':response["items"][0]["statistics"]["viewCount"], 'total_subs':response["items"][0]["statistics"]["subscriberCount"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: florestbotfunctions
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Функции бота Флореста в одной библиотеке.
|
|
5
|
+
Home-page: https://taplink.cc/florestone4185
|
|
6
|
+
Author: florestdev
|
|
7
|
+
Author-email: florestone4185@internet.ru
|
|
8
|
+
Project-URL: Social Resources, https://taplink.cc/florestone4185
|
|
9
|
+
Project-URL: My bot, https://t.me/postbotflorestbot
|
|
10
|
+
Requires-Python: >=3.8.9
|
|
11
|
+
Requires-Dist: MukeshAPI
|
|
12
|
+
Requires-Dist: g4f
|
|
13
|
+
Requires-Dist: curl_cffi
|
|
14
|
+
Requires-Dist: requests
|
|
15
|
+
Requires-Dist: pytubefix
|
|
16
|
+
Requires-Dist: google-api-python-client
|
|
17
|
+
Requires-Dist: bs4
|
|
18
|
+
Requires-Dist: pillow
|
|
19
|
+
Requires-Dist: gtts
|
|
20
|
+
Requires-Dist: qrcode
|
|
21
|
+
|
|
22
|
+
Привет! Данная библиотека включает в себя функции из https://t.me/postbotflorestbot.
|
|
23
|
+
Все функции, с удобным объяснением кода, только здесь.
|
|
24
|
+
P.S. Это официальная библиотека от создателя бота - FlorestDev.
|
|
25
|
+
Все функции предоставляются в ознакомительном порядке.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
setup.cfg
|
|
2
|
+
setup.py
|
|
3
|
+
florestbotfunctions/__init__.py
|
|
4
|
+
florestbotfunctions.egg-info/PKG-INFO
|
|
5
|
+
florestbotfunctions.egg-info/SOURCES.txt
|
|
6
|
+
florestbotfunctions.egg-info/dependency_links.txt
|
|
7
|
+
florestbotfunctions.egg-info/requires.txt
|
|
8
|
+
florestbotfunctions.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
florestbotfunctions
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from setuptools import setup
|
|
3
|
+
|
|
4
|
+
setup(name='florestbotfunctions', version='1.0.0', description=f'Функции бота Флореста в одной библиотеке.', long_description=f'Привет! Данная библиотека включает в себя функции из https://t.me/postbotflorestbot.\nВсе функции, с удобным объяснением кода, только здесь.\nP.S. Это официальная библиотека от создателя бота - FlorestDev.\nВсе функции предоставляются в ознакомительном порядке.', author='florestdev', author_email='florestone4185@internet.ru', url='https://taplink.cc/florestone4185', packages=['florestbotfunctions'], install_requires=['MukeshAPI', 'g4f', 'curl_cffi', 'requests', 'pytubefix', 'google-api-python-client', 'bs4', 'pillow', 'gtts', 'qrcode'], project_urls={"Social Resources":"https://taplink.cc/florestone4185", "My bot":"https://t.me/postbotflorestbot"}, python_requires='>=3.8.9')
|