SaveRestrictedContentBot icon indicating copy to clipboard operation
SaveRestrictedContentBot copied to clipboard

Error: local variable 'msg' referenced before assignment

Open RuyeNet opened this issue 2 years ago • 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

RuyeNet avatar Jul 03 '23 13:07 RuyeNet

docker logs SaveRestrictedContentBot starting Bot ~@DroneBots

RuyeNet avatar Jul 03 '23 13:07 RuyeNet

https://t.me/CocoSaveRestrictedContentBot

RuyeNet avatar Jul 03 '23 13:07 RuyeNet

https://github.com/vasusen-code/SaveRestrictedContentBot/issues/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 avatar Jul 06 '23 17:07 RuyeNet

@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.

RanceZero avatar Jul 12 '23 02:07 RanceZero

@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.

RuyeNet avatar Jul 12 '23 02:07 RuyeNet

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

RanceZero avatar Jul 16 '23 04:07 RanceZero

@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?

abdullayevich avatar Aug 25 '23 12:08 abdullayevich

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 !

timgahmencoding avatar Aug 25 '23 19:08 timgahmencoding

@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.

RanceZero avatar Aug 27 '23 17:08 RanceZero

#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

timgahmen avatar Sep 22 '23 13:09 timgahmen