F
F
fandorin_official2019-07-22 23:00:50
Python
fandorin_official, 2019-07-22 23:00:50

How to trigger the telegram bot to send a message through a function?

There is a function:

@bot.message_handler(commands=['start'])
def start_message(message):
    bot.send_message(message.chat.id,  'Example + '/start')

Through which I can, by sending the /start command to the bot, get a response from him.
And how can I implement a function so that by calling it, let's say this:
def result():
    return 2 + 2;
def send_message(result)

so that at a certain moment the bot sends a message?
What might the send_message() function look like ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Maslov, 2019-08-01
@bziker

In python, it seems that you can pass a function as an argument, but what is the actual problem?
Need a chat timer? To write 32 and he texted you 32 seconds later? What framework do you use?
Here is the solution I like (I use this framework, this solution works 100%):
https://github.com/python-telegram-bot/python-tele...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question