from telethon import TelegramClient, connection, utils
import asyncio
import socks
import random
import time
from telethon.tl.types import InputPeerChat
import nest_asyncio
nest_asyncio.apply()
B = []
A = ["1", "2", "3", "4"]
b = int(len(A) - 1)
api_id = hash
api_hash = 'id'
async def groups():
global entity
async with TelegramClient('3', api_id, api_hash, proxy=(socks.SOCKS5, 'ip', port, True, 'login', 'pwd')) as client:
async for dialog in client.iter_dialogs():
if dialog.is_group:
print('{:>14}: {}'.format(dialog.id, dialog.title))
entity = await client.get_input_entity(dialog.id)
#print(entity)
B.append(entity)
return B
asyncio.run(groups())
async def main():
for i in B:
u = len(B) - 1
while u != -1:
u -= 1
x = B[u]
print(x)
async with TelegramClient('5', api_id, api_hash, proxy=(socks.SOCKS5, 'ip', port, True, 'login', 'pwd')) as client:
await client.send_message(entity=x, message=str(A[random.randint(0, b)]))
asyncio.run(main())
id, hash, ip, port, login, pwd is correct. I just removed 'em (confident ;p ).
Somehow one variant of this code worked once. I think that the given entity is incorrect.
I tried to type entity manually - didnt work.
[code]from telethon import TelegramClient, connection, utils import asyncio import socks import random import time from telethon.tl.types import InputPeerChat import nest_asyncio nest_asyncio.apply() B = [] A = ["1", "2", "3", "4"] b = int(len(A) - 1) api_id = hash api_hash = 'id' async def groups(): global entity async with TelegramClient('3', api_id, api_hash, proxy=(socks.SOCKS5, 'ip', port, True, 'login', 'pwd')) as client: async for dialog in client.iter_dialogs(): if dialog.is_group: print('{:>14}: {}'.format(dialog.id, dialog.title)) entity = await client.get_input_entity(dialog.id) #print(entity) B.append(entity)
return B asyncio.run(groups()) async def main(): for i in B: u = len(B) - 1 while u != -1: u -= 1 x = B[u] print(x) async with TelegramClient('5', api_id, api_hash, proxy=(socks.SOCKS5, 'ip', port, True, 'login', 'pwd')) as client: await client.send_message(entity=x, message=str(A[random.randint(0, b)])) asyncio.run(main()) [/code] id, hash, ip, port, login, pwd is correct. I just removed 'em (confident ;p ). Somehow one variant of this code worked once. I think that the given entity is incorrect. I tried to type entity manually - didnt work.
Я создаю событие Календаря Google в чате (1:1, групповой чат и пространство).
Создание события Календаря Google в чате
После создания и публикации мероприятия с приглашенными в чат отправляется автоматическое сообщение.
Автоматическое сообщение о...
Я столкнулся с проблемой во время сборки проекта Android в Android Studio. Сборка завершается с ошибкой:
org.w3c.dom.DOMException: INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified.
at...
Я столкнулся с проблемой во время сборки проекта Android в Android Studio. Сборка завершается с ошибкой:
org.w3c.dom.DOMException: INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified.
at...
Я разрабатываю пример Kafka Stream в Java, и при запуске приложения появляется ошибка ниже.
Ошибка:
17:34:38.930 DEBUG org.apache.kafka.clients.NetworkClient -- Received METADATA response from node -1 for request with header...