bipinkrish / Save-Restricted-Bot

A Telegram Bot, Which can send you restricted content by it's post link
201 stars 406 forks source link

Problem with Save Restricted Content #22

Closed greyhat94 closed 11 months ago

greyhat94 commented 11 months ago

I was having trouble getting the bot string, so I decided to use Pyrogram to get it. I used this code in python:

from pyrogram import Client

def get_session_string(api_id, api_hash, bot_token):
    session_name = "my_bot.session"  # Nome del file del database della sessione
    app = Client(session_name, api_id=api_id, api_hash=api_hash, bot_token=bot_token)
    with app:
        return app.export_session_string()

if __name__ == "__main__":
    # Sostituisci con i tuoi dati
    API_ID = ""
    API_HASH = ""
    BOT_TOKEN = ""

    session_string = get_session_string(API_ID, API_HASH, BOT_TOKEN)
    print(f"Pyrogram session string: {session_string}")

Everything went like clockwork: I managed to get the string and entered this into the 'config.json' file. I start the bot via the command 'python main.py', and everything runs smoothly. However, as soon as I send the bot a link to a private channel post, it returns this message: "Error : Telegram says: [400 CHANNEL_INVALID] - The channel parameter is invalid (caused by "channels.GetChannels")". How do I solve this problem?

bipinkrish commented 11 months ago

Did you test the string by sending a message

greyhat94 commented 11 months ago

What do you mean? I didn't understand. I just sent a message to the bot containing the link to the private post, and it returned the above error. Did I do something wrong? Should I have tested the string? If so, how? I thank you if you would like to help me.

bipinkrish commented 11 months ago

No, did you used the session string in one of your program to test if the exported string is valid

On Mon, 23 Oct, 2023, 6:56 pm greyhat94, @.***> wrote:

What do you mean? I didn't understand. I just sent a message to the bot containing the link to the private post, and it returned the above error. Did I do something wrong? Should I have tested the string? If so, how? I thank you if you would like to help me.

— Reply to this email directly, view it on GitHub https://github.com/bipinkrish/Save-Restricted-Bot/issues/22#issuecomment-1775193318, or unsubscribe https://github.com/notifications/unsubscribe-auth/AU2SNYA2K37PW7NBR6MQR3LYAZWBNAVCNFSM6AAAAAA6MCDQ2WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZVGE4TGMZRHA . You are receiving this because you commented.Message ID: @.***>

greyhat94 commented 11 months ago

No, I don't know how to do that. How should I test the validity of my string? I thought the string was valid since it was generated by Pyrogram.

bipinkrish commented 11 months ago

Login with that and try sending a message, also show me a screenshot of the chat with your bot

greyhat94 commented 11 months ago

How do I log in with that? When I send links to public channel posts, the bot manages to download the various contents quickly and smoothly. On the other hand, when I try to send links to private channel posts, the bot returns the above error.

bipinkrish commented 11 months ago

Using Pyrogram

greyhat94 commented 11 months ago

How can I log with this? Thank you for your availability. I've tried using Replit, but it didn't work. This was the error:

