基础环境搭建
#coding:utf-8from telethon import TelegramClient, sync,eventsimport loggingimport randomimport asyncioimport telethonfrom telethon.tl.types import PeerUser, PeerChat, PeerChannel,UpdateNewChannelMessagefrom telethon.tl.functions.messages import SendMessageRequestfrom telethon.tl import types, functionsfrom telethon import utilsimport reapi_id = {你的id}api_hash = "{你的api_hash}"client = TelegramClient('随便一个名字', api_id, api_hash).start()
获取chat_id
拉人进群
- 不需要别人同意,即可拉入群。
- 可用于发广告,SEO。
from telethon.tl.functions.messages import AddChatUserRequestclient(AddChatUserRequest( chat_id = -269442445 , #chat_id,从上面获取 user_id = 585015279 , #被邀请人id fwd_limit=10 # Allow the user to see the 10 last messages))
参考资料