Skip to content

Instantly share code, notes, and snippets.

@Smosker
Last active May 11, 2016 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Smosker/2fe94d09aa77a7d7a6301ed731e2cf34 to your computer and use it in GitHub Desktop.
Save Smosker/2fe94d09aa77a7d7a6301ed731e2cf34 to your computer and use it in GitHub Desktop.
import time
import telepot
from telepot.namedtuple import ReplyKeyboardMarkup,InlineKeyboardMarkup,InlineKeyboardButton
TOKEN = 'Put your token here'
previous_message = {}
def handle(msg):
info = telepot.glance(msg)
if msg['text'] =='/start':
message = '''press on button below to see if bug working'''
show_keyboard = ReplyKeyboardMarkup(keyboard=[['Press me']])
bot.sendMessage(info[2], message, reply_markup=show_keyboard,
disable_web_page_preview=True)
if msg['text'] == 'Press me':
if previous_message.get(info[2],None):
print(previous_message[info[2]])
msgid = (info[2], previous_message[info[2]]['message_id'])
bot.editMessageReplyMarkup(msgid)
message = 'https://telegram.org/'
markup_keyboard = InlineKeyboardMarkup(inline_keyboard=
[[InlineKeyboardButton(text='Dont press me just click on "Press me" below again',
callback_data='bug_test')]])
previous_message[info[2]]=bot.sendMessage(info[2], message, reply_markup=markup_keyboard,disable_web_page_preview=True)
bot = telepot.Bot(TOKEN)
print(bot.getMe())
answerer = telepot.helper.Answerer(bot)
bot.message_loop({'chat': handle,
'callback_query': None,
'inline_query': None,
'chosen_inline_result': None})
while 1:
time.sleep(10)
@Smosker
Copy link
Author

Smosker commented May 11, 2016

Problem - when sendind new message with inline keyboard i want get rid of inline keyboard in previous message with it, so i use method "editMessageReplyMarkup" passing it user id amd message id - and it works normal but problem is that it seems to turn off setting "disable_web_page_preview=True" in this message (which keyboard i edit)

Video web version - https://yadi.sk/d/D8MtBBvnrczTu
Video desctop mac - https://yadi.sk/d/caRCcAzvrczck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment