added admin check
This commit is contained in:
parent
e2d506e629
commit
6ce2a443b3
@ -198,7 +198,7 @@ def send_challenge(message):
|
|||||||
|
|
||||||
@bot.message_handler(commands=['guess', 'Guess'])
|
@bot.message_handler(commands=['guess', 'Guess'])
|
||||||
def send_guess(message):
|
def send_guess(message):
|
||||||
"""send guess to user
|
"""let user guess the price of the product
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
message (Message): Message from telegram user, here /guess
|
message (Message): Message from telegram user, here /guess
|
||||||
@ -282,7 +282,13 @@ def add_product(message):
|
|||||||
None: None
|
None: None
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# TODO: Check if user is admin
|
user_id = message.from_user.id
|
||||||
|
|
||||||
|
# Check if user is admin
|
||||||
|
if not session.query(User).filter_by(telegram_id=user_id).first().admin:
|
||||||
|
bot.reply_to(message, "Error: Admin rights are required to add products")
|
||||||
|
return
|
||||||
|
|
||||||
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
|
||||||
@ -294,7 +300,6 @@ def receive_product_data(message):
|
|||||||
Args:
|
Args:
|
||||||
message (Message): Message that is being reacted to. Always from add_product because of next_step_handler
|
message (Message): Message that is being reacted to. Always from add_product because of next_step_handler
|
||||||
"""
|
"""
|
||||||
# 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)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user