--我想要创建一个变量,函数之外的message.chat.id,例如,如下所示的
bot = telebot.teleBot("token")
global message
message = bot.message.chat.id
@bot.message_handler(commands=["start"])
def welcome():
bot.send_message(message,"Welcome on here, pls describe yourself")但是telebot属性错误--消息参数总是必须在函数内部吗?它不能在函数之外成为变量吗?
发布于 2022-11-10 15:06:13
我认为这将是更合适的代码
bot = telebot.teleBot("token")
global message
message = message.chat.id
@bot.message_handler(commands=["start"])
def welcome(message):
global message
bot.send_message(message,"Welcome on here, pls describe yourself")也可以使用bot.reply_to(message,"Hello“),您可以找到完整的docs 这里
https://stackoverflow.com/questions/71208123
复制相似问题