I am studying Telethon library for Telegram that can act as a Telegram client using Telegram API (Important: this is Telegram client API, not Bot API).
The functionality I need is creating a group chat and inviting users there. This works fine when I add somebody who is in my contact list:
import telethon
from telethon.tl.functions.messages import CreateChatRequest
client = telethon.TelegramClient('some_session', 'key', '6284f5acf91b03somehash441ac9eef319')
client.start()
client(CreateChatRequest(['+79297226653'], 'Test Group')) # number from my contact list
However, this breaks if the number I pass is not in my contact list (an I am certain this phone number is registered with Telegram)
File "/Users/1111/.virtualenvs/inviter-WB5rPISo/lib/python3.6/site-packages/telethon/telegram_client.py", line 1680, in _get_entity_from_string
'Cannot turn "{}" into any entity (user or chat)'.format(string)
TypeError: Cannot turn "+79291101517" into any entity (user or chat)
My suspicion is that CreateChatRequest
only works for my PeerUser
s, i.e. using non-peer phones is prohibited in this method.
So the question is, how do I add somebody to a group chat if he is not one of my contacts?