Better commenting, test documentaiton for remaining modules and clsas documentation
This commit is contained in:
parent
c6bc276e56
commit
ecf27aef32
@ -3,7 +3,7 @@ script for telegram bot and its functions
|
|||||||
"""
|
"""
|
||||||
__author__ = "Florian Kellermann, Linus Eickhoff, Florian Kaiser"
|
__author__ = "Florian Kellermann, Linus Eickhoff, Florian Kaiser"
|
||||||
__date__ = "02.05.2022"
|
__date__ = "02.05.2022"
|
||||||
__version__ = "0.4.7"
|
__version__ = "0.6.0"
|
||||||
__license__ = "None"
|
__license__ = "None"
|
||||||
|
|
||||||
# main bot at http://t.me/guess_the_price_bot
|
# 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'])
|
@bot.message_handler(commands=['version', 'Version'])
|
||||||
def send_version(message):
|
def send_version(message):
|
||||||
""" Sending programm version
|
""" Sending program version
|
||||||
:type message: message object bot
|
|
||||||
:param message: message that was reacted to, in this case always containing '/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)
|
bot.reply_to(message, "the current bot version is " + BOT_VERSION)
|
||||||
|
|
||||||
@ -367,8 +365,6 @@ def send_scoreboard(message):
|
|||||||
Test:
|
Test:
|
||||||
type /scoreboard as command in telegram and check if bot responds with scoreboard with correct info and formatting
|
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
|
test with db with no Users and check if bot responds with "No users registered" message
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
alltime_board = []
|
alltime_board = []
|
||||||
weekly_board = []
|
weekly_board = []
|
||||||
@ -522,6 +518,9 @@ def daily_message(message):
|
|||||||
Raises:
|
Raises:
|
||||||
None: None
|
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)
|
user_id = int(message.from_user.id)
|
||||||
|
|
||||||
@ -541,7 +540,7 @@ def daily_message(message):
|
|||||||
for element in all_scores_user:
|
for element in all_scores_user:
|
||||||
if element.date.date() == dt.datetime.now().date():
|
if element.date.date() == dt.datetime.now().date():
|
||||||
bot.send_message(chat_id=user_id, text="You already guessed today!\n"
|
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
|
return
|
||||||
|
|
||||||
|
|
||||||
@ -588,6 +587,11 @@ def get_user_guess(message, start_time):
|
|||||||
Args:
|
Args:
|
||||||
message (Message): Message element to react to. In this case next step after /daily
|
message (Message): Message element to react to. In this case next step after /daily
|
||||||
start_time (time.time): Time the user got the image
|
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()
|
end_time = time.time()
|
||||||
user_id = int(message.from_user.id)
|
user_id = int(message.from_user.id)
|
||||||
|
24
source/db.py
24
source/db.py
@ -19,6 +19,14 @@ Base = declarative_base()
|
|||||||
|
|
||||||
|
|
||||||
class User(Base):
|
class User(Base):
|
||||||
|
"""User Class
|
||||||
|
|
||||||
|
Args:
|
||||||
|
Base (_DeclarativeBase): Base class
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
string: including telegram_id, username and admin
|
||||||
|
"""
|
||||||
__tablename__ = 'user'
|
__tablename__ = 'user'
|
||||||
telegram_id = Column(Integer, primary_key=True)
|
telegram_id = Column(Integer, primary_key=True)
|
||||||
username = Column(String(50))
|
username = Column(String(50))
|
||||||
@ -29,6 +37,14 @@ class User(Base):
|
|||||||
|
|
||||||
|
|
||||||
class Score(Base):
|
class Score(Base):
|
||||||
|
"""Score Class
|
||||||
|
|
||||||
|
Args:
|
||||||
|
Base (_DeclarativeBase): Base class
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
string: including telegram_id, date, product_id, guess and score
|
||||||
|
"""
|
||||||
__tablename__ = 'score'
|
__tablename__ = 'score'
|
||||||
telegram_id = Column(Integer, ForeignKey('user.telegram_id'), primary_key=True)
|
telegram_id = Column(Integer, ForeignKey('user.telegram_id'), primary_key=True)
|
||||||
date = Column(DateTime, primary_key=True)
|
date = Column(DateTime, primary_key=True)
|
||||||
@ -41,6 +57,14 @@ class Score(Base):
|
|||||||
|
|
||||||
|
|
||||||
class Product(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'
|
__tablename__ = 'product'
|
||||||
product_id = Column(String(50), primary_key=True)
|
product_id = Column(String(50), primary_key=True)
|
||||||
price = Column(Float)
|
price = Column(Float)
|
||||||
|
Loading…
Reference in New Issue
Block a user