Traceback (most recent call last):
  File "main.py", line 54, in <module>
    main()
  File "main.py", line 17, in main
    with Client(":memory:", api_id=APP_ID, api_hash=API_HASH) as app:
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pyrogram/client.py", line 251, in __enter__
    return self.start()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pyrogram/sync.py", line 66, in async_to_sync_wrap
    return loop.run_until_complete(coroutine)
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pyrogram/methods/utilities/start.py", line 52, in start
    is_authorized = await self.connect()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pyrogram/methods/auth/connect.py", line 39, in connect
    await self.load_session()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pyrogram/client.py", line 689, in load_session
    await Auth(
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pyrogram/session/auth.py", line 254, in create
    raise e
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pyrogram/session/auth.py", line 89, in create
    res_pq = await self.send(raw.functions.ReqPqMulti(nonce=nonce))
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pyrogram/session/auth.py", line 67, in send
    return self.unpack(response)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pyrogram/session/auth.py", line 60, in unpack
    return TLObject.read(b)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pyrogram/raw/core/tl_object.py", line 33, in read
    return cast(TLObject, objects[int.from_bytes(b.read(4), "little")]).read(b, *args)
KeyError: 0

greyhat94 commented 11 months ago

I tried to authenticate with the help of Pyrogram, using a Telegram bot to generate a string. The authentication was successful. However, when I send a message to the bot, the bot replies with this error: "Telegram says: [400 MESSAGE_EMPTY] - The message sent is empty or contains invalid characters (caused by "messages.SendMessage")". As previously mentioned, I have no problem downloading posts from public channels. In fact, the above-mentioned error only occurs when I send a link to a post from a private channel of which I am a member. For the sake of completeness, I also attach a screenshot of my chat with the bot. photo_2023-10-24_18-04-05

Please let me know how to solve this problem.

bipinkrish commented 11 months ago

Session string will not be used for public chats hence it working

bipinkrish commented 11 months ago

I will make a new replit soon

greyhat94 commented 11 months ago

Okay. So, should I stop using the current string and wait for you to do a new Replit? I rely on your help and hope to receive your feedback as soon as possible. Thank you for your availability and for your prompt response.

Il mer 25 ott 2023, 09:09 Bipin @.***> ha scritto:

Session string will not be used for public chats hence it working

— Reply to this email directly, view it on GitHub https://github.com/bipinkrish/Save-Restricted-Bot/issues/22#issuecomment-1778647494, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3DK2XIFIO2N66AC6ZM5BPTYBC3KVAVCNFSM6AAAAAA6MCDQ2WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZYGY2DONBZGQ . You are receiving this because you authored the thread.Message ID: @.***>

Feastsandfires commented 11 months ago

Was this solved? Because I'm getting the same problem with private channels, even if a member. Getting _ERROR [400 CHANNELINVALID] - The channel parameter is invalid (caused by "channels.GetChannels").

greyhat94 commented 11 months ago

No, it wasn't solved. I'm waiting for the developer to fix this issue. I hope that this problem will be solved soon, as this bot is really powerful, and I love it.

Il giorno mer 25 ott 2023 alle ore 18:40 Feastsandfires < @.***> ha scritto:

Was this solved? Because I'm getting the same problem with private channels, even if a member. Getting ERROR [400 CHANNEL_INVALID] - The channel parameter is invalid (caused by "channels.GetChannels").

— Reply to this email directly, view it on GitHub https://github.com/bipinkrish/Save-Restricted-Bot/issues/22#issuecomment-1779662093, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3DK2XJ25D3AB77EUN5TTT3YBE6GRAVCNFSM6AAAAAA6MCDQ2WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZZGY3DEMBZGM . You are receiving this because you authored the thread.Message ID: @.***>

greyhat94 commented 11 months ago

Another error I'm getting with other private channel of which I'm member is the following: «Telegram says: [400 MESSAGE_EMPTY] - The message sent is empty or contains invalid characters (caused by "messages.SendMessage")».

Feastsandfires commented 11 months ago

No, it wasn't solved. I'm waiting for the developer to fix this issue. I hope that this problem will be solved soon, as this bot is really powerful, and I love it. Il giorno mer 25 ott 2023 alle ore 18:40 Feastsandfires < @.***> ha scritto:

Ah, ok. Thanks for the reply.

Feastsandfires commented 11 months ago

Another error I'm getting with other private channel of which I'm member is the following: «Telegram says: [400 MESSAGE_EMPTY] - The message sent is empty or contains invalid characters (caused by "messages.SendMessage")».

Oh, I haven’t gotten this one. Just the other one about the channel being invalid. It happens with private channels already a member of. Not sure why.

greyhat94 commented 11 months ago

Another error I'm getting with other private channel of which I'm member is the following: «Telegram says: [400 MESSAGE_EMPTY] - The message sent is empty or contains invalid characters (caused by "messages.SendMessage")».

Oh, I haven’t gotten this one. Just the other one about the channel being invalid. It happens with private channels already a member of. Not sure why.

Depending on the private channel, I get the first or second error. I hope this problem will be resolved as soon as possible.

bipinkrish commented 11 months ago

Replit is updated, check now

bipinkrish commented 11 months ago

idk why isnt working on replit, use that locally

greyhat94 commented 11 months ago

Come hai fatto a usare Replit localmente? Ok. Ora, provo a ottenere una nuova stringa.

Il ven 27 ott 2023, 09:10 Bipin @.***> ha scritto:

idk why isnt working on replit, use that locally

— Reply to this email directly, view it on GitHub https://github.com/bipinkrish/Save-Restricted-Bot/issues/22#issuecomment-1782411305, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3DK2XM2OJTEYGO36UNU5ITYBNM5DAVCNFSM6AAAAAA6MCDQ2WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBSGQYTCMZQGU . You are receiving this because you authored the thread.Message ID: @.***>

bipinkrish commented 11 months ago

Come hai fatto a usare Replit localmente? Ok. Ora, provo a ottenere una nuova stringa.

I mean copy the file contents and run locally

greyhat94 commented 11 months ago

Should I copy even the files 'poetry.lock' and 'pyproject.toml'?

Il ven 27 ott 2023, 13:29 Bipin @.***> ha scritto:

Come hai fatto a usare Replit localmente? Ok. Ora, provo a ottenere una nuova stringa.

Il ven 27 ott 2023, 09:10 Bipin @.***> ha scritto:

idk why isnt working on replit, use that locally

— Reply to this email directly, view it on GitHub

22 (comment)

https://github.com/bipinkrish/Save-Restricted-Bot/issues/22#issuecomment-1782411305 , or unsubscribe

https://github.com/notifications/unsubscribe-auth/A3DK2XM2OJTEYGO36UNU5ITYBNM5DAVCNFSM6AAAAAA6MCDQ2WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBSGQYTCMZQGU . You are receiving this because you authored the thread.Message ID: @.***>

I mean copy the file contents and run locally

— Reply to this email directly, view it on GitHub https://github.com/bipinkrish/Save-Restricted-Bot/issues/22#issuecomment-1782753903, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3DK2XPQH3SRWYR6BWKKNVLYBOLJRAVCNFSM6AAAAAA6MCDQ2WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBSG42TGOJQGM . You are receiving this because you authored the thread.Message ID: @.***>

bipinkrish commented 11 months ago

Should I copy even the files 'poetry.lock' and 'pyproject.toml'?

Don't you experience with python? You only need main.py

greyhat94 commented 11 months ago

Yes, I got it! I was able to login. Now, I am going to test the bot. Yes, I have some experience with it.

Il ven 27 ott 2023, 14:12 Bipin @.***> ha scritto:

Should I copy even the files 'poetry.lock' and 'pyproject.toml'?

Don't you experience with python? You only need main.py

— Reply to this email directly, view it on GitHub https://github.com/bipinkrish/Save-Restricted-Bot/issues/22#issuecomment-1782811268, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3DK2XMGKKJOAGY7RESXRR3YBOQL7AVCNFSM6AAAAAA6MCDQ2WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBSHAYTCMRWHA . You are receiving this because you authored the thread.Message ID: @.***>

greyhat94 commented 11 months ago

Now, I can download content from a good number of private channels. However, with one private channel in particular (I don't know why), I get the following message: 'Error : Telegram says: [400 CHANNEL_INVALID] - The channel parameter is invalid (caused by "channels.GetChannels")'.

I tried to start it not from my main account, i.e. the one with which I created the bot, but from another one. I don't think this is the cause of the above-mentioned error, also because I only got this response after I had sent the link to the post of a specific channel.

Anyway, I will now try the same operation from my main account, making sure I am added to the channel whose content I want to get, and I will inform you of the outcome. In the meantime, if you have any further suggestions, please do not hesitate to share them with me.

bipinkrish commented 11 months ago

You have to be in that channel to work or first you need to send an invite link to the bot

Feastsandfires commented 11 months ago

Now, I can download content from a good number of private channels. However, with one private channel in particular (I don't know why), I get the following message: 'Error : Telegram says: [400 CHANNEL_INVALID] - The channel parameter is invalid (caused by "channels.GetChannels")'.

I tried to start it not from my main account, i.e. the one with which I created the bot, but from another one. I don't think this is the cause of the above-mentioned error, also because I only got this response after I had sent the link to the post of a specific channel.

Anyway, I will now try the same operation from my main account, making sure I am added to the channel whose content I want to get, and I will inform you of the outcome. In the meantime, if you have any further suggestions, please do not hesitate to share them with me.

How did you run the replit locally? I can't even find any files to copy. Because when I run the replit link by author and enter the variables, I get an error. Doesn't work. I get KeyError: 0. Exit status 1.

bipinkrish commented 11 months ago

How did you run the replit locally? I can't even find any files to copy. Because when I run the replit link by author and enter the variables, I get an error. Doesn't work. I get KeyError: 0. Exit status 1.

i update it to gist, use that

Feastsandfires commented 11 months ago

How did you run the replit locally? I can't even find any files to copy. Because when I run the replit link by author and enter the variables, I get an error. Doesn't work. I get KeyError: 0. Exit status 1.

i update it to gist, use that

Thank you. Unfortunately, it's still not printing a string. I only see my api_id that is printed, and it doesn't show anything else.

bipinkrish commented 11 months ago

Thank you. Unfortunately, it's still not printing a string. I only see my api_id that is printed, and it doesn't show anything else.

What?, i don't understand.

Feastsandfires commented 11 months ago

Thank you. Unfortunately, it's still not printing a string. I only see my api_id that is printed, and it doesn't show anything else.

What?, i don't understand.

When i debug run the code, main.py, with hash and id, what prints out is only the id again. Nothing else after. It says, "Telegram String Generator my API_id."

bipinkrish commented 11 months ago

When i debug run the code, main.py, with hash and id, what prints out is only the id again. Nothing else after. It says, "Telegram String Generator my API_id."

It is waiting for your input, you have to enter API ID

bipinkrish commented 11 months ago

I will close this, reopen if needed

Feastsandfires commented 11 months ago

When i debug run the code, main.py, with hash and id, what prints out is only the id again. Nothing else after. It says, "Telegram String Generator my API_id."

It is waiting for your input, you have to enter API ID

I did. I put in both id and hash, and it gives me back my id again as the string. Strange.

greyhat94 commented 11 months ago

I sent a message to the bot with the link to the channel, and the bot replied like this: "Error : Telegram says: [400 USER_ALREADY_PARTICIPANT] - The user is already a participant of this chat (caused by "messages.ImportChatInvite")".

So, it means that I am already a member of the channel; however, when I go to resubmit the link to the channel post, I still get the same error as before, which is as follows: "Error : Telegram says: [400 MESSAGE_EMPTY] - The message sent is empty or contains invalid characters (caused by "messages.SendMessage")".

This only happens to me with one particular channel. I don't know if I experience the same inconvenience with others. I hope this will be resolved.

bipinkrish commented 11 months ago

Get the latest version

greyhat94 commented 11 months ago

Should I, therefore, download the bot again and reconfigure it? OK, I will do that.

greyhat94 commented 11 months ago

OK. Now, the bot seems to be working. I have noticed that when I send the link to the bot, I get the same URL in the command prompt window, as well as the fact that an empty 'Download' subdirectory is created in the bot's directory. How does this work? Do I have the option of saving the files, i.e. videos and photos, on my PC? If yes, how? Thank you for making the necessary corrections and for taking the time to improve your script. I will be sure to inform you if I notice any malfunctions or problems, but I don't think this will happen. I look forward to your feedback and thank you in advance.

Feastsandfires commented 11 months ago

It works now. Thanks. My string didn't change, but something in the code (I recloned it) worked. Super. (^^🖒)