Tea
This commit is contained in:
parent
ca28f34ce1
commit
a770244697
15
tea.py
15
tea.py
@ -37,18 +37,23 @@ def tea_message(message):
|
|||||||
user_id = str(message.from_user.id)
|
user_id = str(message.from_user.id)
|
||||||
user_name = message.from_user.username
|
user_name = message.from_user.username
|
||||||
|
|
||||||
|
if not user_id in USERS_BALANCE:
|
||||||
|
USERS_BALANCE[user_id] = [0.0, '']
|
||||||
|
|
||||||
# проверяем, можно ли выпить чай
|
# проверяем, можно ли выпить чай
|
||||||
if user_id in USERS_BALANCE:
|
try:
|
||||||
last_teapot_time = datetime.strptime(USERS_BALANCE[user_id][1], '%Y-%m-%d %H:%M:%S')
|
last_teapot_time = datetime.strptime(USERS_BALANCE[user_id][1], '%Y-%m-%d %H:%M:%S')
|
||||||
print(last_teapot_time)
|
|
||||||
time_delta = datetime.now() - last_teapot_time
|
time_delta = datetime.now() - last_teapot_time
|
||||||
if time_delta.seconds < 1800:
|
if time_delta.seconds < 1800:
|
||||||
bot.reply_to(message, f'Ты уже пил чай {time_delta.seconds//30} минут назад. \n'
|
bot.reply_to(message, f'Ты уже пил чай {time_delta.seconds//30} минут назад. \n'
|
||||||
f'Чай будет готов через {(30 - time_delta.seconds//30)} минут. ☕️')
|
f'Чай будет готов через {(30 - time_delta.seconds//30)} минут. ☕️')
|
||||||
return
|
return
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
# обновляем баланс пользователя
|
# обновляем баланс пользователя
|
||||||
balance = USERS_BALANCE[str(user_id)]
|
balance = USERS_BALANCE[user_id]
|
||||||
|
print(balance)
|
||||||
balance[0] += TEA_PRICE
|
balance[0] += TEA_PRICE
|
||||||
balance[1] = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
balance[1] = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||||
USERS_BALANCE[user_id] = balance
|
USERS_BALANCE[user_id] = balance
|
||||||
@ -60,10 +65,10 @@ def tea_message(message):
|
|||||||
|
|
||||||
@bot.message_handler(commands=['bal'])
|
@bot.message_handler(commands=['bal'])
|
||||||
def balance_message(message):
|
def balance_message(message):
|
||||||
user_id = message.from_user.id
|
user_id = str(message.from_user.id)
|
||||||
|
|
||||||
# проверяем баланс пользователя
|
# проверяем баланс пользователя
|
||||||
user_balance = USERS_BALANCE.get(user_id, [0, ''])[0]
|
user_balance = USERS_BALANCE[user_id][0]
|
||||||
|
|
||||||
bot.reply_to(message, f'Твой баланс: {user_balance} литров. ☕️')
|
bot.reply_to(message, f'Твой баланс: {user_balance} литров. ☕️')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user