Fix bot and back problems
This commit is contained in:
parent
8bfd46988f
commit
ff9c8c76b4
|
@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/4.2/ref/settings/
|
|||
"""
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
|
@ -26,8 +27,13 @@ DEBUG = int(os.getenv('DEBUG', 0))
|
|||
PROD = 1 - DEBUG
|
||||
|
||||
ALLOWED_HOSTS = ['backend', '127.0.0.1']
|
||||
CSRF_TRUSTED_ORIGINS = []
|
||||
if app_url := os.getenv('APP_URL', None):
|
||||
ALLOWED_HOSTS.append(app_url)
|
||||
CSRF_TRUSTED_ORIGINS.append(app_url)
|
||||
url_re = re.compile(r"https?://(www\.)?")
|
||||
app_url_strippped = url_re.sub('', app_url).strip().strip('/')
|
||||
ALLOWED_HOSTS.append(app_url_strippped)
|
||||
|
||||
|
||||
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
||||
USE_X_FORWARDED_HOST = True
|
||||
|
|
|
@ -9,7 +9,7 @@ def deliver_setting(setting_name):
|
|||
setting = Setting.objects.get(name=setting_name)
|
||||
rabbitmq_conf = settings.RABBITMQ
|
||||
dsn = f'{rabbitmq_conf["PROTOCOL"]}://{rabbitmq_conf["USER"]}:{rabbitmq_conf["PASSWORD"]}@{rabbitmq_conf["HOST"]}:{rabbitmq_conf["PORT"]}/'
|
||||
queue = Queue(settings.SETTINGS_QUEUE_NAME, exchange='', routing_key=settings.SETTINGS_QUEUE_NAME)
|
||||
queue = Queue(settings.SETTINGS_QUEUE_NAME, exchange='', routing_key=settings.SETTINGS_QUEUE_NAME, durable=True)
|
||||
with Connection(dsn) as conn:
|
||||
with conn.channel() as channel:
|
||||
producer = Producer(channel)
|
||||
|
@ -17,6 +17,6 @@ def deliver_setting(setting_name):
|
|||
{setting.name: setting.value['value']},
|
||||
exchange='',
|
||||
routing_key=settings.SETTINGS_QUEUE_NAME,
|
||||
declare=[queue]
|
||||
declare=[queue],
|
||||
)
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ from typing import Callable
|
|||
SETTING_QUEUE_NAME = "settings"
|
||||
|
||||
async def consume_setting_updates(set_setting_func: Callable[[str, decimal.Decimal], None], chan: aio_pika.abc.AbstractChannel):
|
||||
queue = await chan.declare_queue(SETTING_QUEUE_NAME)
|
||||
queue = await chan.declare_queue(SETTING_QUEUE_NAME, durable=True)
|
||||
|
||||
async with queue.iterator() as queue_iter:
|
||||
async for msg in queue_iter:
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
from aiogram import Bot, Dispatcher, Router, types
|
||||
from aiogram.fsm.storage.memory import MemoryStorage
|
||||
from create_bot import bot, WEBHOOK_URL
|
||||
import logging
|
||||
from aiogram import Bot, types
|
||||
from aiogram.dispatcher import Dispatcher
|
||||
from create_bot import bot, token, WEBHOOK_URL
|
||||
from handlers.register_handlers import register_all_handlers
|
||||
from aiogram.contrib.fsm_storage.memory import MemoryStorage
|
||||
from loguru import logger
|
||||
|
||||
dp = Dispatcher(storage=MemoryStorage())
|
||||
dp = Dispatcher(bot, storage=MemoryStorage())
|
||||
|
||||
logger.add("logs.log", format = "{time} | {module} : {function} | {level} | {message}", level = "INFO", rotation = "1 week", compression = "zip")#, serialize = True)
|
||||
|
||||
|
@ -17,9 +19,7 @@ async def on_startup():
|
|||
drop_pending_updates=True
|
||||
)
|
||||
|
||||
router = Router()
|
||||
register_all_handlers(router)
|
||||
dp.include_router(router)
|
||||
register_all_handlers(dp)
|
||||
|
||||
|
||||
async def on_shutdown():
|
||||
|
|
|
@ -21,4 +21,4 @@ bot = Bot(token=token)
|
|||
|
||||
important_message = {}
|
||||
|
||||
event_number = {}
|
||||
event_number = {}
|
|
@ -1,71 +1,33 @@
|
|||
from aiogram import types
|
||||
from keyboards import kb_main
|
||||
from aiogram import Bot, Dispatcher
|
||||
import re
|
||||
import json
|
||||
from aiogram.dispatcher import FSMContext
|
||||
from aiogram.dispatcher.filters.state import State, StatesGroup
|
||||
from create_bot import bot, important_message, event_number
|
||||
from aiogram.types import ReplyKeyboardMarkup, KeyboardButton, ReplyKeyboardRemove, InlineKeyboardMarkup, InlineKeyboardButton
|
||||
from aiogram.utils.exceptions import MessageToDeleteNotFound
|
||||
from memcached_def import add_rec, get_rec
|
||||
from aiogram.types import ReplyKeyboardMarkup, KeyboardButton, ReplyKeyboardRemove, InlineKeyboardMarkup, InlineKeyboardButton, FSInputFile
|
||||
|
||||
from loguru import logger
|
||||
|
||||
def get_event_keyboard(number):
|
||||
kb = []
|
||||
dlina = 5
|
||||
button1 = InlineKeyboardButton(text='←', callback_data="num_decr")
|
||||
button2 = InlineKeyboardButton(text=f'{number + 1}/{dlina}', callback_data="element")
|
||||
button3 = InlineKeyboardButton(text='→', callback_data="num_incr")
|
||||
button4 = InlineKeyboardButton(text='Главное меню', callback_data='main_menu_delete')
|
||||
keyboard = InlineKeyboardMarkup()
|
||||
button3 = InlineKeyboardButton('←', callback_data="num_decr")
|
||||
button4 = InlineKeyboardButton(f'{number + 1}/{dlina}', callback_data="element")
|
||||
button5 = InlineKeyboardButton('→', callback_data="num_incr")
|
||||
button6 = InlineKeyboardButton('Главное меню', callback_data='main_menu_delete')
|
||||
if int(number + 1) == 1:
|
||||
kb = [[button2, button3]]
|
||||
keyboard.add(button4, button5)
|
||||
elif int(number + 1) == dlina:
|
||||
kb = [[button1, button2]]
|
||||
keyboard.add(button3, button4)
|
||||
else:
|
||||
kb = [[button1, button2, button3]]
|
||||
kb.append([button4])
|
||||
keyboard = InlineKeyboardMarkup(inline_keyboard=kb)
|
||||
keyboard.add(button3, button4, button5)
|
||||
keyboard.add(button6)
|
||||
return keyboard
|
||||
|
||||
def read_data_from_file(file_path):
|
||||
try:
|
||||
with open(file_path, 'r') as file:
|
||||
data_lines = file.readlines()
|
||||
|
||||
data_dict = {}
|
||||
for line in data_lines:
|
||||
key, value = line.strip().split(": ")
|
||||
data_dict[key.strip()] = value.strip()
|
||||
|
||||
return data_dict
|
||||
except FileNotFoundError:
|
||||
print("File not found.")
|
||||
return None
|
||||
except Exception as e:
|
||||
print("An error occurred:", e)
|
||||
return None
|
||||
|
||||
def update_file(file_path, data_dict):
|
||||
try:
|
||||
with open(file_path, 'r') as file:
|
||||
existing_data = file.readlines()
|
||||
|
||||
with open(file_path, 'w') as file:
|
||||
for line in existing_data:
|
||||
key = line.split(":")[0].strip()
|
||||
if key in data_dict:
|
||||
file.write(f"{key}: {data_dict[key]}\n")
|
||||
else:
|
||||
file.write(line)
|
||||
|
||||
for key, value in data_dict.items():
|
||||
if key not in existing_data:
|
||||
file.write(f"{key}: {value}\n")
|
||||
|
||||
# print("File updated successfully.")
|
||||
except Exception as e:
|
||||
print("An error occurred:", e)
|
||||
|
||||
# Example usage:
|
||||
file_path = "data.txt"
|
||||
|
||||
|
||||
ins_list = ['1.png',
|
||||
|
@ -75,16 +37,13 @@ ins_list = ['1.png',
|
|||
'5.png']
|
||||
|
||||
async def instruction_message(call: types.CallbackQuery):
|
||||
logger.info(f"{call.from_user.id} - @{call.from_user.username} : инструкция")
|
||||
|
||||
add_rec(call.from_user.id, 0)
|
||||
|
||||
await call.message.delete()
|
||||
await bot.send_photo(call.from_user.id, FSInputFile('pictures/1.png', 'rb'), reply_markup=get_event_keyboard(0))
|
||||
# await call.message.delete()
|
||||
await bot.send_photo(call.from_user.id, open('pictures/1.png', 'rb'), reply_markup=get_event_keyboard(0), parse_mode=types.ParseMode.MARKDOWN)
|
||||
|
||||
async def update_instruction(message: types.Message, new_value: int):
|
||||
photo = FSInputFile(f'pictures/{new_value + 1}.png')
|
||||
await message.edit_media(types.InputMediaPhoto(media=photo), reply_markup=get_event_keyboard(new_value))
|
||||
# print(ins_list[event_number.get(message.from_user.id, 0)])
|
||||
await message.edit_media(types.InputMediaPhoto(open(f'pictures/{new_value + 1}.png', 'rb'), parse_mode=types.ParseMode.MARKDOWN), reply_markup=get_event_keyboard(new_value))
|
||||
|
||||
async def callbacks_instruction(callback: types.CallbackQuery):
|
||||
user_value = int(get_rec(callback.from_user.id))
|
||||
|
@ -98,6 +57,5 @@ async def callbacks_instruction(callback: types.CallbackQuery):
|
|||
if user_value - 1 >= 0:
|
||||
add_rec(callback.from_user.id, user_value - 1)
|
||||
await update_instruction(callback.message, user_value - 1)
|
||||
#print("-1")
|
||||
|
||||
await callback.answer()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from aiogram import Router
|
||||
from aiogram.filters import Command
|
||||
from aiogram import F
|
||||
from aiogram import Dispatcher, types
|
||||
from aiogram.dispatcher.filters import Text
|
||||
from aiogram.types.message import ContentType
|
||||
|
||||
from handlers.start_handler import (command_start,
|
||||
get_main_menu_answer,
|
||||
|
@ -11,17 +11,17 @@ from handlers.instruction import (instruction_message,
|
|||
|
||||
|
||||
|
||||
def register_all_handlers(router: Router):
|
||||
handle_register_start_message(router)
|
||||
handle_instruction_message(router)
|
||||
def register_all_handlers(dp: Dispatcher):
|
||||
handle_register_start_message(dp)
|
||||
handle_instruction_message(dp)
|
||||
|
||||
|
||||
def handle_register_start_message(router: Router):
|
||||
router.message.register(command_start, Command(commands=["start"]))
|
||||
router.callback_query.register(get_main_menu_after_picture, F.data.startswith('main_menu_delete'))
|
||||
router.callback_query.register(get_main_menu_answer, F.data.startswith('main_menu'))
|
||||
router.callback_query.register(instruction_message, F.data.startswith("instruction_inline"))
|
||||
def handle_register_start_message(dp: Dispatcher):
|
||||
dp.register_message_handler(command_start, commands=['start'])
|
||||
dp.register_callback_query_handler(get_main_menu_answer, Text(equals='main_menu'))
|
||||
dp.register_callback_query_handler(instruction_message, Text(equals="instruction_inline"))
|
||||
dp.register_callback_query_handler(get_main_menu_after_picture, Text(equals='main_menu_delete'))
|
||||
|
||||
def handle_instruction_message(router: Router):
|
||||
router.callback_query.register(callbacks_instruction, F.data.startswith("num_"))
|
||||
def handle_instruction_message(dp: Dispatcher):
|
||||
dp.register_callback_query_handler(callbacks_instruction, Text(startswith="num_"))
|
||||
|
||||
|
|
|
@ -1,62 +1,115 @@
|
|||
import asyncio
|
||||
|
||||
from aiogram import Bot, Dispatcher, types
|
||||
from keyboards import *
|
||||
from aiogram.dispatcher.filters import Text
|
||||
import re
|
||||
import os
|
||||
import time
|
||||
import shutil
|
||||
import random
|
||||
from create_bot import bot, request_url, important_message, url, token, bucket_name, username, password, endpoint_url
|
||||
from req import check_register
|
||||
import urllib.request
|
||||
from messages import get_main_menu_message
|
||||
from aiogram.enums import ParseMode
|
||||
from aiogram.dispatcher import FSMContext
|
||||
from aiogram.dispatcher.filters.state import State, StatesGroup
|
||||
from aiogram.types import ReplyKeyboardMarkup, KeyboardButton, ReplyKeyboardRemove, InlineKeyboardMarkup, InlineKeyboardButton, WebAppInfo
|
||||
|
||||
from loguru import logger
|
||||
|
||||
|
||||
def download_image(url, new_filename):
|
||||
try:
|
||||
urllib.request.urlretrieve(url, new_filename)
|
||||
print("Image downloaded successfully as:", new_filename)
|
||||
except Exception as e:
|
||||
print("An error occurred:", str(e))
|
||||
|
||||
def copy_and_rename_image(source_folder, image_name, destination_folder, new_image_name):
|
||||
# Check if the source image exists
|
||||
if not os.path.exists(os.path.join(source_folder, image_name)):
|
||||
print(f"Image '{image_name}' does not exist in the source folder.")
|
||||
return
|
||||
|
||||
# Create the destination folder if it doesn't exist
|
||||
if not os.path.exists(destination_folder):
|
||||
os.makedirs(destination_folder)
|
||||
|
||||
# Construct source and destination paths
|
||||
source_path = os.path.join(source_folder, image_name)
|
||||
destination_path = os.path.join(destination_folder, new_image_name)
|
||||
|
||||
try:
|
||||
# Copy the image file
|
||||
shutil.copy(source_path, destination_path)
|
||||
print(f"Successfully copied '{image_name}' to '{destination_path}'.")
|
||||
except Exception as e:
|
||||
print(f"Error copying image: {e}")
|
||||
|
||||
def get_answer_keyboard():
|
||||
button1 = InlineKeyboardButton(text='Главное меню', callback_data='main_menu')
|
||||
kb = [[button1]]
|
||||
keyboard = InlineKeyboardMarkup(inline_keyboard=kb)
|
||||
keyboard = InlineKeyboardMarkup()
|
||||
button1 = InlineKeyboardButton('Главное меню', callback_data='main_menu')
|
||||
keyboard.add(button1)
|
||||
return keyboard
|
||||
|
||||
def get_main_keyboard_inline(is_admin=False, ref_code=None):
|
||||
button1 = InlineKeyboardButton(text='👾 Кликер', web_app=WebAppInfo(url=f'{url}?referred_by={ref_code}'))
|
||||
button2 = InlineKeyboardButton(text='ℹ️ Инструкция', callback_data='instruction_inline')
|
||||
button3 = InlineKeyboardButton(text='🔥 Кто мы?', web_app=WebAppInfo(url='https://test.com'))
|
||||
button4 = InlineKeyboardButton(text='ТЕСТ', callback_data='test_message')
|
||||
kb = [[button1], [button2], [button3]]
|
||||
keyboard = InlineKeyboardMarkup()
|
||||
button1 = InlineKeyboardButton('👾 Кликер', web_app=WebAppInfo(url=f'{url}?referred_by={ref_code}'))
|
||||
button2 = InlineKeyboardButton('ℹ️ Инструкция', callback_data='instruction_inline')
|
||||
# button3 = InlineKeyboardButton('🔥 Кто мы?', web_app=WebAppInfo(url=''))
|
||||
button4 = InlineKeyboardButton('ТЕСТ', callback_data='test_message')
|
||||
keyboard.add(button1)
|
||||
keyboard.add(button2)
|
||||
# keyboard.add(button3)
|
||||
if is_admin:
|
||||
kb.append([button4])
|
||||
keyboard = InlineKeyboardMarkup(inline_keyboard=kb)
|
||||
return keyboard
|
||||
|
||||
def gen_ok_keyboard(number):
|
||||
kb = [[InlineKeyboardButton(text='Подтвердить ✅', callback_data=f'approve_{number}'), InlineKeyboardButton(text='Изменить 🔄', callback_data=f'edit_{number}')]]
|
||||
keyboard = InlineKeyboardMarkup(inline_keyboard=kb)
|
||||
keyboard.add(button4)
|
||||
return keyboard
|
||||
|
||||
async def get_main_menu_answer(call: types.CallbackQuery):
|
||||
logger.info(f"{call.from_user.id} - @{call.from_user.username} : главное меню через инлайн кнопку")
|
||||
await call.message.edit_text(get_main_menu_message(), reply_markup=get_main_keyboard_inline(), parse_mode=ParseMode.MARKDOWN)
|
||||
await call.message.edit_text(get_main_menu_message(), reply_markup=get_main_keyboard_inline(), parse_mode=types.ParseMode.MARKDOWN)
|
||||
|
||||
async def get_main_menu_after_picture(call: types.CallbackQuery):
|
||||
logger.info(f"{call.from_user.id} - @{call.from_user.username} : главное меню через инлайн кнопку после картинки")
|
||||
await call.message.delete()
|
||||
await bot.send_message(call.from_user.id, get_main_menu_message(), reply_markup=get_main_keyboard_inline(), parse_mode=ParseMode.MARKDOWN)
|
||||
await bot.send_message(call.from_user.id, get_main_menu_message(), reply_markup=get_main_keyboard_inline(), parse_mode=types.ParseMode.MARKDOWN)
|
||||
|
||||
# async def get_main_menu(call: types.CallbackQuery):
|
||||
# logger.info(f"{call.from_user.id} - @{call.from_user.username} : главное меню через инлайн кнопку без фото")
|
||||
# call.message.delete()
|
||||
# await bot.send_photo(call.from_user.id, open('pictures/main_menu.jpg', 'rb'), caption=f"{get_main_message(call.from_user.id)}", reply_markup=get_main_keyboard_inline(check_admin(call.from_user.id)), parse_mode=types.ParseMode.MARKDOWN)
|
||||
|
||||
async def command_start(message : types.Message):
|
||||
async def command_start(message : types.Message, state:FSMContext):
|
||||
ref_code = ''
|
||||
if message.text[7:].startswith('user_'):
|
||||
ref_code = message.text[12:]
|
||||
if not check_register(message.from_user.id):
|
||||
user = message.from_user
|
||||
# try:
|
||||
# photos = await bot.get_user_profile_photos(user.id)
|
||||
# photo = photos.photos[0][-1]
|
||||
# file_info = await bot.get_file(photo.file_id)
|
||||
# download_image(f'https://api.telegram.org/file/bot{token}/{file_info["file_path"]}', f'photos/{user.id}.jpg')
|
||||
# except:
|
||||
# copy_and_rename_image('.', 'avatar.jpg', 'photos', f'{user.id}.jpg')
|
||||
|
||||
image_path = f'photos/{user.id}.jpg'
|
||||
s3_key = f'{user.id}.jpg'
|
||||
# upload_image_to_s3(image_path, bucket_name, s3_key, username, password, endpoint_url)
|
||||
|
||||
logger.info(f"{message.from_user.id} - @{message.from_user.username} : команда /start и не зарегистрирован")
|
||||
await bot.send_message(message.from_user.id, '👋', reply_markup=ReplyKeyboardRemove())
|
||||
# await asyncio.sleep(3)
|
||||
await asyncio.sleep(0.5)
|
||||
await bot.send_message(message.from_user.id, '👑 Я - KYC Кликер бот! Зарабатывай баллы кликами, поднимайся в рейтинге и получай бонусы. Развивайся быстрее с нашей специальной системой для новичков!', reply_markup=ReplyKeyboardRemove())
|
||||
# await asyncio.sleep(3)
|
||||
await asyncio.sleep(0.5)
|
||||
await bot.send_message(message.from_user.id, '🎁 Используй баллы в аукционе за ценные призы! Победителей много, приглашаем в увлекательную битву кликов!', reply_markup=ReplyKeyboardRemove())
|
||||
# await asyncio.sleep(3)
|
||||
await asyncio.sleep(0.5)
|
||||
await bot.send_message(message.from_user.id, '👯 Участвуй в реферальной программе, чтобы получать % с кликов друзей и зарабатывать больше баллов для аукциона. ', reply_markup=ReplyKeyboardRemove())
|
||||
# await asyncio.sleep(3)
|
||||
await asyncio.sleep(0.5)
|
||||
await bot.send_message(message.from_user.id, '🍀 Удачи в битве!', reply_markup=ReplyKeyboardRemove())
|
||||
# await asyncio.sleep(3)
|
||||
await asyncio.sleep(0.5)
|
||||
else:
|
||||
logger.info(f"{message.from_user.id} - @{message.from_user.username} : команда /start")
|
||||
|
||||
await bot.send_message(message.from_user.id, get_main_menu_message(), reply_markup=get_main_keyboard_inline(ref_code=ref_code), parse_mode=ParseMode.MARKDOWN)
|
||||
await bot.send_message(message.from_user.id, get_main_menu_message(), reply_markup=get_main_keyboard_inline(ref_code=ref_code), parse_mode=types.ParseMode.MARKDOWN)
|
6
bot/keyboards/__init__.py
Normal file
6
bot/keyboards/__init__.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
from keyboards.user_kb import kb_apply
|
||||
from keyboards.user_kb import kb_register
|
||||
from keyboards.user_kb import kb_number
|
||||
from keyboards.user_kb import kb_geo
|
||||
from keyboards.user_kb import kb_main
|
||||
from keyboards.user_kb import kb_apply
|
36
bot/keyboards/user_kb.py
Normal file
36
bot/keyboards/user_kb.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
from aiogram.types import ReplyKeyboardMarkup, KeyboardButton, ReplyKeyboardRemove
|
||||
|
||||
b1 = KeyboardButton("Подтвердить данные")
|
||||
b2 = KeyboardButton("Ввести новые")
|
||||
kb_apply = ReplyKeyboardMarkup(resize_keyboard=True)
|
||||
kb_apply.row(b1, b2)
|
||||
|
||||
b3 = KeyboardButton("Зарегистрироваться")
|
||||
kb_register = ReplyKeyboardMarkup(resize_keyboard=True, one_time_keyboard=True)
|
||||
kb_register.add(b3)
|
||||
|
||||
b5 = KeyboardButton("Поделиться номером📱", request_contact=True)
|
||||
kb_number = ReplyKeyboardMarkup(resize_keyboard=True)
|
||||
kb_number.add(b5)
|
||||
|
||||
b6 = KeyboardButton('Отправить свою локацию🗺️', request_location=True)
|
||||
kb_geo = ReplyKeyboardMarkup(resize_keyboard=True)
|
||||
kb_geo.add(b6)
|
||||
|
||||
b7 = KeyboardButton("МЕРОПРИЯТИЯ")
|
||||
b7_1 = KeyboardButton("BURN APP")
|
||||
b8 = KeyboardButton("СВЯЗАТЬСЯ С НАМИ")
|
||||
b9 = KeyboardButton("МОЙ АККАУНТ")
|
||||
b10 = KeyboardButton("BURN COMMUNITY")
|
||||
b11 = KeyboardButton("КАТАЛОГ")
|
||||
kb_main = ReplyKeyboardMarkup(resize_keyboard=True)
|
||||
kb_main.add(b7, b7_1)
|
||||
kb_main.add(b8, b9)
|
||||
kb_main.add(b10, b11)
|
||||
|
||||
|
||||
b11 = KeyboardButton("Подтверждаю и соглашаюсь")
|
||||
b12 = KeyboardButton("Спасибо, но нет")
|
||||
kb_apply = ReplyKeyboardMarkup(resize_keyboard=True)
|
||||
kb_apply.add(b11)
|
||||
kb_apply.add(b12)
|
24
bot/logfile.log
Normal file
24
bot/logfile.log
Normal file
|
@ -0,0 +1,24 @@
|
|||
[2024-04-23 10:56:24,265.265] INFO [281472819871024] - Started server process [6]
|
||||
[2024-04-23 10:56:24,266.266] INFO [281472819871024] - Waiting for application startup.
|
||||
[2024-04-23 10:56:24,881.881] INFO [281472819871024] - Application startup complete.
|
||||
[2024-04-23 10:56:24,884.884] INFO [281472819871024] - Uvicorn running on http://0.0.0.0:7313 (Press CTRL+C to quit)
|
||||
[2024-04-23 10:59:42,468.468] INFO [281473536830768] - Started server process [7]
|
||||
[2024-04-23 10:59:42,469.469] INFO [281473536830768] - Waiting for application startup.
|
||||
[2024-04-23 10:59:42,795.795] INFO [281473536830768] - Application startup complete.
|
||||
[2024-04-23 10:59:42,796.796] INFO [281473536830768] - Uvicorn running on http://0.0.0.0:7313 (Press CTRL+C to quit)
|
||||
[2024-04-23 11:02:47,807.807] INFO [281473265835312] - Started server process [7]
|
||||
[2024-04-23 11:02:47,808.808] INFO [281473265835312] - Waiting for application startup.
|
||||
[2024-04-23 11:02:48,548.548] INFO [281473265835312] - Application startup complete.
|
||||
[2024-04-23 11:02:48,550.550] INFO [281473265835312] - Uvicorn running on http://0.0.0.0:7313 (Press CTRL+C to quit)
|
||||
[2024-04-23 11:13:06,927.927] INFO [281473290341680] - Started server process [7]
|
||||
[2024-04-23 11:13:06,928.928] INFO [281473290341680] - Waiting for application startup.
|
||||
[2024-04-23 11:13:07,328.328] INFO [281473290341680] - Application startup complete.
|
||||
[2024-04-23 11:13:07,330.330] INFO [281473290341680] - Uvicorn running on http://0.0.0.0:7313 (Press CTRL+C to quit)
|
||||
[2024-04-23 11:15:55,771.771] INFO [281473096789296] - Started server process [7]
|
||||
[2024-04-23 11:15:55,772.772] INFO [281473096789296] - Waiting for application startup.
|
||||
[2024-04-23 11:15:56,162.162] INFO [281473096789296] - Application startup complete.
|
||||
[2024-04-23 11:15:56,166.166] INFO [281473096789296] - Uvicorn running on http://0.0.0.0:7313 (Press CTRL+C to quit)
|
||||
[2024-04-23 11:23:02,164.164] INFO [281473311243568] - Started server process [7]
|
||||
[2024-04-23 11:23:02,165.165] INFO [281473311243568] - Waiting for application startup.
|
||||
[2024-04-23 11:23:02,508.508] INFO [281473311243568] - Application startup complete.
|
||||
[2024-04-23 11:23:02,519.519] INFO [281473311243568] - Uvicorn running on http://0.0.0.0:7313 (Press CTRL+C to quit)
|
|
@ -1,7 +1,8 @@
|
|||
import os
|
||||
from pymemcache.client import base
|
||||
|
||||
client = base.Client((os.getenv('mem_host', 'localhost'), os.getenv('mem_port', 11211)))
|
||||
|
||||
client = base.Client((os.getenv('MEMCACHED_HOST', 'localhost'), os.getenv('MEMCACHED_PORT', 11211)))
|
||||
|
||||
def add_rec(key, value):
|
||||
client.set(str(key), value)
|
||||
|
|
12
bot/req.py
12
bot/req.py
|
@ -8,7 +8,15 @@ from operator import itemgetter
|
|||
from loguru import logger
|
||||
|
||||
def check_register(tg_id):
|
||||
return False
|
||||
data = requests.get(f'{request_url}/internal/users/check/{tg_id}')
|
||||
return data.status_code == 200
|
||||
|
||||
def check_admin(tg_id):
|
||||
return 0
|
||||
data = requests.get(f'{request_url}/users/get/{tg_id}/', headers={'Authorization': f'Token {api_token}'}).json()
|
||||
if len(data) > 3:
|
||||
if data['is_staff']:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
return False
|
|
@ -1,31 +1,51 @@
|
|||
aiofiles==24.1.0
|
||||
aiogram==3.15.0
|
||||
aiohappyeyeballs==2.4.4
|
||||
aiohttp==3.10.11
|
||||
aiosignal==1.3.2
|
||||
annotated-types==0.7.0
|
||||
attrs==24.2.0
|
||||
boto3==1.35.81
|
||||
botocore==1.35.81
|
||||
certifi==2024.8.30
|
||||
charset-normalizer==3.4.0
|
||||
fastapi==0.115.6
|
||||
frozenlist==1.5.0
|
||||
gunicorn==23.0.0
|
||||
idna==3.10
|
||||
jmespath==1.0.1
|
||||
loguru==0.7.3
|
||||
magic-filter==1.0.12
|
||||
multidict==6.1.0
|
||||
propcache==0.2.1
|
||||
pydantic==2.9.2
|
||||
pydantic_core==2.23.4
|
||||
aiogram==2.25.1
|
||||
aiohttp==3.8.4
|
||||
aiosignal==1.3.1
|
||||
anyio==3.6.2
|
||||
async-timeout==4.0.2
|
||||
attrs==22.2.0
|
||||
Babel==2.9.1
|
||||
boto3==1.34.92
|
||||
cachetools==5.3.0
|
||||
certifi==2022.12.7
|
||||
charset-normalizer==3.1.0
|
||||
click==8.1.3
|
||||
fastapi==0.95.0
|
||||
fastapi-jwt-auth==0.5.0
|
||||
frozenlist==1.3.3
|
||||
geographiclib==2.0
|
||||
geopy==2.3.0
|
||||
google-api-core==2.11.0
|
||||
google-api-python-client==2.82.0
|
||||
google-auth==2.16.3
|
||||
google-auth-httplib2==0.1.0
|
||||
googleapis-common-protos==1.59.0
|
||||
gunicorn==22.0.0
|
||||
h11==0.14.0
|
||||
httplib2==0.22.0
|
||||
idna==3.4
|
||||
loguru==0.6.0
|
||||
magic-filter==1.0.9
|
||||
multidict==6.0.4
|
||||
oauth2client==4.1.3
|
||||
Pillow==10.0.0
|
||||
protobuf==4.22.1
|
||||
pyasn1==0.4.8
|
||||
pyasn1-modules==0.2.8
|
||||
pydantic==1.10.7
|
||||
PyJWT==1.7.1
|
||||
pymemcache==4.0.0
|
||||
python-dateutil==2.9.0.post0
|
||||
requests==2.32.3
|
||||
s3transfer==0.10.4
|
||||
six==1.17.0
|
||||
typing_extensions==4.12.2
|
||||
urllib3==2.2.3
|
||||
uvicorn==0.32.1
|
||||
yarl==1.18.3
|
||||
pyparsing==3.0.9
|
||||
pypng==0.20220715.0
|
||||
pytz==2023.2
|
||||
qrcode==7.4.2
|
||||
requests==2.28.2
|
||||
rsa==4.9
|
||||
six==1.16.0
|
||||
sniffio==1.3.0
|
||||
starlette==0.26.1
|
||||
typing_extensions==4.5.0
|
||||
uritemplate==4.1.1
|
||||
urllib3==1.26.15
|
||||
uvicorn==0.21.1
|
||||
yarl==1.8.2
|
||||
|
|
|
@ -1,23 +1,16 @@
|
|||
from handlers.register_handlers import register_all_handlers
|
||||
from create_bot import bot
|
||||
from aiogram import Bot, Dispatcher
|
||||
from aiogram.fsm.storage.memory import MemoryStorage
|
||||
from aiogram.contrib.fsm_storage.memory import MemoryStorage
|
||||
from loguru import logger
|
||||
from aiogram import Router
|
||||
|
||||
logger.add("logs.log", format = "{time} | {module} : {function} | {level} | {message}", level = "INFO", rotation = "1 week", compression = "zip")#, serialize = True)
|
||||
|
||||
async def run_bot():
|
||||
storage = MemoryStorage()
|
||||
dp = Dispatcher(storage=storage)
|
||||
|
||||
# Create a router to register handlers
|
||||
router = Router()
|
||||
|
||||
# Register all handlers
|
||||
register_all_handlers(router)
|
||||
dp = Dispatcher(bot, storage=MemoryStorage())
|
||||
|
||||
# Mount the router into the dispatcher
|
||||
dp.include_router(router)
|
||||
register_all_handlers(dp)
|
||||
|
||||
await dp.start_polling(bot)
|
||||
await dp.skip_updates()
|
||||
await dp.start_polling()
|
|
@ -20,6 +20,7 @@ services:
|
|||
- .env/prod/back
|
||||
- .env/prod/rmq
|
||||
- .env/prod/bot
|
||||
- .env/prod/web
|
||||
|
||||
bot:
|
||||
build:
|
||||
|
@ -35,10 +36,9 @@ services:
|
|||
- .env/prod/web
|
||||
command: /gunicorn.sh
|
||||
restart: on-failure
|
||||
#
|
||||
# memcached:
|
||||
# container_name: memcached
|
||||
# image: memcached:latest
|
||||
|
||||
memcached:
|
||||
image: memcached:latest
|
||||
|
||||
postgres:
|
||||
image: postgres:14.5-alpine
|
||||
|
|
Loading…
Reference in New Issue
Block a user