K
K
keria5002022-03-07 23:36:03
Python
keria500, 2022-03-07 23:36:03

I have a bot that has a menu below, but it is made for private messages, but I need the same menu to be in the group, how can I do this?

import telebot
import config
import random
from telebot import types
bot = telebot.TeleBot(config.TOKEN)

@bot.message_handler(commands=['start'])
def start(message):
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
item1 = types.KeyboardButton('Random number')
item2 = types.KeyboardButton('Button')

markup.add(item1, item2)

bot.send_message(message.chat.id, 'Hi, {0.first_name}'.format( message.from_user), reply_markup=markup)

@bot.message_handler(content_types=['text'])
def bot_message(message):
if message.chat.type == 'private': #private - pm,
if message.text = ='Random number':
bot.send_message(message.chat.id, str(random.randint(0, 100)))
if message.text == 'Button':
bot.send_message(message.chat.id, 'Why did you click here?')

bot.polling()

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question