Skip to content
Snippets Groups Projects
Commit 3a7fb451 authored by Charlielv04's avatar Charlielv04
Browse files

Menu implementation

parent 548f31a4
No related branches found
No related tags found
No related merge requests found
......@@ -24,7 +24,7 @@ from dotenv import load_dotenv
import os
load_dotenv()
COMMITTEES_TOKEN = os.getenv("SAILORE_COMMITTEE_BOT")
COMMITTEES_TOKEN = os.getenv("TEST_BOT")
PARROT_TOKEN = os.getenv("SAILORE_PARROT_BOT")
SAILORE_TOKEN = os.getenv("SAILORE_BX_BOT")
......
import googleapiclient.errors
from . import base
import utils
import bx_utils
import os
from telegram import Update, Bot, InlineKeyboardButton, InlineKeyboardMarkup
from telegram.constants import ParseMode
......@@ -26,12 +29,16 @@ class Bar(base.Committee_hub_base):
self.info = bx_utils.db.get_committee_info(self.name)
async def menu(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
"""Asks for the receival of the menu"""
if "menu_id" in self.info.keys():
photo_id = self.info["menu_id"]
await context.bot.send_message(chat_id=update.effective_chat.id,
text="This was the previous menu")
await context.bot.send_photo(chat_id=update.effective_chat.id,
photo=photo_id)
file_path = utils.config.ROOT + '/data/temp_files/menu.jpg'
try:
bx_utils.drive.download_committee_file(self.name, 'menu.jpg', file_path)
with open(file_path, 'rb') as file:
await context.bot.send_message(chat_id=update.effective_chat.id,
text="This was the old menu")
await context.bot.send_photo(chat_id=update.effective_chat.id,
photo=file)
except googleapiclient.errors.HttpError:
pass
await context.bot.send_message(chat_id=update.effective_chat.id,
text="Send the photo of the new menu")
return self.state.MENU
......@@ -42,9 +49,7 @@ class Bar(base.Committee_hub_base):
photo_id = photo.file_id
photo_obj = await context.bot.getFile(photo_id)
await photo_obj.download_to_drive(custom_path=utils.config.ROOT + '/data/temp_files/menu.jpg')
bx_utils.drive
bx_utils.db.extra_committee_info(self.name, "menu_id", photo_id)
self.info = bx_utils.db.get_committee_info(self.name)
bx_utils.drive.upload_image_to_committee(self.name, utils.config.ROOT + '/data/temp_files/menu.jpg')
await context.bot.send_message(chat_id=update.effective_chat.id,
text="Photo received")
return self.state.HUB
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment