vasusen-code/SaveRestrictedContentBot

Error: local variable 'msg' referenced before assignment

RuyeNet opened this issue ยท 10 comments

I sent the bot a link, and the bot responded with the following:

Failed to save: https://t.me/********/********

Error: local variable 'msg' referenced before assignment

docker logs SaveRestrictedContentBot
starting Bot ~@DroneBots

#99

add the following code:

msg = await userbot.get_messages(chat, msg_id)

after

    if 't.me/c/' in msg_link: #...
    else:  
        edit = await client.edit_message_text(sender, edit_id, "Cloning.")  
        chat = msg_link.split("/")[-2]  
        # <add to here>  <<<
        try: # ...  

in main/plugins/pyroplug.py

@RuyeNet I am having the same error.

Why did you link that code? Did it fix it for you? For me it changes to this error with that code:
[WARNING/2023-07-12 02:29:41,987] pyrogram.types.messages_and_media.message: Empty messages cannot be copied.

@RuyeNet I am having the same error.

Why did you link that code? Did it fix it for you? For me it changes to this error with that code: [WARNING/2023-07-12 02:29:41,987] pyrogram.types.messages_and_media.message: Empty messages cannot be copied.

This is a different error.
It can only be used for channels, not groups.
The group's link displays empty messages.

I am sorry, you are correct. It worked for channels after the change you proposed.

@RuyeNet I am having the same error.
Why did you link that code? Did it fix it for you? For me it changes to this error with that code: [WARNING/2023-07-12 02:29:41,987] pyrogram.types.messages_and_media.message: Empty messages cannot be copied.

This is a different error. It can only be used for channels, not groups. The group's link displays empty messages.

Did the bot work?

I sent the bot a link, and the bot responded with the following:

Failed to save: https://t.me/********/********

Error: local variable 'msg' referenced before assignment

I have the same error !

@RuyeNet I am having the same error.
Why did you link that code? Did it fix it for you? For me it changes to this error with that code: [WARNING/2023-07-12 02:29:41,987] pyrogram.types.messages_and_media.message: Empty messages cannot be copied.

This is a different error. It can only be used for channels, not groups. The group's link displays empty messages.

Did the bot work?

Yes, the bot did work after the changes proposed by RuyeNet.

#99

add the following code:

msg = await userbot.get_messages(chat, msg_id)

after

    if 't.me/c/' in msg_link: #...
    else:  
        edit = await client.edit_message_text(sender, edit_id, "Cloning.")  
        chat = msg_link.split("/")[-2]  
        # <add to here>  <<<
        try: # ...  

in main/plugins/pyroplug.py

This solve the same problem from the post befor for me ๐Ÿ‘๐Ÿ‘๐Ÿ‘

Should be implemented in the main code of the bot