如何在Python3上使用telebot发送没有bot.polling()的消息
我需要发送消息,但没有任何轮询。我的机器人不必回复它只需要发送的任何消息如何在Python3上使用telebot发送没有bot.polling()的消息,python,python-3.x,Python,Python 3.x,我需要发送消息,但没有任何轮询。我的机器人不必回复它只需要发送的任何消息 import telebot bot = telebot.TeleBot("TOKEN") @bot.message_handler(commands=['start']) def send_message(message, text): bot.send_message(message.from_user.id, text) text = "Text that I want to be sent" se
import telebot
bot = telebot.TeleBot("TOKEN")
@bot.message_handler(commands=['start'])
def send_message(message, text):
bot.send_message(message.from_user.id, text)
text = "Text that I want to be sent"
send_message(text)
bot.polling()
print("Message has been sent")
这里有两个问题:
bot.send_message(msg_id,“Hello!”)
(msg_id是人的id)将帮助您做到这一点,如果您知道人的id
如果您没有,则可以使用
msg.chat.id
轻松获取,其中msg
是用户发送的消息。到目前为止,您尝试了什么@jalazbe,我用code补充了我的问题,我怎样才能找到我的id?你可以使用这个机器人:@userinfobot
,或者发短信给你自己的机器人,然后获取msg.chat.id