add black format
This commit is contained in:
parent
7376de2d13
commit
5bc3eda39b
2
bot.py
2
bot.py
|
@ -38,5 +38,5 @@ async def main():
|
|||
await bot_session.close()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
|
|
|
@ -5,9 +5,7 @@ from asyncpg.connection import Connection
|
|||
|
||||
|
||||
async def drop_tables(connection: Connection):
|
||||
await connection.execute(
|
||||
"DROP TABLE users, tags, categories, projects CASCADE"
|
||||
)
|
||||
await connection.execute("DROP TABLE users, tags, categories, projects CASCADE")
|
||||
|
||||
|
||||
async def main():
|
||||
|
@ -17,5 +15,5 @@ async def main():
|
|||
await connection.close()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
|
|
|
@ -52,5 +52,5 @@ async def main():
|
|||
await connection.close()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
|
|
|
@ -11,14 +11,12 @@ async def start(message: types.Message, repo: Repos):
|
|||
await message.answer(
|
||||
"Добро пожаловать в Бота Теплицы Социальных Технологий "
|
||||
"для организации антивоенных проектов.",
|
||||
reply_markup=default_kb
|
||||
reply_markup=default_kb,
|
||||
)
|
||||
|
||||
|
||||
async def request_invite(message: types.Message, repo: Repos):
|
||||
await repo.get_repo(UserRepo).add(
|
||||
message.from_user.id, message.chat.id
|
||||
)
|
||||
await repo.get_repo(UserRepo).add(message.from_user.id, message.chat.id)
|
||||
logger.debug(f"Added new user {message.from_user.full_name}")
|
||||
|
||||
bot_info = await message.bot.get_me()
|
||||
|
|
|
@ -11,9 +11,7 @@ from states.project import ProjectStates
|
|||
from services.repositories import Repos, ProjectRepo
|
||||
|
||||
|
||||
async def create_project(
|
||||
message: types.Message, state: FSMContext
|
||||
):
|
||||
async def create_project(message: types.Message, state: FSMContext):
|
||||
await state.set_state(ProjectStates.set_fields)
|
||||
await message.reply(
|
||||
"Название проекта: Превращение песиков в котиков\n\n"
|
||||
|
@ -33,14 +31,14 @@ async def create_project(
|
|||
)
|
||||
|
||||
|
||||
async def get_project_fields(
|
||||
message: types.Message, repo: Repos, state: FSMContext
|
||||
):
|
||||
async def get_project_fields(message: types.Message, repo: Repos, state: FSMContext):
|
||||
# TODO: для тегов и категорий вытаскивать из таблиц индексы,
|
||||
# значением для creator должен быть user_id.
|
||||
field_patterns = {
|
||||
"Название проекта": str, "Описание": str, "Кол-во участников": int,
|
||||
"Статус": BitString
|
||||
"Название проекта": str,
|
||||
"Описание": str,
|
||||
"Кол-во участников": int,
|
||||
"Статус": BitString,
|
||||
}
|
||||
field_values = []
|
||||
|
||||
|
@ -59,6 +57,4 @@ async def get_project_fields(
|
|||
|
||||
def register_projects_handlers(dp: Dispatcher):
|
||||
dp.register_message_handler(create_project, Text("Создать проект"))
|
||||
dp.register_message_handler(
|
||||
get_project_fields, state=ProjectStates.set_fields
|
||||
)
|
||||
dp.register_message_handler(get_project_fields, state=ProjectStates.set_fields)
|
||||
|
|
|
@ -2,8 +2,9 @@ from aiogram.types import ReplyKeyboardMarkup
|
|||
|
||||
|
||||
default_kb = ReplyKeyboardMarkup(
|
||||
resize_keyboard=True, keyboard=[
|
||||
resize_keyboard=True,
|
||||
keyboard=[
|
||||
["Мои проекты", "Создать проект"],
|
||||
["Помощь"],
|
||||
]
|
||||
],
|
||||
)
|
||||
|
|
|
@ -8,7 +8,7 @@ class BaseRepo:
|
|||
self.conn = conn
|
||||
|
||||
|
||||
T = TypeVar('T', bound=BaseRepo)
|
||||
T = TypeVar("T", bound=BaseRepo)
|
||||
|
||||
|
||||
class Repos(BaseRepo):
|
||||
|
@ -21,7 +21,8 @@ class UserRepo(BaseRepo):
|
|||
await self.conn.execute(
|
||||
"INSERT INTO users (user_id, chat_id) "
|
||||
"VALUES ($1, $2) ON CONFLICT (user_id) DO NOTHING",
|
||||
user_id, chat_id
|
||||
user_id,
|
||||
chat_id,
|
||||
)
|
||||
|
||||
async def get(self, user_id: int):
|
||||
|
@ -36,11 +37,12 @@ class ProjectRepo(BaseRepo):
|
|||
"INSERT INTO projects "
|
||||
"(name, description, contributors, status) "
|
||||
"VALUES ($1, $2, $3, $4)",
|
||||
name, description, *args
|
||||
name,
|
||||
description,
|
||||
*args
|
||||
)
|
||||
|
||||
async def get(self, user_id: int):
|
||||
return await self.conn.fetchval(
|
||||
"SELECT name, description FROM projects WHERE creator = $1",
|
||||
user_id
|
||||
"SELECT name, description FROM projects WHERE creator = $1", user_id
|
||||
)
|
||||
|
|
Reference in a new issue