Added TODOs, reformatting

This commit is contained in:
Administrator 2022-05-03 14:28:41 +02:00
parent 74cf9d54ef
commit 2e95660945

View File

@ -14,15 +14,16 @@ import os
import sys import sys
import sqlalchemy import sqlalchemy
from sqlalchemy.exc import IntegrityError
import telebot import telebot
from dotenv import load_dotenv from dotenv import load_dotenv
from sqlalchemy.exc import IntegrityError
from telebot import types from telebot import types
# from apscheduler.schedulers.background import BackgroundScheduler
from db import User, session, Product from db import User, session, Product
from fetcher import * from fetcher import *
# from apscheduler.schedulers.background import BackgroundScheduler
load_dotenv(dotenv_path='.env') # load environment variables load_dotenv(dotenv_path='.env') # load environment variables
BOT_VERSION = "0.0.1" # version of bot BOT_VERSION = "0.0.1" # version of bot
@ -37,19 +38,19 @@ def send_start(message):
Args: Args:
message (Message): message from telegram user, here /start message (Message): message from telegram user, here /start
""" """
bot.send_message(chat_id=int(message.from_user.id), text=( "Welcome to the game... \ bot.send_message(chat_id=int(message.from_user.id), text=("Welcome to the game... \
\nTo start please set a name for yourself or type cancel to set default name:")) \nTo start please set a name for yourself or type cancel to set default name:"))
bot.register_next_step_handler(message, start_name_setter) bot.register_next_step_handler(message, start_name_setter)
def start_name_setter(message): def start_name_setter(message):
"""Set name for user and send introduction """Set name for user and send introduction
Args: Args:
message (Message): Message to react to message (Message): Message to react to
""" """
if str(message.text).lower() == "cancel": # Set user name to user if str(message.text).lower() == "cancel": # Set user name to user
bot.reply_to(message, "Your username will be set to default_user. \ bot.reply_to(message, "Your username will be set to default_user. \
\nType /gameinfo for information about GuessThePrice \ \nType /gameinfo for information about GuessThePrice \
\nType /help for an overview of all commands") \nType /help for an overview of all commands")
@ -226,14 +227,14 @@ def add_product(message):
None: None None: None
""" """
# Check if user is admin # TODO: Check if user is admin
user_id = int(message.from_user.id) user_id = int(message.from_user.id)
bot.send_message(chat_id=user_id, text='Please insert the Amazon product id (i.e. B00XKZYZ2S)') bot.send_message(chat_id=user_id, text='Please insert the Amazon product id (i.e. B00XKZYZ2S)')
bot.register_next_step_handler(message, receive_product_data) # executes function when user sends message bot.register_next_step_handler(message, receive_product_data) # executes function when user sends message
def receive_product_data(message): def receive_product_data(message):
# Check if user is admin # TODO: Check if user is admin
user_id = int(message.from_user.id) user_id = int(message.from_user.id)
product_id = str(message.text) product_id = str(message.text)