whats wrong in this code i want to send 100 messages in viber using python code

139 Views Asked by At

This is my code. I want to send 100 messages in Viber using Python code, and it gives this error: text_message: TextMessage = TextMessage(text=message, to=recipient) TypeError: TextMessage.init() got an unexpected keyword argument 'to'

i changed 'to' 'to receiver', it still doesn't work


 ''''''

import time
from **********
from *************************
from *******************************

viber = Api(BotConfiguration(
    name='MyBot',
    avatar='http://viber.com/avatar.jpg',
    auth_token='*******************************'
))

message = "Hello"
recipient = "1234567890"

for i in range(100):
    text_message = TextMessage(text=message, to=recipient)

    viber.send_messages(text_message)
    time.sleep(60)  



1

There are 1 best solutions below

0
On

TextMessage only takes one argument: text.

The keywordargument to belongs to the send_messages method.

example:

text_message = TextMessage(text=message)

viber.send_messages(text_message, to=recipient)