Как добавить контакт в телеграм канал Python
Не удаётся добавить контакт в канал. Копался в документации телеги, не совсем понимаю какой путь у InviteToChannel. Буду очень рад, если подскажете! Ниже часть кода:
import asyncio
from pyrogram import Client
from pyrogram.types import InputPhoneContact
from pyrogram.raw.functions.channels import InviteToChannel
api_id = x
api_hash = "x"
app = Client("volt", api_id, api_hash)
with open("numbers.txt") as f:
numbers = f.read().split("\n")
async def step_1():
async with app:
for number in numbers:
try:
await app.import_contacts([InputPhoneContact(number, "Client")])
except:
continue
async def step_2():
async with app:
for number in numbers:
await app.invoke(InviteToChannel(channel="-1001664379827", users=number))
async def step_3():
async with app:
for number in numbers:
try:
await app.delete_contacts(number)
except:
continue
def main():
app.run(step_1())
app.run(step_2())
app.run(step_3())
main()
AttributeError: 'str' object has no attribute 'write'
Источник: Stack Overflow на русском