Reputation: 11
I'm trying to create a supergroup and enable the forums feature, but I get the error
pyrogram.errors.exceptions.bad_request_400.ChannelInvalid: Telegram says: [400 CHANNEL_INVALID] (caused by "channels.ToggleForum") Pyrogram 2.3.48 thinks: The channel parameter is invalid
I looked at the documentation here https://docs.pyrogram.org/telegram/functions/channels/toggle-forum
but I don't understand where I'm going wrong, it creates the supergroup, but it doesn't enable the 'topic' or forum functionality, so I can't even create forums if I wanted to do it via code
from pyrogram import Client
from pyrogram.raw.functions.channels import ToggleForum
from pyrogram.raw.types import InputChannel
# Configura il client Pyrogram con le tue credenziali API
app = Client("my_account", api_id=xxx, api_hash="xxx")
async def create_supergroup():
# Chiedi conferma all'utente
confirmation = input("Vuoi creare un supergruppo chiamato 'Interruttori'? (s/n): ").strip().lower()
if confirmation == 's':
# Crea un supergruppo con il titolo "Interruttori"
supergroup = await app.create_supergroup("Interruttori", "materiale elettrico")
print(f"Supergruppo creato con successo! ID: {supergroup.id}")
# Abilita la funzionalità di forum nel supergruppo
await app.invoke(ToggleForum(
channel=InputChannel(
channel_id=supergroup.id,
access_hash=supergroup.access_hash
),
enabled=True
))
print("Funzionalità di forum abilitata con successo!")
else:
print("Creazione del supergruppo annullata.")
# Avvia il client e crea il supergruppo
with app:
app.run(create_supergroup())
complete error is this
PS C:\Users\Peter\Desktop\scripts\supegruppi> python supegruppo_creatopic.py
Vuoi creare un supergruppo chiamato 'Interruttori'? (s/n): s
Supergruppo creato con successo! ID: -1002400805610
Traceback (most recent call last):
File "C:\Users\Peter\Desktop\scripts\supegruppi\supegruppo_creatopic.py", line 30, in <module>
app.run(create_supergroup())
File "C:\Users\Peter\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyrogram\methods\utilities\run.py", line 78, in run
run(coroutine)
File "C:\Users\Peter\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\Peter\Desktop\scripts\supegruppi\supegruppo_creatopic.py", line 17, in create_supergroup
await app.invoke(ToggleForum(
File "C:\Users\Peter\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyrogram\methods\advanced\invoke.py", line 80, in invoke
r = await self.session.invoke(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Peter\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyrogram\session\session.py", line 420, in invoke
return await self.send(query, timeout=timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Peter\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyrogram\session\session.py", line 377, in send
RPCError.raise_it(result, type(data))
File "C:\Users\Peter\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyrogram\errors\rpc_error.py", line 93, in raise_it
raise getattr(
pyrogram.errors.exceptions.bad_request_400.ChannelInvalid: Telegram says: [400 CHANNEL_INVALID] (caused by "channels.ToggleForum") Pyrogram 2.3.48 thinks: The channel parameter is invalid
Upvotes: 0
Views: 20