Найти - Пользователи
Полная версия: !!!!!!!Кто поможет реализовать идею?!!!!!!!
Начало » Python для новичков » !!!!!!!Кто поможет реализовать идею?!!!!!!!
1
dinst84
Задача —> бот телеграмм, при нажатии кнопки выбора города (каждый город - отдельный канал), пользователю необходимо ввести сообщение, после оно появляется на предпросомтр, под текстом появляются инлайн кнопки редактировать и опубликовать и если нажимаешь опубликовать, то данное объявление отправляется в нужный канал (версия https://dpaste.org/RFGZp)

import telebot

from telebot import types



token = '!!!!!!!!!!!!!!!!!!!!!!'
bot = telebot.TeleBot(token)

channel_brn = '' # id канала
channel_omsk = '' # id канала

txt = 'Текст'

@bot.message_handler(commands=['start'])

def start(message):
markup = types.ReplyKeyboardMarkup(resize_keyboard = True)
item1 = types.KeyboardButton('Разместить объявление')
item2 = types.KeyboardButton('Правила')
markup.add(item1, item2)
bot.send_message(message.chat.id, txt.format(message.from_user), reply_markup=markup)

@bot.message_handler(content_types=['text'])
def bot_message(message):

if message.text == 'Выберите город':
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
item1 = types.KeyboardButton('Город 1')
item2 = types.KeyboardButton('Город 2')
back = types.KeyboardButton ('<-- Назад')
markup.add(item1, item2, back)
bot.send_message(message.chat.id, 'Выберите город', reply_markup=markup)

elif message.text == 'Город 1':
bot.send_message(message.chat.id, 'Введите текст Вашего объявления для Город 1', parse_mode='html')
bot.send_message(chat_id=channel_brn, text='example')


elif message.text == 'Правила':
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
item1 = types.KeyboardButton('Правила 1')
item2 = types.KeyboardButton('Правила 2')
back = types.KeyboardButton ('<-- Назад')
markup.add(item1, item2, back)
bot.send_message(message.chat.id, 'Правила', reply_markup=markup)

elif message.text == '<-- Назад':
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
item1 = types.KeyboardButton('Разместить объявление')
item2 = types.KeyboardButton('Правила')
markup.add(item1, item2)
bot.send_message(message.chat.id, '<-- Назад', reply_markup=markup)

bot.polling(none_stop=True)
py.user.next
С этой строки на четыре пробела влево всё сдвинь
  
@bot.message_handler(content_types=['text'])
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB