Skip to content

Commit

Permalink
updated readme.md && requirements.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
bralbral committed Sep 29, 2023
1 parent 10cdfd7 commit 11381ce
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Use this bot for communicate with users in case you do not want to provide your

## Usage

Messages with an available [content type](./src/bot/handlers/users.py#L24) will be transfered to admin group or admin chat.
Messages with an **available content type** *(TEXT, ANIMATION, AUDIO, DOCUMENT, PHOTO, VIDEO, VOICE)* will be transferred to **admin group** or **admin chat**.

*(See variable `chat_id` from [config.yaml](./deploy/example.config.yaml#L6))*

If the transfer is successful, the requesting party will be notified.

Admin can answer to message by reply. The answer will be sent to the person who asked.
**Admin** can **answer** to message **by reply**. The answer will be sent to the person who asked.

If the transfer is successful, the administrator will be notified.

Expand Down
7 changes: 3 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
aiogram==3.1.0
sulguk==0.5.0
aiogram==3.1.1
sulguk==0.6.0
pydantic-settings==2.0.3
pyaml==23.9.6
pyaml==23.9.7
structlog~=23.1.0
# asyncio speedup
uvloop==0.17.0; sys_platform == 'linux'
9 changes: 9 additions & 0 deletions src/bot/handlers/admins/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
async def reply_to_user(
message: Message, bot: Bot, messages: Messages, errors: Errors, **kwargs
):
"""
Answer to user by reply from admin chat or group
:param message:
:param bot:
:param messages:
:param errors:
:param kwargs:
:return:
"""
try:
user_id = extract_id(message.reply_to_message)
except ValueError as ex:
Expand Down
7 changes: 7 additions & 0 deletions src/bot/handlers/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
Command("start", "help"),
) # type: ignore
async def start_help_handler(message: Message, messages: Messages, **kwargs) -> None:
"""
Handle /start or /help message
:param message:
:param messages:
:param kwargs:
:return:
"""
await message.answer(
messages.help_message,
disable_web_page_preview=True,
Expand Down
10 changes: 9 additions & 1 deletion src/bot/handlers/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
router = Router(name="users")


# process messages only from PM
@router.message(F.chat.id == F.from_user.id) # type: ignore
async def handle_user_message(
message: Message,
Expand All @@ -21,6 +20,15 @@ async def handle_user_message(
errors: Errors,
**kwargs,
):
"""Handle user message and send it to admin chat (group)
:param message:
:param bot:
:param chat_id:
:param messages:
:param errors:
:param kwargs:
:return:
"""
if message.content_type not in (
ContentType.TEXT,
ContentType.ANIMATION,
Expand Down
4 changes: 4 additions & 0 deletions src/bot/utils/setup_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@


async def setup_bot(config: BotConfig) -> Bot:
"""
:param config:
:return:
"""
bot: Bot = Bot(
token=config.token.get_secret_value(),
)
Expand Down
7 changes: 7 additions & 0 deletions src/bot/utils/setup_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
def setup_dispatcher(
logger: BoundLogger, chat_id: int, messages: Messages, errors: Errors
) -> Dispatcher:
"""
:param logger:
:param chat_id:
:param messages:
:param errors:
:return:
"""
dp: Dispatcher = Dispatcher(
storage=MemoryStorage(),
logger=logger,
Expand Down
4 changes: 4 additions & 0 deletions src/config/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@


def load_config(config_path: str) -> Config:
"""
:param config_path:
:return:
"""
with open(file=config_path, mode="rb") as fh:
raw_data: dict = yaml.load(stream=fh, Loader=yaml.FullLoader)
config: Config = Config.model_validate(raw_data)
Expand Down

0 comments on commit 11381ce

Please sign in to comment.