telebot
为电报编写机器人并用于此任务Django
。现在我摧毁了我的思绪:(
这是我的views.py
代码:
i = 0
keyboard = telebot.types.InlineKeyboardMarkup()
for fish in Calculator.objects.all():
keyboard.add(
telebot.types.InlineKeyboardButton(text=fish.NameFishRus, callback_data='Lfish' + str(fish.IDfish)))
bot.send_message(chat_id, mes, reply_markup=keyboard)
这也是观点:
if callback_data.find('fish') != -1:
fish_id = int(callback_data[5:])
fish = Calculator.objects.get(IDfish=fish_id)
user.fish = fish
return HttpResponse('OK')
和我的models.py
:
class Calculator(models.Model):
IDfish = models.IntegerField(default = 0, null=True, blank=True)
NameFishRus = models.CharField(max_length=250, null=True, blank = True)
NameFishLat = models.CharField(max_length=250, null=True, blank = True)
NameFishEng = models.CharField(max_length=250, null=True, blank = True)
这是回调按钮。 Buuuuut,当我运行我的机器人时,我会看到下一个:
当我点击按钮时,他们不回答我:(
Heelp pls!
P.S我无法附加标签telebot