Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CHAT_ADMIN_REQUIRED #1405

Open
3 tasks done
StegaDP opened this issue Mar 18, 2024 · 5 comments
Open
3 tasks done

CHAT_ADMIN_REQUIRED #1405

StegaDP opened this issue Mar 18, 2024 · 5 comments

Comments

@StegaDP
Copy link

StegaDP commented Mar 18, 2024

Checklist

  • I am sure the error is coming from Pyrogram's code and not elsewhere
  • I have searched in the issue tracker for similar bug reports, including closed ones
  • I ran pip3 install -U https://github.com/pyrogram/pyrogram/archive/master.zip and reproduced the issue using the latest development version

Description

pyrogram.errors.exceptions.bad_request_400.ChatAdminRequired: Telegram says: [400 CHAT_ADMIN_REQUIRED] - The method requires chat admin privileges (caused by "stats.GetMegagroupStats")
app.invoke is throwing this. i'm chat owner(means i'm admin as well lol)

Steps to reproduce

async def main():
async with Client("my_account", api_id, api_hash) as app:
r = await app.invoke(GetMegagroupStats(channel=await app.resolve_peer(super_group_id)))
print(r)

if name == 'main':
asyncio.run(main())

Code example

No response

Logs

No response

@Likheet
Copy link

Likheet commented Mar 19, 2024

This error is likely occurring because the GetMegagroupStats method requires the client to be an administrator in the supergroup. Please assign me this task and I will do my best to fix this issue

@StegaDP
Copy link
Author

StegaDP commented Mar 19, 2024

not really, i'm a group owner, as well as being admin. more likely to be some bug on telegram side idk

image

@Likheet
Copy link

Likheet commented Mar 19, 2024

Did u try GetChatMembers instead of GetMegagroupStats ? But it may not be as detailed

@StegaDP
Copy link
Author

StegaDP commented Mar 19, 2024

well, that's what i needed first. i will try getchatmembers but it doesn't seem to be thing i'm looking for

@Likheet
Copy link

Likheet commented Mar 19, 2024

My logic is, there may be something which is not allowing u to be set as admin. Try getting info on yourself using get_chat_member. I think something similar to this:

`from pyrogram import Client

app = Client("my_account")

@app.on_message()
async def check_admin(client, message):
chat_member = await client.get_chat_member(message.chat.id, message.from_user.id)
if chat_member.status == "administrator" or chat_member.status == "creator":
await message.reply_text("Admin")
else:
await message.reply_text("Not Admin")

app.run()`

Replace my_account with your username

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants