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

[FR] automatic group creating feature #126

Open
QQ-War opened this issue Aug 26, 2022 · 4 comments
Open

[FR] automatic group creating feature #126

QQ-War opened this issue Aug 26, 2022 · 4 comments

Comments

@QQ-War
Copy link

QQ-War commented Aug 26, 2022

Currently, for each contact or group in slave channel, we need to create new group and use /link command to link out.
I am thinking of some ways to make it automaticly.
I find Pyrogram has this kind of interface and we can make use of it.
The idea is like to at least to change 3 parts in the code:

  1. configuration part and class init, need to use a parameter to enable this feature or not. if enable, need to provide api id and api hash, then initiate the client.
  2. message send out part, need to add some mechanism to check if this chat has already link to a group, othewise will use the interface provided by pyrogram to create one and make the link, then update_info of that group.
  3. database part, currently allow 1 group to link more than 1 slave group. maybe need to change 1 to 1. otherwise, I have not think of an idea how to do it.

There are some other issues may need to consider, but to realize it will make life happy.
I am trying to read the code of this project, and maybe I will offer some help to submit on PR later. but what will others think of it?

@blueset
Copy link
Member

blueset commented Aug 28, 2022

Thank you for the suggestion. Automatically creating a Telegram group while trying to link a slave chat is definitely a great feature to have. However, Telegram does not allow a bot to create groups, no matter if it is using the HTTP interface (via python-telegram-bot) or using MTProto (via Pyrogram, Telethon, etc.). Group creation is only possible for normal users that registered with a phone number.

The only way to incorporate such feature, without any privacy concern, would be to ask the user to setup a “user bot” using their own phone number. Including such feature into ETM would require:

  • Additional steps for new user setup, such as acquiring a pair of client API key and token, and a one-time interactive login.
  • Refactor the entire EH Forwarder Bot framework to use Python’s native async features.
    Currently EFB and most modules are running synchronously, with some parts attempt to run stuff asynchronously using Threads. Including an MTProto library – either Telethon or Pyrogram – would need the bot to be running in Python’s native async.
  • Ideally, since we are bringing an MTProto library, we might as well to let the bot use MTProto too, which removes some limitations that is in the HTTP interface, such as file upload/download size limit.

If you feel this is doable, feel free to send in your PRs. I’m glad to answer any question you might have in mind.

@QQ-War
Copy link
Author

QQ-War commented Aug 31, 2022

Thanks very much .
One friend already prepared one version of code, and test running well , except there are 2 issues, we are not very clear how to solve.
the address is:
https://github.com/QQ-War/efb-telegram-master?organization=QQ-War&organization=QQ-War

issue 1: (solved)
after automatic new created one telegram group, the first message send to this slave group, still will be send by the wechat bot, not inside that group, it is very strange. the code position is below:
https://github.com/QQ-War/efb-telegram-master/blob/21cc99146fa07ae3c1f808268e762c11edcb522c/efb_telegram_master/slave_message.py#L247

issue 2:
to update the group name and group image, better to use update_group_info in ChatBindingManager class, but we are not quite clear how to pass the parameters update and context. so we use the pyrogram itself and create some method. it is not graceful and not very efficient, since sometimes it fails. the code position is below, if possible, better change this function to the same position of issue 1.
https://github.com/QQ-War/efb-telegram-master/blob/21cc99146fa07ae3c1f808268e762c11edcb522c/efb_telegram_master/auto_tg_manager.py#L90

could you help to check? Thanks.

@chern91552
Copy link

@QQ-War Thank you for your development. I want to feed back two bugs

  1. Issue 1 which your marked solved still appears
  2. Some friends can't use update_ Info, show:Chat linked (c941b0c2) is not found in the slave channel (WeChat Slave, blueset. wechat)

@blueset
Copy link
Member

blueset commented Dec 23, 2022

For issue 2, if you already have a user bot, it might be easier to just issue an /update_info command to EFB through the user. Alternatively, you can consider constructing an Update object mimicking an /update_info message sent to the bot. It is technically possible since these objects are constructed from plain JSON objects, but it might require more effort than simply sending a message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants