Created
October 3, 2019 18:14
-
-
Save DiZiNnEs/605767de4402762ecc8ed43945182072 to your computer and use it in GitHub Desktop.
Problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Сам database | |
import telebot | |
bot2 = telebot.TeleBot("979774880:AAHS9lVlDxrwr2TbysegQb_oNuUTBY1_D4k") | |
#with open('/home/dizinnes/PycharmProjects/My-telegramBot/recipe/cake with apple.txt', ) as dbcake: | |
#cake = dbcake.read() | |
#with open('/home/dizinnes/PycharmProjects/My-telegramBot/cakephoto.jpg') as photocake: | |
#phcake = photocake.() | |
@bot2.message_handler(content_types=['text']) | |
def outputRecipe(message): | |
if message.text.lower() == 'начальные команды' or message.text.lower() == 'ночальные команды' or message.text.lower() == 'ночалные каманды' or message.text.lower() == 'ночальные каманды': | |
bot2.send_message(message.from_user.id, '\n/start - Стартует бота.') | |
bot2.send_message(message.from_user.id, '\n/help - помощь.') | |
bot2.send_message(message.from_user.id, '\n/Тут - будет команда.') | |
bot2.send_message(message.from_user.id, '\n/Тут - будет команда.') | |
#if message.text.lower() == 'пирог' or message.text.lower() == 'пираг': | |
#with open('/home/dizinnes/PycharmProjects/My-telegramBot/recipe/cake with apple.txt', ) as dbcake: | |
#cake = dbcake.read() | |
#bot.send_message(message.from_user.id, str(cake)) | |
#if message.text.lower() == 'желаю поесть' or message.text.lower() == 'хочу кушать' or message.text.lower(): | |
#with open('/home/dizinnes/PycharmProjects/My-telegramBot/recipeStart/recipeStart.txt', ) as recipeStart: | |
#startRecipe = recipeStart.read() | |
#bot.send_message(message.chat.id, str(startRecipe)) | |
#bot.send_message(message.chat.id, '1)Вегетарианство') | |
#bot.send_message(message.chat.id, '2)Веганство') | |
#bot.send_message(message.chat.id, '3)Сыроедение') | |
#bot.send_message(message.chat.id, '4)Мясоедение') | |
if message.text.lower() == 'вегетерианство' or message.text.lower() == 'вегетарианство': | |
#bot.send_message(message.from_user.id, 'Выберите рецепт по вегетарианству:') | |
with open('/home/dizinnes/PycharmProjects/My-telegramBot/Available recipes/For vegatarians') as forVegatarian: | |
fVegatarian = forVegatarian.read() | |
bot2.send_message(message.from_user.id, str(fVegatarian)) # Тут будет txt c доступными блюдами | |
if message.text.lower() == 'веганство' or message.text.lower() == 'веганства': | |
#bot.send_message(message.from_user.id, 'Выберите рецепт по веганству:') | |
with open('/home/dizinnes/PycharmProjects/My-telegramBot/Available recipes/For vegan') as forVegan: | |
fVegan = forVegan.read() | |
bot2.send_message(message.from_user.id, str(fVegan)) # Тут будет txt c доступными блюдами | |
if message.text.lower() == 'сыроедение' or message.text.lower() == 'сыроедство': | |
#bot.send_message(message.from_user.id, 'Выберите рецепт по сыроедству:') | |
with open('/home/dizinnes/PycharmProjects/My-telegramBot/Available recipes/For row food') as forRow: | |
fRow = forRow.read() | |
bot2.send_message(message.from_user.id, str(fRow)) # Тут будет txt c доступными блюдами | |
if message.text.lower() == 'мясоедение' or message.text.lower() == 'мясоедство' or message.text.lower() == 'мясаа': | |
with open('/home/dizinnes/PycharmProjects/My-telegramBot/Available recipes/For meat eaters') as forMeat: | |
fMeat = forMeat.read() | |
#bot.send_message(message.from_user.id, 'Выберите рецепт по мясоедение:') | |
bot2.send_message(message.from_user.id, str(fMeat)) # Тут будет txt c доступными блюдами | |
bot2.polling(none_stop=True, interval=0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import telebot | |
from telebot import types | |
#Если импортировать то весь нижний код работать не будет, а код который был импортирован работать будет, если не импортировать то весь нижний код работать будет, а импортированный с database не будет, мне нужно что бы работали оба | |
import database | |
bot = telebot.TeleBot("") | |
class start(): | |
@bot.message_handler(commands=['url']) | |
def url(message): | |
markup = types.InlineKeyboardMarkup() | |
btn_my_site = types.InlineKeyboardButton(text='ВК разработчика', url='https://vk.com') | |
markup.add(btn_my_site) | |
bot.send_message(message.chat.id, "Нажми на кнопку и перейди на VK разработчика бота.", reply_markup=markup) | |
# Обработчик команды /start | |
@bot.message_handler(commands=['start']) | |
def handle_start(message): | |
bot.send_message(message.from_user.id, 'Привет, бот успешно стартовал!') | |
# Обработчик команды /help | |
@bot.message_handler(commands=['help']) | |
def handle_help(message): | |
bot.send_message(message.from_user.id, 'Помощь.') | |
# with open('/home/dizinnes/PycharmProjects/My-telegramBot/help.txt') as helpcommand: | |
# printhelp = helpcommand.read() # открытие txt там записана /help | |
# bot.send_message(message.from_user.id, str(printhelp)) | |
@bot.message_handler(content_types=['text', 'photo']) | |
def handle_text(message): | |
# database.handle_text(message) | |
if message.text.lower() == 'желаю поесть': | |
with open('/home/dizinnes/PycharmProjects/My-telegramBot/recipeStart/recipeStart.txt') as recipeStart: | |
startRecipe = recipeStart.read() | |
bot.send_message(message.chat.id, str(startRecipe)) | |
bot.polling(none_stop=True, interval=0) | |
# Будет работать если импортировать, не будет работать если не импортировать | |
def output(): | |
database.outputRecipe() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment