0

I'm using the Madeline Project to automate some activities in the telegram communities. Bots are not suitable to do these tasks due to the restrictions they have. So I'm trying to use normal user accounts.

Everything works smoothly with some types of channels but with the chats I'm encountering some problems.

There are two ways to join a chat/channel. With the TelegramID and with the HASH.

With the HASH is pretty simple, I use this function and works like a charm: $MadelineProto->messages->importChatInvite(['hash' => <HASH_CODE>, ]);

But with the Telegram's IDs the things gets complicate. Because a Telegram ID can identify a Chat OR a Channel Group

Normally I use this function: $MadelineProto->channels->joinChannel(['channel' => <Telegram_ID>, ]); But it fails when the target of the ID is a chat and not a channel.

There isn't any function to join a Chat in MadelineProto. How can I do?

Sorry but the project is very poorly documented. Thank you all.

Dileep Kumar
  • 1,077
  • 9
  • 14
Univers3
  • 935
  • 1
  • 13
  • 34

2 Answers2

1

The only way to join chats without a username is to use importChatInvite.

And I'm sorry about the lack of documentation, I'm not the one maintaining it, telegram should be the one doing that, but unfortunately, they stopped doing that quite a while ago.

Danogentili
  • 664
  • 7
  • 13
  • 1
    You made an amazing work @Danogentili. I can only say thank you. My problem is when the Chat HAVE an username. I cannot use joinChannel because its a Chat. I cannot use importChatInvite because it have a Username. What I have to do? – Univers3 Aug 29 '17 at 14:14
0

It is possible first u should do this

$MadelineProto->contacts->resolveUsername

And lookup by username

$Updates = $MadelineProto->contacts->addContact()

Add rhe contacr in Phone book

$Updates = $MadelineProto->channels->inviteToChannel(['channel' =>...

Latest invite user to channel

All should be done in same script bcs otherwise u will have error... In first one resolveUsername u should use username in the other 2 (updates u should use his id)

jizhihaoSAMA
  • 12,336
  • 9
  • 27
  • 49