Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The bot cannot forward a message when account is hidden for forwarding #1

Open
nuetoban opened this issue Jan 28, 2021 · 5 comments
Open
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@nuetoban
Copy link

The bot won't forward the message to the user when privacy settings like:
image

No error handlers are registered, logging exception.
Traceback (most recent call last):
  File "/home/viktor/.local/lib/python3.8/site-packages/telegram/ext/dispatcher.py", line 432, in process_update
    handler.handle_update(update, self, check, context)
  File "/home/viktor/.local/lib/python3.8/site-packages/telegram/ext/handler.py", line 156, in handle_update
    return self.callback(update, context)
  File "/home/viktor/stuff/telegram-support-bot/handlers.py", line 47, in forward_to_user
    user_id = update.message.reply_to_message.forward_from.id
AttributeError: 'NoneType' object has no attribute 'id'
@ohld ohld added bug Something isn't working good first issue Good for newcomers labels Jan 29, 2021
@ohld
Copy link
Owner

ohld commented Feb 21, 2021

Maybe helpful:

Telegram Update JSON when trying to "reply" to a forwarded message.

{
  "update_id": 471632444,
  "message": {
    "message_id": 3299,
    "date": 1613904069,
    "chat": {
      "id": -392720014,
      "type": "group",
      "title": "test",
      "all_members_are_administrators": true
    },
    "reply_to_message": {
      "message_id": 3297,
      "date": 1613904018,
      "chat": {
        "id": -392720014,
        "type": "group",
        "title": "test",
        "all_members_are_administrators": true
      },
      "forward_date": 1613904018,
      "text": "пп",
      "entities": [],
      "caption_entities": [],
      "photo": [],
      "new_chat_members": [],
      "new_chat_photo": [],
      "delete_chat_photo": false,
      "group_chat_created": false,
      "supergroup_chat_created": false,
      "channel_chat_created": false,
      "forward_sender_name": "Daniil Okhlopkov",
      "from": {
        "id": 1018878145,
        "first_name": "999",
        "is_bot": true,
        "username": "9999"
      }
    },
    "text": "аппп",
    "entities": [],
    "caption_entities": [],
    "photo": [],
    "new_chat_members": [],
    "new_chat_photo": [],
    "delete_chat_photo": false,
    "group_chat_created": false,
    "supergroup_chat_created": false,
    "channel_chat_created": false,
    "from": {
      "id": 49820636,
      "first_name": "Daniil",
      "is_bot": false,
      "last_name": "Okhlopkov",
      "username": "okhlopkov",
      "language_code": "en"
    }
  }
}

@maxver1978
Copy link

У меня в таком виде работает

def forward_to_user(update, context):
    user_id = update.channel_post.reply_to_message.forward_from.id
    context.bot.copy_message(
        message_id=update.channel_post.message_id,
        chat_id=user_id,
        from_chat_id=update.channel_post.chat_id

    )

@MNCTTY
Copy link

MNCTTY commented Apr 29, 2021

у меня не работает в обоих случаях :(
если найду решение, отпишусь

p.s. ошибка возникает даже если акк открыт для пересылки

p.p.s.
кажется, вот здесь проблема
но я пока разбираюсь
"""
:class:telegram.User: The user that sent this update, no matter what kind of update this
is. Will be :obj:None for :attr:channel_post and :attr:poll.
"""

@Nuke142
Copy link

Nuke142 commented Jul 26, 2021

Ничего не изменилось. Перезавёл приложение в Heroku, удалив старое, но как все было, так и осталось - при запрете пересылки сообщений мне не приходят сообщения на мой другой аккаунт. Как только разрешаешь пересылку, то сообщения приходят.

@rus-ai
Copy link
Contributor

rus-ai commented Jul 30, 2021

@Nuke142 - ответил в пулл реквесте. Попробуйте задеплоить из другой ветки.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

6 participants