Answer the question
In order to leave comments, you need to log in
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question