From 0bd622750febb75050ca1ccadde9989d4049576e Mon Sep 17 00:00:00 2001 From: TolaMironcenko Date: Fri, 21 Oct 2022 16:18:49 +0700 Subject: [PATCH] check --- bot.py | 2 +- currencyes.py | 4 ++++ database/models.py | 9 ++++++++- main.py | 32 ++++++++++++++++---------------- requirements.txt | 11 +++++++++++ 5 files changed, 40 insertions(+), 18 deletions(-) create mode 100644 currencyes.py diff --git a/bot.py b/bot.py index df5baba..ea23855 100644 --- a/bot.py +++ b/bot.py @@ -1,5 +1,5 @@ import telebot -TOKEN = '5123679189:AAHTMxCyOUwPSbaeof31m8SjRHVs4qKZci8' +TOKEN = '5123679189:AAHPLBfbPfuCiNK9qCcykcB2pRG-J4OEyrw' bot = telebot.TeleBot(TOKEN) diff --git a/currencyes.py b/currencyes.py new file mode 100644 index 0000000..92f2aa5 --- /dev/null +++ b/currencyes.py @@ -0,0 +1,4 @@ +currensyes = { + 'ru-ruble': '₽', + 'us-dollar': '$' +} diff --git a/database/models.py b/database/models.py index 138265a..95f9058 100644 --- a/database/models.py +++ b/database/models.py @@ -28,11 +28,18 @@ class Transaction(BaseModel): user = ForeignKeyField(User, unique=False) date = DateField(column_name='Date', default=datetime.datetime.today()) time = TimeField(column_name='time', default=datetime.datetime.now()) - category = TextField(column_name='category', default='none category') + category = TextField(column_name='category', default='None category') class Meta: table_name = 'Transaction' +class Check(BaseModel): + id = AutoField(column_name='id') + name = CharField(column_name='name', max_length=50, null=False, default='check') + balance = FloatField(column_name='balance', null=False, default=0) + user = ForeignKeyField(User, unique=False) + + # создаю таблицы conn.create_tables([User, Transaction]) diff --git a/main.py b/main.py index a6d289b..ee1ab21 100644 --- a/main.py +++ b/main.py @@ -1,10 +1,10 @@ import datetime - from termcolor import cprint from bot import bot import locales from changelocale import change_locale from database.models import User, Transaction +from currencyes import currensyes # функция ограничения количества знаков после запятой @@ -32,7 +32,7 @@ def main_bot(messages): mes = 'Баланс: ' elif locales.LOCALE == 'en': mes = 'Balance: ' - mes += to_fixed(user.balance, 2) + '₽' + mes += to_fixed(user.balance, 2) + currensyes['ru-ruble'] bot.send_message(message.chat.id, mes) elif message.text.split(' ')[0] == '/add' or message.text.split(' ')[0] == '+': if len(message.text.split(' ')) < 2: @@ -59,7 +59,7 @@ def main_bot(messages): type='incom', user=User.get(username=message.chat.id) ) - bot.send_message(message.chat.id, to_fixed(user.balance, 2) + '₽') + bot.send_message(message.chat.id, to_fixed(user.balance, 2) + currensyes['ru-ruble']) elif message.text.split(' ')[0] == '/rm' or message.text.split(' ')[0] == '-': if len(message.text.split(' ')) < 2: mes = None @@ -85,7 +85,7 @@ def main_bot(messages): type='consuption', user=User.get(username=message.chat.id) ) - bot.send_message(message.chat.id, to_fixed(user.balance, 2) + '₽') + bot.send_message(message.chat.id, to_fixed(user.balance, 2) + currensyes['ru-ruble']) elif message.text.split(' ')[0] == '/addtoday': transactions = Transaction.select().where( Transaction.type == 'incom', @@ -105,8 +105,8 @@ def main_bot(messages): mes += 'No incomes today' for i in transactions: mes += '-------------------------------------\n' - mes += str(iteration) + ' || +' + str(i.sum) + '₽ || ' + i.category + ' || ' + str(i.date) \ - + ' || ' + i.time.strftime('%H:%M:%S') + ' ||\n' + mes += str(iteration) + ' || +' + str(i.sum) + currensyes['ru-ruble'] + ' || ' + i.category \ + + ' || ' + str(i.date) + ' || ' + i.time.strftime('%H:%M:%S') + ' ||\n' iteration += 1 mes += '-------------------------------------\n' bot.send_message(message.chat.id, mes) @@ -129,8 +129,8 @@ def main_bot(messages): mes += 'No consuptions today' for i in transactions: mes += '-------------------------------------\n' - mes += str(iteration) + ' || -' + str(i.sum) + '₽ || ' + i.category + ' || ' + str(i.date) \ - + ' || ' + i.time.strftime('%H:%M:%S') + ' ||\n' + mes += str(iteration) + ' || -' + str(i.sum) + currensyes['ru-ruble'] + ' || ' + i.category \ + + ' || ' + str(i.date) + ' || ' + i.time.strftime('%H:%M:%S') + ' ||\n' iteration += 1 mes += '-------------------------------------\n' bot.send_message(message.chat.id, mes) @@ -152,8 +152,8 @@ def main_bot(messages): mes += 'No consuptions for all time' for i in transactions: mes += '-------------------------------------\n' - mes += str(iteration) + ' || -' + str(i.sum) + '+ || ' + i.category + ' || ' + str(i.date) \ - + ' || ' + i.time.strftime('%H:%M:%S') + ' ||\n' + mes += str(iteration) + ' || -' + str(i.sum) + currensyes['ru-ruble'] + ' || ' + i.category \ + + ' || ' + str(i.date) + ' || ' + i.time.strftime('%H:%M:%S') + ' ||\n' iteration += 1 mes += '-------------------------------------\n' bot.send_message(message.chat.id, mes) @@ -175,8 +175,8 @@ def main_bot(messages): mes += 'No incomes for all time' for i in transactions: mes += '-------------------------------------\n' - mes += str(iteration) + ' || +' + str(i.sum) + '₽ || ' + i.category + ' || ' + str(i.date) \ - + ' || ' + i.time.strftime('%H:%M:%S') + ' ||\n' + mes += str(iteration) + ' || +' + str(i.sum) + currensyes['ru-ruble'] + ' || ' + i.category \ + + ' || ' + str(i.date) + ' || ' + i.time.strftime('%H:%M:%S') + ' ||\n' iteration += 1 mes += '-------------------------------------\n' bot.send_message(message.chat.id, mes) @@ -200,8 +200,8 @@ def main_bot(messages): for i in transactions: if str(i.date).split('-')[1] == datetime.datetime.today().strftime('%m'): mes += '-------------------------------------\n' - mes += str(iteration) + ' || -' + str(i.sum) + '₽ || ' + i.category + ' || ' + str(i.date) \ - + ' || ' + i.time.strftime('%H:%M:%S') + ' ||\n' + mes += str(iteration) + ' || -' + str(i.sum) + currensyes['ru-ruble'] + ' || ' + i.category \ + + ' || ' + str(i.date) + ' || ' + i.time.strftime('%H:%M:%S') + ' ||\n' iteration += 1 mes += '-------------------------------------\n' bot.send_message(message.chat.id, mes) @@ -225,8 +225,8 @@ def main_bot(messages): for i in transactions: if str(i.date).split('-')[1] == datetime.datetime.today().strftime('%m'): mes += '-------------------------------------\n' - mes += str(iteration) + ' || +' + str(i.sum) + '₽ || ' + i.category + ' || ' + str(i.date) \ - + ' || ' + i.time.strftime('%H:%M:%S') + ' ||\n' + mes += str(iteration) + ' || +' + str(i.sum) + currensyes['ru-ruble'] + ' || ' + i.category \ + + ' || ' + str(i.date) + ' || ' + i.time.strftime('%H:%M:%S') + ' ||\n' iteration += 1 mes += '-------------------------------------\n' bot.send_message(message.chat.id, mes) diff --git a/requirements.txt b/requirements.txt index af7311d..11ebce9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,19 @@ certifi==2022.9.24 charset-normalizer==2.1.1 +contourpy==1.0.5 +cycler==0.11.0 +fonttools==4.37.4 idna==3.4 +kiwisolver==1.4.4 +matplotlib==3.6.1 +numpy==1.23.4 +packaging==21.3 peewee==3.15.3 +Pillow==9.2.0 +pyparsing==3.0.9 pyTelegramBotAPI==4.7.0 +python-dateutil==2.8.2 requests==2.28.1 +six==1.16.0 termcolor==2.0.1 urllib3==1.26.12