I've written a regex so when a user writes in the chat "Kosovo", my bot will send him an audio and a text.
regex = "k+o+s+o+v+o"
try:
nick = update.message.from_user.username
if re.search(regex, contLower):
chatid = update.message.chat.id
audio1 = "/Users/rikardo/Documents/ANGELO/Programmare/Prove di basi/Mat/SUONI/KosovoBello.ogg"
update.message.reply_audio(audio=open(audio1, "rb"))
update.message.reply_text("Stay tuned, @PadriFibra")
return
except Exception as err:
print(err)
return
Then I added this:
print(strftime("%H:%M:%S -")," "+(nick)+" triggered KosovoBello")
and the result was this:
regex = "k+o+s+o+v+o"
try:
nick = update.message.from_user.username
if re.search(regex, contLower):
chatid = update.message.chat.id
audio1 = "/Users/rikardo/Documents/ANGELO/Programmare/Prove di basi/Mat/SUONI/KosovoBello.ogg"
update.message.reply_audio(audio=open(audio1, "rb"))
update.message.reply_text("Stay tuned, @PadriFibra")
print(strftime("%H:%M:%S -")," "+(nick)+" triggered KosovoBello")
return
except Exception as err:
print(err)
return
But when I try to start the bot, the console says this:
$ python3 /Users/rikardo/Documents/ANGELO/Programmare/Prove\ di\ basi/Mat/prova.py
File "/Users/rikardo/Documents/ANGELO/Programmare/Prove di basi/Mat/prova.py", line 107
regex = "k+o+s+o+v+o"
^
SyntaxError: invalid syntax