Better commenting, test documentaiton for remaining modules and clsas documentation

This commit is contained in:
Kellermann 2022-05-30 08:45:24 +02:00
parent c6bc276e56
commit ecf27aef32
2 changed files with 37 additions and 9 deletions

View File

@ -3,7 +3,7 @@ script for telegram bot and its functions
"""
__author__ = "Florian Kellermann, Linus Eickhoff, Florian Kaiser"
__date__ = "02.05.2022"
__version__ = "0.4.7"
__version__ = "0.6.0"
__license__ = "None"
# main bot at http://t.me/guess_the_price_bot
@ -39,13 +39,11 @@ bot = telebot.TeleBot(os.getenv('BOT_API_KEY'))
@bot.message_handler(commands=['version', 'Version'])
def send_version(message):
""" Sending programm version
:type message: message object bot
:param message: message that was reacted to, in this case always containing '/version'
""" Sending program version
:raises: none
Args:
message (Message): Message to react to in this case /version
:rtype:none
"""
bot.reply_to(message, "the current bot version is " + BOT_VERSION)
@ -367,8 +365,6 @@ def send_scoreboard(message):
Test:
type /scoreboard as command in telegram and check if bot responds with scoreboard with correct info and formatting
test with db with no Users and check if bot responds with "No users registered" message
"""
alltime_board = []
weekly_board = []
@ -522,6 +518,9 @@ def daily_message(message):
Raises:
None: None
Test:
type /daily as command in telegram and check if bot sends daily challenge message
type /daily again for message that you already played today and your guess
"""
user_id = int(message.from_user.id)
@ -541,7 +540,7 @@ def daily_message(message):
for element in all_scores_user:
if element.date.date() == dt.datetime.now().date():
bot.send_message(chat_id=user_id, text="You already guessed today!\n"
"Your guess was: {}".format(element.guess))
f"Your guess was: {element.guess}")
return
@ -588,6 +587,11 @@ def get_user_guess(message, start_time):
Args:
message (Message): Message element to react to. In this case next step after /daily
start_time (time.time): Time the user got the image
Test:
Send a price and see if the bot responds correctly (guess accepted)
Send text withwith wrong format (right format = number fitting for float) and see if bot notices and gives you another try
See if score changes after you guessed (only if you guessed somewhat correctly so your score is not 0)
"""
end_time = time.time()
user_id = int(message.from_user.id)

View File

@ -19,6 +19,14 @@ Base = declarative_base()
class User(Base):
"""User Class
Args:
Base (_DeclarativeBase): Base class
Returns:
string: including telegram_id, username and admin
"""
__tablename__ = 'user'
telegram_id = Column(Integer, primary_key=True)
username = Column(String(50))
@ -29,6 +37,14 @@ class User(Base):
class Score(Base):
"""Score Class
Args:
Base (_DeclarativeBase): Base class
Returns:
string: including telegram_id, date, product_id, guess and score
"""
__tablename__ = 'score'
telegram_id = Column(Integer, ForeignKey('user.telegram_id'), primary_key=True)
date = Column(DateTime, primary_key=True)
@ -41,6 +57,14 @@ class Score(Base):
class Product(Base):
"""Product Class
Args:
Base (_DeclarativeBase): Base class
Returns:
string: including product_id, price, image_link, title, description, date, todays_product
"""
__tablename__ = 'product'
product_id = Column(String(50), primary_key=True)
price = Column(Float)