Skip to content

Commit

Permalink
fixing PeerIdInvalid error
Browse files Browse the repository at this point in the history
  • Loading branch information
rking32 committed Jul 8, 2020
1 parent c4b3b03 commit 560c368
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions userge/core/methods/decorators/raw_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
from pyrogram import (
MessageHandler, Message as RawMessage, Filters,
StopPropagation, ContinuePropagation)
from pyrogram.errors.exceptions.bad_request_400 import ChatAdminRequired, UserNotParticipant
from pyrogram.errors.exceptions.bad_request_400 import (
ChatAdminRequired, UserNotParticipant, PeerIdInvalid)

from userge import logging, Config
from ...ext import RawClient
Expand Down Expand Up @@ -55,21 +56,24 @@ async def template(r_c: Union['_client.Userge', '_client._UsergeBot'],
r_m: RawMessage) -> None:
if RawClient.DUAL_MODE:
if check_client or (r_m.from_user and r_m.from_user.id in Config.SUDO_USERS):
bot_available = False
if isinstance(r_c, _client.Userge):
try:
await r_m.chat.get_member((await r_c.bot.get_me()).id)
bot_available = True
except UserNotParticipant:
pass
else:
bot_available = True
try:
# pylint: disable=protected-access
if not Config.USE_USER_FOR_CLIENT_CHECKS and bot_available:
assert isinstance(r_c, _client._UsergeBot)
else:
if Config.USE_USER_FOR_CLIENT_CHECKS:
assert isinstance(r_c, _client.Userge)
else:
bot_available = False
if isinstance(r_c, _client.Userge):
try:
await r_m.chat.get_member((await r_c.bot.get_me()).id)
bot_available = True
except (UserNotParticipant, PeerIdInvalid):
pass
else:
bot_available = True
if bot_available:
assert isinstance(r_c, _client._UsergeBot)
else:
assert isinstance(r_c, _client.Userge)
except AssertionError:
return
if isinstance(flt, types.raw.Command) and r_m.chat and (r_m.chat.type not in scope):
Expand Down

0 comments on commit 560c368

Please sign in to comment.