update project and add ruff
This commit is contained in:
@@ -3,5 +3,7 @@ LABEL authors="dmitrium12"
|
|||||||
|
|
||||||
WORKDIR /audio_resive
|
WORKDIR /audio_resive
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
RUN pip3 install -U pip
|
||||||
RUN pip3 install -r requirements.txt
|
RUN pip3 install -r requirements.txt
|
||||||
RUN pip3 install -U openai-whisper
|
RUN pip3 install -U openai-whisper
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
import time
|
|
||||||
|
|
||||||
from aiogram.utils import executor
|
|
||||||
from aiogram import Bot, Dispatcher, types
|
|
||||||
import json
|
|
||||||
|
|
||||||
bot = Bot(token="6263890573:AAEuIolwpXIsVjMyapvwb_-QTO69uEUspQk") # создаю объект бота
|
|
||||||
dp = Dispatcher(bot) # создаю объект слушателя
|
|
||||||
|
|
||||||
|
|
||||||
@dp.message_handler(commands=['add']) # обрабатываю команду add
|
|
||||||
async def start(message: types.Message):
|
|
||||||
a = message.text.split()
|
|
||||||
d = {"event": a[1], "time": a[2]}
|
|
||||||
with open('событие.json', 'w') as file:
|
|
||||||
json.dump(d, file)
|
|
||||||
await bot.send_message(message.chat.id, f'Привет! Я добавил {message.text}!') # отправляю ответное сообщение
|
|
||||||
|
|
||||||
|
|
||||||
@dp.message_handler(commands=['event']) # обрабатываю команду event
|
|
||||||
async def start(message: types.Message):
|
|
||||||
with open('событие.json') as file:
|
|
||||||
data = json.load(file)
|
|
||||||
for key, value in data.items():
|
|
||||||
if type(value) == list:
|
|
||||||
print(f'{key}: {", ".join(value)}')
|
|
||||||
else:
|
|
||||||
print(f'{key}: {value}')
|
|
||||||
|
|
||||||
await bot.send_message(message.chat.id, f'Привет! Я написал в консоли список дел') # отправляю ответное сообщение
|
|
||||||
|
|
||||||
|
|
||||||
executor.start_polling(dp, skip_updates=True) # запускаю pooling без пропуска пропущенных сообщений
|
|
||||||
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
+1
@@ -21,6 +21,7 @@ class Converter:
|
|||||||
try:
|
try:
|
||||||
r = requests.get("http://192.168.0.108:5000/ping")
|
r = requests.get("http://192.168.0.108:5000/ping")
|
||||||
if r.status_code == 200:
|
if r.status_code == 200:
|
||||||
|
print(self.path_to_file)
|
||||||
response = requests.post(
|
response = requests.post(
|
||||||
"http://192.168.0.108:5000/decrypt_audio",
|
"http://192.168.0.108:5000/decrypt_audio",
|
||||||
files={"file": open(self.path_to_file, "rb").read()},
|
files={"file": open(self.path_to_file, "rb").read()},
|
||||||
|
|||||||
Executable → Regular
Executable → Regular
Executable → Regular
+1
-1
@@ -28,7 +28,7 @@ async def get_audio_messages_func(message: types.Message, logger, bot, model) ->
|
|||||||
file_id = message.audio.file_id
|
file_id = message.audio.file_id
|
||||||
else:
|
else:
|
||||||
file_id = message.video_note.file_id
|
file_id = message.video_note.file_id
|
||||||
file_name = "config/" + str(message.message_id) + '.wav' # создаю file_name
|
file_name = "config/" + str(message.message_id) + '.ogg' # создаю file_name
|
||||||
# достаю имя человека
|
# достаю имя человека
|
||||||
if message.chat.first_name:
|
if message.chat.first_name:
|
||||||
name = message.chat.first_name
|
name = message.chat.first_name
|
||||||
|
|||||||
Executable → Regular
Executable → Regular
+9
-4
@@ -6,11 +6,11 @@ import openai
|
|||||||
|
|
||||||
async def get_response_to_openai(message: types.Message, bot):
|
async def get_response_to_openai(message: types.Message, bot):
|
||||||
if message.from_user.id in json.load(open("not_work_user.json"))["chat_gpt"]:
|
if message.from_user.id in json.load(open("not_work_user.json"))["chat_gpt"]:
|
||||||
await bot.send_message(message.chat.id, "тебе сюда нельзя")
|
await bot.send_message(message.chat.id, "ПИШЁВ ТИ НАХУЙ")
|
||||||
return
|
return
|
||||||
conn = sqlite3.connect('db.sql')
|
conn = sqlite3.connect('db.sql')
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
openai.api_key = "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"
|
openai.api_key = "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"
|
||||||
try:
|
try:
|
||||||
points = cur.execute("SELECT * FROM 'f'".replace("f", str(message.from_user.id))).fetchall()
|
points = cur.execute("SELECT * FROM 'f'".replace("f", str(message.from_user.id))).fetchall()
|
||||||
message_send = []
|
message_send = []
|
||||||
@@ -20,6 +20,7 @@ async def get_response_to_openai(message: types.Message, bot):
|
|||||||
except sqlite3.OperationalError:
|
except sqlite3.OperationalError:
|
||||||
message_send = [{"role": "user", "content": ' '.join(message.text.split()[1:])}]
|
message_send = [{"role": "user", "content": ' '.join(message.text.split()[1:])}]
|
||||||
try:
|
try:
|
||||||
|
await bot.send_message(message.chat.id, "Внимание!!!!\nБот начинает разделение, через 2 дней этот бот перестанет принимать запросы для ChatGPT, вам стоит начать переходит на этого бота: @db_ChatGPT_bot. Бот уже работает.")
|
||||||
response = openai.ChatCompletion.create(
|
response = openai.ChatCompletion.create(
|
||||||
model="gpt-3.5-turbo",
|
model="gpt-3.5-turbo",
|
||||||
messages=message_send,
|
messages=message_send,
|
||||||
@@ -29,8 +30,12 @@ async def get_response_to_openai(message: types.Message, bot):
|
|||||||
frequency_penalty=0.5,
|
frequency_penalty=0.5,
|
||||||
presence_penalty=0.0
|
presence_penalty=0.0
|
||||||
)
|
)
|
||||||
await bot.send_message(message.chat.id, f"ChatGPT\n{response['choices'][0]['message']['content']}",
|
try:
|
||||||
parse_mode="Markdown", reply_to_message_id=message.message_id)
|
await bot.send_message(message.chat.id, f"ChatGPT\n{response['choices'][0]['message']['content']}",
|
||||||
|
parse_mode="Markdown", reply_to_message_id=message.message_id)
|
||||||
|
except Exception as e:
|
||||||
|
await bot.send_message(message.chat.id, f"ChatGPT\n{response['choices'][0]['message']['content']}",
|
||||||
|
parse_mode=None, reply_to_message_id=message.message_id)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
conn = sqlite3.connect('db.sql')
|
conn = sqlite3.connect('db.sql')
|
||||||
|
|||||||
Executable → Regular
+1
@@ -24,3 +24,4 @@ async def start_stat(message: types.Message):
|
|||||||
ChatGPT ботом воспользовались {data["static"]["chatGPT"]} раз
|
ChatGPT ботом воспользовались {data["static"]["chatGPT"]} раз
|
||||||
"""
|
"""
|
||||||
await message.reply(send_message)
|
await message.reply(send_message)
|
||||||
|
|
||||||
|
|||||||
Executable → Regular
@@ -1,11 +1,7 @@
|
|||||||
import multiprocessing
|
|
||||||
from modules.Bot import start_work_bot
|
from modules.Bot import start_work_bot
|
||||||
from modules.Site import Site
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
process1 = multiprocessing.Process(target=Site)
|
|
||||||
process1.start()
|
|
||||||
start_work_bot()
|
start_work_bot()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+10
-6
@@ -1,17 +1,16 @@
|
|||||||
import json
|
|
||||||
|
|
||||||
from aiogram.utils import executor
|
from aiogram.utils import executor
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
from aiogram import Bot, Dispatcher, types
|
from aiogram import Bot, Dispatcher, types
|
||||||
from functions import get_audio_messages_func, file_data, start_stat
|
from functions import get_audio_messages_func, file_data, start_stat
|
||||||
import asyncio
|
import asyncio
|
||||||
import whisper
|
import whisper
|
||||||
|
import json
|
||||||
|
|
||||||
bot = Bot(token="5941118321:AAG0g0keLrlnuH_9U9X6ehpFFAdOX38qeXI") # создаю объект бота
|
bot = Bot(token="5941118321:AAG0g0keLrlnuH_9U9X6ehpFFAdOX38qeXI") # создаю объект бота
|
||||||
dp = Dispatcher(bot) # создаю объект слушателя
|
dp = Dispatcher(bot) # создаю объект слушателя
|
||||||
logger.remove() # удаляю стандартный логер
|
logger.remove() # удаляю стандартный логер
|
||||||
logger.add("static/logs/logging_log.log", level="INFO") # создаю логер
|
logger.add("static/logs/logging_log.log", level="INFO") # создаю логер
|
||||||
model = whisper.load_model("tiny", device='cpu')
|
model = whisper.load_model("small")
|
||||||
lock = asyncio.Lock()
|
lock = asyncio.Lock()
|
||||||
|
|
||||||
|
|
||||||
@@ -44,9 +43,12 @@ async def start(message: types.Message):
|
|||||||
name = message.chat.title
|
name = message.chat.title
|
||||||
logger.info(f"Группа {name} (ID: {message.chat.id}) запустил бота") # записываю в логи
|
logger.info(f"Группа {name} (ID: {message.chat.id}) запустил бота") # записываю в логи
|
||||||
await start_stat.start_stat(message)
|
await start_stat.start_stat(message)
|
||||||
|
await bot.send_message(message.chat.id,
|
||||||
|
'Привет! Отправляй голосовое, я расшифрую!') # отправляю ответное сообщение
|
||||||
|
|
||||||
|
|
||||||
@dp.message_handler(content_types=['voice', 'video_note', 'video', 'audio', 'document']) # обрабатываю голосовые сообщения, кружки, видео
|
@dp.message_handler(content_types=['voice', 'video_note', 'video', 'audio',
|
||||||
|
'document']) # обрабатываю голосовые сообщения, кружки, видео
|
||||||
async def get_audio_messages(message: types.Message):
|
async def get_audio_messages(message: types.Message):
|
||||||
file_data.save_data('audio_resive')
|
file_data.save_data('audio_resive')
|
||||||
if message.chat.type == 'group' or message.chat.type == "supergroup":
|
if message.chat.type == 'group' or message.chat.type == "supergroup":
|
||||||
@@ -55,9 +57,11 @@ async def get_audio_messages(message: types.Message):
|
|||||||
else:
|
else:
|
||||||
file_data.save_data('audio', message.from_user.id)
|
file_data.save_data('audio', message.from_user.id)
|
||||||
async with lock:
|
async with lock:
|
||||||
await get_audio_messages_func.get_audio_messages_func(message, logger, bot, model) # вызываю функцию
|
await get_audio_messages_func.get_audio_messages_func(message, logger, bot,
|
||||||
|
model) # вызываю функцию
|
||||||
|
|
||||||
|
|
||||||
def start_work_bot(): # функция запуска бота
|
def start_work_bot(): # функция запуска бота
|
||||||
logger.info("Бот запустился") # записываю логи
|
logger.info("Бот запустился") # записываю логи
|
||||||
executor.start_polling(dp, skip_updates=False) # запускаю pooling без пропуска пропущенных сообщений
|
executor.start_polling(dp,
|
||||||
|
skip_updates=False) # запускаю pooling без пропуска пропущенных сообщений
|
||||||
|
|||||||
Executable → Regular
+1
-2
@@ -4,7 +4,6 @@ from functions.admin.models import database
|
|||||||
from functions.admin.templates import logins, refresh, logs, log
|
from functions.admin.templates import logins, refresh, logs, log
|
||||||
import uvicorn
|
import uvicorn
|
||||||
|
|
||||||
|
|
||||||
def Site():
|
def Site():
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
templates = templating.Jinja2Templates(directory="static/templates")
|
templates = templating.Jinja2Templates(directory="static/templates")
|
||||||
@@ -34,4 +33,4 @@ def Site():
|
|||||||
async def log_response(request: Request, log_id: int, logged_in: bool = Depends(is_logged_in.is_logged_in)):
|
async def log_response(request: Request, log_id: int, logged_in: bool = Depends(is_logged_in.is_logged_in)):
|
||||||
return await log.log(templates, request, log_id, logged_in)
|
return await log.log(templates, request, log_id, logged_in)
|
||||||
|
|
||||||
uvicorn.run(app)
|
uvicorn.run(app, host="0.0.0.0")
|
||||||
|
|||||||
Executable → Regular
@@ -22,3 +22,20 @@ python-multipart = "^0.0.6"
|
|||||||
[build-system]
|
[build-system]
|
||||||
requires = ["poetry-core"]
|
requires = ["poetry-core"]
|
||||||
build-backend = "poetry.core.masonry.api"
|
build-backend = "poetry.core.masonry.api"
|
||||||
|
|
||||||
|
[tool.ruff]
|
||||||
|
exclude = [
|
||||||
|
".git",
|
||||||
|
".ruff_cache",
|
||||||
|
".venv",
|
||||||
|
"venv",
|
||||||
|
"mongodb",
|
||||||
|
"data",
|
||||||
|
]
|
||||||
|
line-length = 92
|
||||||
|
|
||||||
|
[tool.ruff.lint]
|
||||||
|
select = ["E", "F", "UP", "I"]
|
||||||
|
|
||||||
|
[tool.ruff.format]
|
||||||
|
skip-magic-trailing-comma = true
|
||||||
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
|
Before Width: | Height: | Size: 176 KiB After Width: | Height: | Size: 176 KiB |
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
+114
-5
@@ -44,7 +44,68 @@
|
|||||||
1953616385,
|
1953616385,
|
||||||
5807099397,
|
5807099397,
|
||||||
5096361806,
|
5096361806,
|
||||||
6611897980
|
6611897980,
|
||||||
|
6041332424,
|
||||||
|
1464361640,
|
||||||
|
5961893700,
|
||||||
|
1816362641,
|
||||||
|
2130108799,
|
||||||
|
1225252302,
|
||||||
|
1465900925,
|
||||||
|
5633028685,
|
||||||
|
1349989903,
|
||||||
|
822965653,
|
||||||
|
1443926406,
|
||||||
|
6802413683,
|
||||||
|
6087817793,
|
||||||
|
5860791432,
|
||||||
|
6342799642,
|
||||||
|
6728247202,
|
||||||
|
6393225021,
|
||||||
|
5985444396,
|
||||||
|
6895867788,
|
||||||
|
645196730,
|
||||||
|
5344057269,
|
||||||
|
766871471,
|
||||||
|
5147790662,
|
||||||
|
2136441528,
|
||||||
|
5057371034,
|
||||||
|
878826348,
|
||||||
|
6655277379,
|
||||||
|
6592290797,
|
||||||
|
1814591139,
|
||||||
|
5827290368,
|
||||||
|
5606109891,
|
||||||
|
6826451367,
|
||||||
|
6668614811,
|
||||||
|
6526015809,
|
||||||
|
1189826010,
|
||||||
|
5631787890,
|
||||||
|
1158224414,
|
||||||
|
1633487785,
|
||||||
|
6201987038,
|
||||||
|
5330876339,
|
||||||
|
1778069336,
|
||||||
|
6775816177,
|
||||||
|
5679790345,
|
||||||
|
6702913582,
|
||||||
|
7053885713,
|
||||||
|
5560304418,
|
||||||
|
171317696,
|
||||||
|
6821078288,
|
||||||
|
7022254678,
|
||||||
|
6814594262,
|
||||||
|
6594600678,
|
||||||
|
6277417240,
|
||||||
|
6602397336,
|
||||||
|
7099869885,
|
||||||
|
6125575132,
|
||||||
|
864088273,
|
||||||
|
5906540432,
|
||||||
|
5221310958,
|
||||||
|
1008041257,
|
||||||
|
1838963575,
|
||||||
|
2135981804
|
||||||
],
|
],
|
||||||
"r": [
|
"r": [
|
||||||
620318992,
|
620318992,
|
||||||
@@ -77,7 +138,23 @@
|
|||||||
-1001961013350,
|
-1001961013350,
|
||||||
-4035262483,
|
-4035262483,
|
||||||
-1001727326919,
|
-1001727326919,
|
||||||
-4070895995
|
-4070895995,
|
||||||
|
-1001952971935,
|
||||||
|
-1002091102825,
|
||||||
|
-1002029281036,
|
||||||
|
-1002022154130,
|
||||||
|
-4043763843,
|
||||||
|
-1001907255247,
|
||||||
|
-4118954007,
|
||||||
|
-1002145297922,
|
||||||
|
-4150758493,
|
||||||
|
-4198487540,
|
||||||
|
-4150159765,
|
||||||
|
-1001976333154,
|
||||||
|
-4153309955,
|
||||||
|
-4109298156,
|
||||||
|
-1002030718202,
|
||||||
|
-1002098872159
|
||||||
],
|
],
|
||||||
"audio": [
|
"audio": [
|
||||||
1144937686,
|
1144937686,
|
||||||
@@ -136,10 +213,42 @@
|
|||||||
1145526981,
|
1145526981,
|
||||||
1817488391,
|
1817488391,
|
||||||
822965653,
|
822965653,
|
||||||
1443926406
|
1443926406,
|
||||||
|
5598150726,
|
||||||
|
1283051331,
|
||||||
|
6544399001,
|
||||||
|
5489712116,
|
||||||
|
2014702734,
|
||||||
|
6135829903,
|
||||||
|
1465900925,
|
||||||
|
6196975192,
|
||||||
|
5633028685,
|
||||||
|
6224884213,
|
||||||
|
1395461390,
|
||||||
|
1158224414,
|
||||||
|
2104591954,
|
||||||
|
6342799642,
|
||||||
|
1989941888,
|
||||||
|
766871471,
|
||||||
|
2136441528,
|
||||||
|
997043812,
|
||||||
|
1189826010,
|
||||||
|
5977795561,
|
||||||
|
341018245,
|
||||||
|
6268616798,
|
||||||
|
931111437,
|
||||||
|
1633487785,
|
||||||
|
1710727026,
|
||||||
|
5249469469,
|
||||||
|
1778069336,
|
||||||
|
1797852290,
|
||||||
|
1012664615,
|
||||||
|
1087968824,
|
||||||
|
5261371986,
|
||||||
|
5906540432
|
||||||
],
|
],
|
||||||
"static": {
|
"static": {
|
||||||
"audio_resive": 1191,
|
"audio_resive": 6011,
|
||||||
"chatGPT": 1303
|
"chatGPT": 5759
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user