1

With a python based telegram bot that should help to setup group settings I want to hide/unhide the message history for new group subscribers. I am using the python-telegram-bot API wrapper (documented here).

For setting other permissions there is a method Bot.set_chat_permissions(). But for hide/unhide message history I found no method.

However, in the telegram API documentation there is an endpoint channels.togglePreHistoryHidden, that should do exactly what I want. But I could not figure out how to use that via python-telegram-bot.

Another user has asked a similar question, but related to telethon.

Any hints are appreciated.

sof
  • 33
  • 7
  • When manually changing the "Chat history for new members" setting to "Visible" in the telegram PC client, the chat id changes and the type changes from 'group' to 'supergroup'. Also my bot looses its status as administrator. – sof Nov 30 '22 at 05:37
  • The python-telegram-bot doc says for the service message 'supergroup_chat_created' : 'This field can’t be received in a message coming through updates, because bot can’t be a member of a supergroup when it is created'. https://docs.python-telegram-bot.org/en/v13.14/telegram.message.html So if changing the message history visibility to "Visible" entails that the group is converted into a supergroup, and the bot looses its admin rights in the process - is it even possible to accomplish what I want with the bot? – sof Nov 30 '22 at 05:59

1 Answers1

1

python-telegram-bot is a wrapper for the Bot API. Only those methods listed in the API docs have a counterpart in python-telegram-bot. The togglePreHistoryHidden method is an endpoint of the Telegram API != Bot API.


Disclaimer: I'm currently the maintainer of python-telegram-bot.

CallMeStag
  • 5,467
  • 1
  • 7
  • 22
  • So is it bot impossible to call togglePreHistoryHidden and only works for normal accounts? Or could a bot call this endpoint in the Telegram API? – sof Dec 02 '22 at 14:52
  • 1
    At least not via the bot API. I'm not familiar with using bots directly though the Telegram API, it may be that it's possible that way (but I doubt it) – CallMeStag Dec 02 '22 at 15:21