P
P
PythonWebb2019-10-06 18:46:07
Python
PythonWebb, 2019-10-06 18:46:07

Executing a function 1 time Python?

How can I make a function run only once?

hellos = ["Привет","привет","Здарова","Дарова","Ку","ку","Хай","Хелло","Хеллоу","дарова","Начать"]
@bot.message_handler(content_types=['text'])
def welcome(message):
  for element in hellos:
    if element == message.text:
      bot.send_message(message.chat.id, "Привет, я рад что ты сюда заглянул.")
      return
bot.polling(none_stop = True)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Kulshin, 2019-11-11
@Gramor

What is the point. In your solution, the function is wrapped in a decorator that calls it when new content of type text has flown in. In general, there is a lot of fun with this library, I recommend you to use the vk_api library, I use it in all my projects.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question