Skip to content

Commit 44562c8

Browse files
committed
Fixed: AttributeError: 'ChannelForbidden' object has no attribute 'noforwards'
1 parent b480d7b commit 44562c8

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

  • pyrogram/types/user_and_chats

pyrogram/types/user_and_chats/chat.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,10 @@ def _parse_chat_chat(client, chat: raw.types.Chat) -> "Chat":
230230
def _parse_channel_chat(client, channel: raw.types.Channel) -> "Chat":
231231
peer_id = utils.get_channel_id(channel.id)
232232
restriction_reason = getattr(channel, "restriction_reason", [])
233-
233+
try:
234+
no_forward = channel.noforwards
235+
except AttributeError:
236+
no_forward = None
234237
return Chat(
235238
id=peer_id,
236239
type="supergroup" if getattr(channel, "megagroup", None) else "channel",
@@ -246,7 +249,7 @@ def _parse_channel_chat(client, channel: raw.types.Channel) -> "Chat":
246249
permissions=types.ChatPermissions._parse(getattr(channel, "default_banned_rights", None)),
247250
members_count=getattr(channel, "participants_count", None),
248251
dc_id=getattr(getattr(channel, "photo", None), "dc_id", None),
249-
has_protected_content=channel.noforwards,
252+
has_protected_content=no_forward,
250253
client=client
251254
)
252255

0 commit comments

Comments
 (0)