Telegram bot
Revision as of 11:25, 1 March 2018 by Rafahsolis (talk | contribs) (Created page with "== Button == <source lang=python>@bot.message_handler(commands=['menu']) def command_menu(m): cid = m.chat.id if m.chat.id in whitelist: markup = types.ReplyK...")
Button[edit]
@bot.message_handler(commands=['menu'])
def command_menu(m):
cid = m.chat.id
if m.chat.id in whitelist:
markup = types.ReplyKeyboardMarkup(row_width=2)
itembtn1 = types.KeyboardButton('/extract')
itembtn2 = types.KeyboardButton('/soy')
itembtn3 = types.KeyboardButton('/uptime')
itembtn4 = types.KeyboardButton('/menuoff')
itembtn5 = types.KeyboardButton('/htmlon')
markup.row(itembtn2)
markup.row(itembtn5, itembtn6)
markup.row(itembtn1, itembtn7)
markup.row(itembtn4)
bot.send_message(cid, "Choose an option:", reply_markup=markup)
else:
bot.send_message( cid, 'GO AWAY...')
@bot.message_handler(commands=['menuoff'])
def command_menuoff(m):
cid = m.chat.id
if m.chat.id in whitelist:
markup = types.ReplyKeyboardRemove(selective=False)
bot.send_message(cid, "Menu OFF", reply_markup=markup)
else:
bot.send_message( cid, 'GO AWAY...')