Skip to content

Instantly share code, notes, and snippets.

@onedal
Created June 20, 2018 13:38
Show Gist options
  • Save onedal/c0093fb9489363655d25ef3565a73bb7 to your computer and use it in GitHub Desktop.
Save onedal/c0093fb9489363655d25ef3565a73bb7 to your computer and use it in GitHub Desktop.
for you
import telebot
import requests
from telebot import types
token = ''
bot = telebot.TeleBot(token) # type: TeleBot
@bot.message_handler(commands=['start'])
def start(m):
keyboard = types.InlineKeyboardMarkup()
keyboard.add(*[types.InlineKeyboardButton(text=name,
callback_data=name) for name in ['Шерлок Холмс', 'Доктор Ватсон']])
msg = bot.send_message(m.chat.id, 'Кого выбираешь?',
reply_markup=keyboard)
#bot.register_next_step_handler(msg,name)
@bot.callback_query_handler(func=lambda c: True)
def inline(c):
if c.data == 'Шерлок Холмс':
bot.edit_message_text(
chat_id=c.message.chat.id,
message_id=c.message.message_id,
text='ответ тут лежит',
parse_mode='Markdown'
)
if c.data == 'Доктор Ватсон':
bot.edit_message_text(
chat_id=c.message.chat.id,
message_id=c.message.message_id,
text='ой все!',
parse_mode='Markdown'
)
#def name(m):
# if m.text == 'Шерлок Холмс':
# bot.send_message(m.chat.id, '*ответ будкт тут*',
# parse_mode='Markdown')
#elif m.text == 'Доктор Ватсон'
#@bot.message_handler(commands=['start'])
#def start(message):
# keyboard = types.InlineKeybordMarkup()
# keyboard.add(*[types.InlineKeyboardButton(text=name,
# callback_data=name) for name in ['Шерлок Холмс',
# 'Доктор Ватсон']])
# msg = bot.send_message(m.chat.id, 'Кого выбираешь, друг мой?',
# reply_markup=keyboard)
#@bot.callback_query_handler(func=lambda c: True
#def inline(c):
# if c.data == 'Шерлок Холмс':
# bot.edit_message_text(
# chat_id=c.message.chat.id,
# message_id=c.message.message_id,
# text='ура нажалось',
# parse_mode = 'Markdown')
status = True
timer = 0
while status:
try:
bot.polling()
except Exception:
print('LOL я упал, но я поднимаюсь ...')
timer = timer + 1
if(timer >= 10):
status = False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment