-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
66 lines (49 loc) · 1.91 KB
/
main.py
File metadata and controls
66 lines (49 loc) · 1.91 KB
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
65
66
from telegram import Update, InlineKeyboardMarkup, InlineKeyboardButton
from telegram.ext import Updater, CommandHandler, CallbackQueryHandler
import json
# Paste your Telegram bot token here
TOKEN = "Your Telegram Bot Token: FAKSJFLAKSHFKJAHSŞDJASDKAJSD"
# main menu command
def start(update, context):
chat_id = update.effective_chat.id
user_id = update.effective_user.id
keyboard = [
[InlineKeyboardButton("Seçenek 1", callback_data='option1')],
[InlineKeyboardButton("Seçenek 2", callback_data='option2')],
[InlineKeyboardButton("Seçenek 3", callback_data='option3')]
]
reply_markup = InlineKeyboardMarkup(keyboard)
context.bot.send_message(chat_id=chat_id,
text="Ana menü",
reply_markup=reply_markup)
# Button callback handler
def button(update, context):
query = update.callback_query
if query.data == 'option1':
# Actions for option 1
context.bot.send_message(chat_id=query.message.chat_id,
text="Option 1 selected!")
elif query.data == 'option2':
# Actions for option 2
context.bot.send_message(chat_id=query.message.chat_id,
text="Option 2 selected!")
elif query.data == 'option3':
# Actions for option 3
context.bot.send_message(chat_id=query.message.chat_id,
text="Option 3 selected!")
else:
# For unknown callback data
context.bot.send_message(chat_id=query.message.chat_id,
text="Invalid selected")
query.answer()
def main():
updater = Updater(TOKEN)
dispatcher = updater.dispatcher
# Updater ve Dispatcher
dispatcher.add_handler(CommandHandler('start', start))
# Add button callback handler
dispatcher.add_handler(CallbackQueryHandler(button))
updater.start_polling()
updater.idle()
if __name__ == '__main__':
main()