@bot.message_handler(commands=["callback"])
def cmd_callback(message):
keyboard = types.InlineKeyboardMarkup()
keyboard.add(*[types.InlineKeyboardButton(text=name, callback_data=name) for name in ['Call','SMS']])
@bot.message_handler(content_types=["text"])
def repeat_all_messages(message): # Название функции не играет никакой роли, в принципе
try:
if "Привет" in message.text:
bot.send_message(message.chat.id, message.text)
return
if "Список камер" in message.text:
buildNames = list(cameras_n.ipcam_list.keys())
buildNames.sort()
keyboard = types.InlineKeyboardMarkup()
keyboard.add(*[types.InlineKeyboardButton(text=name, callback_data="build_" + name) for name in buildNames])
bot.send_message(message.chat.id, "Выберите корпус: ", reply_markup=keyboard)
if "/callback" in message.text:
userID = str(message.chat.id)
import telebot
import constant
bot = telebot.TeleBot(constant.token)
upd = bot.get_updates()
last_upd = upd[-1]
message_from_user = last_upd.message
@bot.message_handler(func=lambda message: message.document.mime_type == 'text/plain', content_types=['document'])
def handle_text_doc(message):
if message.text == 'Документ':
bot.send_text(message.from_user.id, constant.document)
#document.close
chat_id = message.chat.id
file_info = bot.get_file(message.document.file_id)
downloaded_file = bot.download_file(file_info.file_path)
src = u'C:\\Users\Hleb\\Python\\excel\\' + message.document.file_name
with open(src, 'wb') as new_file:
new_file.write(downloaded_file)
bot.reply_to(message, "Одну минутку...")
import tableTOtable
bot.send_document
bot.polling(none_stop=True, interval=0)
Address: