Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @bot.message_handler(commands=['start'])
- def start_message(message):
- global user #tried making user,fn and Lname to be global variables
- global fn
- global Lname
- fn=message.chat.first_name
- Lname=message.chat.last_name
- user=str(fn)+' '+str(Lname)
- markup = telebot.types.InlineKeyboardMarkup()
- acct=telebot.types.InlineKeyboardButton(text='👤 Account', callback_data=1)
- ref=telebot.types.InlineKeyboardButton(text='👥 Referrals', callback_data=2)
- stats=telebot.types.InlineKeyboardButton(text='📈 Stats', callback_data=3)
- power=telebot.types.InlineKeyboardButton(text=' ⚡️ Buy Power',callback_data=4)
- payout=telebot.types.InlineKeyboardButton(text='💲 Payouts', callback_data=5)
- withdraw=telebot.types.InlineKeyboardButton(text='💵 Withdraw', callback_data=6)
- markup.row(acct)
- markup.row(ref,stats)
- markup.row(power,payout,withdraw)
- bot.send_message(message.chat.id, text="WELCOME"+user, reply_markup=markup) # user working here in the message handler but won't work in callback_query_handler
- @bot.callback_query_handler(func=lambda call: True)
- def query_handler(call):
- user=str(message.chat.first_name)+' '+str(message.chat.last_name)
- markup = telebot.types.InlineKeyboardMarkup()
- acct=telebot.types.InlineKeyboardButton(text='👤 Account', callback_data=1)
- ref=telebot.types.InlineKeyboardButton(text='👥 Referrals', callback_data=2)
- stats=telebot.types.InlineKeyboardButton(text='📈 Stats', callback_data=3)
- power=telebot.types.InlineKeyboardButton(text=' ⚡️ Buy Power',callback_data=4)
- payout=telebot.types.InlineKeyboardButton(text='💲 Payouts', callback_data=5)
- withdraw=telebot.types.InlineKeyboardButton(text='💵 Withdraw', callback_data=6)
- wallet=telebot.types.InlineKeyboardButton(text='🏦 Wallet', callback_data=7)
- email=telebot.types.InlineKeyboardButton(text='📧 Email', callback_data=8)
- bot.answer_callback_query(callback_query_id=call.id)
- if call.data == '1':
- markup.row(acct)
- markup.row(ref,stats)
- markup.row(wallet,email)
- markup.row(power,payout,withdraw)
- msg='👤 GENERAL INFORMATION\n\n◽ User: '+user+'\n◽ Balance: ' #so I wanted the bot to print the information of the bot user (First_name and last_name) but it's not working. It breaks the code and says user not defined.
- bot.send_message(call.message.chat.id,msg,reply_markup=markup)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement