-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeywarden_messenger_bot.py
39 lines (30 loc) · 1.1 KB
/
keywarden_messenger_bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import telebot
from telebot import types
from dotenv import load_dotenv
import os
load_dotenv()
TOKEN = os.getenv("KEYWARDEN_TOKEN")
# create the bot
bot = telebot.TeleBot(TOKEN)
@bot.message_handler(commands=['start'])
def start(message):
# Create a dynamic keyboard with buttons based on your data
keyboard = create_dynamic_keyboard()
# Send a message with the dynamic keyboard
bot.send_message(message.chat.id, "Choose an option:", reply_markup=keyboard)
def create_dynamic_keyboard():
# Simulate dynamic data for the buttons (replace this with your data)
button_labels = ["Button 1", "Button 2", "Button 3"]
# Create a ReplyKeyboardMarkup
# keyboard = types.ReplyKeyboardMarkup(row_width=1, resize_keyboard=True)
keyboard = types.InlineKeyboardMarkup()
for label in button_labels:
button = types.InlineKeyboardButton(label, callback_data=label)
keyboard.add(button)
return keyboard
@bot.message_handler(func=lambda message: True)
def handle_messages(message):
# Handle other messages if needed
pass
if __name__ == "__main__":
bot.polling()