Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/handlers/chat_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ async def _handle_bot_added(self, event: events.ChatAction.Event, me: User) -> N
chat_id = self._normalize_channel_id(chat.id)
user_id = event.added_by.id

# Проверяем, является ли канал публичным
# Check if the channel is public
if not chat.username:
# Если канал не публичный, выходим из него
# If the channel is not public, leave it
await self.client(LeaveChannelRequest(chat))
# Отправляем сообщение пользователю
# Send a message to the user
# "Sorry, I can only work with public channels. "
# "Please make the channel public and add me again."
await self.client.send_message(
user_id,
"Извините, но я могу работать только с публичными каналами. "
Expand All @@ -81,11 +83,11 @@ async def _handle_bot_added(self, event: events.ChatAction.Event, me: User) -> N
logger.warning(f"Bot left private channel {chat_id} ({chat.title})")
return

# Сохраняем информацию о канале
# Save channel information
self.storage.save_channel_title(chat_id, chat.title)
self.storage.save_channel_username(chat_id, chat.username)

# Получаем и сохраняем администраторов
# Get and save administrators
admins = await self._get_channel_admins(chat)
for admin_id in admins:
self.storage.add_channel_for_user(admin_id, chat_id)
Expand Down