ohld / telegram-support-bot

Easy way to use Telegram bot to hide your identity. Useful for support, anonymous channel management. Free clone of Livegram Bot.
https://t.me/danokhlopkov
MIT License
328 stars 268 forks source link

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

Open nuetoban opened 3 years ago

nuetoban commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

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 commented 3 years ago

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

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 commented 3 years ago

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

rus-ai commented 3 years ago

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