Skip to content

Commit

Permalink
update dependencies... that broke formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
KruASe76 committed Oct 6, 2024
1 parent 49e2aee commit 46d5d14
Show file tree
Hide file tree
Showing 13 changed files with 437 additions and 707 deletions.
12 changes: 7 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
### Custom

cache/

test.py


### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
Expand Down Expand Up @@ -238,8 +245,3 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/


cache/

test.py
17 changes: 0 additions & 17 deletions Pipfile

This file was deleted.

613 changes: 0 additions & 613 deletions Pipfile.lock

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ Mechanism that provides random draw for Secret Santa event

## Used libraries

- [aiogram (v3.0.0b6)](https://pypi.org/project/aiogram/3.0.0b6/) as Telegram Bot API
- [aiogram (v3)](https://pypi.org/project/aiogram/) as Telegram Bot API
- [PyYAML](https://pypi.org/project/PyYAML/) to process YAML configuration
32 changes: 19 additions & 13 deletions handlers/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from aiogram import Router
from aiogram.filters import Command, Text
from aiogram import Router, F
from aiogram.filters import Command
from aiogram.types import Message, CallbackQuery

from handlers.filters import BotAdminMessageFilter, BotAdminCallbackFilter
Expand All @@ -12,26 +12,32 @@

@router.message(Command(commands=["god"]), BotAdminMessageFilter())
async def admin_panel_command(message: Message):
await message.answer("Здарова, отец\!", reply_markup=admin_inline_keyboard)
await message.answer("Здарова, отец!", reply_markup=admin_inline_keyboard)


@router.callback_query(Text(text="santa_progress"), BotAdminCallbackFilter())
async def shutdown_query(callback: CallbackQuery):
@router.callback_query(F.data == "santa_progress", BotAdminCallbackFilter())
async def santa_progress_query(callback: CallbackQuery):
await callback.answer()
await callback.message.answer(
f"*{(taken := len(conf.santa_map))}/{(total := len(conf.santa_participants))}*" +
("\n\n_Ждем\-с_:\n" if taken < total else "") +
"\n".join(map(
lambda p: p[1],
filter(lambda p: p[0] not in conf.santa_map.keys(), conf.santa_participants.items())
))
f"**{(taken := len(conf.santa_map))}/{(total := len(conf.santa_participants))}**"
+ ("\n\n__Ждем-с__:\n" if taken < total else "")
+ "\n".join(
map(
lambda p: p[1],
filter(
lambda p: p[0] not in conf.santa_map.keys(),
conf.santa_participants.items(),
),
)
)
)

@router.callback_query(Text(text="shutdown"), BotAdminCallbackFilter())

@router.callback_query(F.data == "shutdown", BotAdminCallbackFilter())
async def shutdown_query(callback: CallbackQuery):
save_config()

await callback.answer()
await callback.message.answer("Конфиг сохранен\nБот уходит в закат\.\.\.")
await callback.message.answer("Конфиг сохранен\nБот уходит в закат...")

exit()
2 changes: 1 addition & 1 deletion handlers/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class BotAdminMessageFilter(BaseFilter):
async def __call__(self, message: Message) -> bool:
if flag := (message.from_user.id != admin_id):
await message.reply("Ты не отец\! 🫵")
await message.reply("Ты не отец! 🫵")
return not flag


Expand Down
39 changes: 24 additions & 15 deletions handlers/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
@router.message(Command(commands=["start", "help"]))
async def help_command(message: Message):
await message.answer(
"Привет\! Я \- бот великого недопрогера @KruASe\nУмею пока немного: всего пара команд",
reply_markup=ReplyKeyboardRemove()
"Привет! Я - бот великого недопрогера @KruASe\nУмею пока немного: всего пара команд",
reply_markup=ReplyKeyboardRemove(),
)

if message.chat.type == "private":
Expand All @@ -25,31 +25,40 @@ async def help_command(message: Message):

@router.message(Command(commands=["santa"]))
async def santa_command(message: Message):
if (id := message.from_user.id) not in conf.santa_participants.keys() and id not in conf.santa_map.values():
await message.reply("Не для таких жалких людей, как ты, была создана эта команда\!")
if (
id := message.from_user.id
) not in conf.santa_participants.keys() and id not in conf.santa_map.values():
await message.reply("Не для таких жалких людей, как ты, была создана эта команда!")
return

if not (participants := tuple(filter(
lambda p: p[0] not in conf.santa_map.values() and p[0] != id,
conf.santa_participants.items()
))):
if not (
participants := tuple(
filter(
lambda p: p[0] not in conf.santa_map.values() and p[0] != id,
conf.santa_participants.items(),
)
)
):
if len(conf.santa_map) + 1 == len(conf.santa_participants):
await message.reply(
"Ты последним вызвал эту команду, и так получилось\.\.\.\nЧто ты еще и единственный, "
f"кто остался невыбранным\.\.\.\nПолучается, ты сам себе Санта в этот раз{lucky_suffix}"
"Ты последним вызвал эту команду, и так получилось...\nЧто ты еще и единственный, "
f"кто остался невыбранным...\nПолучается, ты сам себе Санта в этот раз{lucky_suffix}"
)
else:
await message.reply("Всех уже разобрали\!\n\n все а раньше надо было_")
await message.reply("Всех уже разобрали\!\n\n__А все а раньше надо было__")
return

if id not in conf.users:
await message.reply("Сначала запусти бота\!\nТаковы правила Телеграма\.\.\.", reply_markup=not_started_keyboard)
await message.reply(
"Сначала запусти бота!\nТаковы правила Телеграма...",
reply_markup=not_started_keyboard,
)
return

if id in conf.santa_map.keys():
await bot.send_message(
id,
f"Тебе уже предоставлен подопечный\!\nА именно *{conf.santa_participants[conf.santa_map[id]]}*"
f"Тебе уже предоставлен подопечный!\nА именно **{conf.santa_participants[conf.santa_map[id]]}**",
)
return

Expand All @@ -60,6 +69,6 @@ async def santa_command(message: Message):
await bot.send_message(
id,
f"__Запрос {len(conf.santa_map)}/{len(conf.santa_participants)}__\n\n"
f"Тебе достается\.\.\.\n*{recipient_name}*\!"
f"{lucky_suffix if recipient_name == 'Борис Игоревич' else ''}" # easter egg
f"Тебе достается...\n**{recipient_name}**\!"
f"{lucky_suffix if recipient_name == 'Борис Игоревич' else ''}", # easter egg
)
4 changes: 3 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
import logging

from aiogram import Bot, Dispatcher
from aiogram.client.default import DefaultBotProperties
from aiogram.enums.parse_mode import ParseMode

from handlers import user
from handlers import admin


bot = Bot(token=os.environ.get("TOKEN"), parse_mode="MarkdownV2")
bot = Bot(token=os.environ.get("TOKEN"), efault=DefaultBotProperties(parse_mode=ParseMode.MARKDOWN))
dp = Dispatcher()

logging.basicConfig(level=logging.INFO)
Expand Down
2 changes: 1 addition & 1 deletion misc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Config:
conf = Config(
users=set(),
santa_participants=yaml.load(participants_file, yaml.FullLoader),
santa_map={}
santa_map={},
)


Expand Down
28 changes: 5 additions & 23 deletions misc/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,19 @@


not_started_keyboard = InlineKeyboardMarkup(
row_width=1,
inline_keyboard=[
[
InlineKeyboardButton(
text="Бот",
url="https://t.me/KruASe_bot"
)
]
]
row_width=1, inline_keyboard=[[InlineKeyboardButton(text="Бот", url="https://t.me/KruASe_bot")]]
)


lucky_suffix = "\n\n_Повезло повезло\.\.\._"
lucky_suffix = "\n\n__Повезло повезло...__"


admin_id = 737286150

admin_inline_keyboard = InlineKeyboardMarkup(
row_width=1,
inline_keyboard=[
[
InlineKeyboardButton(
text="Прогресс Тайного Санты 🎅",
callback_data="santa_progress"
)
],
[
InlineKeyboardButton(
text="Спать! ⛔️",
callback_data="shutdown"
)
]
]
[InlineKeyboardButton(text="Прогресс Тайного Санты 🎅", callback_data="santa_progress")],
[InlineKeyboardButton(text="Спать! ⛔️", callback_data="shutdown")],
],
)
10 changes: 10 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[project]
name = "kruase-telegram-bot"
version = "1.0.0"
description = "My first multi-purpose Telegram bot"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"aiogram>=3.13.1",
"pyyaml>=6.0.2",
]
34 changes: 17 additions & 17 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
-i https://pypi.org/simple
aiofiles==22.1.0 ; python_version >= '3.7' and python_version < '4.0'
aiogram==3.0.0b6
aiohttp==3.8.3 ; python_version >= '3.6'
aiosignal==1.3.1 ; python_version >= '3.7'
async-timeout==4.0.2 ; python_version >= '3.6'
attrs==22.2.0 ; python_version >= '3.6'
certifi==2022.12.7 ; python_version >= '3.6'
charset-normalizer==2.1.1 ; python_full_version >= '3.6.0'
frozenlist==1.3.3 ; python_version >= '3.7'
idna==3.4 ; python_version >= '3.5'
magic-filter==1.0.9 ; python_version >= '3.7' and python_version < '4.0'
multidict==6.0.4 ; python_version >= '3.7'
pydantic==1.10.4 ; python_version >= '3.7'
pyyaml==6.0
typing-extensions==4.4.0 ; python_version >= '3.7'
yarl==1.8.2 ; python_version >= '3.7'
aiofiles==24.1.0
aiogram==3.13.1
aiohappyeyeballs==2.4.3
aiohttp==3.10.9
aiosignal==1.3.1
annotated-types==0.7.0
attrs==24.2.0
certifi==2024.8.30
frozenlist==1.4.1
idna==3.10
magic-filter==1.0.12
multidict==6.1.0
pydantic==2.9.2
pydantic-core==2.23.4
pyyaml==6.0.2
typing-extensions==4.12.2
yarl==1.13.1
Loading

0 comments on commit 46d5d14

Please sign in to comment.