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