A
A
Andriy4262021-07-21 20:21:33
Python
Andriy426, 2021-07-21 20:21:33

How to make the bot write to the user when sending the first message?

When sending a message, a bot can send a message only to the user who has already started a dialogue with him. For some reason, the first bot cannot write. Help decide.

JoinedFile = open('C:/Users/Andro/id.txt', 'r')
JoinedUsers = set ()

for line in JoinedFile:
    JoinedUsers.add(line.strip())
JoinedFile.close()

@bot.message_handler(commands=['storeget'])
def mail(message):
    try:
        for user in JoinedUsers:
            bot.send_message(user, message.text[message.text.find(' '):])
    except:
        pass

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-07-21
@Andriy426

why can't he write

Because telegram does not allow spamming everyone in a PM, so no way (thank you)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question