Answer the question
In order to leave comments, you need to log in
The right to write a command only to the administrator?
How to make it so that only the admin has the right to write commands to the bot
import telebot
bot = telebot.TeleBot('my_token')
joinedFile = open('D:\\ras_bot\\joined.txt', 'r')
joinedUsers = set()
for line in joinedFile:
joinedUsers.add(line.strip())
joinedFile.close()
@bot.message_handler(commands=['sub'])
def startJoin(message):
if not str(message.chat.id) in joinedUsers:
joinedFile = open('D:\\ras_bot\\joined.txt', 'a')
joinedFile.write(str(message.chat.id) + '\n')
joinedUsers.add(message.chat.id)
@bot.message_handler(commands=['send'])
def mess(message):
for user in joinedUsers:
bot.send_message(user, message.text[message.text.find(' '):])
@bot.message_handler(commands=["start"])
def start(m, res=False):
bot.send_message(m.chat.id, 'Я на связи')
bot.polling(none_stop=True, interval=0)
Answer the question
In order to leave comments, you need to log in
Can also be used as an example
admin_keyboard = telebot.types.ReplyKeyboardMarkup(True)
admin_keyboard.row(" Купить")
admin_keyboard.row("ℹ️ Изменить FAQ ")
user_keyboard = telebot.types.ReplyKeyboardMarkup(True)
user_keyboard.row(" Купить", "ℹ️ FAQ")
reply_markup
you assign who can use the command. It's either admin_keyboard or user_keyboard.row ignor_command = ["ℹ️ Изменить FAQ ",]
admin_keyboard = telebot.types.ReplyKeyboardMarkup(True)
admin_keyboard.row(" Купить", "ℹ️ FAQ")
admin_keyboard.row("ℹ️ Изменить FAQ ")
user_keyboard = telebot.types.ReplyKeyboardMarkup(True)
user_keyboard.row(" Купить", "ℹ️ FAQ")
ignor_command = ["ℹ️ Изменить FAQ "]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question