我使用telebot库构建了一个简单的电报机器人,它已经成功运行了!然后我把机器人加入一个电报频道,它不起作用了!另外,我把同一个机器人添加到一个电报组中,然后它就开始工作了!我有点搞不懂为什么电报机器人不在我的电报频道工作?有人能帮我渡过难关吗?
这是我的密码。
import telebot
from constatnts import API_KEY
bot = telebot.TeleBot(API_KEY, parse_mode=None)
@bot.message_handler(commands=['help', 'hello'])
def send_help_message(msg):
bot.reply_to(msg, "Hello this is test bot for ml5")
print(msg)
@bot.message_handler(func=lambda msg: msg.content_type == 'text' )
def send_message(msg):
bot.reply_to(msg, "Gotcha")
bot.polling()
发布于 2021-12-14 06:20:37
IIRC、消息和通道帖子有不同的处理程序:
@bot.channel_post_handler(commands=['help', 'hello'])
还要确保bot是通道的管理员。
发布于 2021-12-14 06:27:14
import telebot
from constatnts import API_KEY
bot = telebot.TeleBot(API_KEY, parse_mode=None)
@bot.channel_post_handler(commands=['help', 'hello'])
def send_help_message(msg):
bot.reply_to(msg, "Hello this is test bot for ml5")
print(msg)
@bot.message_handler(func=lambda msg: msg.content_type == 'text' )
def send_message(msg):
bot.reply_to(msg, "Gotcha")
bot.polling()
https://stackoverflow.com/questions/70107369
复制相似问题