upd
This commit is contained in:
parent
d4e736d6a8
commit
d2f13150e3
@ -1,4 +1,6 @@
|
|||||||
from config import types, InlineKeyboardBuilder
|
from aiogram.utils.keyboard import InlineKeyboardBuilder, ReplyKeyboardBuilder
|
||||||
|
from aiogram import types
|
||||||
|
|
||||||
from filters import filtersbot
|
from filters import filtersbot
|
||||||
from sql_function import databasework
|
from sql_function import databasework
|
||||||
import math
|
import math
|
||||||
|
@ -16,7 +16,19 @@ sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../')))
|
|||||||
|
|
||||||
from bot.db.models import UserTg
|
from bot.db.models import UserTg
|
||||||
from bot.config import bot
|
from bot.config import bot
|
||||||
|
from aiogram.utils.keyboard import InlineKeyboardBuilder, ReplyKeyboardBuilder
|
||||||
|
|
||||||
|
def start_markup(): # старт кнопки
|
||||||
|
|
||||||
|
markup = (
|
||||||
|
InlineKeyboardBuilder()
|
||||||
|
.button(text='Тич-Пицца', callback_data='pizza') #
|
||||||
|
.button(text='Ебидоеби', callback_data='ebi')
|
||||||
|
.adjust(1, repeat=True)
|
||||||
|
.as_markup()
|
||||||
|
)
|
||||||
|
|
||||||
|
return markup
|
||||||
|
|
||||||
key = os.getenv('SECRET_KEY_AUTH')
|
key = os.getenv('SECRET_KEY_AUTH')
|
||||||
cipher_suite = Fernet(key)
|
cipher_suite = Fernet(key)
|
||||||
@ -79,3 +91,10 @@ async def send_newsletter(message: str, db_session: AsyncSession) -> dict:
|
|||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logging.error(ex)
|
logging.error(ex)
|
||||||
raise NewsletterException(status_code=502, detail=f"Ошибка, рассылка не была начата - {ex}")
|
raise NewsletterException(status_code=502, detail=f"Ошибка, рассылка не была начата - {ex}")
|
||||||
|
|
||||||
|
async def send_msg(user_id: int):
|
||||||
|
try:
|
||||||
|
markup = start_markup()
|
||||||
|
await bot.send_message(chat_id=user_id, text='⭐️ Добро пожаловать в бота, используйте кнопки ниже', reply_markup=markup)
|
||||||
|
except Exception as ex:
|
||||||
|
logging.error(f"ERROR send msg - {ex}")
|
@ -6,7 +6,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from db import crud
|
from db import crud
|
||||||
from db.db import async_session
|
from db.db import async_session
|
||||||
from function import decrypt_token, get_authenticated_user, send_newsletter, get_user_with_access
|
from function import decrypt_token, get_authenticated_user, send_newsletter, get_user_with_access, send_msg
|
||||||
from config import templates
|
from config import templates
|
||||||
from db.models import User
|
from db.models import User
|
||||||
from sqlalchemy.future import select
|
from sqlalchemy.future import select
|
||||||
@ -90,7 +90,12 @@ async def update_status(
|
|||||||
if not user_record:
|
if not user_record:
|
||||||
raise HTTPException(status_code=404, detail="User not found")
|
raise HTTPException(status_code=404, detail="User not found")
|
||||||
|
|
||||||
user_record.has_access = not user_record.has_access
|
|
||||||
|
if user_record.has_access == True:
|
||||||
|
user_record.has_access = False
|
||||||
|
else:
|
||||||
|
user_record.has_access = True
|
||||||
|
await send_msg(user_record.user_id)
|
||||||
|
|
||||||
db_session.add(user_record)
|
db_session.add(user_record)
|
||||||
await db_session.commit()
|
await db_session.commit()
|
||||||
|
Loading…
Reference in New Issue
Block a user