Telegram bot

From RHS Wiki
Jump to navigation Jump to search

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...')