-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.py
64 lines (52 loc) · 2.82 KB
/
start.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import telebot
import os
from dotenv import load_dotenv
from telebot import types
load_dotenv()
API_TOKEN = os.getenv("TELEGRAM_BOT_TOKEN")
bot = telebot.TeleBot(API_TOKEN)
@bot.message_handler(func=lambda message: True)
def start(message):
markup = types.InlineKeyboardMarkup()
button = types.InlineKeyboardButton("Начнем!", callback_data='step2')
markup.add(button)
with open("./games/test_game/1.md", "r", encoding="utf-8") as file:
with open("./games/test_game/1.jpeg", "rb") as photo:
bot.send_photo(message.chat.id, photo)
markdown_content = file.read()
bot.send_message(message.chat.id, markdown_content, parse_mode="Markdown", reply_markup=markup)
@bot.callback_query_handler(func=lambda call: True)
def callback_handler(call):
markup = types.InlineKeyboardMarkup()
if call.data == 'step2':
with open("./games/test_game/2.md", "r", encoding="utf-8") as file:
with open("./games/test_game/2.jpeg", "rb") as photo:
bot.send_photo(call.message.chat.id, photo)
markdown_content = file.read()
button1 = types.InlineKeyboardButton("Опция 1", callback_data='step3.1')
button2 = types.InlineKeyboardButton("Опция 2", callback_data='step3.2')
markup.add(button1, button2)
bot.send_message(call.message.chat.id, markdown_content, parse_mode="Markdown", reply_markup=markup)
elif call.data == 'step3.1':
with open("./games/test_game/3.1.md", "r", encoding="utf-8") as file:
with open("./games/test_game/3.1.jpeg", "rb") as photo:
bot.send_photo(call.message.chat.id, photo)
markdown_content = file.read()
button = types.InlineKeyboardButton("В конец", callback_data='step4')
markup.add(button)
bot.send_message(call.message.chat.id, markdown_content, parse_mode="Markdown", reply_markup=markup)
elif call.data == 'step3.2':
with open("./games/test_game/3.2.md", "r", encoding="utf-8") as file:
with open("./games/test_game/3.2.jpeg", "rb") as photo:
bot.send_photo(call.message.chat.id, photo)
markdown_content = file.read()
button = types.InlineKeyboardButton("В конец", callback_data='step4')
markup.add(button)
bot.send_message(call.message.chat.id, markdown_content, parse_mode="Markdown", reply_markup=markup)
elif call.data == 'step4':
with open("./games/test_game/4.md", "r", encoding="utf-8") as file:
with open("./games/test_game/4.jpeg", "rb") as photo:
bot.send_photo(call.message.chat.id, photo)
markdown_content = file.read()
bot.send_message(call.message.chat.id, markdown_content, parse_mode="Markdown", reply_markup=markup)
bot.polling()