LonamiWebs / Telethon

Pure Python 3 MTProto API Telegram client library, for bots too!
https://docs.telethon.dev
MIT License
10.01k stars 1.41k forks source link

Error Sending Messages #3228

Closed labvilse closed 2 years ago

labvilse commented 2 years ago

Checklist

Code that causes the issue

time.sleep(3)

Abre el fichero con los Id's

fichero="D:\Proyectos\idtelegram_sergi\members_name.csv" fentrada=open(fichero,'r') usuario_old='Javivi' usuario_ultimo='Javivi'

Para cada usuario

for usuario in fentrada:

try:

    #Envio del mensaje
    #client.send_message(int(usuario), message, parse_mode='html')
    if usuario != usuario_old:
        m1 = random.randint(0, 3)
        m2 = random.randint(0, 3) 
        m3 = random.randint(0, 3)
        m4 = random.randint(0, 3)
        emoticono1 = random.randint(0, (num_emoticonos-1))
        emoticono2 = random.randint(0, (num_emoticonos-1))
        emoticono3 = random.randint(0, (num_emoticonos-1))
        emo1 = lista_emoticonos[emoticono1]
        emo2 = lista_emoticonos[emoticono2]
        emo3 = lista_emoticonos[emoticono3]
        misatge =  emo1 + mensaje1[m1] + mensaje2[m2] + emo2 + mensaje3[m3] + emo3 + mensaje4[m4]
        usuario_envio= client.get_input_entity(usuario)
        print(usuario_envio)
        time.sleep(60)
        client.send_message(usuario_envio, misatge , parse_mode='html')
        usuario_old=usuario
        time.sleep(60)
        print(usuario)
        usuario_ultimo=usuario

#except:
#   print('No se ha podido enviar el mensaje')
#   print(usuario_ultimo)

fentrada.close()

...


**Traceback**
I'm trying to send messages to users, but only works with the known users. I saved previously one file with different usernames, some are known and others exists but i have not contact with they. With this last ones i have problems, an exception occurs.

Why? 

InputPeerUser(user_id=1911315585, access_hash=-1291217305039290110)
Traceback (most recent call last):
  File "D:\Proyectos\idtelegram_sergi\mensajes_masivos.py", line 81, in <module>
    client.send_message(usuario_envio, misatge , parse_mode='html')
  File "D:\Programas_instalados\phyton\lib\site-packages\telethon\sync.py", line 39, in syncified
    return loop.run_until_complete(coro)
  File "D:\Programas_instalados\phyton\lib\asyncio\base_events.py", line 642, in run_until_complete
    return future.result()
  File "D:\Programas_instalados\phyton\lib\site-packages\telethon\client\messages.py", line 872, in send_message
    result = await self(request)
  File "D:\Programas_instalados\phyton\lib\site-packages\telethon\client\users.py", line 30, in __call__
    return await self._call(self._sender, request, ordered=ordered)
  File "D:\Programas_instalados\phyton\lib\site-packages\telethon\client\users.py", line 84, in _call
    result = await future
telethon.errors.rpcerrorlist.PeerFloodError: Too many requests (caused by SendMessageRequest)
Lonami commented 2 years ago

The account is restricted. Mass messaging new users is considered spam.