When i try to GetFullUser to newly created bot id i get error ValueError: Could not find the input entity for PeerUser(user_id=7828538638) (PeerUser), but when i try to GetFullUser with bot username everything is good, but if i do it too fast i got UserFull object with previously created bot info
Читать полностью…Hi, how i can get all the join requests from a private channel?
im trying with this function:
result = client(functions.messages.GetChatInviteImportersRequest(
peer='username',
offset_date=datetime.datetime(2018, 6, 25),
offset_user='username',
limit=100,
requested=True,
subscription_expired=True,
link='some string here',
q='some string here'
))
yes, because this group is for telethon only, and the error may be pyrogram-related
Читать полностью…Can someone help me code this?
I want to collect information about those who are banned from joining a specific channel, but this error appears
error: 'str' object has no attribute 'value'
code:
from pyrogram import Client, filters
from pyrogram.errors import ChatAdminRequired, PeerIdInvalid
from pyrogram.types import Message
API_ID =
API_HASH = .
BOT_TOKEN = .
app = Client("ooo", api_id=API_ID, api_hash=API_HASH, bot_token=BOT_TOKEN)
@app.on_message(filters.command("Get") & filters.private)
async def banned(client: Client, message: Message):
if len(message.command) < 2:
await message.reply("Please specify the channel username after the command.")
return
channel_username = message.command[1].strip()
banned_users_file = "banned_users.txt"
try:
banned_user_ids = []
if not isinstance(channel_username, str) or not channel_username.startswith("@"):
await message.reply("Make sure to enter the channel username correctly (starting with @).")
return
async for member in client.get_chat_members(channel_username, filter="banned"):
if member.user:
banned_user_ids.append(str(member.user.id))
else:
print("Member without user attribute:", member)
with open(banned_users_file, "w") as file:
file.write("\n".join(banned_user_ids))
await message.reply("User IDs have been collected. Sending the file...")
await client.send_document(chat_id=message.chat.id, document=banned_users_file)
except ChatAdminRequired:
await message.reply("The bot needs admin privileges in the channel with permission to ban members.")
except PeerIdInvalid:
await message.reply("Invalid channel username. Please enter it correctly.")
except Exception as e:
print(f"Error: {e}")
await message.reply(f"An error occurred: {str(e)}")
app.run()
explain more
I couldn't recognise what have you meant of 'information'
Did you mean 'description' ?
Hi and welcome to the group. Before asking any questions, please read the rules from the group's description, and don't forget to read the docs. Make sure you are using the latest version with pip3 install -U telethon, since most problems have already been fixed in newer versions.
Читать полностью…reply message isn't sent by server, so you would need to do await message.get_reply_message()
, but it's a waste of request and reply message could already be deleted anyways and since delete_messages doesn't raise error for that case it's shorter to delete right away by id.
.reply_to isn't library property, it's a raw api thing, which can be None
if message.is_reply:Читать полностью…
await self.bot.client.delete_messages(message.chat_id, message.reply_to_msg_id)
Whats the best way to delete a replied to message? await message.reply_to.delete()
does not work. do i have to get the message.reply_to_msg_id
and delete that manually?
something like
if hasattr(message, 'reply_to'): await self.bot.client.delete(message.reply_to_msg_id)Читать полностью…
you won't know it unless a chat was initiated with you or send a message to them, for obvious privacy reasons
Читать полностью…I tried the same code on Telethon, but there is an error: it collects only 10% of the information of banned people.
Читать полностью…Is there any objection to asking for help with a pyrogram library since it is the same method for making a telethon?
Читать полностью…Hey Ai, don't do that again (offtopic, insults, unnecessarily tagging admins) or I will ban you. You have been warned.
Читать полностью…